Commit fb0cb1e
authored
[metal] Improve layer initialization and resizing (#6107)
* [metal]: Create a new layer instead of overwriting the existing one
Overriding the `layer` on `NSView` makes the view "layer-hosting", see
[wantsLayer], which disables drawing functionality on the view like
`drawRect:`/`updateLayer`.
This prevents crates like Winit from providing a robust rendering
callback that integrates well with the rest of the system.
Instead, if the layer is not CAMetalLayer, we create a new sublayer, and
render to that instead.
[wantsLayer]: https://developer.apple.com/documentation/appkit/nsview/1483695-wantslayer?language=objc
* [metal]: Fix double-free when re-using layer
* doc: Document the behavior when mis-configuring width/height of Surface
* [metal]: Use kCAGravityResize for smoother resizing
* [metal] Do not keep the view around that the surface was created from
We do not need to use it, and the layer itself is already retained, so
it won't be de-allocated from under our feet.
* Always set delegate on layers created by Wgpu
* More docs on contentsGravity1 parent 9b36a3e commit fb0cb1e
File tree
4 files changed
+216
-112
lines changed- wgpu-hal/src
- metal
- vulkan
- wgpu-types/src
4 files changed
+216
-112
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
| |||
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 114 | + | |
119 | 115 | | |
120 | 116 | | |
121 | 117 | | |
| |||
126 | 122 | | |
127 | 123 | | |
128 | 124 | | |
129 | | - | |
130 | | - | |
| 125 | + | |
131 | 126 | | |
132 | 127 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
139 | 131 | | |
140 | 132 | | |
141 | 133 | | |
| |||
367 | 359 | | |
368 | 360 | | |
369 | 361 | | |
370 | | - | |
371 | 362 | | |
372 | 363 | | |
373 | 364 | | |
| |||
0 commit comments