Repository navigation
perf(desktop-gpui): fast row blit for opaque picker thumbnails - #2670
Open
nikolas-sapa wants to merge 3 commits into
Open
nikolas-sapa wants to merge 3 commits into
nikolas-sapa wants to merge 3 commits into
Conversation
- Replace per-pixel imageops::overlay with row-by-row slice copy when thumbnail is opaque - Keeps identical bit-for-bit output while skipping per-pixel float alpha blending and bounds checks - Speedup: 5.7x to 8.3x on fitted thumbnails (e.g. fitted-wide: 65 µs -> 8 µs, fitted-near-full: 77 µs -> 9.3 µs)
Contributor
|
@nikolas-sapa is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
@greptileai review |
This branch has not been deployed
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.
Description
In
fit_centered, centering a fitted image onto a newly created transparent canvas currently usesimage::imageops::overlay.Because
canvasis already empty ([0, 0, 0, 0]), source-over alpha blending onto it is an identity operation:alpha == 255),overlayruns floating-point alpha calculations, bounds checks, andput_pixelper-pixel.is_opaquehelper, we can copy rows directly viacopy_from_slice, completely bypassing the per-pixel float math and bounds checks.imageops::overlayto preserve identical behavior.Benchmarks
Tested on Apple Silicon using
cargo bench --bench thumbnail_fit:fitted-widefitted-tallfitted-squarefitted-near-fullupscaledownscaledownscale-1080pVerification
cargo test -p cap-gpui-kernels: all 30 tests pass (includingfitted_sources_keep_exact_centering_and_transparent_padding,resized_sources_match_lanczos_reference,exact_size_preserves_hidden_rgb_and_source_pixels).

Confidence Score: 5/5
This PR appears safe to merge.Summary
fit_centerednow copies opaque thumbnail rows directly into the transparent canvas.Reviews (2) · Last reviewed commit: "Merge branch 'main' into perf/gpui-fast-..." · Reviewed by Greptile