fix: anti-alias presentation downscaling with an area filter - #29
Open
maryny4 wants to merge 1 commit into
Open
Conversation
Presentation scaling picked a single nearest source pixel per output pixel, so downscaling a 4K output to a window-sized presentation drops most source pixels and renders text with heavy aliasing. Average the source region each output pixel covers instead (integer box filter, rounded). For upscaling the box degenerates to one source pixel, matching the previous behavior, and the identity path is untouched. (cherry picked from commit 5edcda3)
maryny4
marked this pull request as draft
August 6, 2026 13:18
maryny4
marked this pull request as ready for review
August 6, 2026 13:22
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.
Problem
Presentation scaling picks a single nearest source pixel per output pixel. When a 4K physical output is presented at a window-sized resolution (e.g. 3840x2160 → ~1536x864), most source pixels are simply dropped, and fine content — text above all — renders with heavy aliasing ("pixelated" look reported by users of physical-output capture).
Fix
Average the source region each output pixel covers (integer box filter with rounding). Downscaling now anti-aliases; for upscaling the box degenerates to a single source pixel, matching the previous behavior byte for byte, and the identity path stays zero-copy as before.
A regression test downscales a black/white pair to one pixel and asserts mid-gray — nearest sampling would return one of the extremes.
cargo fmt --check,clippy -- -D warnings,cargo test(both feature sets) pass.