Title: [222026] trunk
Revision
222026
Author
[email protected]
Date
2017-09-14 09:35:02 -0700 (Thu, 14 Sep 2017)

Log Message

Allow passing sequences to various WebGL2 methods.
https://bugs.webkit.org/show_bug.cgi?id=176892

Patch by Ms2ger <[email protected]> on 2017-09-14
Reviewed by Sam Weinig.

This matches the specification as well as Gecko and Chromium.

Source/WebCore:

Test: fast/canvas/webgl/webgl2/sequences.html

* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::uniform1uiv):
(WebCore::WebGL2RenderingContext::uniform2uiv):
(WebCore::WebGL2RenderingContext::uniform3uiv):
(WebCore::WebGL2RenderingContext::uniform4uiv):
(WebCore::WebGL2RenderingContext::uniformMatrix2x3fv):
(WebCore::WebGL2RenderingContext::uniformMatrix3x2fv):
(WebCore::WebGL2RenderingContext::uniformMatrix2x4fv):
(WebCore::WebGL2RenderingContext::uniformMatrix4x2fv):
(WebCore::WebGL2RenderingContext::uniformMatrix3x4fv):
(WebCore::WebGL2RenderingContext::uniformMatrix4x3fv):
(WebCore::WebGL2RenderingContext::vertexAttribI4iv):
(WebCore::WebGL2RenderingContext::vertexAttribI4uiv):
(WebCore::WebGL2RenderingContext::clearBufferiv):
(WebCore::WebGL2RenderingContext::clearBufferuiv):
(WebCore::WebGL2RenderingContext::clearBufferfv):
* html/canvas/WebGL2RenderingContext.h:
* html/canvas/WebGL2RenderingContext.idl:

LayoutTests:

* fast/canvas/webgl/webgl2/sequences-expected.txt: Added.
* fast/canvas/webgl/webgl2/sequences.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222025 => 222026)


--- trunk/LayoutTests/ChangeLog	2017-09-14 16:22:07 UTC (rev 222025)
+++ trunk/LayoutTests/ChangeLog	2017-09-14 16:35:02 UTC (rev 222026)
@@ -1,3 +1,15 @@
+2017-09-14  Ms2ger  <[email protected]>
+
+        Allow passing sequences to various WebGL2 methods.
+        https://bugs.webkit.org/show_bug.cgi?id=176892
+
+        Reviewed by Sam Weinig.
+
+        This matches the specification as well as Gecko and Chromium.
+
+        * fast/canvas/webgl/webgl2/sequences-expected.txt: Added.
+        * fast/canvas/webgl/webgl2/sequences.html: Added.
+
 2017-09-14  Ryan Haddad  <[email protected]>
 
         Rebaseline fast/forms/append-children-during-form-submission.html for iOS.

Added: trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences-expected.txt (0 => 222026)


--- trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences-expected.txt	2017-09-14 16:35:02 UTC (rev 222026)
@@ -0,0 +1,32 @@
+
+PASS uniform1uiv data with typed array of type ui 
+PASS uniform1uiv data with sequence of type ui 
+PASS uniform2uiv data with typed array of type ui 
+PASS uniform2uiv data with sequence of type ui 
+PASS uniform3uiv data with typed array of type ui 
+PASS uniform3uiv data with sequence of type ui 
+PASS uniform4uiv data with typed array of type ui 
+PASS uniform4uiv data with sequence of type ui 
+PASS uniformMatrix2x3fv data with typed array of type f 
+PASS uniformMatrix2x3fv data with sequence of type f 
+PASS uniformMatrix3x2fv data with typed array of type f 
+PASS uniformMatrix3x2fv data with sequence of type f 
+PASS uniformMatrix2x4fv data with typed array of type f 
+PASS uniformMatrix2x4fv data with sequence of type f 
+PASS uniformMatrix4x2fv data with typed array of type f 
+PASS uniformMatrix4x2fv data with sequence of type f 
+PASS uniformMatrix3x4fv data with typed array of type f 
+PASS uniformMatrix3x4fv data with sequence of type f 
+PASS uniformMatrix4x3fv data with typed array of type f 
+PASS uniformMatrix4x3fv data with sequence of type f 
+PASS vertexAttribI4iv values with typed array of type i 
+PASS vertexAttribI4iv values with sequence of type i 
+PASS vertexAttribI4uiv values with typed array of type ui 
+PASS vertexAttribI4uiv values with sequence of type ui 
+PASS clearBufferiv values with typed array of type i 
+PASS clearBufferiv values with sequence of type i 
+PASS clearBufferuiv values with typed array of type ui 
+PASS clearBufferuiv values with sequence of type ui 
+PASS clearBufferfv values with typed array of type f 
+PASS clearBufferfv values with sequence of type f 
+

