Implement WebGLShaderPrecisionFormat
authorzmo@google.com <zmo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2012 21:48:37 +0000 (21:48 +0000)
committerzmo@google.com <zmo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2012 21:48:37 +0000 (21:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75925

Reviewed by Kenneth Russell.

Source/Platform:

* chromium/public/WebGraphicsContext3D.h: Add getShaderPrecisionFormat().
(WebGraphicsContext3D):

Source/WebCore:

Test: fast/canvas/webgl/shader-precision-format.html

* CMakeLists.txt: Add new source files webglshaderprecisionformat.h/idl
* DerivedSources.make: Ditto.
* DerivedSources.pri: Ditto.
* GNUmakefile.list.am: Ditto.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* html/canvas/WebGLRenderingContext.cpp: Add getShaderPrecisionFormat.
(WebCore):
(WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
* html/canvas/WebGLRenderingContext.h: Ditto.
(WebCore):
(WebGLRenderingContext):
* html/canvas/WebGLRenderingContext.idl: Ditto.
* html/canvas/WebGLShaderPrecisionFormat.h: Added.
(WebCore):
(WebGLShaderPrecisionFormat):
(WebCore::WebGLShaderPrecisionFormat::create):
(WebCore::WebGLShaderPrecisionFormat::rangeMin):
(WebCore::WebGLShaderPrecisionFormat::rangeMax):
(WebCore::WebGLShaderPrecisionFormat::precision):
(WebCore::WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat):
* html/canvas/WebGLShaderPrecisionFormat.idl: Added.
* page/DOMWindow.idl: Expose new type WebGLShaderPrecisionFormat for instanceof.
* platform/graphics/GraphicsContext3D.h: Add getShaderPrecisionFormat().
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Ditto.
(WebCore::GraphicsContext3D::getShaderPrecisionFormat):
(WebCore):
* platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: Ditto.
(WebCore::GraphicsContext3D::getShaderPrecisionFormat):
(WebCore):
* platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
(WebCore::GraphicsContext3D::getShaderPrecisionFormat):
(WebCore):

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp: Add getShaderPrecisionFormat().
(WebCore):
* src/GraphicsContext3DPrivate.h: Ditto.
(GraphicsContext3DPrivate):
* tests/FakeWebGraphicsContext3D.h: Ditto.
(FakeWebGraphicsContext3D):

LayoutTests:

* fast/canvas/webgl/instanceof-test-expected.txt: Add new WebGLShaderPrecisionFormat failure.
* fast/canvas/webgl/instanceof-test.html:
* fast/canvas/webgl/shader-precision-format-expected.txt: Added.
* fast/canvas/webgl/shader-precision-format.html: Added.
* fast/dom/Window/script-tests/window-property-descriptors.js: Add new type WebGLShaderPrecisionFormat.
* fast/dom/Window/window-properties.html: Ditto.
* fast/dom/script-tests/prototype-inheritance-2.js: Ditto.
(constructorNamesForWindow):
* fast/dom/script-tests/prototype-inheritance.js: Ditto.
* fast/js/script-tests/global-constructors.js: Ditto.

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

35 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/instanceof-test-expected.txt
LayoutTests/fast/canvas/webgl/instanceof-test.html
LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/shader-precision-format.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/script-tests/window-property-descriptors.js
LayoutTests/fast/dom/Window/window-properties.html
LayoutTests/fast/dom/script-tests/prototype-inheritance-2.js
LayoutTests/fast/dom/script-tests/prototype-inheritance.js
LayoutTests/fast/js/script-tests/global-constructors.js
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebGraphicsContext3D.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/DerivedSources.pri
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.h
Source/WebCore/html/canvas/WebGLRenderingContext.idl
Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.idl [new file with mode: 0644]
Source/WebCore/page/DOMWindow.idl
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
Source/WebKit/chromium/src/GraphicsContext3DPrivate.h
Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h

index 9484ec9..4c388fe 100644 (file)
@@ -1,3 +1,21 @@
+2012-04-02  Zhenyao Mo  <zmo@google.com>
+
+        Implement WebGLShaderPrecisionFormat
+        https://bugs.webkit.org/show_bug.cgi?id=75925
+
+        Reviewed by Kenneth Russell.
+
+        * fast/canvas/webgl/instanceof-test-expected.txt: Add new WebGLShaderPrecisionFormat failure.
+        * fast/canvas/webgl/instanceof-test.html:
+        * fast/canvas/webgl/shader-precision-format-expected.txt: Added.
+        * fast/canvas/webgl/shader-precision-format.html: Added.
+        * fast/dom/Window/script-tests/window-property-descriptors.js: Add new type WebGLShaderPrecisionFormat.
+        * fast/dom/Window/window-properties.html: Ditto.
+        * fast/dom/script-tests/prototype-inheritance-2.js: Ditto.
+        (constructorNamesForWindow):
+        * fast/dom/script-tests/prototype-inheritance.js: Ditto.
+        * fast/js/script-tests/global-constructors.js: Ditto.
+
 2012-04-03  Zalan Bujtas  <zbujtas@gmail.com>
 
         Add test case for 3 level nested iframes with frame flattening on.
index 7a323c8..1e9b143 100644 (file)
@@ -1,3 +1,7 @@
+WebGL instanceof test.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
 Tests that instanceof works on WebGL objects.
 
 PASS gl instanceof WebGLRenderingContext is true
@@ -22,6 +26,7 @@ PASS new WebGLRenderbuffer threw an error
 PASS new WebGLShader threw an error
 PASS new WebGLTexture threw an error
 PASS new WebGLUniformLocation threw an error
+PASS new WebGLShaderPrecisionFormat threw an error
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 80cd521..d293235 100644 (file)
@@ -1,88 +1,89 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\r
-  "http://www.w3.org/TR/html4/loose.dtd">\r
-<html>\r
-<head>\r
-<title>WebGL instanceof test.</title>\r
-<script src="../../js/resources/js-test-pre.js"></script>\r
-<script src="resources/webgl-test.js"> </script>\r
-<script src="resources/webgl-test-utils.js"> </script>\r
-</head>\r
-<body>\r
-<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>\r
-<script id="vshader" type="x-shader/x-vertex">\r
-attribute vec4 vPosition;\r
-varying vec2 texCoord;\r
-void main()\r
-{\r
-    gl_Position = vPosition;\r
-}\r
-</script>\r
-\r
-<script id="fshader" type="x-shader/x-fragment">\r
-#ifdef GL_ES\r
-precision mediump float;\r
-#endif\r
-uniform vec4 color;\r
-void main()\r
-{\r
-    gl_FragColor = color;\r
-}\r
-</script>\r
-<script>\r
-var wtu = WebGLTestUtils;\r
-debug("Tests that instanceof works on WebGL objects.");\r
-debug("");\r
-var gl = create3DContext(document.getElementById("canvas"));\r
-shouldBeTrue('gl instanceof WebGLRenderingContext');\r
-shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer');\r
-shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer');\r
-shouldBeTrue('gl.createProgram() instanceof WebGLProgram');\r
-shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer');\r
-shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader');\r
-shouldBeTrue('gl.createTexture() instanceof WebGLTexture');\r
-\r
-var program = wtu.setupProgram(\r
-    gl,\r
-    [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),\r
-     wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],\r
-    ['vPosition'], [0]);\r
-\r
-shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLocation');\r
-shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo');\r
-shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo');\r
-\r
-debug("");\r
-debug("Tests that those WebGL objects can not be constructed through new operator");\r
-debug("");\r
-\r
-function shouldThrowWithNew(objectType, objectName)\r
-{\r
-    try {\r
-        new objectType;\r
-        testFailed('new ' + objectName + ' did not throw');\r
-    } catch (e) {\r
-        testPassed('new ' + objectName + ' threw an error');\r
-    }\r
-}\r
-\r
-shouldThrowWithNew(WebGLRenderingContext, 'WebGLRenderingContext');\r
-shouldThrowWithNew(WebGLActiveInfo, 'WebGLActiveInfo');\r
-shouldThrowWithNew(WebGLBuffer, 'WebGLBuffer');\r
-shouldThrowWithNew(WebGLFramebuffer, 'WebGLFramebuffer');\r
-shouldThrowWithNew(WebGLProgram, 'WebGLProgram');\r
-shouldThrowWithNew(WebGLRenderbuffer, 'WebGLRenderbuffer');\r
-shouldThrowWithNew(WebGLShader, 'WebGLShader');\r
-shouldThrowWithNew(WebGLTexture, 'WebGLTexture');\r
-shouldThrowWithNew(WebGLUniformLocation, 'WebGLUniformLocation');\r
-\r
-</script>\r
-</body>\r
-<script src="../../js/resources/js-test-post.js"></script>\r
-\r
-<script>\r
-</script>\r
-\r
-</body>\r
-</html>\r
-\r
-\r
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL instanceof test.</title>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<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>
+<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+varying vec2 texCoord;
+void main()
+{
+    gl_Position = vPosition;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+uniform vec4 color;
+void main()
+{
+    gl_FragColor = color;
+}
+</script>
+<script>
+var wtu = WebGLTestUtils;
+description(document.title);
+debug("Tests that instanceof works on WebGL objects.");
+debug("");
+var gl = create3DContext(document.getElementById("canvas"));
+shouldBeTrue('gl instanceof WebGLRenderingContext');
+shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer');
+shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer');
+shouldBeTrue('gl.createProgram() instanceof WebGLProgram');
+shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer');
+shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader');
+shouldBeTrue('gl.createTexture() instanceof WebGLTexture');
+
+var program = wtu.setupProgram(
+    gl,
+    [wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
+     wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
+    ['vPosition'], [0]);
+
+shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLocation');
+shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo');
+shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo');
+
+debug("");
+debug("Tests that those WebGL objects can not be constructed through new operator");
+debug("");
+
+function shouldThrowWithNew(objectType, objectName)
+{
+    try {
+        new objectType;
+        testFailed('new ' + objectName + ' did not throw');
+    } catch (e) {
+        testPassed('new ' + objectName + ' threw an error');
+    }
+}
+
+shouldThrowWithNew(window.WebGLRenderingContext, 'WebGLRenderingContext');
+shouldThrowWithNew(window.WebGLActiveInfo, 'WebGLActiveInfo');
+shouldThrowWithNew(window.WebGLBuffer, 'WebGLBuffer');
+shouldThrowWithNew(window.WebGLFramebuffer, 'WebGLFramebuffer');
+shouldThrowWithNew(window.WebGLProgram, 'WebGLProgram');
+shouldThrowWithNew(window.WebGLRenderbuffer, 'WebGLRenderbuffer');
+shouldThrowWithNew(window.WebGLShader, 'WebGLShader');
+shouldThrowWithNew(window.WebGLTexture, 'WebGLTexture');
+shouldThrowWithNew(window.WebGLUniformLocation, 'WebGLUniformLocation');
+shouldThrowWithNew(window.WebGLShaderPrecisionFormat, 'WebGLShaderPrecisionFormat');
+
+successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+
+</body>
+</html>
+
+
diff --git a/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt b/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt
new file mode 100644 (file)
index 0000000..d3ccc2e
--- /dev/null
@@ -0,0 +1,32 @@
+WebGL shader precision format test.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat work.
+
+
+Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionFormat object.
+
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_INT) instanceof WebGLShaderPrecisionFormat is true
+PASS gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_INT) instanceof WebGLShaderPrecisionFormat is true
+
+Test that getShaderPrecisionFormat throws an error with invalid parameters.
+
+PASS gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER) generated expected GL error: INVALID_ENUM.
+
+Test that getShaderPrecisionFormat returns the same thing every call.
+
+PASS shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin is true
+PASS shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax is true
+PASS shaderPrecisionFormat.precision == shaderPrecisionFormat2.precision is true
+
diff --git a/LayoutTests/fast/canvas/webgl/shader-precision-format.html b/LayoutTests/fast/canvas/webgl/shader-precision-format.html
new file mode 100644 (file)
index 0000000..5e03dba
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL shader precision format test.</title>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<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>
+<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+var wtu = WebGLTestUtils;
+description(document.title);
+debug("Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat work.");
+debug("");
+var gl = create3DContext(document.getElementById("canvas"));
+
+function verifyShaderPrecisionFormat(shadertype, precisiontype) {
+    shouldBeTrue('gl.getShaderPrecisionFormat(' + shadertype + ', ' +
+                 precisiontype + ') instanceof WebGLShaderPrecisionFormat');
+}
+
+debug("");
+debug("Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionFormat object.");
+debug("");
+
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_FLOAT');
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_FLOAT');
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_FLOAT');
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_INT');
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_INT');
+verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_INT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_FLOAT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_FLOAT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_FLOAT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_INT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_INT');
+verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_INT');
+
+debug("");
+debug("Test that getShaderPrecisionFormat throws an error with invalid parameters.");
+debug("");
+
+shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER)');
+
+debug("");
+debug("Test that getShaderPrecisionFormat returns the same thing every call.");
+debug("");
+
+var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
+var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin');
+shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax');
+shouldBeTrue('shaderPrecisionFormat.precision == shaderPrecisionFormat2.precision');
+
+finishTest();
+</script>
+
+</body>
+</html>
+
+
index b14410b..96811cb 100644 (file)
@@ -44,6 +44,7 @@ var __skip__ = {
     "WebGLRenderbuffer" : 1,
     "WebGLRenderingContext" : 1,
     "WebGLShader" : 1,
+    "WebGLShaderPrecisionFormat" : 1,
     "WebGLTexture" : 1,
     "WebGLUniformLocation" : 1,
     "WebKitBlobBuilder" : 1,
index dc7f86d..feb30af 100644 (file)
@@ -88,6 +88,7 @@ var __skip__ = {
     "window.WebGLRenderbuffer" : 1, 
     "window.WebGLRenderingContext" : 1, 
     "window.WebGLShader" : 1, 
+    "window.WebGLShaderPrecisionFormat" : 1, 
     "window.WebGLTexture" : 1, 
     "window.WebGLUniformLocation" : 1, 
     "window.WebKitBlobBuilder" : 1,
index dfbc726..fcf8104 100644 (file)
@@ -80,6 +80,7 @@ function constructorNamesForWindow(globalObject)
             type == "WebGLProgramConstructor" ||
             type == "WebGLRenderbufferConstructor" ||
             type == "WebGLShaderConstructor" ||
+            type == "WebGLShaderPrecisionFormatConstructor" ||
             type == "WebGLTextureConstructor" ||
             type == "WebGLUniformLocationConstructor" ||
             type == "ArrayBufferConstructor" ||
index dfc5b8f..014fd2e 100644 (file)
@@ -18,7 +18,7 @@ var skippedProperties = [
     "webkitNotifications",
     "webkitAudioPannerNode",
     "performance",
-    "WebGLRenderingContext", "WebGLActiveInfo", "WebGLBuffer", "WebGLFramebuffer", "WebGLProgram", "WebGLRenderbuffer", "WebGLShader", "WebGLTexture", "WebGLUniformLocation",
+    "WebGLRenderingContext", "WebGLActiveInfo", "WebGLBuffer", "WebGLFramebuffer", "WebGLProgram", "WebGLRenderbuffer", "WebGLShader", "WebGLShaderPrecisionFormat", "WebGLTexture", "WebGLUniformLocation",
     "ArrayBuffer",
     "DataView", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array",
     "FileError", "FileReader", "WebKitBlobBuilder", "webkitRequestFileSystem",
index 00116e2..da13d17 100644 (file)
@@ -24,6 +24,7 @@ for (var x in constructorNames) {
         name == "WebGLProgram" ||
         name == "WebGLRenderbuffer" ||
         name == "WebGLShader" ||
+        name == "WebGLShaderPrecisionFormat" ||
         name == "WebGLTexture" ||
         name == "WebGLUniformLocation" ||
         name == "ArrayBuffer" ||
index 3ecfa5a..c91277f 100644 (file)
@@ -1,3 +1,13 @@
+2012-04-02  Zhenyao Mo  <zmo@google.com>
+
+        Implement WebGLShaderPrecisionFormat
+        https://bugs.webkit.org/show_bug.cgi?id=75925
+
+        Reviewed by Kenneth Russell.
+
+        * chromium/public/WebGraphicsContext3D.h: Add getShaderPrecisionFormat().
+        (WebGraphicsContext3D):
+
 2012-04-03  Adam Barth  <abarth@webkit.org>
 
         Attempt to fix the Windows component build by including these headers
index 2f8677f..371e8f4 100644 (file)
@@ -286,10 +286,7 @@ public:
     virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) = 0;
     virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) = 0;
     virtual WebString getShaderInfoLog(WebGLId shader) = 0;
-
-    // TBD
-    // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-
+    virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precisiontype, WGC3Dint* range, WGC3Dint* precision) = 0;
     virtual WebString getShaderSource(WebGLId shader) = 0;
     virtual WebString getString(WGC3Denum name) = 0;
     virtual void getTexParameterfv(WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value) = 0;
index 3c4cd44..59c0507 100644 (file)
@@ -2290,6 +2290,7 @@ IF (ENABLE_WEBGL)
         html/canvas/WebGLRenderbuffer.cpp
         html/canvas/WebGLRenderingContext.cpp
         html/canvas/WebGLShader.cpp
+        html/canvas/WebGLShaderPrecisionFormat.cpp
         html/canvas/WebGLSharedObject.cpp
         html/canvas/WebGLTexture.cpp
         html/canvas/WebGLUniformLocation.cpp
@@ -2321,6 +2322,7 @@ IF (ENABLE_WEBGL)
         html/canvas/WebGLRenderbuffer.idl
         html/canvas/WebGLRenderingContext.idl
         html/canvas/WebGLShader.idl
+        html/canvas/WebGLShaderPrecisionFormat.idl
         html/canvas/WebGLTexture.idl
         html/canvas/WebGLUniformLocation.idl
         html/canvas/WebGLVertexArrayObjectOES.idl
index cb02166..95032cd 100644 (file)
@@ -1,3 +1,47 @@
+2012-04-02  Zhenyao Mo  <zmo@google.com>
+
+        Implement WebGLShaderPrecisionFormat
+        https://bugs.webkit.org/show_bug.cgi?id=75925
+
+        Reviewed by Kenneth Russell.
+
+        Test: fast/canvas/webgl/shader-precision-format.html
+
+        * CMakeLists.txt: Add new source files webglshaderprecisionformat.h/idl
+        * DerivedSources.make: Ditto.
+        * DerivedSources.pri: Ditto.
+        * GNUmakefile.list.am: Ditto.
+        * Target.pri: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * html/canvas/WebGLRenderingContext.cpp: Add getShaderPrecisionFormat.
+        (WebCore):
+        (WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
+        * html/canvas/WebGLRenderingContext.h: Ditto.
+        (WebCore):
+        (WebGLRenderingContext):
+        * html/canvas/WebGLRenderingContext.idl: Ditto.
+        * html/canvas/WebGLShaderPrecisionFormat.h: Added.
+        (WebCore):
+        (WebGLShaderPrecisionFormat):
+        (WebCore::WebGLShaderPrecisionFormat::create):
+        (WebCore::WebGLShaderPrecisionFormat::rangeMin):
+        (WebCore::WebGLShaderPrecisionFormat::rangeMax):
+        (WebCore::WebGLShaderPrecisionFormat::precision):
+        (WebCore::WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat):
+        * html/canvas/WebGLShaderPrecisionFormat.idl: Added.
+        * page/DOMWindow.idl: Expose new type WebGLShaderPrecisionFormat for instanceof.
+        * platform/graphics/GraphicsContext3D.h: Add getShaderPrecisionFormat().
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Ditto.
+        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
+        (WebCore):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: Ditto.
+        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
+        (WebCore):
+        * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
+        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
+        (WebCore):
+
 2012-04-03  Zalan Bujtas  <zbujtas@gmail.com>
 
         Frame flattening: Do not restart layout from parent frame, when the parent is clean.
index 803eb83..c918480 100644 (file)
@@ -368,6 +368,7 @@ BINDING_IDLS = \
     $(WebCore)/html/canvas/WebGLRenderbuffer.idl \
     $(WebCore)/html/canvas/WebGLRenderingContext.idl \
     $(WebCore)/html/canvas/WebGLShader.idl \
+    $(WebCore)/html/canvas/WebGLShaderPrecisionFormat.idl \
     $(WebCore)/html/canvas/WebGLTexture.idl \
     $(WebCore)/html/canvas/WebGLUniformLocation.idl \
     $(WebCore)/html/canvas/WebGLVertexArrayObjectOES.idl \
index e2d95c1..5ee35ae 100644 (file)
@@ -294,6 +294,7 @@ IDL_BINDINGS += \
     $$PWD/html/canvas/WebGLRenderbuffer.idl \
     $$PWD/html/canvas/WebGLRenderingContext.idl \
     $$PWD/html/canvas/WebGLShader.idl \
+    $$PWD/html/canvas/WebGLShaderPrecisionFormat.idl \
     $$PWD/html/canvas/Int16Array.idl \
     $$PWD/html/canvas/WebGLTexture.idl \
     $$PWD/html/canvas/WebGLUniformLocation.idl \
index 401d303..4417c3f 100644 (file)
@@ -577,6 +577,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSWebGLRenderingContext.h \
        DerivedSources/WebCore/JSWebGLShader.cpp \
        DerivedSources/WebCore/JSWebGLShader.h \
+       DerivedSources/WebCore/JSWebGLShaderPrecisionFormat.cpp \
+       DerivedSources/WebCore/JSWebGLShaderPrecisionFormat.h \
        DerivedSources/WebCore/JSWebGLTexture.cpp \
        DerivedSources/WebCore/JSWebGLTexture.h \
        DerivedSources/WebCore/JSWebGLUniformLocation.cpp \
@@ -904,6 +906,7 @@ dom_binding_idls += \
        $(WebCore)/html/canvas/WebGLRenderbuffer.idl \
        $(WebCore)/html/canvas/WebGLRenderingContext.idl \
        $(WebCore)/html/canvas/WebGLShader.idl \
+       $(WebCore)/html/canvas/WebGLShaderPrecisionFormat.idl \
        $(WebCore)/html/canvas/WebGLTexture.idl \
        $(WebCore)/html/canvas/WebGLUniformLocation.idl \
        $(WebCore)/html/canvas/WebGLVertexArrayObjectOES.idl \
@@ -5805,6 +5808,8 @@ webcore_sources += \
        Source/WebCore/html/canvas/WebGLRenderingContext.h \
        Source/WebCore/html/canvas/WebGLShader.cpp \
        Source/WebCore/html/canvas/WebGLShader.h \
+       Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.cpp \
+       Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.h \
        Source/WebCore/html/canvas/WebGLSharedObject.cpp \
        Source/WebCore/html/canvas/WebGLSharedObject.h \
        Source/WebCore/html/canvas/WebGLTexture.cpp \
index 50e5165..110404f 100644 (file)
@@ -3769,6 +3769,7 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/WebGLRenderbuffer.h \
         html/canvas/WebGLRenderingContext.h \
         html/canvas/WebGLShader.h \
+        html/canvas/WebGLShaderPrecisionFormat.h \
         html/canvas/WebGLSharedObject.h \
         html/canvas/EXTTextureFilterAnisotropic.h \
         html/canvas/OESStandardDerivatives.h \
@@ -3810,6 +3811,7 @@ contains(DEFINES, ENABLE_WEBGL=1) {
         html/canvas/WebGLRenderbuffer.cpp \
         html/canvas/WebGLRenderingContext.cpp \
         html/canvas/WebGLShader.cpp \
+        html/canvas/WebGLShaderPrecisionFormat.cpp \
         html/canvas/WebGLSharedObject.cpp \
         html/canvas/EXTTextureFilterAnisotropic.cpp \
         html/canvas/OESStandardDerivatives.cpp \
index ba4630d..da98a03 100644 (file)
             'html/canvas/WebGLRenderbuffer.idl',
             'html/canvas/WebGLRenderingContext.idl',
             'html/canvas/WebGLShader.idl',
+            'html/canvas/WebGLShaderPrecisionFormat.idl',
             'html/canvas/WebGLTexture.idl',
             'html/canvas/WebGLUniformLocation.idl',
             'html/canvas/WebGLVertexArrayObjectOES.idl',
             'html/canvas/WebGLRenderingContext.h',
             'html/canvas/WebGLShader.cpp',
             'html/canvas/WebGLShader.h',
+            'html/canvas/WebGLShaderPrecisionFormat.cpp',
+            'html/canvas/WebGLShaderPrecisionFormat.h',
             'html/canvas/WebGLSharedObject.cpp',
             'html/canvas/WebGLSharedObject.h',
             'html/canvas/WebGLTexture.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLRenderingContext.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLShader.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLShader.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLShaderPrecisionFormat.cpp',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLShaderPrecisionFormat.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLTexture.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLTexture.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSWebGLUniformLocation.cpp',
index da01814..00b11f5 100644 (file)
                9FFE3EA511B5A4390037874E /* JSMemoryInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9FFE3EA311B5A4390037874E /* JSMemoryInfo.cpp */; };
                9FFE3EA611B5A4390037874E /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FFE3EA411B5A4390037874E /* JSMemoryInfo.h */; };
                A00B721A11DE6428008AB9FF /* CheckedInt.h in Headers */ = {isa = PBXBuildFile; fileRef = A00B721911DE6427008AB9FF /* CheckedInt.h */; };
+               A07D3355152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A07D3353152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp */; };
+               A07D3356152B630E001B6393 /* JSWebGLShaderPrecisionFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = A07D3354152B630E001B6393 /* JSWebGLShaderPrecisionFormat.h */; };
+               A07D3358152B632D001B6393 /* WebGLShaderPrecisionFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = A07D3357152B632D001B6393 /* WebGLShaderPrecisionFormat.h */; };
+               A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A08CF153152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp */; };
                A0EE0DF5144F825500F80B0D /* WebGLDebugRendererInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF1144F825500F80B0D /* WebGLDebugRendererInfo.cpp */; };
                A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF2144F825500F80B0D /* WebGLDebugRendererInfo.h */; };
                A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */; };
                9FFE3EA311B5A4390037874E /* JSMemoryInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMemoryInfo.cpp; sourceTree = "<group>"; };
                9FFE3EA411B5A4390037874E /* JSMemoryInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMemoryInfo.h; sourceTree = "<group>"; };
                A00B721911DE6427008AB9FF /* CheckedInt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CheckedInt.h; path = canvas/CheckedInt.h; sourceTree = "<group>"; };
+               A07D3353152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLShaderPrecisionFormat.cpp; sourceTree = "<group>"; };
+               A07D3354152B630E001B6393 /* JSWebGLShaderPrecisionFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLShaderPrecisionFormat.h; sourceTree = "<group>"; };
+               A07D3357152B632D001B6393 /* WebGLShaderPrecisionFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLShaderPrecisionFormat.h; path = canvas/WebGLShaderPrecisionFormat.h; sourceTree = "<group>"; };
+               A07D3359152B633E001B6393 /* WebGLShaderPrecisionFormat.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLShaderPrecisionFormat.idl; path = canvas/WebGLShaderPrecisionFormat.idl; sourceTree = "<group>"; };
+               A08CF153152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLShaderPrecisionFormat.cpp; path = canvas/WebGLShaderPrecisionFormat.cpp; sourceTree = "<group>"; };
                A0EE0DEF144F823200F80B0D /* WebGLDebugShaders.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLDebugShaders.idl; path = canvas/WebGLDebugShaders.idl; sourceTree = "<group>"; };
                A0EE0DF0144F824300F80B0D /* WebGLDebugRendererInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLDebugRendererInfo.idl; path = canvas/WebGLDebugRendererInfo.idl; sourceTree = "<group>"; };
                A0EE0DF1144F825500F80B0D /* WebGLDebugRendererInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLDebugRendererInfo.cpp; path = canvas/WebGLDebugRendererInfo.cpp; sourceTree = "<group>"; };
                49484FAE102CF01E00187DD3 /* canvas */ = {
                        isa = PBXGroup;
                        children = (
+                               A08CF153152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp */,
+                               A07D3359152B633E001B6393 /* WebGLShaderPrecisionFormat.idl */,
+                               A07D3357152B632D001B6393 /* WebGLShaderPrecisionFormat.h */,
                                49EECDCC10503C2300099FAB /* ArrayBuffer.idl */,
                                49EECDC910503C2300099FAB /* ArrayBufferView.idl */,
                                6E4E91A710F7FB3100A2779C /* CanvasContextAttributes.cpp */,
                                49EED1411051969400099FAB /* JSWebGLRenderingContext.h */,
                                49C7B98F1042D2D30009D447 /* JSWebGLShader.cpp */,
                                49C7B9901042D2D30009D447 /* JSWebGLShader.h */,
+                               A07D3353152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp */,
+                               A07D3354152B630E001B6393 /* JSWebGLShaderPrecisionFormat.h */,
                                49C7B9911042D2D30009D447 /* JSWebGLTexture.cpp */,
                                49C7B9921042D2D30009D447 /* JSWebGLTexture.h */,
                                0C45342510CDBBFA00869157 /* JSWebGLUniformLocation.cpp */,
                                93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
-                FD581FAF1520F91F003A7A75 /* Oscillator.h in Headers */,
-                FD581FB51520F93B003A7A75 /* WaveTable.h in Headers */,
-                FDEA6243152102E200479DF0 /* JSOscillator.h in Headers */,
-                FDEA6247152102FC00479DF0 /* JSWaveTable.h in Headers */,
+                               FD581FAF1520F91F003A7A75 /* Oscillator.h in Headers */,
+                               FD581FB51520F93B003A7A75 /* WaveTable.h in Headers */,
+                               FDEA6243152102E200479DF0 /* JSOscillator.h in Headers */,
+                               FDEA6247152102FC00479DF0 /* JSWaveTable.h in Headers */,
                                FD537353137B651800008DCE /* ZeroPole.h in Headers */,
                                1A3586E015264C450022A659 /* RenderMultiColumnFlowThread.h in Headers */,
                                E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
+                               A07D3356152B630E001B6393 /* JSWebGLShaderPrecisionFormat.h in Headers */,
+                               A07D3358152B632D001B6393 /* WebGLShaderPrecisionFormat.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1A3FF9C315265359002288A1 /* RenderNamedFlowThread.cpp in Sources */,
                                E1B25106152A0BAF0069B779 /* StylePropertyShorthand.cpp in Sources */,
                                71CC7A20152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp in Sources */,
+                               A07D3355152B630E001B6393 /* JSWebGLShaderPrecisionFormat.cpp in Sources */,
+                               A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index d5da182..e98059e 100644 (file)
@@ -66,6 +66,7 @@
 #include "WebGLProgram.h"
 #include "WebGLRenderbuffer.h"
 #include "WebGLShader.h"
+#include "WebGLShaderPrecisionFormat.h"
 #include "WebGLTexture.h"
 #include "WebGLUniformLocation.h"
 
@@ -2686,6 +2687,38 @@ String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod
     return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader)));
 }
 
+PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContext::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode& ec)
+{
+    UNUSED_PARAM(ec);
+    if (isContextLost())
+        return 0;
+    switch (shaderType) {
+    case GraphicsContext3D::VERTEX_SHADER:
+    case GraphicsContext3D::FRAGMENT_SHADER:
+        break;
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type");
+        return 0;
+    }
+    switch (precisionType) {
+    case GraphicsContext3D::LOW_FLOAT:
+    case GraphicsContext3D::MEDIUM_FLOAT:
+    case GraphicsContext3D::HIGH_FLOAT:
+    case GraphicsContext3D::LOW_INT:
+    case GraphicsContext3D::MEDIUM_INT:
+    case GraphicsContext3D::HIGH_INT:
+        break;
+    default:
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid precision type");
+        return 0;
+    }
+
+    GC3Dint range[2] = {0, 0};
+    GC3Dint precision = 0;
+    m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &precision);
+    return WebGLShaderPrecisionFormat::create(range[0], range[1], precision);
+}
+
 String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode& ec)
 {
     UNUSED_PARAM(ec);
index 8542001..d3c0832 100644 (file)
@@ -65,6 +65,7 @@ class WebGLProgram;
 class WebGLRenderbuffer;
 class WebGLShader;
 class WebGLSharedObject;
+class WebGLShaderPrecisionFormat;
 class WebGLTexture;
 class WebGLUniformLocation;
 class WebGLVertexArrayObjectOES;
@@ -166,10 +167,7 @@ public:
     WebGLGetInfo getRenderbufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode&);
     WebGLGetInfo getShaderParameter(WebGLShader*, GC3Denum pname, ExceptionCode&);
     String getShaderInfoLog(WebGLShader*, ExceptionCode&);
