aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2018-07-02 16:02:11 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2018-07-05 14:20:47 +0200
commit0018e5e6ba21ea85157f44f68ed66a7127f314bd (patch)
tree87e6e60794b97fd194d212f5f4a87fc290c3df14 /components/script
parentf108a3e797be9ee6b87d14496d1b57496997f504 (diff)
downloadservo-0018e5e6ba21ea85157f44f68ed66a7127f314bd.tar.gz
servo-0018e5e6ba21ea85157f44f68ed66a7127f314bd.zip
Refactor some vertex attrib checks
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/webglrenderingcontext.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 631ad4ca84f..7a6b558144c 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -2202,13 +2202,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
}
- {
- // https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
- let buffers = self.vertex_attribs.borrow();
- if buffers.iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
- return self.webgl_error(InvalidOperation);
- }
- }
+ handle_potential_webgl_error!(self, self.vertex_attribs.validate_for_draw(), return);
if !self.validate_framebuffer_complete() {
return;
@@ -2277,13 +2271,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
}
- {
- // https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
- let buffers = self.vertex_attribs.borrow();
- if buffers.iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
- return self.webgl_error(InvalidOperation);
- }
- }
+ handle_potential_webgl_error!(self, self.vertex_attribs.validate_for_draw(), return);
if !self.validate_framebuffer_complete() {
return;
@@ -3852,6 +3840,14 @@ impl VertexAttribs {
fn bind_buffer(&self, index: u32, buffer: &WebGLBuffer) {
self.attribs.borrow_mut()[index as usize].buffer = Some(Dom::from_ref(buffer));
}
+
+ fn validate_for_draw(&self) -> WebGLResult<()> {
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
+ if self.borrow().iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
+ return Err(InvalidOperation);
+ }
+ Ok(())
+ }
}
#[derive(Clone, Default, JSTraceable, MallocSizeOf)]