Bug 1048745 - Uniform with GLuint. r=jgilbert
authorDan Glastonbury <dglastonbury@mozilla.com>
Mon, 23 Mar 2015 12:13:10 +1000
changeset 252820 4dae2d1f59ff0c5e4bd799067331888fb2a3b999
parent 252819 dfe2490b2b2be3b2d0f2ba30a236e142057d01fa
child 252821 ec8f020d47ae5b0bd587dcf9f3d6a4cfa8be64f0
push idunknown
push userunknown
push dateunknown
reviewersjgilbert
bugs1048745
milestone39.0a1
Bug 1048745 - Uniform with GLuint. r=jgilbert
dom/canvas/WebGL2Context.h
dom/canvas/WebGL2ContextUniforms.cpp
--- a/dom/canvas/WebGL2Context.h
+++ b/dom/canvas/WebGL2Context.h
@@ -108,20 +108,37 @@ public:
     // Uniforms and attributes - WebGL2ContextUniforms.cpp
     void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
 
     // GL 3.0 & ES 3.0
     void Uniform1ui(WebGLUniformLocation* location, GLuint v0);
     void Uniform2ui(WebGLUniformLocation* location, GLuint v0, GLuint v1);
     void Uniform3ui(WebGLUniformLocation* location, GLuint v0, GLuint v1, GLuint v2);
     void Uniform4ui(WebGLUniformLocation* location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-    void Uniform1uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
-    void Uniform2uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
-    void Uniform3uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
-    void Uniform4uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
+
+private:
+    void Uniform1uiv_base(WebGLUniformLocation* loc, size_t arrayLength, const GLuint* data);
+    void Uniform2uiv_base(WebGLUniformLocation* loc, size_t arrayLength, const GLuint* data);
+    void Uniform3uiv_base(WebGLUniformLocation* loc, size_t arrayLength, const GLuint* data);
+    void Uniform4uiv_base(WebGLUniformLocation* loc, size_t arrayLength, const GLuint* data);
+
+public:
+    void Uniform1uiv(WebGLUniformLocation* loc, const dom::Sequence<GLuint>& arr) {
+        Uniform1uiv_base(loc,arr.Length(), arr.Elements());
+    }
+    void Uniform2uiv(WebGLUniformLocation* loc, const dom::Sequence<GLuint>& arr) {
+        Uniform2uiv_base(loc,arr.Length(), arr.Elements());
+    }
+    void Uniform3uiv(WebGLUniformLocation* loc, const dom::Sequence<GLuint>& arr) {
+        Uniform3uiv_base(loc,arr.Length(), arr.Elements());
+    }
+    void Uniform4uiv(WebGLUniformLocation* loc, const dom::Sequence<GLuint>& arr) {
+        Uniform4uiv_base(loc,arr.Length(), arr.Elements());
+    }
+
 private:
     void UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
                                  size_t arrayLength, const GLfloat* data);
     void UniformMatrix3x2fv_base(WebGLUniformLocation* loc, bool transpose,
                                  size_t arrayLength, const GLfloat* data);
     void UniformMatrix2x4fv_base(WebGLUniformLocation* loc, bool transpose,
                                  size_t arrayLength, const GLfloat* data);
     void UniformMatrix4x2fv_base(WebGLUniformLocation* loc, bool transpose,
--- a/dom/canvas/WebGL2ContextUniforms.cpp
+++ b/dom/canvas/WebGL2ContextUniforms.cpp
@@ -114,66 +114,124 @@ WebGL2Context::VertexAttribIPointer(GLui
     vd.normalized = false;
     vd.integer = true;
 
     MakeContextCurrent();
     gl->fVertexAttribIPointer(index, size, type, stride, reinterpret_cast<void*>(offset));
 }
 
 void
-WebGL2Context::Uniform1ui(WebGLUniformLocation* location, GLuint v0)
+WebGL2Context::Uniform1ui(WebGLUniformLocation* loc, GLuint v0)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    if (!ValidateUniformSetter(loc, 1, LOCAL_GL_UNSIGNED_INT, "uniform1ui", &rawLoc))
+        return;
+
+    MakeContextCurrent();
+    gl->fUniform1ui(rawLoc, v0);
 }
 
 void
