[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

oliver at apple.com oliver at apple.com
Thu Oct 29 20:42:51 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit b1aede6707067ddbb1e0a4ecbf70dc9a0649b816
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Oct 10 21:16:58 2009 +0000

    Implement getActiveAttrib and getActiveUniform
    https://bugs.webkit.org/show_bug.cgi?id=30276
    
    Reviewed by Eric Carlson.
    
    Implements the getActiveAttrib and getActiveUniform APIs.
    Rather simple patch, adds CanvasActiveInfo definition and implementation
    and adds forwarding to the GraphicsContext3D.
    
    Test: fast/canvas/webgl/getActiveTest.html
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8cb2827..bc24522 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
+2009-10-10  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Implement getActiveAttrib and getActiveUniform
+        https://bugs.webkit.org/show_bug.cgi?id=30276
+
+        Adds test for getActiveAttrib and getActiveUniform.  Additionally
+        adds a basic shader pair, and a utility library to do the more
+        mechanical work needed to set up a WebGL context for testing.
+
+        * fast/canvas/webgl/getActiveTest-expected.txt: Added.
+        * fast/canvas/webgl/getActiveTest.html: Added.
+        * fast/canvas/webgl/resources/fragmentShader.frag: Added.
+        * fast/canvas/webgl/resources/shader-test.js: Added.
+        (getShaderSource):
+        (create3DContext):
+        (loadStandardProgram):
+        * fast/canvas/webgl/resources/vertexShader.vert: Added.
+        * fast/canvas/webgl/script-tests/getActiveTest.js: Added.
+
 2009-10-09  Ryosuke Niwa  <rniwa at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/fast/canvas/webgl/getActiveTest-expected.txt b/LayoutTests/fast/canvas/webgl/getActiveTest-expected.txt
new file mode 100644
index 0000000..8de69a8
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/getActiveTest-expected.txt
@@ -0,0 +1,39 @@
+Test of getActiveAttrib and getActiveUniform
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS context.getError() is 0
+PASS context.getActiveUniform(program, 0).name is 'u_modelViewProjMatrix'
+PASS context.getActiveUniform(program, 0).type is context.FLOAT_MAT4
+PASS context.getActiveUniform(program, 0).size is 1
+PASS context.getActiveUniform(program, 1) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is context.INVALID_VALUE
+PASS context.getActiveUniform(program, -1) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is context.INVALID_VALUE
+PASS context.getActiveUniform(null, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is 0
+PASS context.getActiveAttrib(program, 0).name is 'a_normal'
+PASS context.getActiveAttrib(program, 0).type is context.FLOAT_VEC3
+PASS context.getActiveAttrib(program, 0).size is 1
+PASS context.getActiveAttrib(program, 1).name is 'a_vertex'
+PASS context.getActiveAttrib(program, 1).type is context.FLOAT_VEC4
+PASS context.getActiveAttrib(program, 1).size is 1
+PASS context.getActiveAttrib(program, 2) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is context.INVALID_VALUE
+PASS context.getActiveAttrib(program, -1) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is context.INVALID_VALUE
+PASS context.getActiveAttrib(null, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is 0
+PASS context2.getError() is 0
+PASS context2.getActiveAttrib(program, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context2.getError() is 0
+PASS context2.getActiveUniform(program, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context2.getError() is 0
+PASS context.getActiveUniform(program, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is 0
+PASS context.getActiveAttrib(program, 0) threw exception Error: INDEX_SIZE_ERR: DOM Exception 1.
+PASS context.getError() is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/webgl/getActiveTest.html b/LayoutTests/fast/canvas/webgl/getActiveTest.html
new file mode 100644
index 0000000..d70c418
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/getActiveTest.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/shader-test.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script src="script-tests/getActiveTest.js"></script>
+
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag b/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
new file mode 100644
index 0000000..53a556b
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
@@ -0,0 +1,6 @@
+varying vec3 v_normal;
+
+void main()
+{
+    gl_FragColor = vec4(v_normal/2.0+vec3(0.5), 1);
+}
diff --git a/LayoutTests/fast/canvas/webgl/resources/shader-test.js b/LayoutTests/fast/canvas/webgl/resources/shader-test.js
new file mode 100644
index 0000000..3c0a2c5
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/resources/shader-test.js
@@ -0,0 +1,28 @@
+function getShaderSource(file) {
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", file, false);
+    xhr.send();
+    return xhr.responseText;
+}
+
+function create3DContext() {
+    var canvas = document.createElement("canvas");
+    try {
+        return canvas.getContext("webkit-3d");
+    } catch(e) {}
+    return canvas.getContext("moz-webgl");
+}
+
+function loadStandardProgram(context) {
+    var program = context.createProgram();
+    var vertexShader = context.createShader(context.VERTEX_SHADER);
+    context.shaderSource(vertexShader, getShaderSource("resources/vertexShader.vert"));
+    context.compileShader(vertexShader);
+    var fragmentShader = context.createShader(context.FRAGMENT_SHADER);
+    context.shaderSource(fragmentShader, getShaderSource("resources/fragmentShader.frag"));
+    context.compileShader(fragmentShader);
+    context.attachShader(program, vertexShader);
+    context.attachShader(program, fragmentShader);
+    context.linkProgram(program);
+    return program;
+}
diff --git a/LayoutTests/fast/canvas/webgl/resources/vertexShader.vert b/LayoutTests/fast/canvas/webgl/resources/vertexShader.vert
new file mode 100644
index 0000000..9ef2632
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/resources/vertexShader.vert
@@ -0,0 +1,12 @@
+attribute vec4 a_vertex;
+attribute vec3 a_normal;
+
+uniform mat4 u_modelViewProjMatrix;
+
+varying vec3 v_normal;
+
+void main()
+{ 
+    v_normal = a_normal;
+    gl_Position =  u_modelViewProjMatrix * a_vertex;
+}
diff --git a/LayoutTests/fast/canvas/webgl/script-tests/getActiveTest.js b/LayoutTests/fast/canvas/webgl/script-tests/getActiveTest.js
new file mode 100644
index 0000000..1410bf1
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/script-tests/getActiveTest.js
@@ -0,0 +1,44 @@
+description("Test of getActiveAttrib and getActiveUniform");
+
+var context = create3DContext();
+var context2 = create3DContext();
+var program = loadStandardProgram(context);
+var program2 = loadStandardProgram(context2);
+
+shouldBe("context.getError()", "0");
+shouldBe("context.getActiveUniform(program, 0).name", "'u_modelViewProjMatrix'");
+shouldBe("context.getActiveUniform(program, 0).type", "context.FLOAT_MAT4");
+shouldBe("context.getActiveUniform(program, 0).size", "1");
+shouldThrow("context.getActiveUniform(program, 1)");
+shouldBe("context.getError()", "context.INVALID_VALUE");
+shouldThrow("context.getActiveUniform(program, -1)");
+shouldBe("context.getError()", "context.INVALID_VALUE");
+shouldThrow("context.getActiveUniform(null, 0)");
+shouldBe("context.getError()", "0");
+
+shouldBe("context.getActiveAttrib(program, 0).name", "'a_normal'");
+shouldBe("context.getActiveAttrib(program, 0).type", "context.FLOAT_VEC3");
+shouldBe("context.getActiveAttrib(program, 0).size", "1");
+shouldBe("context.getActiveAttrib(program, 1).name", "'a_vertex'");
+shouldBe("context.getActiveAttrib(program, 1).type", "context.FLOAT_VEC4");
+shouldBe("context.getActiveAttrib(program, 1).size", "1");
+shouldThrow("context.getActiveAttrib(program, 2)");
+shouldBe("context.getError()", "context.INVALID_VALUE");
+shouldThrow("context.getActiveAttrib(program, -1)");
+shouldBe("context.getError()", "context.INVALID_VALUE");
+shouldThrow("context.getActiveAttrib(null, 0)");
+shouldBe("context.getError()", "0");
+
+shouldBe("context2.getError()", "0");
+shouldThrow("context2.getActiveAttrib(program, 0)");
+shouldBe("context2.getError()", "0");
+shouldThrow("context2.getActiveUniform(program, 0)");
+shouldBe("context2.getError()", "0");
+
+context.deleteProgram(program);
+shouldThrow("context.getActiveUniform(program, 0)");
+shouldBe("context.getError()", "0");
+shouldThrow("context.getActiveAttrib(program, 0)");
+shouldBe("context.getError()", "0");
+
+successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 70b763b..e1900d1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,39 @@
+2009-10-10  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Implement getActiveAttrib and getActiveUniform
+        https://bugs.webkit.org/show_bug.cgi?id=30276
+
+        Implements the getActiveAttrib and getActiveUniform APIs.
+        Rather simple patch, adds CanvasActiveInfo definition and implementation
+        and adds forwarding to the GraphicsContext3D.
+
+        Test: fast/canvas/webgl/getActiveTest.html
+
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/CanvasActiveInfo.h: Added.
+        (WebCore::CanvasActiveInfo::create):
+        (WebCore::CanvasActiveInfo::name):
+        (WebCore::CanvasActiveInfo::type):
+        (WebCore::CanvasActiveInfo::size):
+        (WebCore::CanvasActiveInfo::CanvasActiveInfo):
+        * html/canvas/CanvasActiveInfo.idl: Added.
+        * html/canvas/CanvasObject.h:
+        (WebCore::CanvasObject::context):
+          Need to make the context public as it is needed to ensure we don't
+          provide a program from one context as an argument to another.
+        * html/canvas/CanvasRenderingContext3D.cpp:
+        (WebCore::CanvasRenderingContext3D::getActiveAttrib):
+        (WebCore::CanvasRenderingContext3D::getActiveUniform):
+        * html/canvas/CanvasRenderingContext3D.h:
+        * html/canvas/CanvasRenderingContext3D.idl:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/mac/GraphicsContext3DMac.cpp:
+        (WebCore::GraphicsContext3D::getActiveAttrib):
+        (WebCore::GraphicsContext3D::getActiveUniform):
+
 2009-10-10  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/DerivedSources.make b/WebCore/DerivedSources.make
index fa37a3d..46e6108 100644
--- a/WebCore/DerivedSources.make
+++ b/WebCore/DerivedSources.make
@@ -70,6 +70,7 @@ DOM_CLASSES = \
     CSSValueList \
     CSSVariablesRule \
     CSSVariablesDeclaration \
+    CanvasActiveInfo \
     CanvasArray \
     CanvasArrayBuffer \
     CanvasBuffer \
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index fc7a9b6..9cf3111 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2396,6 +2396,9 @@
 		A7CFB3D20B7ED10A0070C32D /* DragImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A7CFB3D00B7ED10A0070C32D /* DragImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A7CFB3D50B7ED1180070C32D /* DragImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */; };
 		A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */; };
+		A7D20F62107F406900A80392 /* JSCanvasActiveInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */; };
+		A7D20F63107F406900A80392 /* JSCanvasActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */; };
+		A7D20F6D107F438B00A80392 /* CanvasActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */; };
 		A7D27FC40E0A599F0079AD2B /* SVGFETile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D27FC30E0A599F0079AD2B /* SVGFETile.cpp */; };
 		A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */; };
