diff options
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 29 | ||||
-rw-r--r-- | tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/object-deletion-behaviour.html.ini | 3 |
2 files changed, 24 insertions, 8 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index cd336e02e50..96eb0ae98df 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -61,6 +61,24 @@ macro_rules! handle_potential_webgl_error { }; } +// From the GLES 2.0.25 spec, page 85: +// +// "If a texture that is currently bound to one of the targets +// TEXTURE_2D, or TEXTURE_CUBE_MAP is deleted, it is as though +// BindTexture had been executed with the same target and texture +// zero." +// +// and similar text occurs for other object types. +macro_rules! handle_object_deletion { + ($binding:expr, $object:ident) => { + if let Some(bound_object) = $binding.get() { + if bound_object.id() == $object.id() { + $binding.set(None); + } + } + }; +} + /// Set of bitflags for texture unpacking (texImage2d, etc...) bitflags! { #[derive(HeapSizeOf, JSTraceable)] @@ -1101,6 +1119,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 fn DeleteBuffer(&self, buffer: Option<&WebGLBuffer>) { if let Some(buffer) = buffer { + handle_object_deletion!(self.bound_buffer_array, buffer); + handle_object_deletion!(self.bound_buffer_element_array, buffer); buffer.delete() } } @@ -1108,11 +1128,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 fn DeleteFramebuffer(&self, framebuffer: Option<&WebGLFramebuffer>) { if let Some(framebuffer) = framebuffer { - if let Some(bound_fb) = self.bound_framebuffer.get() { - if bound_fb.id() == framebuffer.id() { - self.bound_framebuffer.set(None); - } - } + handle_object_deletion!(self.bound_framebuffer, framebuffer); framebuffer.delete() } } @@ -1127,6 +1143,8 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8 fn DeleteTexture(&self, texture: Option<&WebGLTexture>) { if let Some(texture) = texture { + handle_object_deletion!(self.bound_texture_2d, texture); + handle_object_deletion!(self.bound_texture_cube_map, texture); texture.delete() } } @@ -1134,6 +1152,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 fn DeleteProgram(&self, program: Option<&WebGLProgram>) { if let Some(program) = program { + handle_object_deletion!(self.current_program, program); program.delete() } } diff --git a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/object-deletion-behaviour.html.ini b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/object-deletion-behaviour.html.ini index 2dc8b16d510..04cdda15902 100644 --- a/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/object-deletion-behaviour.html.ini +++ b/tests/wpt/metadata/webgl/conformance-1.0.3/conformance/misc/object-deletion-behaviour.html.ini @@ -68,9 +68,6 @@ [WebGL test #48: getError expected: NO_ERROR. Was INVALID_ENUM : after evaluating: gl.bindTexture(gl.TEXTURE_2D, t)] expected: FAIL - [WebGL test #52: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)] - expected: FAIL - [WebGL test #56: gl.getParameter(gl.TEXTURE_BINDING_2D) should be [object WebGLTexture\]. Was null.] expected: FAIL |