aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2015-12-29 13:51:10 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-01-13 13:41:30 +0100
commit221a58378450d26ff9e3bb645df8fcf5fb43994f (patch)
tree8680d4237fabc0f3b4956caa3a98665888967af3 /components/script/dom/webglrenderingcontext.rs
parent532b53ddc94cd99d737411b635f2fb6a6d50af51 (diff)
downloadservo-221a58378450d26ff9e3bb645df8fcf5fb43994f.tar.gz
servo-221a58378450d26ff9e3bb645df8fcf5fb43994f.zip
webgl: Track uniformlocation's program
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs29
1 files changed, 21 insertions, 8 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 701ae737ba8..33735d83633 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -79,6 +79,7 @@ pub struct WebGLRenderingContext {
bound_texture_cube_map: MutNullableHeap<JS<WebGLTexture>>,
bound_buffer_array: MutNullableHeap<JS<WebGLBuffer>>,
bound_buffer_element_array: MutNullableHeap<JS<WebGLBuffer>>,
+ current_program: MutNullableHeap<JS<WebGLProgram>>,
}
impl WebGLRenderingContext {
@@ -106,6 +107,7 @@ impl WebGLRenderingContext {
bound_texture_cube_map: MutNullableHeap::new(None),
bound_buffer_array: MutNullableHeap::new(None),
bound_buffer_element_array: MutNullableHeap::new(None),
+ current_program: MutNullableHeap::new(None),
}
})
}
@@ -804,7 +806,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
name: DOMString) -> Option<Root<WebGLUniformLocation>> {
if let Some(program) = program {
handle_potential_webgl_error!(self, program.get_uniform_location(name), None)
- .map(|location| WebGLUniformLocation::new(self.global().r(), location))
+ .map(|location| WebGLUniformLocation::new(self.global().r(), location, program.id()))
} else {
None
}
@@ -934,13 +936,18 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn Uniform1f(&self,
uniform: Option<&WebGLUniformLocation>,
val: f32) {
- let uniform_id = match uniform {
- Some(uniform) => uniform.id(),
+ let uniform = match uniform {
+ Some(uniform) => uniform,
None => return,
};
+ match self.current_program.get() {
+ Some(ref program) if program.id() == uniform.program_id() => {},
+ _ => return self.webgl_error(InvalidOperation),
+ };
+
self.ipc_renderer
- .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform1f(uniform_id, val)))
+ .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform1f(uniform.id(), val)))
.unwrap()
}
@@ -959,13 +966,18 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
fn Uniform4f(&self,
uniform: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32, w: f32) {
- let uniform_id = match uniform {
- Some(uniform) => uniform.id(),
+ let uniform = match uniform {
+ Some(uniform) => uniform,
None => return,
};
+ match self.current_program.get() {
+ Some(ref program) if program.id() == uniform.program_id() => {},
+ _ => return self.webgl_error(InvalidOperation),
+ };
+
self.ipc_renderer
- .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform4f(uniform_id, x, y, z, w)))
+ .send(CanvasMsg::WebGL(CanvasWebGLMsg::Uniform4f(uniform.id(), x, y, z, w)))
.unwrap()
}
@@ -993,7 +1005,8 @@ 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 {
- program.use_program()
+ program.use_program();
+ self.current_program.set(Some(program));
}
}