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/dom/vertexarrayobject.rs | |
parent | 60e75314feaf0b5009f0cabfca6930ef1a584f27 (diff) | |
download | servo-9c343fcc9600a1a2b768a4632793d0856d55ddce.tar.gz servo-9c343fcc9600a1a2b768a4632793d0856d55ddce.zip |
Replaced failible boolean with an enum
Diffstat (limited to 'components/script/dom/vertexarrayobject.rs')
-rw-r--r-- | components/script/dom/vertexarrayobject.rs | 23 |
1 files changed, 11 insertions, 12 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); } } } |