Commit 2dd86016 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2011-01-20 Ben Vanik <ben.vanik@gmail.com>

        Reviewed by Kenneth Russell.

        Implementation of the OES_standard_derivatives WebGL extension.
        https://bugs.webkit.org/show_bug.cgi?id=51678

        Changes are modeled off of the existing OESTextureFloat extension. New files,
        extension retrieval, etc all match the existing code.

        Changed ANGLEWebKitBridge to allow for multiple sets of the ANGLE shader compiler
        options. This supports the enabling of the standard derivatives flag when the
        extension is enabled. Refactored the cleanup code to make the destruction of the
        compilers (if they had been created) cleaner.

        Tested with the WebGL conformance test:
        https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/oes-standard-derivatives.html
        Passes on WebKit/OSX, Chromium/OSX, and Chromium/Windows.

        * CMakeLists.txt:
        * DerivedSources.make:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pri:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSWebGLRenderingContextCustom.cpp:
        (WebCore::toJS):
        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
        (WebCore::toV8Object):
        * html/canvas/OESStandardDerivatives.cpp: Added.
        (WebCore::OESStandardDerivatives::OESStandardDerivatives):
        (WebCore::OESStandardDerivatives::~OESStandardDerivatives):
        (WebCore::OESStandardDerivatives::getName):
        (WebCore::OESStandardDerivatives::create):
        * html/canvas/OESStandardDerivatives.h: Added.
        * html/canvas/OESStandardDerivatives.idl: Added.
        * html/canvas/WebGLExtension.h:
        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::getExtension): Enable and return the new extension.
        (WebCore::WebGLRenderingContext::getParameter): Support extension enum when enabled.
        (WebCore::WebGLRenderingContext::getSupportedExtensions):
        (WebCore::WebGLRenderingContext::hint): Validate extension enum when enabled.
        (WebCore::WebGLRenderingContext::getNumberOfExtensions):
        (WebCore::WebGLRenderingContext::getExtensionNumber):
        * html/canvas/WebGLRenderingContext.h:
        * platform/graphics/ANGLEWebKitBridge.cpp:
        (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge): Cleaned up compiler cleanup.
        (WebCore::ANGLEWebKitBridge::cleanupCompilers): Destruct compilers.
        (WebCore::ANGLEWebKitBridge::setResources): Cleanup existing compilers when changing
        ANGLE settings.
        (WebCore::ANGLEWebKitBridge::validateShaderSource): Cleaned up compiler cleanup on error.
        * platform/graphics/ANGLEWebKitBridge.h:
        (WebCore::ANGLEWebKitBridge::getResources):
        * platform/graphics/Extensions3D.h: Added enumeration for the extension.
        * platform/graphics/GraphicsContext3D.h: lumbing for GraphicsContext3D.
        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
        (WebCore::Extensions3DOpenGL::Extensions3DOpenGL): Plumbed through a pointer to the
        GraphicsContext3D to handle resetting the shader compilers.
        (WebCore::Extensions3DOpenGL::supports): Desktop GL always supports this extension,
        so always return true.
        (WebCore::Extensions3DOpenGL::ensureEnabled): Reset shader compilers as required.
        * platform/graphics/opengl/Extensions3DOpenGL.h: Plumbing for GraphicsContext3D.
        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
        (WebCore::GraphicsContext3D::getExtensions): Plumbing for GraphicsContext3D to
        Extensions3DOpenGL.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c6606872