Added: trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences.html (0 => 222026)


--- trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl2/sequences.html	2017-09-14 16:35:02 UTC (rev 222026)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>WebGL2RenderingContext: support for sequences and typed arrays</title>
+<script src=""
+<script src=""
+<div id="log"></div>
+<script>
+function create_typed_array(type) {
+  switch (type) {
+    case "i":
+      return new Int32Array();
+    case "ui":
+      return new Uint32Array();
+    case "f":
+      return new Float32Array();
+    default:
+      throw new Error(`Unexpected type: ${type}`);
+  }
+}
+
+let context, methods = [];
+setup(function() {
+  window.internals.settings.setWebGL2Enabled(true);
+
+  context = document.createElement("canvas").getContext("webgl2");
+  if (!context) {
+    throw new Error("Could not create webgl2 context");
+  }
+
+  for (let i = 1; i <= 4; ++i) {
+    methods.push([`uniform${i}uiv`, "ui", [null], `uniform${i}uiv data`]);
+  }
+  for (let dim of ["2x3", "3x2", "2x4", "4x2", "3x4", "4x3"]) {
+    methods.push([`uniformMatrix${dim}fv`, "f", [null, false], `uniformMatrix${dim}fv data`]);
+  }
+  for (let type of ["i", "ui"]) {
+    methods.push([`vertexAttribI4${type}v`, type, [0], `vertexAttribI4${type}v values`]);
+  }
+  for (let type of ["i", "ui", "f"]) {
+    methods.push([`clearBuffer${type}v`, type, [context.COLOR, 0], `clearBuffer${type}v values`]);
+  }
+});
+
+for (var [method, type, args, name] of methods) {
+  test(function() {
+    context[method](...args, create_typed_array(type));
+  }, `${name} with typed array of type ${type}`);
+
+  test(function() {
+    context[method](...args, [0]);
+  }, `${name} with sequence of type ${type}`);
+}
+</script>

Modified: trunk/Source/WebCore/ChangeLog (222025 => 222026)


--- trunk/Source/WebCore/ChangeLog	2017-09-14 16:22:07 UTC (rev 222025)
+++ trunk/Source/WebCore/ChangeLog	2017-09-14 16:35:02 UTC (rev 222026)
@@ -1,3 +1,33 @@
+2017-09-14  Ms2ger  <[email protected]>
+
+        Allow passing sequences to various WebGL2 methods.
+        https://bugs.webkit.org/show_bug.cgi?id=176892
+
+        Reviewed by Sam Weinig.
+
+        This matches the specification as well as Gecko and Chromium.
+
+        Test: fast/canvas/webgl/webgl2/sequences.html
+
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::uniform1uiv):
+        (WebCore::WebGL2RenderingContext::uniform2uiv):
+        (WebCore::WebGL2RenderingContext::uniform3uiv):
+        (WebCore::WebGL2RenderingContext::uniform4uiv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix2x3fv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix3x2fv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix2x4fv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix4x2fv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix3x4fv):
+        (WebCore::WebGL2RenderingContext::uniformMatrix4x3fv):
+        (WebCore::WebGL2RenderingContext::vertexAttribI4iv):
+        (WebCore::WebGL2RenderingContext::vertexAttribI4uiv):
+        (WebCore::WebGL2RenderingContext::clearBufferiv):
+        (WebCore::WebGL2RenderingContext::clearBufferuiv):
+        (WebCore::WebGL2RenderingContext::clearBufferfv):
+        * html/canvas/WebGL2RenderingContext.h:
+        * html/canvas/WebGL2RenderingContext.idl:
+
 2017-09-14  Sam Weinig  <[email protected]>
 
         [Cleanup] Cleanup uses of the FileList class

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp (222025 => 222026)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2017-09-14 16:22:07 UTC (rev 222025)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp	2017-09-14 16:35:02 UTC (rev 222026)
@@ -524,43 +524,43 @@
 {
 }
 
