diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-04-24 02:04:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 02:04:07 -0400 |
commit | 25220049d9793ad3d488bc061951a65c3f8a487e (patch) | |
tree | f598798a20f0a4777d1c62130ae2b70f5acd2be5 /components/script/dom/webglrenderingcontext.rs | |
parent | 412bc1cddd8027596950164f3b396198bdcba25e (diff) | |
parent | 9c343fcc9600a1a2b768a4632793d0856d55ddce (diff) | |
download | servo-25220049d9793ad3d488bc061951a65c3f8a487e.tar.gz servo-25220049d9793ad3d488bc061951a65c3f8a487e.zip |
Auto merge of #26289 - he4d:master, r=jdm
Replaced failible boolean with an enum
<!-- Please describe your changes on the following line: -->
Replaced the boolean `fallible` argument of some WebGL object methods with the new `enum Operation { Fallible, Infallible }` that was added to the `webglrenderingcontext`. This improves the readability of that methods.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #26047 (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the issue says so
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 6fa67680cbe..bb9f8d16934 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); @@ -2839,9 +2845,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 @@ -2861,7 +2867,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { WebGLFramebufferBindingRequest::Default )) ); - framebuffer.delete(false) + framebuffer.delete(Operation::Infallible) } } @@ -2878,7 +2884,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { None )) ); - renderbuffer.delete(false) + renderbuffer.delete(Operation::Infallible) } } @@ -2913,7 +2919,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { )); } - texture.delete(false) + texture.delete(Operation::Infallible) } } @@ -2921,7 +2927,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) } } @@ -2929,7 +2935,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) } } |