Skip to content

Add HDR decode and display - #1104

Open
kean wants to merge 4 commits into
mainfrom
feat/hdr-decode
Open

kean wants to merge 4 commits into
mainfrom
feat/hdr-decode

Conversation

@kean

@kean kean commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Adds opt-in HDR: ImageRequest.dynamicRange applies gain maps with kCGImageSourceDecodeToHDR, and LazyImage.allowedDynamicRange(_:) also displays them. Standard requests decode as before. Thumbnails keep HDR; a request with processors stays standard, because they draw in 8 bits. See the new high-dynamic-range article.

Proof

  • Brightest pixel through the real pipeline (1.0 = SDR white), Ultra HDR JPEG on Mac Catalyst (real UIKit and GPU): .standard 1.02 → .high 8.84, isHighDynamicRange true. macOS keeps it in 10 bits, also at 8.84.
  • iOS 27 and tvOS 27 simulators can't apply a gain map, and Image I/O returns an all-zero image, so .high falls back to the SDR base (0.88). A 10-bit PQ HEIC reaches 4.17 there. Removing the guard fails gainMapIsApplied.
  • preparingForDisplay() flattens a gain map (3.51 → 0.88), so HDR skips decompression. Removing that fails decompressionIsSkipped; the memory key, disk and processor rules are mutation-checked too.
  • 20 new Nuke and 5 new NukeUI tests. macOS 1,783 + 638, iOS 27 1,831 + 648, tvOS 27 1,828 + 648: only ImagePipelinePreviewPolicyTests failed, under load, which it also does on main, and it passes alone. watchOS, visionOS, SPM and snippets compile.
  • Default path: ImageRequest stays 112 bytes, a cache read is +7 instructions (+0.35%), a full load −0.65% against a control at −0.65%.
  • Not run on a physical device, or compiled with Xcode 26.x (the local install is broken).

kean added 4 commits November 2, 2026 19:21
Off by default. A gain map is applied with kCGImageSourceDecodeToHDR, and the image skips decompression, because preparingForDisplay() goes back to the SDR base. A request with processors stays standard, and HDR is never encoded for the disk cache.
@kean kean added this to the 14.1.0 milestone Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant