Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MacOS retina support #2

Closed
wants to merge 4 commits into from
Closed

Conversation

khogeland
Copy link
Contributor

@khogeland khogeland commented Mar 14, 2024

Ensures the IOSurfaces are created with real pixel values.

See runelite/runelite#17575

@Adam-
Copy link
Member

Adam- commented Mar 14, 2024

This breaks when the display resolution is changed with the display resolution is changed with the game open

Can you elaborate on what this means? Do you mean the resolution or the scaling factor?

@khogeland khogeland closed this Mar 15, 2024
@khogeland khogeland reopened this Mar 15, 2024
@khogeland
Copy link
Contributor Author

Ok, this mostly works, but the screen will freak out when, very specifically: launching with a scale factor of 2, switching to a scale factor of 1, switching back to 2. The screen will flicker until the client is resized or the GPU plugin toggled.

Someone more familiar with this code should take a look, this was way more than I planned on doing. 😄

@khogeland
Copy link
Contributor Author

khogeland commented Mar 15, 2024

Okay, I think this is done now. The flickering was because only one buffer was getting resized, and I'm now getting the current window's scale factor via AWT so it'll update when dragging between monitors etc.

@Adam-
Copy link
Member

Adam- commented Mar 15, 2024

Have you looked at either https://developer.apple.com/documentation/quartzcore/calayer/1410801-rasterizationscale?language=objc or https://developer.apple.com/documentation/quartzcore/calayer/1410746-contentsscale?language=objc ? You might be able to avoid the upcall to get the scale if you can just read it from the calayer.

@khogeland
Copy link
Contributor Author

Yeah, we have to update that field ourselves because the layer we create isn't automatically managed by a view.

rlawt.h Outdated Show resolved Hide resolved
rlawt_mac.m Outdated
}
|| IOSurfaceGetWidth(ctx->buffer[ctx->back]) != ctx->layer.frame.size.width
|| IOSurfaceGetHeight(ctx->buffer[ctx->back]) != ctx->layer.frame.size.height
|| ctx->backingScaleFactor != ctx->layer.superlayer.contentsScale) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the scales are tied to the buffers I would probably make a CGfloat scale[2] in AWTContext to avoid this double-swap

@Adam-
Copy link
Member

Adam- commented Apr 12, 2024

This has been added in d5229d0. Note that your PR is recreating both IO surfaces each frame due to not scaling the dimensions used for the resize check.

@Adam- Adam- closed this Apr 12, 2024
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