......@@ -292,6 +292,7 @@ SET(WebCore_IDL_FILES
html/canvas/Int16Array.idl
html/canvas/Int32Array.idl
html/canvas/Int8Array.idl
html/canvas/OESStandardDerivatives.idl
html/canvas/OESTextureFloat.idl
html/canvas/Uint16Array.idl
html/canvas/Uint32Array.idl
......
2011-01-20 Ben Vanik <ben.vanik@gmail.com>
Reviewed by Kenneth Russell.
Implementation of the OES_standard_derivatives WebGL extension.
https://bugs.webkit.org/show_bug.cgi?id=51678
Changes are modeled off of the existing OESTextureFloat extension. New files,
extension retrieval, etc all match the existing code.
Changed ANGLEWebKitBridge to allow for multiple sets of the ANGLE shader compiler
options. This supports the enabling of the standard derivatives flag when the
extension is enabled. Refactored the cleanup code to make the destruction of the
compilers (if they had been created) cleaner.
Tested with the WebGL conformance test:
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/oes-standard-derivatives.html
Passes on WebKit/OSX, Chromium/OSX, and Chromium/Windows.
* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pri:
* WebCore.pro:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::toJS):
* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
(WebCore::toV8Object):
* html/canvas/OESStandardDerivatives.cpp: Added.
(WebCore::OESStandardDerivatives::OESStandardDerivatives):
(WebCore::OESStandardDerivatives::~OESStandardDerivatives):
(WebCore::OESStandardDerivatives::getName):
(WebCore::OESStandardDerivatives::create):
* html/canvas/OESStandardDerivatives.h: Added.
* html/canvas/OESStandardDerivatives.idl: Added.
* html/canvas/WebGLExtension.h:
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getExtension): Enable and return the new extension.
(WebCore::WebGLRenderingContext::getParameter): Support extension enum when enabled.
(WebCore::WebGLRenderingContext::getSupportedExtensions):
(WebCore::WebGLRenderingContext::hint): Validate extension enum when enabled.
(WebCore::WebGLRenderingContext::getNumberOfExtensions):
(WebCore::WebGLRenderingContext::getExtensionNumber):
* html/canvas/WebGLRenderingContext.h:
* platform/graphics/ANGLEWebKitBridge.cpp:
(WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge): Cleaned up compiler cleanup.
(WebCore::ANGLEWebKitBridge::cleanupCompilers): Destruct compilers.
(WebCore::ANGLEWebKitBridge::setResources): Cleanup existing compilers when changing
ANGLE settings.
(WebCore::ANGLEWebKitBridge::validateShaderSource): Cleaned up compiler cleanup on error.
* platform/graphics/ANGLEWebKitBridge.h:
(WebCore::ANGLEWebKitBridge::getResources):
* platform/graphics/Extensions3D.h: Added enumeration for the extension.
* platform/graphics/GraphicsContext3D.h: lumbing for GraphicsContext3D.
* platform/graphics/opengl/Extensions3DOpenGL.cpp:
(WebCore::Extensions3DOpenGL::Extensions3DOpenGL): Plumbed through a pointer to the
GraphicsContext3D to handle resetting the shader compilers.
(WebCore::Extensions3DOpenGL::supports): Desktop GL always supports this extension,
so always return true.
(WebCore::Extensions3DOpenGL::ensureEnabled): Reset shader compilers as required.
* platform/graphics/opengl/Extensions3DOpenGL.h: Plumbing for GraphicsContext3D.
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::getExtensions): Plumbing for GraphicsContext3D to
Extensions3DOpenGL.
2011-01-20 Xiaomei Ji <xji@chromium.org>
 
