Repository navigation
feat(skia): decode JPEG images with SkiaSharp's SKCodec, scaled and bit-identical (#374) - #485
Merged
Merged
Conversation
…kia-jpeg-decoder # Conflicts: # docs/conformance/iso-32000-2.md
…kia-jpeg-decoder # Conflicts: # docs/conformance/iso-32000-2.md
SkiaImageDecodeBenchmarks and SkiaFirstTileBenchmarks are new. The values are the CI gate's measurements. The 4:2:0 first tile at 1206 px decodes managed, because the Skia decoder declines full-size 4:2:0.
…kia-jpeg-decoder # Conflicts: # docs/conformance/iso-32000-2.md
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
The eight SkiaFirstTileBenchmarks cases (added by #485) each allocate 96 B more per call with the #472 changes. This is a one-time cost per document in the cold path, where every call opens a new document and converts its image; it is not paid per row or pixel. The packing and gray-expansion kernels allocate nothing (PixelPackingBenchmarks reads 0). The baseline takes the gate's measured values. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com>
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
Reverts the previous baseline update. The next gate run measured the original values for the eight SkiaFirstTileBenchmarks cases, so their 96 B difference flips from run to run on the same code and #472 does not cause it. The baseline keeps the values #485 recorded. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com>
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
… (#493) * perf(rendering): vectorize the box filter's channel accumulation (#475) * docs(benchmarks): record the box filter kernel and its whole-page effect (#475) * docs(benchmarks): add the browser CI kernel lines for the box filter (#475) * docs(rendering): say the box filter's vector path is slower in both browser builds (#475) * test(perf): record the SkiaFirstTileBenchmarks allocations as measured (#475) The gate reported only the eight SkiaFirstTileBenchmarks.FirstTile cases, each 224 B per call above the baseline from #485 (these cases include image conversion); every other case is unchanged. Updated to the values the gate measured. * docs(benchmarks): add the x64 bench gate replays for the box filter (#475)
michaelstonis
added a commit
that referenced
this pull request
Nov 11, 2026
…xpansion (#472) (#491) * perf(rendering): vectorize BGRA packing, premultiplication and gray expansion (#472) - PixelPacking packs a converted RGB row and its folded opacity into premultiplied BGRA (or RGBA for WebGL) with Vector128: four overlapping loads and one constant shuffle per four pixels, the multiply and the rounding division by 255 in 16-bit lanes. Bit-exact with the scalar loop it replaces (exhaustive over every color and opacity, and every opaque RGB triple). - ImageRows.PackBgra and PackRgba expose it to the software rasterizer's ImageSource and to the Skia, CoreGraphics, Direct2D, Android and WebGL image converters, which all carried the same scalar loop. - GrayExpansion replaces the per-sample three-byte table copy of a one-component space whose byte table holds the grays (DeviceGray on an RGB device) with three constant shuffles per 16 samples; other tables are looked up without the per-sample Slice and CopyTo. - PixelPackingBenchmarks, KernelBenchmarks cases for the browser builds, and the allocation baseline entries at 0. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * docs(benchmarks): record the #472 pixel packing and gray expansion kernels Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * test(perf): record the SkiaFirstTileBenchmarks allocations after #472 The eight SkiaFirstTileBenchmarks cases (added by #485) each allocate 96 B more per call with the #472 changes. This is a one-time cost per document in the cold path, where every call opens a new document and converts its image; it is not paid per row or pixel. The packing and gray-expansion kernels allocate nothing (PixelPackingBenchmarks reads 0). The baseline takes the gate's measured values. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> * test(perf): restore the SkiaFirstTileBenchmarks allocation baseline Reverts the previous baseline update. The next gate run measured the original values for the eight SkiaFirstTileBenchmarks cases, so their 96 B difference flips from run to run on the same code and #472 does not cause it. The baseline keeps the values #485 recorded. Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.com> --------- Signed-off-by: Michael Stonis <120685+michaelstonis@users.noreply.github.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.
Closes #374.
What
SkiaImageDecoder(Broadside.Rendering.Skia) implementsIPlatformImageDecoderwith SkiaSharp'sSKCodec, which wraps libjpeg-turbo:GetScaledDimensions(1/2^r)picks the DCT scaling, and the decoder reports the reduction it delivers.DecodedImageBuilderas 1 or 3 components.UseSkiaImageDecoder()registers it.PdfViewregisters the decoder in the engine it builds; the logic moved fromPdfView.WithSkiatoSkiaViewerOptions.For. An engine the app gives is used as it is.DocumentOptions.WithPlatformImageDecoder("skia", false)turns the decoder off.PlatformImageRequest.ChromaHorizontalSubsamplingandChromaVerticalSubsamplinggive Hmax / Hc and Vmax / Vc, 0 for patterns that have no single ratio. They are byte-backed, so the struct does not grow.Deviations from the issue, with reasons
Exact, notTolerance, and the decoder is on by default in the MAUI viewer.testorig, 40 to 46 dB on the 4:2:2 and 4:4:0 vectors, and 51.9 dB with 1.075% of pixels over 2 levels on a 4:2:0 photograph.CanDecodetherefore uses libjpeg-turbo's own rule (jdmaster.cchroma IDCT enlargement,jdsample.cfancy upsampling) to decline the interpolated cases. The rule needs the new chroma ratios.Rgb888x. Skia's JPEG codec returnsInvalidConversionforRgb888x. The decoder reads RGBA and drops the alpha byte.GetPixelsbuffer. The only scratch is 16 rows; an image-sized buffer would be 32 MB for 8 MP. The output is identical either way.Task.Run. A synchronousDecodeAsyncis never in flight inPlatformImageDecoding.Join, so concurrent tiles each decoded the image (a test measured 8 decodes for 8 tiles). This made the half-width iOS view slower than managed. Filed Platform image decoding: a decoder that completes synchronously is not shared by concurrent prefetches #484 for the core fix, since the ImageIO and Android decoders are exposed the same way.sk_codec_*yuva*export and no managed member. A full-size 4:2:0 image decodes managed.ImageDecodedManaged. The core's shared rule never offers them, so no diagnostic is recorded. The test asserts that they decode managed and that there are no platform diagnostics. Data Skia rejects (a truncated scan) recordsImageDecodedManaged.Tests
Broadside.Rendering.Skia.Tests.SkiaImageDecoderTests, underVerifyPlatformImageDecoder:ImageDecodedManaged;dct-*.pdfand the covers are byte-identical with the decoder on and off;Broadside.Viewer.Maui.Tests.SkiaImageDecoderRegistrationTestsandPlatformImageEligibilityTests(chroma ratios).Measurements
The full figures are in
docs/benchmarks/skia-image-decoder.md.PhotoBench:issue12841_reduced.pdf(the issue's gate file): unchanged, 175 vs 179 ms. The page draws its 4:2:0 image enlarged, so no reduction applies and the image stays managed.Checklist
SkiaImageDecodeBenchmarksandSkiaFirstTileBenchmarks. Their gate baseline entries come from CI's artifact.PublicAPI.Unshipped.txtupdated for core and Skia.ConformanceCheckOK.PlatformImageEligibility, which theplatform-image-eligibilitytarget already covers.