diff options
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/crates/gpu/src/context.rs | 9 | ||||
| -rw-r--r-- | rust/wasm/src/compositor.rs | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/rust/crates/gpu/src/context.rs b/rust/crates/gpu/src/context.rs index da835280..353d54da 100644 --- a/rust/crates/gpu/src/context.rs +++ b/rust/crates/gpu/src/context.rs @@ -604,6 +604,10 @@ impl GpuContext { width: u32, height: u32, ) -> Result<(), GpuError> { + let previous_size = self + .gl_canvas + .as_ref() + .map(|gl_canvas| (gl_canvas.width(), gl_canvas.height())); let gl_canvas = self.render_texture_to_gl_canvas_surface(texture, width, height)?; let ctx: web_sys::OffscreenCanvasRenderingContext2d = canvas @@ -616,6 +620,11 @@ impl GpuContext { ctx.draw_image_with_html_canvas_element(gl_canvas, 0.0, 0.0) .map_err(|_| GpuError::AdapterUnavailable)?; + if let Some((previous_width, previous_height)) = previous_size { + gl_canvas.set_width(previous_width); + gl_canvas.set_height(previous_height); + } + Ok(()) } diff --git a/rust/wasm/src/compositor.rs b/rust/wasm/src/compositor.rs index 7652b3f3..4d73e9ad 100644 --- a/rust/wasm/src/compositor.rs +++ b/rust/wasm/src/compositor.rs @@ -81,13 +81,11 @@ pub fn resize_compositor(width: u32, height: u32) -> Result<(), JsValue> { }; runtime.canvas.set_width(width); runtime.canvas.set_height(height); - if runtime.surface_size != (width, height) { - gpu_runtime - .context - .configure_surface(&runtime.surface, width, height) - .map_err(|error| JsValue::from_str(&error.to_string()))?; - runtime.surface_size = (width, height); - } + gpu_runtime + .context + .configure_surface(&runtime.surface, width, height) + .map_err(|error| JsValue::from_str(&error.to_string()))?; + runtime.surface_size = (width, height); Ok(()) }) }) |
