[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
cmarrin at apple.com
cmarrin at apple.com
Wed Dec 22 12:10:37 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 404c4eeafd5fcdd8d0c572a2b4911a7f2a49089b
Author: cmarrin at apple.com <cmarrin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Aug 16 19:18:45 2010 +0000
2010-08-16 Paul Sawaya <psawaya at apple.com>
Reviewed by Chris Marrin.
Added shader validation via ANGLE
https://bugs.webkit.org/show_bug.cgi?id=42405
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65446 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index 755109e..c3d2c84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-16 Paul Sawaya <psawaya at apple.com>
+
+ Reviewed by Chris Marrin.
+
+ Added shader validation via ANGLE
+ https://bugs.webkit.org/show_bug.cgi?id=42405
+
+ Added ANGLE build to Makefile
+
+ * Makefile:
+
2010-08-16 Kevin Ollivier <kevino at theolliviers.com>
[wx] Build fix, do not build WebCore as a convenience library as this leads to
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index feae80d..d556c4b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-16 Chris Marrin <cmarrin at apple.com>
+
+ Reviewed by Chris Marrin.
+
+ Added shader validation via ANGLE
+ https://bugs.webkit.org/show_bug.cgi?id=42405
+
+ Updated tests to pass with shader validation
+
+ * fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html:
+ * fast/canvas/webgl/gl-bind-attrib-location-test.html:
+ * fast/canvas/webgl/read-pixels-pack-alignment.html:
+ * fast/canvas/webgl/resources/fragmentShader.frag:
+ * fast/canvas/webgl/texImage2DImageDataTest.html:
+ * fast/canvas/webgl/texture-active-bind.html:
+ * fast/canvas/webgl/texture-complete.html:
+ * fast/canvas/webgl/texture-transparent-pixels-initialized.html:
+
2010-08-16 Mihai Parparita <mihaip at chromium.org>
Reviewed by Nate Chapin.
diff --git a/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html b/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
index 0c7d040..3b7c354 100644
--- a/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
+++ b/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
@@ -16,7 +16,7 @@ void main()
</script>
<script id="fshader" type="x-shader/x-fragment">
-varying vec4 color;
+varying highp vec4 color;
void main()
{
diff --git a/LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-test.html b/LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-test.html
index ee8be57..d76a81f 100644
--- a/LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-test.html
+++ b/LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-test.html
@@ -23,7 +23,7 @@ void main()
}
</script>
<script id="fshader" type="text/something-not-javascript">
-varying vec4 color;
+varying highp vec4 color;
void main()
{
gl_FragColor = color;
diff --git a/LayoutTests/fast/canvas/webgl/read-pixels-pack-alignment.html b/LayoutTests/fast/canvas/webgl/read-pixels-pack-alignment.html
index c8dc910..f8bd2fa 100644
--- a/LayoutTests/fast/canvas/webgl/read-pixels-pack-alignment.html
+++ b/LayoutTests/fast/canvas/webgl/read-pixels-pack-alignment.html
@@ -16,7 +16,7 @@ void main()
</script>
<script id="fshader" type="x-shader/x-fragment">
-varying vec4 color;
+varying highp vec4 color;
void main()
{
diff --git a/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag b/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
index 53a556b..c62e381 100644
--- a/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
+++ b/LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
@@ -1,4 +1,4 @@
-varying vec3 v_normal;
+varying highp vec3 v_normal;
void main()
{
diff --git a/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html b/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
index e8e9f08..e9173c7 100644
--- a/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
+++ b/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
@@ -16,7 +16,7 @@
<script id="fshader" type="x-shader/x-fragment">
uniform sampler2D tex;
- varying vec2 texCoord;
+ varying highp vec2 texCoord;
void main()
{
gl_FragColor = texture2D(tex, texCoord);
diff --git a/LayoutTests/fast/canvas/webgl/texture-active-bind.html b/LayoutTests/fast/canvas/webgl/texture-active-bind.html
index 83224c8..8391b3c 100644
--- a/LayoutTests/fast/canvas/webgl/texture-active-bind.html
+++ b/LayoutTests/fast/canvas/webgl/texture-active-bind.html
@@ -26,7 +26,7 @@ void main()
<script id="fshader" type="x-shader/x-fragment">
uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
void main()
{
gl_FragColor = texture2D(tex, texCoord);
diff --git a/LayoutTests/fast/canvas/webgl/texture-complete.html b/LayoutTests/fast/canvas/webgl/texture-complete.html
index 9c6ab36..c3b15f7 100644
--- a/LayoutTests/fast/canvas/webgl/texture-complete.html
+++ b/LayoutTests/fast/canvas/webgl/texture-complete.html
@@ -15,7 +15,7 @@
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
attribute vec2 texCoord0;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
void main()
{
gl_Position = vPosition;
@@ -25,7 +25,7 @@ void main()
<script id="fshader" type="x-shader/x-fragment">
uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
void main()
{
gl_FragColor = texture2D(tex, texCoord);
diff --git a/LayoutTests/fast/canvas/webgl/texture-transparent-pixels-initialized.html b/LayoutTests/fast/canvas/webgl/texture-transparent-pixels-initialized.html
index 26eb02a..9c9d117 100644
--- a/LayoutTests/fast/canvas/webgl/texture-transparent-pixels-initialized.html
+++ b/LayoutTests/fast/canvas/webgl/texture-transparent-pixels-initialized.html
@@ -18,7 +18,7 @@ void main()
<script id="fshader" type="x-shader/x-fragment">
uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
void main()
{
diff --git a/Makefile b/Makefile
index 1e50d1d..cdee9da 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools
+MODULES = JavaScriptCore JavaScriptGlue ANGLE WebCore WebKit WebKit2 WebKitTools
all:
@for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 316c954..163f6c5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-08-16 Paul Sawaya <psawaya at apple.com>
+
+ Reviewed by Chris Marrin.
+
+ Added shader validation via ANGLE
+ https://bugs.webkit.org/show_bug.cgi?id=42405
+
+ Added validation to WebGL via ANGLE
+
+ * Configurations/WebCore.xcconfig:
+ * WebCore.gypi:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/ANGLEWebKitBridge.cpp: Added.
+ (WebCore::ANGLEWebKitBridge::ANGLEWebKitBridge):
+ (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge):
+ (WebCore::ANGLEWebKitBridge::validateShaderSource):
+ * platform/graphics/ANGLEWebKitBridge.h: Added.
+ (WebCore::):
+ (WebCore::ANGLEWebKitBridge::setResources):
+ * platform/graphics/GraphicsContext3D.h:
+ (WebCore::GraphicsContext3D::):
+ * platform/graphics/mac/GraphicsContext3DMac.mm:
+ (WebCore::GraphicsContext3D::GraphicsContext3D):
+ (WebCore::GraphicsContext3D::compileShader):
+ (WebCore::GraphicsContext3D::shaderSource):
+ (WebCore::GraphicsContext3D::getShaderiv):
+ (WebCore::GraphicsContext3D::getShaderInfoLog):
+ (WebCore::GraphicsContext3D::getShaderSource):
+
2010-08-16 Kevin Ollivier <kevino at theolliviers.com>
[wx] Build fix, do not build WebCore as a convenience library as this leads to
diff --git a/WebCore/Configurations/WebCore.xcconfig b/WebCore/Configurations/WebCore.xcconfig
index 73e3519..83e535c 100644
--- a/WebCore/Configurations/WebCore.xcconfig
+++ b/WebCore/Configurations/WebCore.xcconfig
@@ -43,14 +43,14 @@ FRAMEWORK_SEARCH_PATHS_iphoneos_Production = $(PRODUCTION_FRAMEWORKS_DIR);
FRAMEWORK_SEARCH_PATHS_iphonesimulator = $(FRAMEWORK_SEARCH_PATHS_iphoneos_$(CONFIGURATION));
FRAMEWORK_SEARCH_PATHS_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks $(FRAMEWORK_SEARCH_PATHS);
-HEADER_SEARCH_PATHS = ForwardingHeaders icu /usr/include/libxslt /usr/include/libxml2 $(SQLITE3_HEADER_SEARCH_PATHS) "${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore" $(HEADER_SEARCH_PATHS);
+HEADER_SEARCH_PATHS = ForwardingHeaders icu /usr/include/libxslt /usr/include/libxml2 $(SQLITE3_HEADER_SEARCH_PATHS) "${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore" "${BUILT_PRODUCTS_DIR}/usr/local/include" $(HEADER_SEARCH_PATHS);
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = $(INSTALL_PATH_$(REAL_PLATFORM_NAME));
INSTALL_PATH_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks;
INSTALLHDRS_COPY_PHASE = YES;
INSTALLHDRS_SCRIPT_PHASE = YES;
PRODUCT_NAME = WebCore;
-OTHER_LDFLAGS_BASE = -l$(SQLITE3_LIBRARY) -lobjc;
+OTHER_LDFLAGS_BASE = -l$(SQLITE3_LIBRARY) -lobjc -lANGLE;
OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(REAL_PLATFORM_NAME));
OTHER_LDFLAGS_iphoneos = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework QuartzCore;
OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos);
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index b7d0b31..bd1f1b6 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2485,6 +2485,8 @@
'platform/graphics/wx/PenWx.cpp',
'platform/graphics/wx/SimpleFontDataWx.cpp',
'platform/graphics/wx/TransformationMatrixWx.cpp',
+ 'platform/graphics/ANGLEWebkitBridge.cpp',
+ 'platform/graphics/ANGLEWebkitBridge.h',
'platform/graphics/BitmapImage.cpp',
'platform/graphics/BitmapImage.h',
'platform/graphics/Color.cpp',
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index cc702b8..0e7b4d4 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -901,6 +901,8 @@
46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DA0B0D60170028EE36 /* aliasCursor.png */; };
46F9D5DE0B0D60170028EE36 /* noDropCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DB0B0D60170028EE36 /* noDropCursor.png */; };
46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DC0B0D60170028EE36 /* progressCursor.png */; };
+ 490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
+ 490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
492273A31083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */; };
49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
@@ -6683,6 +6685,8 @@
46F9D5DA0B0D60170028EE36 /* aliasCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = aliasCursor.png; sourceTree = "<group>"; };
46F9D5DB0B0D60170028EE36 /* noDropCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = noDropCursor.png; sourceTree = "<group>"; };
46F9D5DC0B0D60170028EE36 /* progressCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = progressCursor.png; sourceTree = "<group>"; };
+ 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
+ 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferViewCustom.cpp; sourceTree = "<group>"; };
49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
@@ -15675,6 +15679,8 @@
B2A015910AF6CD53006BCE0E /* graphics */ = {
isa = PBXGroup;
children = (
+ 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */,
+ 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */,
B27535290B053814002CE64F /* cg */,
A75E8B7F0E1DE2B0007F2481 /* filters */,
B27535490B053814002CE64F /* mac */,
@@ -20182,6 +20188,7 @@
97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
+ 490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -20241,6 +20248,7 @@
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -22612,6 +22620,7 @@
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */,
+ 490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
new file mode 100644
index 0000000..3757d77
--- /dev/null
+++ b/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 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 COMPUTER, 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 COMPUTER, 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "ANGLEWebKitBridge.h"
+
+namespace WebCore {
+
+
+ANGLEWebKitBridge::ANGLEWebKitBridge() :
+ builtCompilers(false)
+{
+ ShInitialize();
+}
+
+ANGLEWebKitBridge::~ANGLEWebKitBridge()
+{
+ if (builtCompilers) {
+ ShDestruct(m_fragmentCompiler);
+ ShDestruct(m_vertexCompiler);
+ }
+
+ ShFinalize();
+}
+
+bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog)
+{
+ if (!builtCompilers) {
+ m_fragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecWebGL, &m_resources);
+ m_vertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecWebGL, &m_resources);
+
+ builtCompilers = true;
+ }
+
+ ShHandle compiler;
+
+ if (shaderType == SHADER_TYPE_VERTEX)
+ compiler = m_vertexCompiler;
+ else if (shaderType == SHADER_TYPE_FRAGMENT)
+ compiler = m_fragmentCompiler;
+
+ const char* const shaderSourceStrings[] = { shaderSource };
+
+ bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, EShOptNone, EDebugOpIntermediate);
+
+ translatedShaderSource = ShGetObjectCode(compiler);
+ shaderValidationLog = ShGetInfoLog(compiler);
+
+ return validateSuccess;
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/platform/graphics/ANGLEWebKitBridge.h b/WebCore/platform/graphics/ANGLEWebKitBridge.h
new file mode 100644
index 0000000..d01de8f
--- /dev/null
+++ b/WebCore/platform/graphics/ANGLEWebKitBridge.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 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 COMPUTER, 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 COMPUTER, 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 ANGLEWebKitBridge_h
+#define ANGLEWebKitBridge_h
+
+#include "ANGLE/ShaderLang.h"
+#include "PlatformString.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+enum ANGLEShaderType {
+ SHADER_TYPE_VERTEX = EShLangVertex,
+ SHADER_TYPE_FRAGMENT = EShLangFragment
+};
+
+class ANGLEWebKitBridge {
+public:
+
+ ANGLEWebKitBridge();
+ ~ANGLEWebKitBridge();
+
+ void setResources(TBuiltInResource resources) { m_resources = resources; }
+
+ bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog);
+
+private:
+
+ ShHandle m_fragmentCompiler;
+ ShHandle m_vertexCompiler;
+
+ bool builtCompilers;
+
+ TBuiltInResource m_resources;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
index dabd0ae..3c5eb50 100644
--- a/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/WebCore/platform/graphics/GraphicsContext3D.h
@@ -26,9 +26,11 @@
#ifndef GraphicsContext3D_h
#define GraphicsContext3D_h
+#include "ANGLEWebKitBridge.h"
#include "GraphicsLayer.h"
#include "PlatformString.h"
+#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
@@ -811,6 +813,15 @@ public:
int m_currentWidth, m_currentHeight;
+ typedef struct {
+ String source;
+ String log;
+ bool isValid;
+ } ShaderSourceEntry;
+ HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap;
+
+ ANGLEWebKitBridge m_compiler;
+
#if PLATFORM(MAC)
Attributes m_attrs;
Vector<Vector<float> > m_vertexArray;
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
index fd503fc..b798832 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
@@ -31,6 +31,7 @@
#import "BlockExceptions.h"
+#include "ANGLE/ResourceLimits.h"
#include "ArrayBuffer.h"
#include "ArrayBufferView.h"
#include "WebGLObject.h"
@@ -181,6 +182,30 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
}
+ // ANGLE initialization.
+
+ TBuiltInResource ANGLEResources;
+
+ ANGLEResources.maxVertexAttribs = 0;
+ getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.maxVertexAttribs);
+ ANGLEResources.maxVertexUniformVectors = 0;
+ getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.maxVertexUniformVectors);
+ ANGLEResources.maxVaryingVectors = 0;
+ getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.maxVaryingVectors);
+ ANGLEResources.maxVertexTextureImageUnits = 0;
+ getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxVertexTextureImageUnits);
+ ANGLEResources.maxCombinedTextureImageUnits = 0;
+ getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxCombinedTextureImageUnits);
+ ANGLEResources.maxTextureImageUnits = 0;
+ getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxTextureImageUnits);
+ ANGLEResources.maxFragmentUniformVectors = 0;
+ getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.maxFragmentUniformVectors);
+
+ // Always set to 1 for OpenGL ES.
+ ANGLEResources.maxDrawBuffers = 1;
+
+ m_compiler.setResources(ANGLEResources);
+
::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
::glClearColor(0, 0, 0, 0);
}
@@ -617,7 +642,52 @@ void GraphicsContext3D::compileShader(Platform3DObject shader)
{
ASSERT(shader);
ensureContext(m_contextObj);
+
+ int GLshaderType;
+ ANGLEShaderType shaderType;
+
+ glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
+
+ if (GLshaderType == VERTEX_SHADER)
+ shaderType = SHADER_TYPE_VERTEX;
+ else if (GLshaderType == FRAGMENT_SHADER)
+ shaderType = SHADER_TYPE_FRAGMENT;
+ else
+ return; // Invalid shader type.
+
+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+ if (result == m_shaderSourceMap.end())
+ return;
+
+ ShaderSourceEntry& entry = result->second;
+
+ String translatedShaderSource;
+ String shaderInfoLog;
+
+ bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
+
+ entry.log = shaderInfoLog;
+ entry.isValid = isValid;
+
+ if (!isValid)
+ return; // Shader didn't validate, don't move forward with compiling translated source
+
+ int translatedShaderLength = translatedShaderSource.length();
+
+ const CString& translatedShaderCString = translatedShaderSource.utf8();
+ const char* translatedShaderPtr = translatedShaderCString.data();
+
+ ::glShaderSource((GLuint) shader, 1, &translatedShaderPtr, &translatedShaderLength);
+
::glCompileShader((GLuint) shader);
+
+ int GLCompileSuccess;
+
+ ::glGetShaderiv((GLuint) shader, COMPILE_STATUS, &GLCompileSuccess);
+
+ // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
+ ASSERT(GLCompileSuccess == GL_TRUE);
}
void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
@@ -998,11 +1068,12 @@ void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri
ASSERT(shader);
ensureContext(m_contextObj);
- const CString& cs = string.utf8();
- const char* s = cs.data();
-
- int length = string.length();
- ::glShaderSource((GLuint) shader, 1, &s, &length);
+
+ ShaderSourceEntry entry;
+
+ entry.source = string;
+
+ m_shaderSourceMap.set(shader, entry);
}
void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
@@ -1346,26 +1417,77 @@ void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname
ASSERT(shader);
ensureContext(m_contextObj);
- ::glGetShaderiv((GLuint) shader, pname, value);
+
+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+ switch (pname) {
+ case DELETE_STATUS:
+ case SHADER_TYPE:
+ // Let OpenGL handle these.
+
+ ::glGetShaderiv((GLuint) shader, pname, value);
+ break;
+
+ case COMPILE_STATUS:
+ if (result == m_shaderSourceMap.end()) {
+ (*value) = static_cast<int>(false);
+ return;
+ }
+
+ (*value) = static_cast<int>(result->second.isValid);
+ break;
+
+ case INFO_LOG_LENGTH:
+ if (result == m_shaderSourceMap.end()) {
+ (*value) = 0;
+ return;
+ }
+
+ (*value) = getShaderInfoLog(shader).length();
+ break;
+
+ case SHADER_SOURCE_LENGTH:
+ (*value) = getShaderSource(shader).length();
+ break;
+
+ default:
+ synthesizeGLError(INVALID_ENUM);
+ }
}
String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
{
ASSERT(shader);
-
+
ensureContext(m_contextObj);
GLint length;
::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
-
- GLsizei size;
- GLchar* info = (GLchar*) fastMalloc(length);
- if (!info)
- return "";
-
- ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
- String s(info);
- fastFree(info);
- return s;
+
+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+ if (result == m_shaderSourceMap.end())
+ return "";
+
+ ShaderSourceEntry entry = result->second;
+
+ if (entry.isValid) {
+ GLint length;
+ ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
+
+ GLsizei size;
+ GLchar* info = (GLchar*) fastMalloc(length);
+ if (!info)
+ return "";
+
+ ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
+
+ String s(info);
+ fastFree(info);
+ return s;
+ }
+ else {
+ return entry.log;
+ }
}
String GraphicsContext3D::getShaderSource(Platform3DObject shader)
@@ -1373,18 +1495,13 @@ String GraphicsContext3D::getShaderSource(Platform3DObject shader)
ASSERT(shader);
ensureContext(m_contextObj);
- GLint length;
- ::glGetShaderiv((GLuint) shader, GL_SHADER_SOURCE_LENGTH, &length);
-
- GLsizei size;
- GLchar* info = (GLchar*) fastMalloc(length);
- if (!info)
+
+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+ if (result == m_shaderSourceMap.end())
return "";
-
- ::glGetShaderSource((GLuint) shader, length, &size, info);
- String s(info);
- fastFree(info);
- return s;
+
+ return result->second.source;
}
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index beca330..8b85ea3 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-16 Paul Sawaya <psawaya at apple.com>
+
+ Reviewed by Chris Marrin.
+
+ Added shader validation via ANGLE
+ https://bugs.webkit.org/show_bug.cgi?id=42405
+
+ Added ANGLE to webkit build
+
+ * Scripts/build-webkit:
+
2010-08-16 Kevin Ollivier <kevino at theolliviers.com>
[wx] Build fix, do not build WebCore as a convenience library as this leads to
diff --git a/WebKitTools/Scripts/build-webkit b/WebKitTools/Scripts/build-webkit
index b12fc42..036011e 100755
--- a/WebKitTools/Scripts/build-webkit
+++ b/WebKitTools/Scripts/build-webkit
@@ -341,6 +341,9 @@ if (isGtk()) {
# Apple builds JavaScriptGlue, and only on the Mac.
splice @projects, 1, 0, "JavaScriptGlue";
+ # ANGLE is only supported in SnowLeopard and later at present, and must come before WebCore
+ splice @projects, 0, 0, "ANGLE" if osXVersion()->{"minor"} >= 6;
+
# WebKit2 is only supported in SnowLeopard and later at present.
push @projects, ("WebKit2", "WebKitTools/MiniBrowser") if osXVersion()->{"minor"} >= 6;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list