Use raw-window-metal to do layer creation#6067
Merged
tronical merged 1 commit intoslint-ui:masterfrom Sep 10, 2024
Merged
Conversation
4044350 to
12b221a
Compare
tronical
approved these changes
Sep 10, 2024
Member
tronical
left a comment
There was a problem hiding this comment.
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.
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.
The logic for creating the
CAMetalLayerif 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 intoraw-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 toashand PR tovulkanofor more details and reasoning.I'm pretty sure that you can remove
Surface::set_scale_factorafter this, it seems to have only been used forMetalSurface, but it would be a breaking change so I'm inclined to let someone else do it later.Note also the change from setting
layerContentsPlacementtocontentsGravity, this should be a non-functional change, since we do as the documentation suggests, and checkcontentsAreFlippedfirst, but I haven't tested it enough to be certain.