@@ -7601,6 +7604,10 @@
 		A7CFB3D00B7ED10A0070C32D /* DragImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DragImage.h; sourceTree = "<group>"; };
 		A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragImageMac.mm; sourceTree = "<group>"; };
 		A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageDataCustom.cpp; sourceTree = "<group>"; };
+		A7D20F3B107F373800A80392 /* CanvasActiveInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CanvasActiveInfo.idl; path = canvas/CanvasActiveInfo.idl; sourceTree = "<group>"; };
+		A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSCanvasActiveInfo.cpp; path = /Users/oliver/builds/Debug/DerivedSources/WebCore/JSCanvasActiveInfo.cpp; sourceTree = "<absolute>"; };
+		A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSCanvasActiveInfo.h; path = /Users/oliver/builds/Debug/DerivedSources/WebCore/JSCanvasActiveInfo.h; sourceTree = "<absolute>"; };
+		A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasActiveInfo.h; path = canvas/CanvasActiveInfo.h; sourceTree = "<group>"; };
 		A7D27FC30E0A599F0079AD2B /* SVGFETile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFETile.cpp; sourceTree = "<group>"; };
 		A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHelper.h; sourceTree = "<group>"; };
 		A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WorkerScriptLoader.h; path = workers/WorkerScriptLoader.h; sourceTree = "<group>"; };
@@ -10620,6 +10627,8 @@
 				49EECDDC10503C2300099FAB /* CanvasUnsignedShortArray.cpp */,
 				49EECDDD10503C2400099FAB /* CanvasUnsignedShortArray.h */,
 				49EECDDE10503C2400099FAB /* CanvasUnsignedShortArray.idl */,
