Repository navigation
feat(coregraphics): decode images at the resolution they are drawn (#428 part 3) - #439
Merged
michaelstonis merged 1 commit intoOct 27, 2026
Merged
Conversation
) Part 3 of #428. With CoreGraphicsRenderer.ScaledImageDecode (list renders, off by default) or RenderOptions.ScaledImageDecode (page renders), an image is converted at the reduction DisplayImage.GetReduction gives for the device at ImageSamplesPerPixel (k, 2 by default), masks at their own rule; the converted image cache is keyed by the delivered reduction, a finer one serving a coarser request. Off, renders are byte-identical to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 3 of #428 (CoreGraphics). Does not close the issue; parts 4 (Android Canvas) and 5 (Direct2D) remain.
What changed
CoreGraphicsRenderer.ScaledImageDecode(off by default) andImageSamplesPerPixel(k, 2 by default; must be a finite number of at least 1) for list renders. Page renders takeRenderOptions.ScaledImageDecode/ImageSamplesPerPixel(off by default; overprint preview forces it off).r = image.GetReduction(unit square to device pixels, k, converter to RGB)fromGetSamplesAt(r)(DecodeMapFor(samples)for the widened Decode map). The grid comes from the source size and the delivered reduction, and the overhang is clipped to the unit square, both in the backend's own resampling and in CoreGraphics' sampling.DisplayImage.GetReduction(..., null)for soft masks;DisplayImageMask.GetReductionfor stencils and explicit masks, as 8-bit coverage).GetSamplesAt, and a new reduction forgets the old resampling transforms.PrefetchImagesAsyncto implement and no pool to share (MAUI/Skia tiles: every pooled tile backend converts the same full-size image (3.7 GB peak on a catalogue page) #432 does not apply).Tests
CoreGraphicsScaledImageDecodeTests(29 cases), run locally on macOS: the full CoreGraphics suite passes, 262/262.ScaledImagePages(depths, stencil, soft masks of the image's size and of another size, an explicit mask of another size, and a colour key that is never reduced). All are within PSNR ≥ 35 dB and ≤ 4% of pixels more than 8 levels off, compared with full conversion.Byte identity when off: SHA-256 of 116 page renders (the scaled-image pages, the cover and 20 corpus image files, each at 0.125, 0.25, 1 and 2) is the same on this branch and on the integration tip.
Measurements (macOS, M4 Max;
docs/benchmarks/native-scaled-image-decode.md)First render of the cover's list (decode plus conversion):
At full width (1180 px) and k = 2 nothing changes (no reduction applies).
Conformance: §8.9.4, §8.9.6.2, §8.9.6.3 and §11.6.5.2 rows list the new tests.
🤖 Generated with Claude Code