diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2018-07-05 09:40:22 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-07-05 14:20:47 +0200 |
commit | 15389586d9b36fa548a3adab5681b6f96cf90daa (patch) | |
tree | 038b6455b762ad57ab9b1c4505105fcc4c2aadb4 | |
parent | fc593c68c58580d0694450894840fd4117f4e318 (diff) | |
download | servo-15389586d9b36fa548a3adab5681b6f96cf90daa.tar.gz servo-15389586d9b36fa548a3adab5681b6f96cf90daa.zip |
Make gl.useProgram(null) do the right thing
-rw-r--r-- | components/canvas/webgl_thread.rs | 5 | ||||
-rw-r--r-- | components/canvas_traits/webgl.rs | 2 | ||||
-rw-r--r-- | components/script/dom/webglprogram.rs | 13 | ||||
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 9 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/programs/program-test.html.ini | 3 |
5 files changed, 9 insertions, 23 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 754b073328d..abdda3c812a 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -826,8 +826,6 @@ impl WebGLImpl { ctx.gl().uniform_matrix_3fv(uniform_id, transpose, v), WebGLCommand::UniformMatrix4fv(uniform_id, transpose, ref v) => ctx.gl().uniform_matrix_4fv(uniform_id, transpose, v), - WebGLCommand::UseProgram(program_id) => - ctx.gl().use_program(program_id.get()), WebGLCommand::ValidateProgram(program_id) => ctx.gl().validate_program(program_id.get()), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => @@ -965,6 +963,9 @@ impl WebGLImpl { WebGLCommand::LinkProgram(program_id, ref sender) => { return sender.send(Self::link_program(ctx.gl(), program_id)).unwrap(); } + WebGLCommand::UseProgram(program_id) => { + ctx.gl().use_program(program_id.map_or(0, |p| p.get())) + } } // TODO: update test expectations in order to enable debug assertions diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index f39ceb2c7fb..6446c0c18d8 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -249,7 +249,7 @@ pub enum WebGLCommand { UniformMatrix2fv(i32, bool, Vec<f32>), UniformMatrix3fv(i32, bool, Vec<f32>), UniformMatrix4fv(i32, bool, Vec<f32>), - UseProgram(WebGLProgramId), + UseProgram(Option<WebGLProgramId>), ValidateProgram(WebGLProgramId), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer(u32, i32, u32, bool, i32, u32), diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 97ebb92d70f..4c52ed75928 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -130,19 +130,6 @@ impl WebGLProgram { Ref::map(self.active_attribs.borrow(), |attribs| &**attribs) } - /// glUseProgram - pub fn use_program(&self) -> WebGLResult<()> { - if self.is_deleted() { - return Err(WebGLError::InvalidOperation); - } - if !self.linked.get() { - return Err(WebGLError::InvalidOperation); - } - - self.renderer.send(WebGLCommand::UseProgram(self.id)).unwrap(); - Ok(()) - } - /// glValidateProgram pub fn validate(&self) -> WebGLResult<()> { if self.is_deleted() { diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 0750d5f5e5d..cb4c5dbcfb0 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -2314,7 +2314,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn GetActiveAttrib(&self, program: &WebGLProgram, index: u32) -> Option<DomRoot<WebGLActiveInfo>> { - handle_potential_webgl_error!(self, program.get_active_attrib(index), None) + handle_potential_webgl_error!(self, program.get_active_attrib(index).map(Some), None) } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 @@ -3242,11 +3242,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 fn UseProgram(&self, program: Option<&WebGLProgram>) { if let Some(program) = program { - match program.use_program() { - Ok(()) => self.current_program.set(Some(program)), - Err(e) => self.webgl_error(e), + if program.is_deleted() || !program.is_linked() { + return self.webgl_error(InvalidOperation); } } + self.send_command(WebGLCommand::UseProgram(program.map(|p| p.id()))); + self.current_program.set(program); } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/programs/program-test.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/programs/program-test.html.ini index 947742cb1e9..164f0e3c2a2 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/programs/program-test.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/programs/program-test.html.ini @@ -1,7 +1,4 @@ [program-test.html] - [WebGL test #53: getError expected: INVALID_OPERATION. Was NO_ERROR : drawing with a null program should generate INVALID_OPERATION] - expected: FAIL - [WebGL test #64: getError expected: NO_ERROR. Was INVALID_OPERATION : delete the current program shouldn't change the current rendering state] expected: FAIL |