File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,18 @@ impl UnsafeWindowSurface {
163
163
164
164
context. present ( ) . map_err ( JsErrorBox :: from_err)
165
165
}
166
+
167
+ #[ fast]
168
+ fn resize ( & self , width : u32 , height : u32 , scope : & mut v8:: HandleScope ) {
169
+ self . width . replace ( width) ;
170
+ self . height . replace ( height) ;
171
+
172
+ let Some ( context) = self . context . try_unwrap ( scope) else {
173
+ return ;
174
+ } ;
175
+
176
+ context. resize_configure ( width, height) ;
177
+ }
166
178
}
167
179
168
180
struct UnsafeWindowSurfaceOptions {
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ pub struct Configuration {
32
32
pub device : Ptr < GPUDevice > ,
33
33
pub usage : u32 ,
34
34
pub format : GPUTextureFormat ,
35
+ pub surface_config :
36
+ wgpu_types:: SurfaceConfiguration < Vec < wgpu_types:: TextureFormat > > ,
35
37
}
36
38
37
39
pub struct GPUCanvasContext {
@@ -97,6 +99,7 @@ impl GPUCanvasContext {
97
99
device,
98
100
usage : configuration. usage ,
99
101
format : configuration. format ,
102
+ surface_config : conf,
100
103
} ) ;
101
104
102
105
Ok ( ( ) )
@@ -173,6 +176,27 @@ impl GPUCanvasContext {
173
176
174
177
Ok ( ( ) )
175
178
}
179
+
180
+ pub fn resize_configure ( & self , width : u32 , height : u32 ) {
181
+ self . width . replace ( width) ;
182
+ self . height . replace ( height) ;
183
+
184
+ let mut config = self . config . borrow_mut ( ) ;
185
+ let Some ( config) = & mut * config else {
186
+ return ;
187
+ } ;
188
+
189
+ config. surface_config . width = width;
190
+ config. surface_config . height = height;
191
+
192
+ let err = config. device . instance . surface_configure (
193
+ self . surface_id ,
194
+ config. device . id ,
195
+ & config. surface_config ,
196
+ ) ;
197
+
198
+ config. device . error_handler . push_error ( err) ;
199
+ }
176
200
}
177
201
178
202
#[ derive( WebIDL ) ]
You can’t perform that action at this time.
0 commit comments