diff options
-rw-r--r-- | components/script/dom/webglbuffer.rs | 20 | ||||
-rw-r--r-- | components/script/dom/webglframebuffer.rs | 14 | ||||
-rw-r--r-- | components/script/dom/webglprogram.rs | 14 | ||||
-rw-r--r-- | components/script/dom/webglrenderbuffer.rs | 14 | ||||
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 20 | ||||
-rw-r--r-- | components/script/dom/webglshader.rs | 14 | ||||
-rw-r--r-- | components/script/dom/webgltexture.rs | 11 | ||||
-rw-r--r-- | components/script/dom/webglvertexarrayobjectoes.rs | 14 |
8 files changed, 78 insertions, 43 deletions
diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index acf30e28855..9fd8df489d6 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -91,21 +91,25 @@ impl WebGLBuffer { self.capacity.get() } - pub fn mark_for_deletion(&self) { + pub fn mark_for_deletion(&self, fallible: bool) { if self.marked_for_deletion.get() { return; } self.marked_for_deletion.set(true); if self.is_deleted() { - self.delete(); + self.delete(fallible); } } - fn delete(&self) { + fn delete(&self, fallible: bool) { assert!(self.is_deleted()); - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteBuffer(self.id)); + let context = self.upcast::<WebGLObject>().context(); + let cmd = WebGLCommand::DeleteBuffer(self.id); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } } pub fn is_marked_for_deletion(&self) -> bool { @@ -149,7 +153,7 @@ impl WebGLBuffer { .expect("refcount underflowed"), ); if self.is_deleted() { - self.delete(); + self.delete(false); } } @@ -160,6 +164,6 @@ impl WebGLBuffer { impl Drop for WebGLBuffer { fn drop(&mut self) { - self.mark_for_deletion(); + self.mark_for_deletion(true); } } diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 86fb30fb8fd..114ede38b01 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -140,12 +140,16 @@ impl WebGLFramebuffer { )); } - pub fn delete(&self) { + pub fn delete(&self, fallible: bool) { if !self.is_deleted.get() { self.is_deleted.set(true); - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteFramebuffer(self.id)); + let context = self.upcast::<WebGLObject>().context(); + let cmd = WebGLCommand::DeleteFramebuffer(self.id); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } } } @@ -588,7 +592,7 @@ impl WebGLFramebuffer { impl Drop for WebGLFramebuffer { fn drop(&mut self) { - self.delete(); + self.delete(true); } } diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 0dcee20e341..bf198e5382c 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -77,14 +77,18 @@ impl WebGLProgram { } /// glDeleteProgram - pub fn mark_for_deletion(&self) { + pub fn mark_for_deletion(&self, fallible: bool) { if self.marked_for_deletion.get() { return; } self.marked_for_deletion.set(true); - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteProgram(self.id)); + let cmd = WebGLCommand::DeleteProgram(self.id); + let context = self.upcast::<WebGLObject>().context(); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } if self.is_deleted() { self.detach_shaders(); } @@ -443,7 +447,7 @@ impl WebGLProgram { impl Drop for WebGLProgram { fn drop(&mut self) { self.in_use(false); - self.mark_for_deletion(); + self.mark_for_deletion(true); } } diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 459b76466e3..f210b579e88 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -89,7 +89,7 @@ impl WebGLRenderbuffer { .send_command(WebGLCommand::BindRenderbuffer(target, Some(self.id))); } - pub fn delete(&self) { + pub fn delete(&self, fallible: bool) { if !self.is_deleted.get() { self.is_deleted.set(true); @@ -106,9 +106,13 @@ impl WebGLRenderbuffer { fb.detach_renderbuffer(self); } - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteRenderbuffer(self.id)); + let context = self.upcast::<WebGLObject>().context(); + let cmd = WebGLCommand::DeleteRenderbuffer(self.id); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } } } @@ -199,6 +203,6 @@ impl WebGLRenderbuffer { impl Drop for WebGLRenderbuffer { fn drop(&mut self) { - self.delete(); + self.delete(true); } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 3a273f3cfa3..529b9285f2d 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -339,6 +339,12 @@ impl WebGLRenderingContext { .unwrap(); } + pub fn send_command_ignored(&self, command: WebGLCommand) { + let _ = self + .webgl_sender + .send(command, capture_webgl_backtrace(self)); + } + #[inline] pub fn send_vr_command(&self, command: WebVRCommand) { self.webgl_sender.send_vr(command).unwrap(); @@ -1039,7 +1045,7 @@ impl WebGLRenderingContext { self.current_vao.set(None); self.send_command(WebGLCommand::BindVertexArray(None)); } - vao.delete(); + vao.delete(false); } } @@ -2172,7 +2178,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { self.bound_buffer_array.set(None); buffer.decrement_attached_counter(); } - buffer.mark_for_deletion(); + buffer.mark_for_deletion(false); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 @@ -2188,7 +2194,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { WebGLFramebufferBindingRequest::Default )) ); - framebuffer.delete() + framebuffer.delete(false) } } @@ -2205,7 +2211,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { None )) ); - renderbuffer.delete() + renderbuffer.delete(false) } } @@ -2240,7 +2246,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { )); } - texture.delete() + texture.delete(false) } } @@ -2248,7 +2254,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn DeleteProgram(&self, program: Option<&WebGLProgram>) { if let Some(program) = program { handle_potential_webgl_error!(self, self.validate_ownership(program), return); - program.mark_for_deletion() + program.mark_for_deletion(false) } } @@ -2256,7 +2262,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { fn DeleteShader(&self, shader: Option<&WebGLShader>) { if let Some(shader) = shader { handle_potential_webgl_error!(self, self.validate_ownership(shader), return); - shader.mark_for_deletion() + shader.mark_for_deletion(false) } } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 18ec81b1a98..eae89fe3dcb 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -178,12 +178,16 @@ impl WebGLShader { /// Mark this shader as deleted (if it wasn't previously) /// and delete it as if calling glDeleteShader. /// Currently does not check if shader is attached - pub fn mark_for_deletion(&self) { + pub fn mark_for_deletion(&self, fallible: bool) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteShader(self.id)); + let context = self.upcast::<WebGLObject>().context(); + let cmd = WebGLCommand::DeleteShader(self.id); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } } } @@ -230,6 +234,6 @@ impl WebGLShader { impl Drop for WebGLShader { fn drop(&mut self) { - self.mark_for_deletion(); + self.mark_for_deletion(true); } } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 8982e4bca0c..a7e548dcdef 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -180,7 +180,7 @@ impl WebGLTexture { self.populate_mip_chain(self.base_mipmap_level, last_level) } - pub fn delete(&self) { + pub fn delete(&self, fallible: bool) { if !self.is_deleted.get() { self.is_deleted.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -204,7 +204,12 @@ impl WebGLTexture { fb.detach_texture(self); } - context.send_command(WebGLCommand::DeleteTexture(self.id)); + let cmd = WebGLCommand::DeleteTexture(self.id); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } } } @@ -404,7 +409,7 @@ impl WebGLTexture { impl Drop for WebGLTexture { fn drop(&mut self) { - self.delete(); + self.delete(true); } } diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index 871de741c39..22d162782d8 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -57,16 +57,20 @@ impl WebGLVertexArrayObjectOES { self.is_deleted.get() } - pub fn delete(&self) { + pub fn delete(&self, fallible: bool) { assert!(self.id.is_some()); if self.is_deleted.get() { return; } self.is_deleted.set(true); - self.upcast::<WebGLObject>() - .context() - .send_command(WebGLCommand::DeleteVertexArray(self.id.unwrap())); + let context = self.upcast::<WebGLObject>().context(); + let cmd = WebGLCommand::DeleteVertexArray(self.id.unwrap()); + if fallible { + context.send_command_ignored(cmd); + } else { + context.send_command(cmd); + } for attrib_data in &**self.vertex_attribs.borrow() { if let Some(buffer) = attrib_data.buffer() { @@ -248,7 +252,7 @@ impl WebGLVertexArrayObjectOES { impl Drop for WebGLVertexArrayObjectOES { fn drop(&mut self) { if self.id.is_some() { - self.delete(); + self.delete(true); } } } |