+				A7D20F3B107F373800A80392 /* CanvasActiveInfo.idl */,
+				A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */,
 			);
 			name = canvas;
 			sourceTree = "<group>";
@@ -12713,6 +12722,8 @@
 		A83B79080CCAFF2B000B0825 /* HTML */ = {
 			isa = PBXGroup;
 			children = (
+				A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */,
+				A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */,
 				49EECF19105072F300099FAB /* JSCanvasArray.cpp */,
 				49EECF1A105072F300099FAB /* JSCanvasArray.h */,
 				49EECEF2105070C400099FAB /* JSCanvasArrayBuffer.cpp */,
@@ -18011,6 +18022,8 @@
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
 				97DCE20210807C750057D394 /* HistoryController.h in Headers */,
+				A7D20F63107F406900A80392 /* JSCanvasActiveInfo.h in Headers */,
+				A7D20F6D107F438B00A80392 /* CanvasActiveInfo.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -20139,6 +20152,7 @@
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
 				97DCE20110807C750057D394 /* HistoryController.cpp in Sources */,
+				A7D20F62107F406900A80392 /* JSCanvasActiveInfo.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/html/canvas/CanvasActiveInfo.h b/WebCore/html/canvas/CanvasActiveInfo.h
new file mode 100644
index 0000000..b04b0d0
--- /dev/null
+++ b/WebCore/html/canvas/CanvasActiveInfo.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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 CanvasActiveInfo_h
+#define CanvasActiveInfo_h
+
+#include "PlatformString.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class CanvasActiveInfo : public RefCounted<CanvasActiveInfo> {
+public:
+    static PassRefPtr<CanvasActiveInfo> create(const String& name, unsigned type, int size)
+    {
+        return adoptRef(new CanvasActiveInfo(name, type, size));
+    }
+    String name() const { return m_name; }
+    unsigned type() const { return m_type; }
+    int size() const { return m_size; }
+
+private:
+    CanvasActiveInfo(const String& name, unsigned type, int size)
+        : m_name(name)
+        , m_type(type)
+        , m_size(size)
+    {
+        ASSERT(name.length());
+        ASSERT(type);
+        ASSERT(size);
+    }
+    String m_name;
+    unsigned m_type;
+    int m_size;
+};
+
+}
+
+#endif // CanvasActiveInfo_h
diff --git a/WebCore/html/canvas/CanvasActiveInfo.idl b/WebCore/html/canvas/CanvasActiveInfo.idl
new file mode 100644
index 0000000..6ceae29
--- /dev/null
+++ b/WebCore/html/canvas/CanvasActiveInfo.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE INC. ``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 APPLE INC. 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=3D_CANVAS,
+    ] CanvasActiveInfo {
+        readonly attribute int size;
+        readonly attribute unsigned int type;
+        readonly attribute DOMString name;
+    };
+
+}
diff --git a/WebCore/html/canvas/CanvasObject.h b/WebCore/html/canvas/CanvasObject.h
index 413da71..748278d 100644
--- a/WebCore/html/canvas/CanvasObject.h
+++ b/WebCore/html/canvas/CanvasObject.h
@@ -48,12 +48,12 @@ namespace WebCore {
             deleteObject();
             m_context = 0;
         }
-        
+
+        CanvasRenderingContext3D* context() const { return m_context; }
+
     protected:
         CanvasObject(CanvasRenderingContext3D*);
         virtual void _deleteObject(Platform3DObject) = 0;
-        
-        CanvasRenderingContext3D* context() const { return m_context; }
     
     private:
         Platform3DObject m_object;
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.cpp b/WebCore/html/canvas/CanvasRenderingContext3D.cpp
index b810500..35f18ef 100644
--- a/WebCore/html/canvas/CanvasRenderingContext3D.cpp
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.cpp
@@ -28,6 +28,8 @@
 #if ENABLE(3D_CANVAS)
 
 #include "CanvasRenderingContext3D.h"
+
+#include "CanvasActiveInfo.h"
 #include "CanvasBuffer.h"
 #include "CanvasFramebuffer.h"
 #include "CanvasProgram.h"
@@ -477,6 +479,26 @@ void CanvasRenderingContext3D::generateMipmap(unsigned long target)
     cleanupAfterGraphicsCall(false);
 }
 
+PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveAttrib(CanvasProgram* program, unsigned long index, ExceptionCode& ec)
+{
+    ActiveInfo info;
+    if (!program || program->context() != this || !m_context.getActiveAttrib(program, index, info)) {
+        ec = INDEX_SIZE_ERR;
+        return 0;
+    }
+    return CanvasActiveInfo::create(info.name, info.type, info.size);
+}
+
+PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveUniform(CanvasProgram* program, unsigned long index, ExceptionCode& ec)
+{
+    ActiveInfo info;
+    if (!program || program->context() != this || !m_context.getActiveUniform(program, index, info)) {
+        ec = INDEX_SIZE_ERR;
+        return 0;
+    }
+    return CanvasActiveInfo::create(info.name, info.type, info.size);
+}
+
 int CanvasRenderingContext3D::getAttribLocation(CanvasProgram* program, const String& name)
 {
     return m_context.getAttribLocation(program, name);
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.h b/WebCore/html/canvas/CanvasRenderingContext3D.h
index a4a68fc..3471aca 100644
--- a/WebCore/html/canvas/CanvasRenderingContext3D.h
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.h
@@ -36,6 +36,7 @@
 
 namespace WebCore {
 
+class CanvasActiveInfo;
 class CanvasBuffer;
 class CanvasFramebuffer;
 class CanvasObject;
@@ -123,7 +124,10 @@ class WebKitCSSMatrix;
         void framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, CanvasTexture*, long level);
         void frontFace(unsigned long mode);
         void generateMipmap(unsigned long target);
-        
+
+        PassRefPtr<CanvasActiveInfo> getActiveAttrib(CanvasProgram*, unsigned long index, ExceptionCode&);
+        PassRefPtr<CanvasActiveInfo> getActiveUniform(CanvasProgram*, unsigned long index, ExceptionCode&);
+
         int  getAttribLocation(CanvasProgram*, const String& name);
 
         bool getBoolean(unsigned long pname);
diff --git a/WebCore/html/canvas/CanvasRenderingContext3D.idl b/WebCore/html/canvas/CanvasRenderingContext3D.idl
index 4b9a889..7b0daa9 100644
--- a/WebCore/html/canvas/CanvasRenderingContext3D.idl
+++ b/WebCore/html/canvas/CanvasRenderingContext3D.idl
@@ -530,8 +530,11 @@ module html {
         void         generateMipmap(in unsigned long target);
         
         // FIXME: these need to be added per the WebGL spec
-        // CanvasActiveInfo getActiveAttrib(GLuint program, GLuint index);
-        // CanvasActiveInfo getActiveUniform(GLuint program, GLuint index);
+        CanvasActiveInfo getActiveAttrib(in CanvasProgram program, in unsigned long index)
+            raises (DOMException);
+        CanvasActiveInfo getActiveUniform(in CanvasProgram program, in unsigned long index)
+            raises (DOMException);
+
         // CanvasShaderArray glGetAttachedShaders(GLuint program);
 
         int          getAttribLocation(in CanvasProgram program, in DOMString name);
diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
index 5223e05..314fc82 100644
--- a/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/WebCore/platform/graphics/GraphicsContext3D.h
@@ -45,6 +45,7 @@ const Platform3DObject NullPlatform3DObject = 0;
 #endif
 
 namespace WebCore {
+    class CanvasActiveInfo;
     class CanvasArray;
     class CanvasBuffer;
     class CanvasUnsignedByteArray;
@@ -61,7 +62,13 @@ namespace WebCore {
     class HTMLVideoElement;
     class ImageData;
     class WebKitCSSMatrix;
-    
+
+    struct ActiveInfo {
+        String name;
+        unsigned type;
+        int size;
+    };
+
     // FIXME: ideally this would be used on all platforms.
 #if PLATFORM(CHROMIUM)
     class GraphicsContext3DInternal;
@@ -141,6 +148,9 @@ namespace WebCore {
         void frontFace(unsigned long mode);
         void generateMipmap(unsigned long target);
 
+        bool getActiveAttrib(CanvasProgram* program, unsigned long index, ActiveInfo&);
+        bool getActiveUniform(CanvasProgram* program, unsigned long index, ActiveInfo&);
+
         int  getAttribLocation(CanvasProgram*, const String& name);
 
         bool getBoolean(unsigned long pname);
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
index cd66445..9eee2d0 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
@@ -30,9 +30,10 @@
 #include "GraphicsContext3D.h"
 
 #include "CachedImage.h"
+#include "CanvasActiveInfo.h"
+#include "CanvasArray.h"
 #include "CanvasBuffer.h"
 #include "CanvasFramebuffer.h"
-#include "CanvasArray.h"
 #include "CanvasFloatArray.h"
 #include "CanvasIntArray.h"
 #include "CanvasObject.h"
@@ -442,6 +443,46 @@ void GraphicsContext3D::generateMipmap(unsigned long target)
     ::glGenerateMipmapEXT(target);
 }
 
+bool GraphicsContext3D::getActiveAttrib(CanvasProgram* program, unsigned long index, ActiveInfo& info)
+{
+    if (!program->object())
+        return false;
+    ensureContext(m_contextObj);
+    GLint maxAttributeSize = 0;
+    ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
+    GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination
+    GLsizei nameLength = 0;
+    GLint size = 0;
+    GLenum type = 0;
+    ::glGetActiveAttrib(static_cast<GLuint>(program->object()), index, maxAttributeSize, &nameLength, &size, &type, name);
+    if (!nameLength)
+        return false;
+    info.name = String(name, nameLength);
+    info.type = type;
+    info.size = size;
+    return true;
+}
+    
+bool GraphicsContext3D::getActiveUniform(CanvasProgram* program, unsigned long index, ActiveInfo& info)
+{
+    if (!program->object())
+        return false;
+    ensureContext(m_contextObj);
+    GLint maxUniformSize = 0;
+    ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
+    GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination
+    GLsizei nameLength = 0;
+    GLint size = 0;
+    GLenum type = 0;
+    ::glGetActiveUniform(static_cast<GLuint>(program->object()), index, maxUniformSize, &nameLength, &size, &type, name);
+    if (!nameLength)
+        return false;
+    info.name = String(name, nameLength);
+    info.type = type;
+    info.size = size;
+    return true;
+}
+
 int GraphicsContext3D::getAttribLocation(CanvasProgram* program, const String& name)
 {
     if (!program)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list