-
-    // TBD
-    // void glGetShaderPrecisionFormat (GC3Denum shadertype, GC3Denum precisiontype, GC3Dint* range, GC3Dint* precision);
-
+    PassRefPtr<WebGLShaderPrecisionFormat> getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode&);
     String getShaderSource(WebGLShader*, ExceptionCode&);
     Vector<String> getSupportedExtensions();
     WebGLGetInfo getTexParameter(GC3Denum target, GC3Denum pname, ExceptionCode&);
index 3aed436..1cd9941 100644 (file)
@@ -550,8 +550,7 @@ module html {
 
         [StrictTypeChecking, TreatReturnedNullStringAs=Null] DOMString    getShaderInfoLog(in WebGLShader shader) raises(DOMException);
 
-        // TBD
-        // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+        [StrictTypeChecking] WebGLShaderPrecisionFormat getShaderPrecisionFormat(in unsigned long shadertype, in unsigned long precisiontype) raises(DOMException);
 
         [StrictTypeChecking, TreatReturnedNullStringAs=Null] DOMString    getShaderSource(in WebGLShader shader) raises(DOMException);
 
diff --git a/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.cpp b/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.cpp
new file mode 100644 (file)
index 0000000..b9c5163
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEBGL)
+
+#include "WebGLShaderPrecisionFormat.h"
+
+namespace WebCore {
+
+// static
+PassRefPtr<WebGLShaderPrecisionFormat> WebGLShaderPrecisionFormat::create(GC3Dint rangeMin, GC3Dint rangeMax, GC3Dint precision)
+{
+    return adoptRef(new WebGLShaderPrecisionFormat(rangeMin, rangeMax, precision));
+}
+
+GC3Dint WebGLShaderPrecisionFormat::rangeMin() const
+{
+    return m_rangeMin;
+}
+
+GC3Dint WebGLShaderPrecisionFormat::rangeMax() const
+{
+    return m_rangeMax;
+}
+
+GC3Dint WebGLShaderPrecisionFormat::precision() const
+{
+    return m_precision;
+}
+
+WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat(GC3Dint rangeMin, GC3Dint rangeMax, GC3Dint precision)
+    : m_rangeMin(rangeMin)
+    , m_rangeMax(rangeMax)
+    , m_precision(precision)
+{
+}
+
+}
+
+#endif // ENABLE(WEBGL)
+
diff --git a/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.h b/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.h
new file mode 100644 (file)
index 0000000..c4c7b78
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebGLShaderPrecisionFormat_h
+#define WebGLShaderPrecisionFormat_h
+
+#include "GraphicsContext3D.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class WebGLShaderPrecisionFormat : public RefCounted<WebGLShaderPrecisionFormat> {
+public:
+    static PassRefPtr<WebGLShaderPrecisionFormat> create(GC3Dint rangeMin, GC3Dint rangeMax, GC3Dint precision);
+
+    GC3Dint rangeMin() const;
+    GC3Dint rangeMax() const;
+    GC3Dint precision() const;
+
+private:
+    WebGLShaderPrecisionFormat(GC3Dint rangeMin, GC3Dint rangeMax, GC3Dint precision);
+
+    GC3Dint m_rangeMin;
+    GC3Dint m_rangeMax;
+    GC3Dint m_precision;
+};
+
+}
+
+#endif // WebGLShaderPrecisionFormat_h
diff --git a/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.idl b/Source/WebCore/html/canvas/WebGLShaderPrecisionFormat.idl
new file mode 100644 (file)
index 0000000..7cfb80e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+
+    interface [
+        Conditional=WEBGL,
+    ] WebGLShaderPrecisionFormat {
+        readonly attribute int rangeMin;
+        readonly attribute int rangeMax;
+        readonly attribute int precision;
+    };
+
+}
index 0efa7bf..b239d15 100644 (file)
@@ -496,6 +496,7 @@ module window {
         attribute [Conditional=WEBGL] WebGLRenderbufferConstructor WebGLRenderbuffer;
         attribute [Conditional=WEBGL] WebGLRenderingContextConstructor WebGLRenderingContext;
         attribute [Conditional=WEBGL] WebGLShaderConstructor WebGLShader;
+        attribute [Conditional=WEBGL] WebGLShaderPrecisionFormatConstructor WebGLShaderPrecisionFormat;
         attribute [Conditional=WEBGL] WebGLTextureConstructor WebGLTexture;
         attribute [Conditional=WEBGL] WebGLUniformLocationConstructor WebGLUniformLocation;
 
index 3bb85f8..c2293e4 100644 (file)
@@ -709,10 +709,7 @@ public:
     void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
     void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
     String getShaderInfoLog(Platform3DObject);
-
-    // TBD
-    // void glGetShaderPrecisionFormat (GC3Denum shadertype, GC3Denum precisiontype, GC3Dint* range, GC3Dint* precision);
-
+    void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision);
     String getShaderSource(Platform3DObject);
     String getString(GC3Denum name);
     void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value);