Reviewed by Dan Bernstein.
......@@ -312,6 +312,7 @@ DOM_CLASSES = \
Notation \
Notification \
NotificationCenter \
OESStandardDerivatives \
OESTextureFloat \
OverflowEvent \
PageTransitionEvent \
......
......@@ -482,6 +482,8 @@ webcore_built_sources += \
DerivedSources/WebCore/JSNotificationCenter.h \
DerivedSources/WebCore/JSNotification.cpp \
DerivedSources/WebCore/JSNotification.h \
DerivedSources/WebCore/JSOESStandardDerivatives.cpp \
DerivedSources/WebCore/JSOESStandardDerivatives.h \
DerivedSources/WebCore/JSOESTextureFloat.cpp \
DerivedSources/WebCore/JSOESTextureFloat.h \
DerivedSources/WebCore/JSOverflowEvent.cpp \
......@@ -1582,6 +1584,8 @@ webcore_sources += \
Source/WebCore/html/canvas/Int8Array.cpp \
Source/WebCore/html/canvas/Int8Array.h \
Source/WebCore/html/canvas/IntegralTypedArrayBase.h \
Source/WebCore/html/canvas/OESStandardDerivatives.cpp \
Source/WebCore/html/canvas/OESStandardDerivatives.h \
Source/WebCore/html/canvas/OESTextureFloat.cpp \
Source/WebCore/html/canvas/OESTextureFloat.h \
Source/WebCore/html/canvas/TypedArrayBase.h \
......
......@@ -216,6 +216,7 @@
'html/canvas/Int16Array.idl',
'html/canvas/Int32Array.idl',
'html/canvas/Int8Array.idl',
'html/canvas/OESStandardDerivatives.idl',
'html/canvas/OESTextureFloat.idl',
'html/canvas/Uint16Array.idl',
'html/canvas/Uint32Array.idl',
......@@ -1920,6 +1921,8 @@
'html/canvas/Int8Array.cpp',
'html/canvas/Int8Array.h',
'html/canvas/IntegralTypedArrayBase.h',
'html/canvas/OESStandardDerivatives.cpp',
'html/canvas/OESStandardDerivatives.h',
'html/canvas/OESTextureFloat.cpp',
'html/canvas/OESTextureFloat.h',
'html/canvas/TypedArrayBase.h',
......
......@@ -193,6 +193,7 @@ IDL_BINDINGS += \
html/canvas/CanvasPattern.idl \
html/canvas/CanvasRenderingContext.idl \
html/canvas/CanvasRenderingContext2D.idl \
html/canvas/OESStandardDerivatives.idl \
html/canvas/OESTextureFloat.idl \
html/canvas/WebGLActiveInfo.idl \
html/canvas/WebGLBuffer.idl \
......
......@@ -3810,6 +3810,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) {
html/canvas/WebGLRenderbuffer.h \
html/canvas/WebGLRenderingContext.h \
html/canvas/WebGLShader.h \
html/canvas/OESStandardDerivatives.h \
html/canvas/OESTextureFloat.h \
html/canvas/WebGLTexture.h \
html/canvas/WebGLUniformLocation.h \
......@@ -3834,6 +3835,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) {
html/canvas/WebGLRenderbuffer.cpp \
html/canvas/WebGLRenderingContext.cpp \
html/canvas/WebGLShader.cpp \
html/canvas/OESStandardDerivatives.cpp \
html/canvas/OESTextureFloat.cpp \
html/canvas/WebGLTexture.cpp \
html/canvas/WebGLUniformLocation.cpp \
......
......@@ -2760,6 +2760,11 @@
8F67561B1288B17B0047ACA3 /* EventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F6756191288B17B0047ACA3 /* EventQueue.h */; };
8F67561C1288B17B0047ACA3 /* EventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F67561A1288B17B0047ACA3 /* EventQueue.cpp */; };
8FAC774D119872CB0015AE94 /* JSMainThreadExecState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */; };
9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001773D12E0347800648462 /* OESStandardDerivatives.cpp */; };
9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001773E12E0347800648462 /* OESStandardDerivatives.h */; };
9001774212E0347800648462 /* OESStandardDerivatives.idl in Resources */ = {isa = PBXBuildFile; fileRef = 9001773F12E0347800648462 /* OESStandardDerivatives.idl */; };
9001788012E0370700648462 /* JSOESStandardDerivatives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */; };
9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */ = {isa = PBXBuildFile; fileRef = 9001787F12E0370700648462 /* JSOESStandardDerivatives.h */; };
9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */; };
9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
9305B24D098F1B6B00C28855 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9305B24C098F1B6B00C28855 /* Timer.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -9147,6 +9152,11 @@
8F67561A1288B17B0047ACA3 /* EventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventQueue.cpp; sourceTree = "<group>"; };
8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMainThreadExecState.h; sourceTree = "<group>"; };
8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMainThreadExecState.cpp; sourceTree = "<group>"; };
9001773D12E0347800648462 /* OESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OESStandardDerivatives.cpp; path = canvas/OESStandardDerivatives.cpp; sourceTree = "<group>"; };
9001773E12E0347800648462 /* OESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESStandardDerivatives.h; path = canvas/OESStandardDerivatives.h; sourceTree = "<group>"; };
9001773F12E0347800648462 /* OESStandardDerivatives.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OESStandardDerivatives.idl; path = canvas/OESStandardDerivatives.idl; sourceTree = "<group>"; };
9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESStandardDerivatives.cpp; sourceTree = "<group>"; };
9001787F12E0370700648462 /* JSOESStandardDerivatives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESStandardDerivatives.h; sourceTree = "<group>"; };
9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroup.cpp; sourceTree = "<group>"; };
9302B0BE0D79F82C00C7EE83 /* PageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroup.h; sourceTree = "<group>"; };
9305B24C098F1B6B00C28855 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = "<group>"; };
......@@ -13290,6 +13300,9 @@
49C7B9AC1042D32E0009D447 /* Int8Array.h */,
49C7B9AD1042D32E0009D447 /* Int8Array.idl */,
6E96BB1A11986EE1007D94CD /* IntegralTypedArrayBase.h */,
9001773D12E0347800648462 /* OESStandardDerivatives.cpp */,
9001773E12E0347800648462 /* OESStandardDerivatives.h */,
9001773F12E0347800648462 /* OESStandardDerivatives.idl */,
6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */,
6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */,
6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */,
......@@ -16192,6 +16205,8 @@
49C7B9831042D2D30009D447 /* JSInt8Array.h */,
E44614100CD6826900FADA75 /* JSMediaError.cpp */,
E44614110CD6826900FADA75 /* JSMediaError.h */,
9001787E12E0370700648462 /* JSOESStandardDerivatives.cpp */,
9001787F12E0370700648462 /* JSOESStandardDerivatives.h */,
6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */,
6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */,
BCEF45F30E687B5C001C1287 /* JSTextMetrics.cpp */,
......@@ -22394,6 +22409,8 @@
A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */,
A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */,
A6148A7912E41E3B0044A784 /* JSHTMLKeygenElement.h in Headers */,
9001774112E0347800648462 /* OESStandardDerivatives.h in Headers */,
9001788112E0370700648462 /* JSOESStandardDerivatives.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -22516,6 +22533,7 @@
85136CA80AED665900F90A3D /* westResizeCursor.png in Resources */,
1AB1AE7A0C051FDE00139F4F /* zoomInCursor.png in Resources */,
1AB1AE7B0C051FDE00139F4F /* zoomOutCursor.png in Resources */,
9001774212E0347800648462 /* OESStandardDerivatives.idl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -25086,6 +25104,8 @@
7AA365EE12E7265400DCA242 /* InspectorRuntimeAgent.cpp in Sources */,
A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */,
A6148A7812E41E3B0044A784 /* JSHTMLKeygenElement.cpp in Sources */,
9001774012E0347800648462 /* OESStandardDerivatives.cpp in Sources */,
9001788012E0370700648462 /* JSOESStandardDerivatives.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -37,6 +37,7 @@
#include "JSHTMLCanvasElement.h"
#include "JSHTMLImageElement.h"
#include "JSImageData.h"
#include "JSOESStandardDerivatives.h"
#include "JSOESTextureFloat.h"
#include "JSWebGLBuffer.h"
#include "JSFloat32Array.h"
......@@ -50,6 +51,7 @@
#include "JSUint8Array.h"
#include "JSWebKitCSSMatrix.h"
#include "NotImplemented.h"
#include "OESStandardDerivatives.h"
#include "OESTextureFloat.h"
#include "WebGLBuffer.h"
#include "Float32Array.h"
......@@ -173,6 +175,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten
switch (extension->getName()) {
case WebGLExtension::WebKitLoseContextName:
return toJS(exec, globalObject, static_cast<WebKitLoseContext*>(extension));
case WebGLExtension::OESStandardDerivativesName:
return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension));
case WebGLExtension::OESTextureFloatName:
return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension));
}
......
......@@ -48,6 +48,7 @@
#include "V8Int16Array.h"
#include "V8Int32Array.h"
#include "V8Int8Array.h"
#include "V8OESStandardDerivatives.h"
#include "V8OESTextureFloat.h"
#include "V8Proxy.h"
#include "V8Uint16Array.h"
......@@ -160,6 +161,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
case WebGLExtension::WebKitLoseContextName:
extensionObject = toV8(static_cast<WebKitLoseContext*>(extension));
break;
case WebGLExtension::OESStandardDerivativesName:
extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension));
break;
case WebGLExtension::OESTextureFloatName:
extensionObject = toV8(static_cast<OESTextureFloat*>(extension));
break;
......
/*
* Copyright (C) 2011 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:
*
* 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 AND ITS 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 APPLE OR ITS 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 "OESStandardDerivatives.h"
namespace WebCore {
OESStandardDerivatives::OESStandardDerivatives() : WebGLExtension()
{
}
OESStandardDerivatives::~OESStandardDerivatives()
{
}
WebGLExtension::ExtensionName OESStandardDerivatives::getName() const
{
return OESStandardDerivativesName;
}
PassRefPtr<OESStandardDerivatives> OESStandardDerivatives::create()
{
return adoptRef(new OESStandardDerivatives);
}
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)
/*
* Copyright (C) 2011 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:
*
* 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 AND ITS 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 APPLE OR ITS 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 OESStandardDerivatives_h
#define OESStandardDerivatives_h
#include "WebGLExtension.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class OESStandardDerivatives : public WebGLExtension {
public:
static PassRefPtr<OESStandardDerivatives> create();
virtual ~OESStandardDerivatives();
virtual ExtensionName getName() const;
private:
OESStandardDerivatives();
};
} // namespace WebCore
#endif // OESStandardDerivatives_h
/*
* Copyright (C) 2011 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:
*
* 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 AND ITS 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 APPLE OR ITS 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, OmitConstructor, DontCheckEnums] OESStandardDerivatives {
const unsigned int FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B;
};
}
......@@ -36,6 +36,7 @@ public:
enum ExtensionName {
WebKitLoseContextName,
OESTextureFloatName,
OESStandardDerivativesName,
};
virtual ~WebGLExtension();
......
......@@ -44,6 +44,7 @@
#include "ImageData.h"
#include "IntSize.h"
#include "NotImplemented.h"
#include "OESStandardDerivatives.h"
#include "OESTextureFloat.h"
#include "RenderBox.h"
#include "RenderLayer.h"
......@@ -1757,6 +1758,14 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
if (isContextLost())
return 0;
if (equalIgnoringCase(name, "OES_standard_derivatives")
&& m_context->getExtensions()->supports("GL_OES_standard_derivatives")) {
if (!m_oesStandardDerivatives) {
m_context->getExtensions()->ensureEnabled("GL_OES_standard_derivatives");
m_oesStandardDerivatives = OESStandardDerivatives::create();
}
return m_oesStandardDerivatives.get();
}
if (equalIgnoringCase(name, "OES_texture_float")
&& m_context->getExtensions()->supports("GL_OES_texture_float")) {
if (!m_oesTextureFloat) {
......@@ -1764,7 +1773,8 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
m_oesTextureFloat = OESTextureFloat::create();
}
return m_oesTextureFloat.get();
} else if (equalIgnoringCase(name, "WEBKIT_lose_context")) {
}
if (equalIgnoringCase(name, "WEBKIT_lose_context")) {
if (!m_webkitLoseContext)
m_webkitLoseContext = WebKitLoseContext::create(this);
return m_webkitLoseContext.get();
......@@ -2006,6 +2016,11 @@ WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&
return WebGLGetInfo("WebGL 1.0 (" + m_context->getString(GraphicsContext3D::VERSION) + ")");
case GraphicsContext3D::VIEWPORT:
return getWebGLIntArrayParameter(pname);
case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
if (m_oesStandardDerivatives)
return getUnsignedLongParameter(Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return WebGLGetInfo();
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return WebGLGetInfo();
......@@ -2173,6 +2188,8 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions()
Vector<String> result;
if (m_context->getExtensions()->supports("GL_OES_texture_float"))
result.append("OES_texture_float");
if (m_context->getExtensions()->supports("GL_OES_standard_derivatives"))
result.append("OES_standard_derivatives");
result.append("WEBKIT_lose_context");
return result;
}
......@@ -2417,7 +2434,17 @@ void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode)
{
if (isContextLost())
return;
if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) {
bool isValid = false;
switch (target) {
case GraphicsContext3D::GENERATE_MIPMAP_HINT:
isValid = true;
break;
case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
if (m_oesStandardDerivatives)
isValid = true;
break;
}
if (!isValid) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return;
}
......@@ -4536,11 +4563,16 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
int WebGLRenderingContext::getNumberOfExtensions()
{
return (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0);
return (m_oesStandardDerivatives ? 1 : 0) + (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0);
}
WebGLExtension* WebGLRenderingContext::getExtensionNumber(int i)
{
if (m_oesStandardDerivatives) {
if (!i)
return m_oesStandardDerivatives.get();
--i;
}
if (m_webkitLoseContext) {
if (!i)
return m_webkitLoseContext.get();
......
......@@ -57,6 +57,7 @@ class HTMLVideoElement;
class ImageBuffer;
class ImageData;
class IntSize;
class OESStandardDerivatives;
class OESTextureFloat;
class WebGLRenderingContext : public CanvasRenderingContext {
......@@ -452,6 +453,7 @@ public:
// Enabled extension objects.
RefPtr<OESTextureFloat> m_oesTextureFloat;
RefPtr<OESStandardDerivatives> m_oesStandardDerivatives;
RefPtr<WebKitLoseContext> m_webkitLoseContext;
// Helpers for getParameter and others
......
......@@ -42,6 +42,11 @@ ANGLEWebKitBridge::ANGLEWebKitBridge() :
}
ANGLEWebKitBridge::~ANGLEWebKitBridge()
{
cleanupCompilers();
}
void ANGLEWebKitBridge::cleanupCompilers()
{
if (m_fragmentCompiler)
ShDestruct(m_fragmentCompiler);
......@@ -49,6 +54,16 @@ ANGLEWebKitBridge::~ANGLEWebKitBridge()
if (m_vertexCompiler)
ShDestruct(m_vertexCompiler);
m_vertexCompiler = 0;
builtCompilers = false;
}
void ANGLEWebKitBridge::setResources(ShBuiltInResources resources)
{
// Resources are (possibly) changing - cleanup compilers if we had them already
cleanupCompilers();
m_resources = resources;
}
bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog)
......@@ -57,12 +72,7 @@ bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShad
m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, &m_resources);
m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, &m_resources);
if (!m_fragmentCompiler || !m_vertexCompiler) {
if (m_fragmentCompiler)
ShDestruct(m_fragmentCompiler);
m_fragmentCompiler = 0;
if (m_vertexCompiler)
ShDestruct(m_vertexCompiler);
m_vertexCompiler = 0;
cleanupCompilers();
return false;
}
......
......@@ -44,12 +44,15 @@ public:
ANGLEWebKitBridge();
~ANGLEWebKitBridge();
void setResources(ShBuiltInResources resources) { m_resources = resources; }
ShBuiltInResources getResources() { return m_resources; }
void setResources(ShBuiltInResources);
bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog);
private:
void cleanupCompilers();
bool builtCompilers;
ShHandle m_fragmentCompiler;
......
......@@ -51,6 +51,7 @@ public:
// GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
// GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
// GL_OES_texture_float
// GL_OES_standard_derivatives
// Takes full name of extension; for example,
// "GL_EXT_texture_format_BGRA8888".
......@@ -82,7 +83,10 @@ public:
// GL_ANGLE_framebuffer_multisample names
RENDERBUFFER_SAMPLES = 0x8CAB,
FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
MAX_SAMPLES = 0x8D57
MAX_SAMPLES = 0x8D57,
// GL_OES_standard_derivatives names
FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
};
// GL_ARB_robustness
......
......@@ -883,6 +883,7 @@ public:
} ShaderSourceEntry;
HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap;
friend class Extensions3DOpenGL;
ANGLEWebKitBridge m_compiler;
OwnPtr<Extensions3DOpenGL> m_extensions;
......