Skip to content

perf(desktop-gpui): encode screenshot save and copy with the parallel PNG writer - #2717

Open
kyzer1023 wants to merge 1 commit into
CapSoftware:mainfrom
kyzer1023:cursor/parallel-screenshot-png-c876
Open

kyzer1023 wants to merge 1 commit into
CapSoftware:mainfrom
kyzer1023:cursor/parallel-screenshot-png-c876

Conversation

@kyzer1023

@kyzer1023 kyzer1023 commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

encode_png_rgba (used by screenshot save, copy, transparent share, and the screenshot editor's PNG export) went through the image crate's single-threaded PNG encoder. It now calls the in-tree png::encode (zlib level 6, parallel strips), the same path write_png_file already uses for default compression with adaptive filtering. The CompressionType::Fast capture path is unchanged.

One commit, one file: apps/desktop-gpui/kernels/src/codec.rs. Based on main at 85219015c.

Correctness

Decoded pixels match the previous encoder. cargo +stable test -p cap-gpui-kernels passes (41 tests), including a 16×16 frame of every alpha value (the pattern unannotated_composite_and_copy_preserve_all_alpha_values encodes) and the existing 3024×1964 strip round trip. PNG size stays within about 0.1%.

The full desktop-gpui binary was not built here because gpui is patched to a local zed-cap checkout.

Benchmarks

kernels/benches/png_encode.rs, stable rustc 1.99.1, release, 4 vCPU. Bench median of 10 samples; the bench asserts decoded pixels equal the source.

UI-like RGBA (toolbar, solid window, translucent edge), median of five runs:

Size Before After Speedup
3024×1964 41.6 ms 24.0 ms 1.73×
3840×2160 57.7 ms 34.8 ms 1.66×

Detailed RGBA (screen_like), two runs:

Size Before After Speedup
3024×1964 223.3 / 243.7 ms 68.7 / 77.4 ms 3.25× / 3.15×
3840×2160 305.4 / 305.0 ms 94.6 / 94.6 ms 3.23× / 3.22×

Flat frames have less deflate work, so the gain is smaller there. More cores should widen the gap (the writer uses up to 8 strips).

Overlap

Does not touch filter_rows / adaptive filter code (#2674), rgba_to_rgb / encode_jpeg_rgba_as_rgb (#2672), or capture write_png (#2703).

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge; no actionable issues were found.

Summary

encode_png_rgba now uses the existing parallel PNG writer for screenshot save, copy, transparent share, and PNG export.

  • Screenshot PNG exports use the parallel encoder.

Reviews (1) · Last reviewed commit: "perf(desktop-gpui): encode screenshot PN..." · Reviewed by Greptile

Screenshot save and copy encoded RGBA through the single-threaded image PNG
encoder. encode_png_rgba now calls png::encode (level 6, parallel strips),
the same path write_png_file uses for Default + Adaptive compression.
@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

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