index 7c47778..5a5ea5c 100644 (file)
@@ -189,6 +189,37 @@ void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
     }
 }
 
+void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision)
+{
+    UNUSED_PARAM(shaderType);
+    ASSERT(range);
+    ASSERT(precision);
+
+    makeContextCurrent();
+
+    // These constants came from the Chromium port; we believe they originally
+    // came from making the actual API call on a representative desktop system.
+    switch (precisionType) {
+    case GraphicsContext3D::LOW_INT:
+    case GraphicsContext3D::MEDIUM_INT:
+    case GraphicsContext3D::HIGH_INT:
+        range[0] = -31;
+        range[1] = 31;
+        precision[0] = 0;
+        break;
+    case GraphicsContext3D::LOW_FLOAT:
+    case GraphicsContext3D::MEDIUM_FLOAT:
+    case GraphicsContext3D::HIGH_FLOAT:
+        range[0] = -62;
+        range[1] = 62;
+        precision[0] = -16;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
 {
     if (width && height && !pixels) {
index 4faa663..5641662 100644 (file)
@@ -127,6 +127,15 @@ void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value)
     ::glGetIntegerv(pname, value);
 }
 
+void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision)
+{
+    ASSERT(range);
+    ASSERT(precision);
+
+    makeContextCurrent();
+    ::glGetShaderPrecisionFormat(shaderType, precisionType, range, precision);
+}
+
 bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
 {
     if (width && height && !pixels) {
index f8f9052..6125e73 100644 (file)
@@ -1360,6 +1360,39 @@ String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
     return result;
 }
 
+void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision)
+{
+    // FIXME: this should be retargeted at the real getShaderPrecisionFormat()
+    // call on true ES 2.0 hardware.
+    UNUSED_PARAM(shaderType);
+    ASSERT(range);
+    ASSERT(precision);
+
+    makeContextCurrent();
+
+    // These constants came from the Chromium port; we believe they originally
+    // came from making the actual API call on a representative desktop system.
+    switch (precisionType) {
+    case GraphicsContext3D::LOW_INT:
+    case GraphicsContext3D::MEDIUM_INT:
+    case GraphicsContext3D::HIGH_INT:
+        range[0] = -31;
+        range[1] = 31;
+        precision[0] = 0;
+        break;
+    case GraphicsContext3D::LOW_FLOAT:
+    case GraphicsContext3D::MEDIUM_FLOAT:
+    case GraphicsContext3D::HIGH_FLOAT:
+        range[0] = -62;
+        range[1] = 62;
+        precision[0] = -16;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
 {
     makeContextCurrent();
index 5e7cc35..f0c55ee 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-02  Zhenyao Mo  <zmo@google.com>
+
+        Implement WebGLShaderPrecisionFormat
+        https://bugs.webkit.org/show_bug.cgi?id=75925
+
+        Reviewed by Kenneth Russell.
+
+        * src/GraphicsContext3DChromium.cpp: Add getShaderPrecisionFormat().
+        (WebCore):
+        * src/GraphicsContext3DPrivate.h: Ditto.
+        (GraphicsContext3DPrivate):
+        * tests/FakeWebGraphicsContext3D.h: Ditto.
+        (FakeWebGraphicsContext3D):
+
 2012-04-03  Dirk Pranke  <dpranke@chromium.org>
 
         disable incremental linking for debug of webkit
index 3f76630..fbea64a 100644 (file)
@@ -612,6 +612,8 @@ String GraphicsContext3DPrivate::getShaderInfoLog(Platform3DObject shader)
     return m_impl->getShaderInfoLog(shader);
 }
 
+DELEGATE_TO_IMPL_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*)
+
 String GraphicsContext3DPrivate::getShaderSource(Platform3DObject shader)
 {
     return m_impl->getShaderSource(shader);
@@ -1155,6 +1157,7 @@ DELEGATE_TO_INTERNAL_1R(getProgramInfoLog, Platform3DObject, String)
 DELEGATE_TO_INTERNAL_3(getRenderbufferParameteriv, GC3Denum, GC3Denum, GC3Dint*)
 DELEGATE_TO_INTERNAL_3(getShaderiv, Platform3DObject, GC3Denum, GC3Dint*)
 DELEGATE_TO_INTERNAL_1R(getShaderInfoLog, Platform3DObject, String)
+DELEGATE_TO_INTERNAL_4(getShaderPrecisionFormat, GC3Denum, GC3Denum, GC3Dint*, GC3Dint*)
 DELEGATE_TO_INTERNAL_1R(getShaderSource, Platform3DObject, String)
 DELEGATE_TO_INTERNAL_1R(getString, GC3Denum, String)
 DELEGATE_TO_INTERNAL_3(getTexParameterfv, GC3Denum, GC3Denum, GC3Dfloat*)
index 52e9807..b798989 100644 (file)
@@ -164,6 +164,7 @@ public:
     void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
     void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
     String getShaderInfoLog(Platform3DObject);
+    void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision);
 
     String getShaderSource(Platform3DObject);
     String getString(GC3Denum name);
index 966f142..191d05f 100644 (file)
@@ -158,7 +158,7 @@ public:
     }
 
     virtual WebString getShaderInfoLog(WebGLId shader) { return WebString(); }
-
+    virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precisiontype, WGC3Dint* range, WGC3Dint* precision) { }
     virtual WebString getShaderSource(WebGLId shader) { return WebString(); }
     virtual WebString getString(WGC3Denum name) { return WebString(); }
     virtual void getTexParameterfv(WGC3Denum target, WGC3Denum pname, WGC3Dfloat* value) { }