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

This commit is contained in:
Kevin Reid authored and GitHub committed 2023-08-16 17:11:30 -04:00
1 parent f61ed50dbf
commit a2c929427b
1 file changed
+3
+3
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 {