-void WebGL2RenderingContext::uniform1uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::uniform1uiv(WebGLUniformLocation*, Uint32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniform2uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::uniform2uiv(WebGLUniformLocation*, Uint32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniform3uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::uniform3uiv(WebGLUniformLocation*, Uint32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniform4uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::uniform4uiv(WebGLUniformLocation*, Uint32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix2x3fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix2x3fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix3x2fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix3x2fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix2x4fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix2x4fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix4x2fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix4x2fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix3x4fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix3x4fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
-void WebGL2RenderingContext::uniformMatrix4x3fv(WebGLUniformLocation*, GC3Dboolean, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::uniformMatrix4x3fv(WebGLUniformLocation*, GC3Dboolean, Float32List&&)
 {
 }
 
@@ -568,7 +568,7 @@
 {
 }
 
-void WebGL2RenderingContext::vertexAttribI4iv(GC3Duint, RefPtr<Int32Array>&&)
+void WebGL2RenderingContext::vertexAttribI4iv(GC3Duint, Int32List&&)
 {
 }
 
@@ -576,7 +576,7 @@
 {
 }
 
-void WebGL2RenderingContext::vertexAttribI4uiv(GC3Duint, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::vertexAttribI4uiv(GC3Duint, Uint32List&&)
 {
 }
 
@@ -668,7 +668,7 @@
     }
 }
 
-void WebGL2RenderingContext::clearBufferiv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Int32Array>&&)
+void WebGL2RenderingContext::clearBufferiv(GC3Denum buffer, GC3Dint drawbuffer, Int32List&&)
 {
     switch (buffer) {
     case GraphicsContext3D::COLOR:
@@ -693,7 +693,7 @@
     }
 }
 
-void WebGL2RenderingContext::clearBufferuiv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Uint32Array>&&)
+void WebGL2RenderingContext::clearBufferuiv(GC3Denum buffer, GC3Dint drawbuffer, Uint32List&&)
 {
     switch (buffer) {
     case GraphicsContext3D::COLOR:
@@ -712,7 +712,7 @@
     }
 }
 
-void WebGL2RenderingContext::clearBufferfv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Float32Array>&&)
+void WebGL2RenderingContext::clearBufferfv(GC3Denum buffer, GC3Dint drawbuffer, Float32List&&)
 {
     switch (buffer) {
     case GraphicsContext3D::COLOR:

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (222025 => 222026)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2017-09-14 16:22:07 UTC (rev 222025)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h	2017-09-14 16:35:02 UTC (rev 222026)
@@ -77,26 +77,28 @@
     
     // Programs and shaders
     GC3Dint getFragDataLocation(WebGLProgram*, const String& name);
-    
+
     // Uniforms and attributes
+    using Uint32List = TypedList<Uint32Array, uint32_t>;
+    using Float32List = TypedList<Float32Array, float>;
     void uniform1ui(WebGLUniformLocation*, GC3Duint v0);
     void uniform2ui(WebGLUniformLocation*, GC3Duint v0, GC3Duint v1);
     void uniform3ui(WebGLUniformLocation*, GC3Duint v0, GC3Duint v1, GC3Duint v2);
     void uniform4ui(WebGLUniformLocation*, GC3Duint v0, GC3Duint v1, GC3Duint v2, GC3Duint v3);
-    void uniform1uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&& value);
-    void uniform2uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&& value);
-    void uniform3uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&& value);
-    void uniform4uiv(WebGLUniformLocation*, RefPtr<Uint32Array>&& value);
-    void uniformMatrix2x3fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
-    void uniformMatrix3x2fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
-    void uniformMatrix2x4fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
-    void uniformMatrix4x2fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
-    void uniformMatrix3x4fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
-    void uniformMatrix4x3fv(WebGLUniformLocation*, GC3Dboolean transpose, RefPtr<Float32Array>&& value);
+    void uniform1uiv(WebGLUniformLocation*, Uint32List&&);
+    void uniform2uiv(WebGLUniformLocation*, Uint32List&& value);
+    void uniform3uiv(WebGLUniformLocation*, Uint32List&& value);
+    void uniform4uiv(WebGLUniformLocation*, Uint32List&& value);
+    void uniformMatrix2x3fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
+    void uniformMatrix3x2fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
+    void uniformMatrix2x4fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
+    void uniformMatrix4x2fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
+    void uniformMatrix3x4fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
+    void uniformMatrix4x3fv(WebGLUniformLocation*, GC3Dboolean transpose, Float32List&& value);
     void vertexAttribI4i(GC3Duint index, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w);
