aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAdrian Utrilla <adrianutrilla@gmail.com>2016-04-02 19:46:39 +0200
committerAdrian Utrilla <adrianutrilla@gmail.com>2016-04-02 20:48:29 +0200
commitbd1448ab5661e808e92185ea40b4b95d1d392f6f (patch)
tree6d73faf2f4c057bb0a38cf8192fbc23959d2fe92 /components/script
parent7f4929d52dd33bcb3e231e776179314304fe1889 (diff)
downloadservo-bd1448ab5661e808e92185ea40b4b95d1d392f6f.tar.gz
servo-bd1448ab5661e808e92185ea40b4b95d1d392f6f.zip
Added Uniform4iv and Uniform4i
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/webglrenderingcontext.rs41
-rw-r--r--components/script/dom/webidls/WebGLRenderingContext.webidl4
2 files changed, 44 insertions, 1 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index e614b7afc6f..3bc032420c3 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -961,6 +961,47 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4i(&self,
+ uniform: Option<&WebGLUniformLocation>,
+ x: i32, y: i32, z: i32, w: i32) {
+ 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(WebGLCommand::Uniform4i(uniform.id(), x, y, z, w)))
+ .unwrap()
+ }
+
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
+ fn Uniform4iv(&self,
+ _cx: *mut JSContext,
+ uniform: Option<&WebGLUniformLocation>,
+ data: Option<*mut JSObject>) {
+ let data = match data {
+ Some(data) => data,
+ None => return self.webgl_error(InvalidValue),
+ };
+
+ if let Some(data) = array_buffer_view_to_vec_checked::<i32>(data) {
+ if data.len() < 4 {
+ return self.webgl_error(InvalidOperation);
+ }
+
+ self.Uniform4i(uniform, data[0], data[1], data[2], data[3]);
+ } else {
+ self.webgl_error(InvalidValue);
+ }
+ }
+
+ // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10
fn Uniform4f(&self,
uniform: Option<&WebGLUniformLocation>,
x: f32, y: f32, z: f32, w: f32) {
diff --git a/components/script/dom/webidls/WebGLRenderingContext.webidl b/components/script/dom/webidls/WebGLRenderingContext.webidl
index ea49e38d4bd..a348cb3d552 100644
--- a/components/script/dom/webidls/WebGLRenderingContext.webidl
+++ b/components/script/dom/webidls/WebGLRenderingContext.webidl
@@ -669,9 +669,11 @@ interface WebGLRenderingContextBase
// in the meantime
void uniform4fv(WebGLUniformLocation? location, optional object v);
//void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v);
- //void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
+ void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
//void uniform4iv(WebGLUniformLocation? location, Int32Array v);
//void uniform4iv(WebGLUniformLocation? location, sequence<long> v);
+ // See FIXME above
+ void uniform4iv(WebGLUniformLocation? location, optional object v);
//void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose,
// Float32Array value);