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

Use raw-window-metal to do layer creation #6067

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Sep 9, 2024

The logic for creating the CAMetalLayer if it doesn't exist is complex, and currently Slint is doing it wrong and prevents Winit from scheduling redraw events at the correct time. I have abstracted this away into raw-window-metal, it works by creating a layer, and inserting that as a sublayer. The bounds and scale factor are then kept in-sync with an observer, ensuring smooth resizing. This is also important for iOS support, since overwriting the layer, as currently done, isn't possible there.

See also corresponding PR to wgpu, PR to ash and PR to vulkano for more details and reasoning.

I'm pretty sure that you can remove Surface::set_scale_factor after this, it seems to have only been used for MetalSurface, but it would be a breaking change so I'm inclined to let someone else do it later.

Note also the change from setting layerContentsPlacement to contentsGravity, this should be a non-functional change, since we do as the documentation suggests, and check contentsAreFlipped first, but I haven't tested it enough to be certain.

@CLAassistant
Copy link

CLAassistant commented Sep 9, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@tronical tronical left a comment

Choose a reason for hiding this comment

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

Thank you! Just last week I observed your new crate and was going to do exactly what you suggested. I've also made the same observation with iOS.

@tronical tronical merged commit 945e65f into slint-ui:master Sep 10, 2024
36 checks passed
@madsmtm madsmtm deleted the raw-window-metal branch September 10, 2024 08:22
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.

3 participants