Correct the drawing surface density on non-HiDPI displays (macOS) - #113
Open
hard25670559 wants to merge 1 commit into
Open
Correct the drawing surface density on non-HiDPI displays (macOS)#113hard25670559 wants to merge 1 commit into
hard25670559 wants to merge 1 commit into
Conversation
The layer being rendered into can be left at a 2x contents scale while the window reports a 1x backing scale, making the real drawing surface twice the size the window system reports. Everything is then drawn into the lower-left quarter of the window, and only resizing the window or dragging it to another display — either of which rebuilds the surface — restores it. GLFW pushes the window's backing scale onto the layer only when the content scale changes, so a window that opens with the wrong scale and stays on one display is never corrected. Compare the layer's scale against the window's backing scale each frame, correct it when they diverge, and re-read the framebuffer size when it does. This also keeps the surface right when the window moves between displays of differing density.
This was referenced Aug 10, 2026
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
On macOS, the layer being rendered into can be left at a 2x contents scale while the window reports a 1x backing scale. The real drawing surface is then twice the size the window system reports, and everything is drawn into the lower-left quarter of the window. Resizing the window, or dragging it to another display, rebuilds the surface and restores it — which is why the problem looks like it fixes itself.
The macOS packaging fork currently works around this by disabling the Retina/DPI_AWARE renderer path entirely (stevschmid/PathOfBuilding-Mac#3), noting there that
External display/DPI change is out of scope for the moment.Cause
GLFW pushes the window's backing scale onto the layer only from
updateContentScale, i.e. when the scale changes:A window that opens with the wrong scale and then stays on one display never sees a change, so it is never corrected.
Change
Compare the layer's contents scale against the window's backing scale each frame, correct it when they diverge, and re-read the framebuffer size when it does. The check is a float comparison against a cached value and does nothing in the common case.
This also keeps the surface correct when a window is moved between displays of differing density, rather than depending on the resize that may accompany it.
Verification
Built for
arm64-osxand run on a three-display setup (2560x1440 @1x main, 1728x1117 @2x built-in, 1920x1080 @1x).Measured on the affected display before the change:
viewBounds=1280x720 layerScale=2.00 winBacking=1.00 screenBacking=1.00.Notes
Non-Apple platforms are unaffected —
SyncSurfaceScalecompiles to nothing and the helper lives in the existing macOS platform file.If this lands, the workaround in the macOS packaging fork can be reverted so that build regains the Retina renderer path.