Skip to content

fix(desktop-gpui): preserve translucent pixels in mask-only exports - #3244

Merged
richiemcilroy merged 1 commit into
CapSoftware:mainfrom
himanshu748:fix/gpui-mask-only-export-alpha
Oct 25, 2026
Merged

richiemcilroy merged 1 commit into
CapSoftware:mainfrom
himanshu748:fix/gpui-mask-only-export-alpha

Conversation

@himanshu748

@himanshu748 himanshu748 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Mask-only screenshot exports currently premultiply and demultiply the entire canvas even though the shape/text draw loop skips every annotation. Besides unnecessary work, that round trip changes translucent pixels outside the privacy mask: [17, 30, 77, 1] becomes [0, 0, 0, 1]. Even an entirely off-canvas mask triggers it.

Skip that draw stage when the annotation list contains only masks. Mask filtering still runs before it; shape/text exports retain their existing path. The production change is six lines.

Three regression tests cover all alpha values, an off-canvas mask, actual pixelation with untouched translucent pixels outside the mask, and mixed mask/rectangle drawing. All three fail on the original implementation and pass with this change.

CPU benchmark

One on-canvas 256×256 pixelate mask at level 16, on synthetic opaque images or images with a 32-pixel translucent border. Linux x86_64 KVM guest, AMD EPYC 7763, rustc 1.99.1, release thin LTO and one codegen unit. Before and after production compositors ran in the same executable with alternating order, five warmups and 30 measured samples, repeated three times. Times below are medians of the three run medians.

Workload Before After Speedup across runs
1080p opaque 1.516 ms 1.106 ms 1.36–1.40×
1080p translucent border 5.111 ms 2.388 ms 2.11–2.16×
4K opaque 13.884 ms 10.115 ms 1.37–1.38×
4K translucent border 26.962 ms 18.803 ms 1.43–1.44×

Opaque outputs are asserted byte-identical. Translucent outputs intentionally change to preserve original colors; the benchmark asserts preservation outside the mask. These measurements cover CPU composition only, excluding GPU rendering, PNG encoding, disk and native UI. They are not macOS or end-to-end export timings.

The standalone ignored test also confirmed the improvement, but absolute timings differed from the paired harness (4K translucent border: 49.161 → 39.436 ms). Treat the table as the paired synthetic benchmark, not an exact export-latency prediction.

The added ignored test reproduces these workloads against the checked-out revision:

cd apps/desktop-gpui
cargo test -p cap-desktop-gpui --bin cap-gpui screenshot_export::tests
cargo test --release -p cap-desktop-gpui --bin cap-gpui benchmark_mask_only_screenshot_composite -- --ignored --nocapture

Validation and limitations

  • Ran the complete production screenshot_export.rs test module in an isolated Linux harness using actual project types, pixel kernels, tiny-skia, cosmic-text and extracted production geometry/color helpers. Patched: 12 passed, 2 benchmarks ignored; baseline: 9 passed and the three new regressions fail. The new ignored benchmark was also run separately on both revisions and passed.
  • The same harness compiles both production revisions for the paired benchmark; baseline is 0983901353c759f4857520afdfdc5fe12b2ff19a.
  • Touched-file rustfmt and git diff --check pass. Workspace formatting reports existing differences in untouched files.
  • The official setup successfully prepared the public, pinned zed-cap dependency and Cap's six patches; locked Cargo dependencies were fetched as well. The subsequent local cargo check --locked --offline exited at alsa-sys because pkg-config could not find alsa.pc (the required ALSA development package). No interactive application or macOS performance measurement was performed here.
  • Upstream native GPUI CI passed on Linux (1495 app tests), Windows (1402), Apple Silicon macOS (1443), and Intel macOS (1438). Each job's logs explicitly show all three new regressions passing. Linux desktop reliability, Engine verify, Verify recording, and Perf budget also passed. All GitHub Actions workflows completed successfully on commit 7c6102c12f4abcf6c95a98c42d31289c404afcf0.

This follows the empty-annotation optimization in #2493 and is compatible with #2742's draw-call relocation. It does not change the frame-copy work in #3138.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Preserves translucent colors in mask-only screenshot exports by skipping an unnecessary alpha conversion.

  • Mask-only screenshot exports preserve untouched translucent pixels.

No actionable issues found. Review was based on code inspection; no tests or benchmarks were run.

Reviews (1) · Last reviewed commit: "fix(desktop-gpui): preserve translucent ..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@himanshu748 is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

@himanshu748
himanshu748 marked this pull request as ready for review October 25, 2026 13:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T13:31:19.870923Z
We couldn’t complete this review. Comment @codex review to try again.
7c6102c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@richiemcilroy
richiemcilroy merged commit 7ed9c74 into CapSoftware:main Oct 25, 2026
61 of 63 checks passed
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.

2 participants