diff options
author | Tobias Tschinkowitz <tobias.tschinkowitz@icloud.com> | 2020-04-23 18:23:01 +0200 |
---|---|---|
committer | Tobias Tschinkowitz <tobias.tschinkowitz@icloud.com> | 2020-04-23 18:23:01 +0200 |
commit | 9c343fcc9600a1a2b768a4632793d0856d55ddce (patch) | |
tree | 468ae96e83fb1986e392d5b1c2bdece3bd17f67f /components/script | |
parent | 60e75314feaf0b5009f0cabfca6930ef1a584f27 (diff) | |
download | servo-9c343fcc9600a1a2b768a4632793d0856d55ddce.tar.gz servo-9c343fcc9600a1a2b768a4632793d0856d55ddce.zip |
Replaced failible boolean with an enum
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/vertexarrayobject.rs | 23 | ||||
-rw-r--r-- | components/script/dom/webgl2renderingcontext.rs | 18 | ||||
-rw-r--r-- | components/script/dom/webglbuffer.rs | 21 | ||||
-rw-r--r-- | components/script/dom/webglframebuffer.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglprogram.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglquery.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglrenderbuffer.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 26 | ||||
-rw-r--r-- | components/script/dom/webglsampler.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglshader.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglsync.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webgltexture.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webgltransformfeedback.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglvertexarrayobject.rs | 6 | ||||
-rw-r--r-- | components/script/dom/webglvertexarrayobjectoes.rs | 6 |
15 files changed, 106 insertions, 111 deletions
diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index 34ef5b428bb..fcf6461e2a8 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.rs @@ -7,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebG use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::root::{Dom, MutNullableDom}; use crate::dom::webglbuffer::WebGLBuffer; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{ ActiveAttribInfo, WebGLCommand, WebGLError, WebGLResult, WebGLVersion, WebGLVertexArrayId, }; @@ -45,26 +45,25 @@ impl VertexArrayObject { self.is_deleted.get() } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { assert!(self.id.is_some()); if self.is_deleted.get() { return; } self.is_deleted.set(true); let cmd = WebGLCommand::DeleteVertexArray(self.id.unwrap()); - if fallible { - self.context.send_command_ignored(cmd); - } else { - self.context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => self.context.send_command_ignored(cmd), + Operation::Infallible => self.context.send_command(cmd), } for attrib_data in &**self.vertex_attribs.borrow() { if let Some(buffer) = attrib_data.buffer() { - buffer.decrement_attached_counter(fallible); + buffer.decrement_attached_counter(operation_fallibility); } } if let Some(buffer) = self.element_array_buffer.get() { - buffer.decrement_attached_counter(fallible); + buffer.decrement_attached_counter(operation_fallibility); } } @@ -156,7 +155,7 @@ impl VertexArrayObject { offset as u32, )); if let Some(old) = data.buffer() { - old.decrement_attached_counter(false); + old.decrement_attached_counter(Operation::Infallible); } *data = VertexAttribData { @@ -188,7 +187,7 @@ impl VertexArrayObject { if b.id() != buffer.id() { continue; } - b.decrement_attached_counter(false); + b.decrement_attached_counter(Operation::Infallible); } attrib.buffer = None; } @@ -197,7 +196,7 @@ impl VertexArrayObject { .get() .map_or(false, |b| buffer == &*b) { - buffer.decrement_attached_counter(false); + buffer.decrement_attached_counter(Operation::Infallible); self.element_array_buffer.set(None); } } @@ -256,7 +255,7 @@ impl VertexArrayObject { impl Drop for VertexArrayObject { fn drop(&mut self) { if self.id.is_some() { - self.delete(true); + self.delete(Operation::Fallible); } } } diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 4bb102bff12..9d73a22e0ad 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -26,7 +26,7 @@ use crate::dom::webglprogram::WebGLProgram; use crate::dom::webglquery::WebGLQuery; use crate::dom::webglrenderbuffer::WebGLRenderbuffer; use crate::dom::webglrenderingcontext::{ - uniform_get, uniform_typed, LayoutCanvasWebGLRenderingContextHelpers, VertexAttrib, + uniform_get, uniform_typed, LayoutCanvasWebGLRenderingContextHelpers, Operation, VertexAttrib, WebGLRenderingContext, }; use crate::dom::webglsampler::{WebGLSampler, WebGLSamplerValue}; @@ -339,7 +339,7 @@ impl WebGL2RenderingContext { fn unbind_from(&self, slot: &MutNullableDom<WebGLBuffer>, buffer: &WebGLBuffer) { if slot.get().map_or(false, |b| buffer == &*b) { - buffer.decrement_attached_counter(false); + buffer.decrement_attached_counter(Operation::Infallible); slot.set(None); } } @@ -1633,7 +1633,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { self.unbind_from(&binding.buffer, &buffer); } - buffer.mark_for_deletion(false); + buffer.mark_for_deletion(Operation::Infallible); } /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 @@ -3054,7 +3054,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } } - query.delete(false); + query.delete(Operation::Infallible); } } @@ -3080,7 +3080,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { slot.set(None); } } - sampler.delete(false); + sampler.delete(Operation::Infallible); } } @@ -3311,7 +3311,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { fn DeleteSync(&self, sync: Option<&WebGLSync>) { if let Some(sync) = sync { handle_potential_webgl_error!(self.base, self.base.validate_ownership(sync), return); - sync.delete(false); + sync.delete(Operation::Infallible); } } @@ -3390,7 +3390,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { self.base.webgl_error(InvalidOperation); return; } - tf.delete(false); + tf.delete(Operation::Infallible); self.current_transform_feedback.set(None); } } @@ -3624,7 +3624,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { for slot in &[&generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { - old.decrement_attached_counter(false); + old.decrement_attached_counter(Operation::Infallible); } slot.set(buffer); } @@ -3702,7 +3702,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { for slot in &[&generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { - old.decrement_attached_counter(false); + old.decrement_attached_counter(Operation::Infallible); } slot.set(buffer); } diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index 5ee1e7e1373..f81270d8240 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -9,7 +9,7 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::webgl_channel; use canvas_traits::webgl::{WebGLBufferId, WebGLCommand, WebGLError, WebGLResult}; use dom_struct::dom_struct; @@ -97,24 +97,23 @@ impl WebGLBuffer { self.capacity.get() } - pub fn mark_for_deletion(&self, fallible: bool) { + pub fn mark_for_deletion(&self, operation_fallibility: Operation) { if self.marked_for_deletion.get() { return; } self.marked_for_deletion.set(true); if self.is_deleted() { - self.delete(fallible); + self.delete(operation_fallibility); } } - fn delete(&self, fallible: bool) { + fn delete(&self, operation_fallibility: Operation) { assert!(self.is_deleted()); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteBuffer(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } @@ -164,7 +163,7 @@ impl WebGLBuffer { ); } - pub fn decrement_attached_counter(&self, fallible: bool) { + pub fn decrement_attached_counter(&self, operation_fallibility: Operation) { self.attached_counter.set( self.attached_counter .get() @@ -172,7 +171,7 @@ impl WebGLBuffer { .expect("refcount underflowed"), ); if self.is_deleted() { - self.delete(fallible); + self.delete(operation_fallibility); } } @@ -183,6 +182,6 @@ impl WebGLBuffer { impl Drop for WebGLBuffer { fn drop(&mut self) { - self.mark_for_deletion(true); + self.mark_for_deletion(Operation::Fallible); } } diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 4b2f7c7d56e..9f38365c4c7 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::webglobject::WebGLObject; use crate::dom::webglrenderbuffer::WebGLRenderbuffer; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::webgltexture::WebGLTexture; use crate::dom::xrsession::XRSession; use canvas_traits::webgl::{webgl_channel, WebGLError, WebGLResult, WebGLVersion}; @@ -207,15 +207,14 @@ impl WebGLFramebuffer { )); } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteFramebuffer(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -977,7 +976,7 @@ impl WebGLFramebuffer { impl Drop for WebGLFramebuffer { fn drop(&mut self) { - let _ = self.delete(true); + let _ = self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 79598f7f5c1..88cecf0296f 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -12,7 +12,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::DOMString; use crate::dom::webglactiveinfo::WebGLActiveInfo; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::webglshader::WebGLShader; use crate::dom::webgluniformlocation::WebGLUniformLocation; use canvas_traits::webgl::{webgl_channel, WebGLProgramId, WebGLResult}; @@ -84,17 +84,16 @@ impl WebGLProgram { } /// glDeleteProgram - pub fn mark_for_deletion(&self, fallible: bool) { + pub fn mark_for_deletion(&self, operation_fallibility: Operation) { if self.marked_for_deletion.get() { return; } self.marked_for_deletion.set(true); let cmd = WebGLCommand::DeleteProgram(self.id); let context = self.upcast::<WebGLObject>().context(); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } if self.is_deleted() { self.detach_shaders(); @@ -639,7 +638,7 @@ impl WebGLProgram { impl Drop for WebGLProgram { fn drop(&mut self) { self.in_use(false); - self.mark_for_deletion(true); + self.mark_for_deletion(Operation::Fallible); } } diff --git a/components/script/dom/webglquery.rs b/components/script/dom/webglquery.rs index d7418471936..454fe72954e 100644 --- a/components/script/dom/webglquery.rs +++ b/components/script/dom/webglquery.rs @@ -8,7 +8,7 @@ use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::task_source::TaskSource; use canvas_traits::webgl::WebGLError::*; use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLQueryId}; @@ -96,16 +96,15 @@ impl WebGLQuery { Ok(()) } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); let command = WebGLCommand::DeleteQuery(self.gl_id); - if fallible { - context.send_command_ignored(command); - } else { - context.send_command(command); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(command), + Operation::Infallible => context.send_command(command), } } } @@ -187,6 +186,6 @@ impl WebGLQuery { impl Drop for WebGLQuery { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index f1a3ba99c53..204fe9ab46e 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::webglframebuffer::WebGLFramebuffer; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{ webgl_channel, GlType, InternalFormatIntVec, WebGLCommand, WebGLError, WebGLRenderbufferId, WebGLResult, WebGLVersion, @@ -90,7 +90,7 @@ impl WebGLRenderbuffer { .send_command(WebGLCommand::BindRenderbuffer(target, Some(self.id))); } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); @@ -113,10 +113,9 @@ impl WebGLRenderbuffer { } let cmd = WebGLCommand::DeleteRenderbuffer(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -277,6 +276,6 @@ impl WebGLRenderbuffer { impl Drop for WebGLRenderbuffer { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 53dff84c6ec..8c02ad6ec69 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -155,6 +155,12 @@ pub enum VertexAttrib { Uint(u32, u32, u32, u32), } +#[derive(Clone, Copy, Debug)] +pub enum Operation { + Fallible, + Infallible, +} + #[dom_struct] pub struct WebGLRenderingContext { reflector_: Reflector, @@ -1142,7 +1148,7 @@ impl WebGLRenderingContext { self.current_vao.set(None); self.send_command(WebGLCommand::BindVertexArray(None)); } - vao.delete(false); + vao.delete(Operation::Infallible); } } @@ -1160,7 +1166,7 @@ impl WebGLRenderingContext { self.current_vao_webgl2.set(None); self.send_command(WebGLCommand::BindVertexArray(None)); } - vao.delete(false); + vao.delete(Operation::Infallible); } } @@ -1335,7 +1341,7 @@ impl WebGLRenderingContext { self.send_command(WebGLCommand::BindBuffer(target, buffer.map(|b| b.id()))); if let Some(old) = slot.get() { - old.decrement_attached_counter(false); + old.decrement_attached_counter(Operation::Infallible); } slot.set(buffer); @@ -2583,9 +2589,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { .map_or(false, |b| buffer == &*b) { self.bound_buffer_array.set(None); - buffer.decrement_attached_counter(false); + buffer.decrement_attached_counter(Operation::Infallible); } - buffer.mark_for_deletion(false); + buffer.mark_for_deletion(Operation::Infallible); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 @@ -2605,7 +2611,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { WebGLFramebufferBindingRequest::Default )) ); - framebuffer.delete(false) + framebuffer.delete(Operation::Infallible) } } @@ -2622,7 +2628,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { None )) ); - renderbuffer.delete(false) + renderbuffer.delete(Operation::Infallible) } } @@ -2657,7 +2663,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { )); } - texture.delete(false) + texture.delete(Operation::Infallible) } } @@ -2665,7 +2671,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(false) + program.mark_for_deletion(Operation::Infallible) } } @@ -2673,7 +2679,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(false) + shader.mark_for_deletion(Operation::Infallible) } } diff --git a/components/script/dom/webglsampler.rs b/components/script/dom/webglsampler.rs index c80e2a6a508..063decffe8f 100644 --- a/components/script/dom/webglsampler.rs +++ b/components/script/dom/webglsampler.rs @@ -7,7 +7,7 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::WebGLError::*; use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSamplerId}; use dom_struct::dom_struct; @@ -90,16 +90,15 @@ impl WebGLSampler { ) } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); let command = WebGLCommand::DeleteSampler(self.gl_id); let context = self.upcast::<WebGLObject>().context(); - if fallible { - context.send_command_ignored(command); - } else { - context.send_command(command); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(command), + Operation::Infallible => context.send_command(command), } } } @@ -180,6 +179,6 @@ impl WebGLSampler { impl Drop for WebGLSampler { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 9be334f6595..0e2a8253968 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -12,7 +12,7 @@ use crate::dom::webgl_extensions::ext::extshadertexturelod::EXTShaderTextureLod; use crate::dom::webgl_extensions::ext::oesstandardderivatives::OESStandardDerivatives; use crate::dom::webgl_extensions::WebGLExtensions; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{webgl_channel, GlType, WebGLVersion}; use canvas_traits::webgl::{GLLimits, WebGLCommand, WebGLError}; use canvas_traits::webgl::{WebGLResult, WebGLSLVersion, WebGLShaderId}; @@ -344,15 +344,14 @@ 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, fallible: bool) { + pub fn mark_for_deletion(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteShader(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -400,6 +399,6 @@ impl WebGLShader { impl Drop for WebGLShader { fn drop(&mut self) { - self.mark_for_deletion(true); + self.mark_for_deletion(Operation::Fallible); } } diff --git a/components/script/dom/webglsync.rs b/components/script/dom/webglsync.rs index dd6acb5be9a..a6288f69c1e 100644 --- a/components/script/dom/webglsync.rs +++ b/components/script/dom/webglsync.rs @@ -8,7 +8,7 @@ use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::task_source::TaskSource; use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSyncId}; use dom_struct::dom_struct; @@ -82,15 +82,14 @@ impl WebGLSync { self.client_wait_status.get() } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if self.is_valid() { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteSync(self.sync_id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -131,6 +130,6 @@ impl WebGLSync { impl Drop for WebGLSync { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 682920df96e..3059dc7bf4e 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -13,7 +13,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::webgl_validations::types::TexImageTarget; use crate::dom::webglframebuffer::WebGLFramebuffer; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{webgl_channel, TexDataType, TexFormat, WebGLResult, WebGLTextureId}; use canvas_traits::webgl::{DOMToTextureCommand, WebGLCommand, WebGLError}; use dom_struct::dom_struct; @@ -183,7 +183,7 @@ impl WebGLTexture { self.populate_mip_chain(self.base_mipmap_level, last_level) } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -210,10 +210,9 @@ impl WebGLTexture { } let cmd = WebGLCommand::DeleteTexture(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -420,7 +419,7 @@ impl WebGLTexture { impl Drop for WebGLTexture { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webgltransformfeedback.rs b/components/script/dom/webgltransformfeedback.rs index fe4b0753843..3b0b2abf0a2 100644 --- a/components/script/dom/webgltransformfeedback.rs +++ b/components/script/dom/webgltransformfeedback.rs @@ -6,7 +6,7 @@ use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{webgl_channel, WebGLCommand}; use dom_struct::dom_struct; use std::cell::Cell; @@ -98,15 +98,14 @@ impl WebGLTransformFeedback { self.is_paused.get() } - pub fn delete(&self, fallible: bool) { + pub fn delete(&self, operation_fallibility: Operation) { if self.is_valid() && self.id() != 0 { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteTransformFeedback(self.id); - if fallible { - context.send_command_ignored(cmd); - } else { - context.send_command(cmd); + match operation_fallibility { + Operation::Fallible => context.send_command_ignored(cmd), + Operation::Infallible => context.send_command(cmd), } } } @@ -126,6 +125,6 @@ impl WebGLTransformFeedback { impl Drop for WebGLTransformFeedback { fn drop(&mut self) { - self.delete(true); + self.delete(Operation::Fallible); } } diff --git a/components/script/dom/webglvertexarrayobject.rs b/components/script/dom/webglvertexarrayobject.rs index b425a7c4219..07f53af0316 100644 --- a/components/script/dom/webglvertexarrayobject.rs +++ b/components/script/dom/webglvertexarrayobject.rs @@ -8,7 +8,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{ActiveAttribInfo, WebGLResult, WebGLVertexArrayId}; use dom_struct::dom_struct; @@ -41,8 +41,8 @@ impl WebGLVertexArrayObject { self.array_object.is_deleted() } - pub fn delete(&self, fallible: bool) { - self.array_object.delete(fallible); + pub fn delete(&self, operation_fallibility: Operation) { + self.array_object.delete(operation_fallibility); } pub fn ever_bound(&self) -> bool { diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index f10c10d949b..215d39c1a5a 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -8,7 +8,7 @@ use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglobject::WebGLObject; -use crate::dom::webglrenderingcontext::WebGLRenderingContext; +use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use canvas_traits::webgl::{ActiveAttribInfo, WebGLResult, WebGLVertexArrayId}; use dom_struct::dom_struct; @@ -41,8 +41,8 @@ impl WebGLVertexArrayObjectOES { self.array_object.is_deleted() } - pub fn delete(&self, fallible: bool) { - self.array_object.delete(fallible); + pub fn delete(&self, operation_fallibility: Operation) { + self.array_object.delete(operation_fallibility); } pub fn ever_bound(&self) -> bool { |