-    void vertexAttribI4iv(GC3Duint index, RefPtr<Int32Array>&& v);
+    void vertexAttribI4iv(GC3Duint index, Int32List&& v);
     void vertexAttribI4ui(GC3Duint index, GC3Duint x, GC3Duint y, GC3Duint z, GC3Duint w);
-    void vertexAttribI4uiv(GC3Duint index, RefPtr<Uint32Array>&& v);
+    void vertexAttribI4uiv(GC3Duint index, Uint32List&& v);
     void vertexAttribIPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dsizei stride, GC3Dint64 offset);
     
     // Writing to the drawing buffer
@@ -108,9 +110,9 @@
     
     // Multiple render targets
     void drawBuffers(const Vector<GC3Denum>& buffers);
-    void clearBufferiv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Int32Array>&& value);
-    void clearBufferuiv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Uint32Array>&& value);
-    void clearBufferfv(GC3Denum buffer, GC3Dint drawbuffer, RefPtr<Float32Array>&& value);
+    void clearBufferiv(GC3Denum buffer, GC3Dint drawbuffer, Int32List&& value);
+    void clearBufferuiv(GC3Denum buffer, GC3Dint drawbuffer, Uint32List&& value);
+    void clearBufferfv(GC3Denum buffer, GC3Dint drawbuffer, Float32List&& value);
     void clearBufferfi(GC3Denum buffer, GC3Dint drawbuffer, GC3Dfloat depth, GC3Dint stencil);
     
     // Query objects

Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl (222025 => 222026)


--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl	2017-09-14 16:22:07 UTC (rev 222025)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.idl	2017-09-14 16:35:02 UTC (rev 222026)
@@ -40,6 +40,9 @@
 typedef unrestricted float GLfloat;
 typedef unrestricted float GLclampf;
 typedef (ArrayBuffer or ArrayBufferView) BufferDataSource;
+typedef (Float32Array or sequence<GLfloat>) Float32List;
+typedef (Int32Array or sequence<GLint>) Int32List;
+typedef (Uint32Array or sequence<GLuint>) Uint32List;
 
 // FIXME: Should allow ImageBitmap too.
 typedef (ImageData or HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) TexImageSource;
@@ -377,20 +380,20 @@
     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, Uint32Array value);
-    void uniform2uiv(WebGLUniformLocation? location, Uint32Array value);
-    void uniform3uiv(WebGLUniformLocation? location, Uint32Array value);
-    void uniform4uiv(WebGLUniformLocation? location, Uint32Array value);
-    void uniformMatrix2x3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
-    void uniformMatrix3x2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
-    void uniformMatrix2x4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
-    void uniformMatrix4x2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
-    void uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
-    void uniformMatrix4x3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
+    void uniform1uiv(WebGLUniformLocation? location, Uint32List data);
+    void uniform2uiv(WebGLUniformLocation? location, Uint32List data);
+    void uniform3uiv(WebGLUniformLocation? location, Uint32List data);
+    void uniform4uiv(WebGLUniformLocation? location, Uint32List data);
+    void uniformMatrix2x3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix3x2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix2x4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix4x2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix4x3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
     void vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
-    void vertexAttribI4iv(GLuint index, Int32Array v);
+    void vertexAttribI4iv(GLuint index, Int32List values);
     void vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-    void vertexAttribI4uiv(GLuint index, Uint32Array v);
+    void vertexAttribI4uiv(GLuint index, Uint32List values);
     void vertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
 
     /* Writing to the drawing buffer */
@@ -401,9 +404,9 @@
 
     /* Multiple Render Targets */
     void drawBuffers(sequence<GLenum> buffers);
-    void clearBufferiv(GLenum buffer, GLint drawbuffer, Int32Array values);
-    void clearBufferuiv(GLenum buffer, GLint drawbuffer, Uint32Array values);
-    void clearBufferfv(GLenum buffer, GLint drawbuffer, Float32Array values);
+    void clearBufferiv(GLenum buffer, GLint drawbuffer, Int32List values);
+    void clearBufferuiv(GLenum buffer, GLint drawbuffer, Uint32List values);
+    void clearBufferfv(GLenum buffer, GLint drawbuffer, Float32List values);
     void clearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
 
     /* Query Objects */
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to