Fix DPI-aware TreeView glyph rendering in Translucent Windows - #5
Open
63OR63 wants to merge 1 commit into
Open
Conversation
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
Fixes oversized and blurry TreeView expand/collapse chevrons at non-100% display scaling when Windows theme custom rendering is enabled.
The issue is especially noticeable in the File Explorer navigation pane and also occurs with fractional/custom scaling values such as 120%.
Cause
The existing TreeView glyph rendering path has several DPI-related issues:
Explorer::TreeViewdetection relies on exact floating-point comparison (width / (16 * scale) == 1), which is unreliable at fractional scaling because the expected size can be fractional while the actualRECTdimensions are integers.DrawNineGridStretch(), introducing another bitmap scaling step.Fix
The TreeView glyph is now rendered directly at the final physical target size:
pRectdimensions are passed toCacheTreeViewGlyph().Explorer::TreeViewdetection uses rounded expected physical dimensions instead of exact floating-point equality.AlphaBlend()instead of being resized withDrawNineGridStretch().This avoids resampling an already-rasterized glyph and keeps the chevrons sharp at fractional DPI scaling.
Tested successfully in File Explorer at 100%, custom 120%, 125%, 150%, and 175% display scaling.
Screenshots
Before the fix, at 125% display scaling:

After the fix, at 125% display scaling:

Changelog