Use raw-window-metal
to do layer creation
#6067
Merged
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
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 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 toash
and PR tovulkano
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 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
layerContentsPlacement
tocontentsGravity
, this should be a non-functional change, since we do as the documentation suggests, and checkcontentsAreFlipped
first, but I haven't tested it enough to be certain.