-WebGL2Context::Uniform2ui(WebGLUniformLocation* location, GLuint v0, GLuint v1)
+WebGL2Context::Uniform2ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    if (!ValidateUniformSetter(loc, 2, LOCAL_GL_UNSIGNED_INT, "uniform2ui", &rawLoc))
+        return;
+
+    MakeContextCurrent();
+    gl->fUniform2ui(rawLoc, v0, v1);
 }
 
 void
-WebGL2Context::Uniform3ui(WebGLUniformLocation* location, GLuint v0, GLuint v1, GLuint v2)
+WebGL2Context::Uniform3ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    if (!ValidateUniformSetter(loc, 3, LOCAL_GL_UNSIGNED_INT, "uniform3ui", &rawLoc))
+        return;
+
+    MakeContextCurrent();
+    gl->fUniform3ui(rawLoc, v0, v1, v2);
 }
 
 void
-WebGL2Context::Uniform4ui(WebGLUniformLocation* location, GLuint v0, GLuint v1,
-                          GLuint v2, GLuint v3)
+WebGL2Context::Uniform4ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    if (!ValidateUniformSetter(loc, 4, LOCAL_GL_UNSIGNED_INT, "uniform4ui", &rawLoc))
+        return;
+
+    MakeContextCurrent();
+    gl->fUniform4ui(rawLoc, v0, v1, v2, v3);
 }
 
 void
-WebGL2Context::Uniform1uiv(WebGLUniformLocation* location,
-                           const dom::Sequence<GLuint>& value)
+WebGL2Context::Uniform1uiv_base(WebGLUniformLocation* loc, size_t arrayLength,
+                                const GLuint* data)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    GLsizei numElementsToUpload;
+
+    if (!ValidateUniformArraySetter(loc, 1, LOCAL_GL_UNSIGNED_INT, arrayLength,
+                                    "uniform1uiv", &rawLoc, &numElementsToUpload))
+    {
+        return;
+    }
+
+    MakeContextCurrent();
+    gl->fUniform1uiv(rawLoc, numElementsToUpload, data);
 }
 
 void
-WebGL2Context::Uniform2uiv(WebGLUniformLocation* location,
-                           const dom::Sequence<GLuint>& value)
+WebGL2Context::Uniform2uiv_base(WebGLUniformLocation* loc, size_t arrayLength,
+                                const GLuint* data)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    GLsizei numElementsToUpload;
+
+    if (!ValidateUniformArraySetter(loc, 2, LOCAL_GL_UNSIGNED_INT, arrayLength,
+                                    "uniform2uiv", &rawLoc, &numElementsToUpload))
+    {
+        return;
+    }
+
+    MakeContextCurrent();
+    gl->fUniform2uiv(rawLoc, numElementsToUpload, data);
 }
 
 void
-WebGL2Context::Uniform3uiv(WebGLUniformLocation* location,
-                           const dom::Sequence<GLuint>& value)
+WebGL2Context::Uniform3uiv_base(WebGLUniformLocation* loc, size_t arrayLength,
+                                const GLuint* data)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    GLsizei numElementsToUpload;
+
+    if (!ValidateUniformArraySetter(loc, 3, LOCAL_GL_UNSIGNED_INT, arrayLength,
+                                    "uniform3uiv", &rawLoc, &numElementsToUpload))
+    {
+        return;
+    }
+
+    MakeContextCurrent();
+    gl->fUniform1uiv(rawLoc, numElementsToUpload, data);
 }
 
 void
-WebGL2Context::Uniform4uiv(WebGLUniformLocation* location,
-                           const dom::Sequence<GLuint>& value)
+WebGL2Context::Uniform4uiv_base(WebGLUniformLocation* loc, size_t arrayLength,
+                                const GLuint* data)
 {
-    MOZ_CRASH("Not Implemented.");
+    GLuint rawLoc;
+    GLsizei numElementsToUpload;
+
+    if (!ValidateUniformArraySetter(loc, 4, LOCAL_GL_UNSIGNED_INT, arrayLength,
+                                    "uniform4uiv", &rawLoc, &numElementsToUpload)) {
+        return;
+    }
+
+    MakeContextCurrent();
+    gl->fUniform4uiv(rawLoc, numElementsToUpload, data);
 }
 
 void
 WebGL2Context::UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
                                        size_t arrayLength, const GLfloat* data)
 {
     GLuint rawLoc;
     GLsizei numElementsToUpload;