Expose WebGL texture compression methods on WebGLRenderingContext
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 09:19:50 +0000 (09:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2012 09:19:50 +0000 (09:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76763

Patch by Gregg Tavares <gman@google.com> on 2012-01-24
Reviewed by Kenneth Russell.

Source/WebCore:

Test: fast/canvas/webgl/compressed-tex-image.html

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::compressedTexImage2D):
(WebCore::WebGLRenderingContext::compressedTexSubImage2D):
* html/canvas/WebGLRenderingContext.h:
* html/canvas/WebGLRenderingContext.idl:

LayoutTests:

* fast/canvas/webgl/compressed-tex-image-expected.txt: Added.
* fast/canvas/webgl/compressed-tex-image.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105706 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/compressed-tex-image-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/compressed-tex-image.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.h
Source/WebCore/html/canvas/WebGLRenderingContext.idl

index ed42609..5843170 100644 (file)
@@ -1,3 +1,13 @@
+2012-01-24  Gregg Tavares  <gman@google.com>
+
+        Expose WebGL texture compression methods on WebGLRenderingContext
+        https://bugs.webkit.org/show_bug.cgi?id=76763
+
+        Reviewed by Kenneth Russell.
+
+        * fast/canvas/webgl/compressed-tex-image-expected.txt: Added.
+        * fast/canvas/webgl/compressed-tex-image.html: Added.
+
 2012-01-24  Kenichi Ishibashi  <bashi@chromium.org>
 
         [V8] Add Uint8ClampedArray support
diff --git a/LayoutTests/fast/canvas/webgl/compressed-tex-image-expected.txt b/LayoutTests/fast/canvas/webgl/compressed-tex-image-expected.txt
new file mode 100644 (file)
index 0000000..f8ae149
--- /dev/null
@@ -0,0 +1,16 @@
+This test ensures WebGL implementations correctly implement compressedTexImage2D and compressedTexSubImage2D.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS context exists
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8)) generated expected GL error: INVALID_ENUM.
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8)) generated expected GL error: INVALID_ENUM.
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, new Uint8Array(16)) generated expected GL error: INVALID_ENUM.
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ETC1_RGB8_OES, 4, 4, 0, new Uint8Array(8)) generated expected GL error: INVALID_ENUM.
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8)) generated expected GL error: INVALID_ENUM.
+PASS gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8)) generated expected GL error: INVALID_ENUM.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/webgl/compressed-tex-image.html b/LayoutTests/fast/canvas/webgl/compressed-tex-image.html
new file mode 100644 (file)
index 0000000..5eea42b
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL CompressedTexImage and CompressedTexSubImage Tests</title>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description("This test ensures WebGL implementations correctly implement compressedTexImage2D and compressedTexSubImage2D.");
+
+debug("");
+
+var wtu = WebGLTestUtils;
+var canvas = document.createElement("canvas");
+var gl = wtu.create3DContext(canvas);
+
+const  COMPRESSED_RGB_S3TC_DXT1_EXT        = 0x83F0;
+const  COMPRESSED_RGBA_S3TC_DXT1_EXT       = 0x83F1;
+const  COMPRESSED_RGBA_S3TC_DXT5_EXT       = 0x83F3;
+const  ETC1_RGB8_OES                       = 0x8D64;
+const  COMPRESSED_RGB_PVRTC_4BPPV1_IMG     = 0x8C00;
+const  COMPRESSED_RGBA_PVRTC_4BPPV1_IMG    = 0x8C02;
+
+if (!gl) {
+  testFailed("context does not exist");
+} else {
+  testPassed("context exists");
+
+  var tex = gl.createTexture();
+  gl.bindTexture(gl.TEXTURE_2D, tex);
+
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, new Uint8Array(8))");
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, new Uint8Array(16))");
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ETC1_RGB8_OES, 4, 4, 0, new Uint8Array(8))");
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
+  shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.compressedTexImage2D(gl.TEXTURE_2D, 0, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 8, 8, 0, new Uint8Array(8))");
+}
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
+
index b0a91e8..1fa6bac 100644 (file)
@@ -1,3 +1,18 @@
+2012-01-24  Gregg Tavares  <gman@google.com>
+
+        Expose WebGL texture compression methods on WebGLRenderingContext
+        https://bugs.webkit.org/show_bug.cgi?id=76763
+
+        Reviewed by Kenneth Russell.
+
+        Test: fast/canvas/webgl/compressed-tex-image.html
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::compressedTexImage2D):
+        (WebCore::WebGLRenderingContext::compressedTexSubImage2D):
+        * html/canvas/WebGLRenderingContext.h:
+        * html/canvas/WebGLRenderingContext.idl:
+
 2012-01-24  Kenichi Ishibashi  <bashi@chromium.org>
 
         [V8] Add Uint8ClampedArray support
index fc6fdbd..1ac7a36 100644 (file)
@@ -1195,6 +1195,26 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
     cleanupAfterGraphicsCall(false);
 }
 
+void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
+                                                 GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
+{
+    if (isContextLost())
+        return;
+
+    // FIXME: implement this.
+    m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+}
+
+void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
+                                                    GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
+{
+    if (isContextLost())
+        return;
+
+    // FIXME: implement this.
+    m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
+}
+
 void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
 {
     if (isContextLost())
index 5f63cf1..5550360 100644 (file)
@@ -109,8 +109,10 @@ public:
     void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha);
     void compileShader(WebGLShader*, ExceptionCode&);
 
-    // void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data);
-    // void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data);
+    void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
+                              GC3Dsizei height, GC3Dint border, ArrayBufferView* data);
+    void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
+                                 GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data);
 
     void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
     void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
index 5103af0..0c1700a 100644 (file)
@@ -478,9 +478,11 @@ module html {
         [StrictTypeChecking] void         clearStencil(in long s);
         [StrictTypeChecking] void         colorMask(in boolean red, in boolean green, in boolean blue, in boolean alpha);
         [StrictTypeChecking] void         compileShader(in WebGLShader shader) raises(DOMException);
-        
-        //void         compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in unsigned long width, in unsigned long height, in long border, in unsigned long imageSize, const void* data);
-        //void         compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in unsigned long width, in unsigned long height, in unsigned long format, in unsigned long imageSize, const void* data);
+
+        [StrictTypeChecking] void         compressedTexImage2D(in unsigned long target, in long level, in unsigned long internalformat,
+                                                               in long width, in long height, in long border, in ArrayBufferView data);
+        [StrictTypeChecking] void         compressedTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset,
+                                                                  in long width, in long height, in unsigned long format, in ArrayBufferView data);
         
         [StrictTypeChecking] void         copyTexImage2D(in unsigned long target, in long level, in unsigned long internalformat, in long x, in long y, in long width, in long height, in long border);
         [StrictTypeChecking] void         copyTexSubImage2D(in unsigned long target, in long level, in long xoffset, in long yoffset, in long x, in long y, in long width, in long height);