webgl: Comment why it's okay to overwrite webgl2_context. (#4064)

This commit is contained in:
Kevin Reid
2023-08-16 14:11:30 -07:00
committed by GitHub
parent f61ed50dbf
commit a2c929427b

View File

@@ -25,6 +25,7 @@ impl AdapterContext {
#[derive(Debug)]
pub struct Instance {
/// Set when a canvas is provided, and used to implement [`Instance::enumerate_adapters()`].
webgl2_context: Mutex<Option<web_sys::WebGl2RenderingContext>>,
}
@@ -82,6 +83,8 @@ impl Instance {
.dyn_into()
.expect("canvas context is not a WebGl2RenderingContext");
// It is not inconsistent to overwrite an existing context, because the only thing that
// `self.webgl2_context` is used for is producing the response to `enumerate_adapters()`.
*self.webgl2_context.lock() = Some(webgl2_context.clone());
Ok(Surface {