|
pub(crate) struct WebGL2RenderingContext { |
|
reflector_: Reflector, |
|
base: Dom<WebGLRenderingContext>, |
This is wrong. The WebGLRenderingContext is supposed to be the first field of the struct, not stored separately in a Dom wrapper.
However, this is complicated by this code:
|
let samplers = (0..base.limits().max_combined_texture_image_units) |
|
.map(|_| Default::default()) |
|
.collect::<Vec<_>>() |
|
.into(); |
|
let indexed_uniform_buffer_bindings = (0..base.limits().max_uniform_buffer_bindings) |
|
.map(|_| IndexedBinding::new()) |
|
.collect::<Vec<_>>() |
|
.into(); |
|
let indexed_transform_feedback_buffer_bindings = |
|
(0..base.limits().max_transform_feedback_separate_attribs) |
|
.map(|_| IndexedBinding::new()) |
|
.collect::<Vec<_>>() |
|
.into(); |
We need the limits obtained from creating the context in order to initialize the new DOM context object. I think the way forward here is to extract
|
if pref!(webgl_testing_context_creation_error) { |
|
return Err("WebGL context creation error forced by pref `webgl.testing.context_creation_error`".into()); |
|
} |
|
|
|
let webgl_chan = match window.webgl_chan() { |
|
Some(chan) => chan, |
|
None => return Err("WebGL initialization failed early on".into()), |
|
}; |
|
|
|
let (sender, receiver) = webgl_channel().unwrap(); |
|
webgl_chan |
|
.send(WebGLMsg::CreateContext( |
|
window.webview_id().into(), |
|
webgl_version, |
|
size, |
|
attrs, |
|
sender, |
|
)) |
|
.unwrap(); |
|
let result = receiver.recv().unwrap(); |
into a separate static method that can be called from both WebGLRenderingContext::new and WebGL2RenderingContext::new, and WebGLRenderingContext::new_inherited can just take the values that it needs as arguments.
servo/components/script/dom/webgl/webgl2renderingcontext.rs
Lines 99 to 101 in 8c5aa91
This is wrong. The WebGLRenderingContext is supposed to be the first field of the struct, not stored separately in a Dom wrapper.
However, this is complicated by this code:
servo/components/script/dom/webgl/webgl2renderingcontext.rs
Lines 144 to 156 in 8c5aa91
We need the limits obtained from creating the context in order to initialize the new DOM context object. I think the way forward here is to extract
servo/components/script/dom/webgl/webglrenderingcontext.rs
Lines 240 to 259 in 8c5aa91