2011-04-04 Martin Robinson <mrobinson@igalia.com>
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 22:07:05 +0000 (22:07 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 22:07:05 +0000 (22:07 +0000)
        Reviewed by Gustavo Noronha Silva.

        [GTK] WebGL support
        https://bugs.webkit.org/show_bug.cgi?id=31517

        * configure.ac: Update configure.ac to ensure that GL/GLX headers exist.
2011-04-04  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] WebGL support
        https://bugs.webkit.org/show_bug.cgi?id=31517

        Add WebGL support for the GTK+ bits of WebCore.

        No new tests. This will be covered by the existing WebGL tests once
        the bots are capable of running WebGL tests.

        * GNUmakefile.am: Added new files required for WebGL support.
        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::getContext): Extend #ifdef to cover GTK+ as well, which does not
        yet support accelerated compositing.
        * platform/graphics/ANGLEWebKitBridge.h: Update to reflect the fact that ANGLE isn't compiled as
        a framework for GTK+.
        * platform/graphics/GraphicsContext3D.h:
        (WebCore::GraphicsContext3D::platformTexture): Added a declaration of this method for Cairo.
        (WebCore::GraphicsContext3D::paintsIntoCanvasBuffer): Ditto.
        * platform/graphics/cairo/GraphicsContext3DCairo.cpp: Added.
        (WebCore::GraphicsContext3D::getImageData): Added.
        (WebCore::GraphicsContext3D::paintToCanvas): Added.
        * platform/graphics/cairo/OpenGLShims.cpp: Added. This file controls loading of GL extension
        functions dynamically. They have different names across the different vendors' GL implementations.
        (WebCore::lookupOpenGLFunctionAddress): Added
        (WebCore::openGLFunctionTable): Added
        (WebCore::initializeOpenGLShims): Added
        * platform/graphics/cairo/OpenGLShims.h: Added.
        * platform/graphics/gtk/DrawingBufferGtk.cpp: Added.
        (WebCore::DrawingBuffer::DrawingBuffer): Very generic implementation for Cairo.
        (WebCore::DrawingBuffer::~DrawingBuffer): Ditto.
        (WebCore::DrawingBuffer::didReset): Ditto.
        (WebCore::DrawingBuffer::platformColorBuffer): Ditto.
        * platform/graphics/gtk/GraphicsContext3DGtk.cpp: Added.
        (WebCore::GraphicsContext3D::create): Initial implementation.
        (WebCore::GraphicsContext3D::GraphicsContext3D): Ditto.
        (WebCore::GraphicsContext3D::~GraphicsContext3D): Ditto.
        (WebCore::GraphicsContext3D::makeContextCurrent): Ditto.
        (WebCore::GraphicsContext3D::platformGraphicsContext3D): Ditto.
        (WebCore::GraphicsContext3D::isGLES2Compliant): Ditto.
        * platform/graphics/gtk/GraphicsContext3DInternal.cpp: Added.
        (sharedDisplay): Added this shared display which is required by some
        display drivers.
        (WebCore::activeGraphicsContexts): This method keeps track of all active GraphicsContext3D
        contexts, in order to clean them up at exit. This prevents crashes on certain OpenGL drivers.
        (WebCore::GraphicsContext3DInternal::addActiveGraphicsContext): Ditto.
        (WebCore::GraphicsContext3DInternal::removeActiveGraphicsContext): Ditto.
        (WebCore::GraphicsContext3DInternal::cleanupActiveContextsAtExit): Ditto.
        (WebCore::GraphicsContext3DInternal::create): Figure out the best way to create an OpenGL
        context given the current environment.
        (WebCore::GraphicsContext3DInternal::createPbufferContext): Pbuffer context initializer.
        (WebCore::GraphicsContext3DInternal::createPixmapContext): Pixmap context initializer.
        (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): Initial implementation.
        (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): Ditto.
        (WebCore::GraphicsContext3DInternal::makeContextCurrent): Ditto.
        * platform/graphics/gtk/GraphicsContext3DInternal.h: Added.
        * platform/graphics/opengl/Extensions3DOpenGL.cpp: Added generic implementation.
        (WebCore::Extensions3DOpenGL::ensureEnabled): Ditto.
        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
        (WebCore::GraphicsContext3D::reshape): Test for the context using the public API rather than
        the private bits that are specific to the Apple port.
2011-04-04  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] WebGL support
        https://bugs.webkit.org/show_bug.cgi?id=31517

        Add support for toggling WebGL at runtime when it's enabled.

        * webkit/webkitwebsettings.cpp: Add the enable-webgl property. When ENABLE_WEBGL
        is not enabled, it's a no-op.
        (webkit_web_settings_class_init): Update to support enable-webgl.
        (webkit_web_settings_set_property): Ditto.
        (webkit_web_settings_get_property): Ditto.
        * webkit/webkitwebview.cpp:
        (webkit_web_view_update_settings): Ditto.
2011-04-04  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Gustavo Noronha Silva.

        [GTK] WebGL support
        https://bugs.webkit.org/show_bug.cgi?id=31517

        Add support to the DRT for turning on WebGL when a layout tests requests it.

        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::overridePreference): Allow turning on WebGL from tests.

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

23 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/cairo/OpenGLShims.h [new file with mode: 0644]
Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gtk/GraphicsContext3DGtk.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.h [new file with mode: 0644]
Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/GNUmakefile.am
Source/WebKit/gtk/webkit/webkitwebsettings.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Tools/ChangeLog
Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
configure.ac

index eb52cd6..9c26dc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-04  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] WebGL support
+        https://bugs.webkit.org/show_bug.cgi?id=31517
+
+        * configure.ac: Update configure.ac to ensure that GL/GLX headers exist.
+
 2011-04-04  Jon Lee  <jonlee@apple.com>
 
         Reviewed by Eric Seidel.
index 5ededef..f73f8c0 100644 (file)
@@ -1,3 +1,67 @@
+2011-04-04  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] WebGL support
+        https://bugs.webkit.org/show_bug.cgi?id=31517
+
+        Add WebGL support for the GTK+ bits of WebCore.
+
+        No new tests. This will be covered by the existing WebGL tests once
+        the bots are capable of running WebGL tests.
+
+        * GNUmakefile.am: Added new files required for WebGL support.
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::getContext): Extend #ifdef to cover GTK+ as well, which does not
+        yet support accelerated compositing.
+        * platform/graphics/ANGLEWebKitBridge.h: Update to reflect the fact that ANGLE isn't compiled as
+        a framework for GTK+.
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::platformTexture): Added a declaration of this method for Cairo.
+        (WebCore::GraphicsContext3D::paintsIntoCanvasBuffer): Ditto.
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp: Added.
+        (WebCore::GraphicsContext3D::getImageData): Added.
+        (WebCore::GraphicsContext3D::paintToCanvas): Added.
+        * platform/graphics/cairo/OpenGLShims.cpp: Added. This file controls loading of GL extension
+        functions dynamically. They have different names across the different vendors' GL implementations.
+        (WebCore::lookupOpenGLFunctionAddress): Added
+        (WebCore::openGLFunctionTable): Added
+        (WebCore::initializeOpenGLShims): Added
+        * platform/graphics/cairo/OpenGLShims.h: Added.
+        * platform/graphics/gtk/DrawingBufferGtk.cpp: Added.
+        (WebCore::DrawingBuffer::DrawingBuffer): Very generic implementation for Cairo.
+        (WebCore::DrawingBuffer::~DrawingBuffer): Ditto.
+        (WebCore::DrawingBuffer::didReset): Ditto.
+        (WebCore::DrawingBuffer::platformColorBuffer): Ditto.
+        * platform/graphics/gtk/GraphicsContext3DGtk.cpp: Added.
+        (WebCore::GraphicsContext3D::create): Initial implementation.
+        (WebCore::GraphicsContext3D::GraphicsContext3D): Ditto.
+        (WebCore::GraphicsContext3D::~GraphicsContext3D): Ditto.
+        (WebCore::GraphicsContext3D::makeContextCurrent): Ditto.
+        (WebCore::GraphicsContext3D::platformGraphicsContext3D): Ditto.
+        (WebCore::GraphicsContext3D::isGLES2Compliant): Ditto.
+        * platform/graphics/gtk/GraphicsContext3DInternal.cpp: Added.
+        (sharedDisplay): Added this shared display which is required by some
+        display drivers.
+        (WebCore::activeGraphicsContexts): This method keeps track of all active GraphicsContext3D
+        contexts, in order to clean them up at exit. This prevents crashes on certain OpenGL drivers.
+        (WebCore::GraphicsContext3DInternal::addActiveGraphicsContext): Ditto.
+        (WebCore::GraphicsContext3DInternal::removeActiveGraphicsContext): Ditto.
+        (WebCore::GraphicsContext3DInternal::cleanupActiveContextsAtExit): Ditto.
+        (WebCore::GraphicsContext3DInternal::create): Figure out the best way to create an OpenGL
+        context given the current environment.
+        (WebCore::GraphicsContext3DInternal::createPbufferContext): Pbuffer context initializer.
+        (WebCore::GraphicsContext3DInternal::createPixmapContext): Pixmap context initializer.
+        (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): Initial implementation.
+        (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): Ditto.
+        (WebCore::GraphicsContext3DInternal::makeContextCurrent): Ditto.
+        * platform/graphics/gtk/GraphicsContext3DInternal.h: Added.
+        * platform/graphics/opengl/Extensions3DOpenGL.cpp: Added generic implementation.
+        (WebCore::Extensions3DOpenGL::ensureEnabled): Ditto.
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        (WebCore::GraphicsContext3D::reshape): Test for the context using the public API rather than
+        the private bits that are specific to the Apple port.
+
 2011-04-04  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Dan Bernstein.
index a8c335d..e04dfd2 100644 (file)
@@ -5,6 +5,9 @@ WEBCORE_CSS_PROPERTY_NAMES := $(WebCore)/css/CSSPropertyNames.in
 WEBCORE_CSS_VALUE_KEYWORDS := $(WebCore)/css/CSSValueKeywords.in
 
 webcore_cppflags += \
+       -I$(srcdir)/Source/ThirdParty/ANGLE/src \
+       -I$(srcdir)/Source/ThirdParty/ANGLE/include \
+       -I$(srcdir)/Source/ThirdParty/ANGLE/include/GLSLANG \
        -I$(srcdir)/Source/WebCore \
        -I$(srcdir)/Source/WebCore/accessibility \
        -I$(srcdir)/Source/WebCore/bindings \
@@ -40,6 +43,8 @@ webcore_cppflags += \
        -I$(srcdir)/Source/WebCore/platform/audio \
        -I$(srcdir)/Source/WebCore/platform/graphics \
        -I$(srcdir)/Source/WebCore/platform/graphics/filters \
+       -I$(srcdir)/Source/WebCore/platform/graphics/gpu \
+       -I$(srcdir)/Source/WebCore/platform/graphics/opengl \
        -I$(srcdir)/Source/WebCore/platform/graphics/opentype \
        -I$(srcdir)/Source/WebCore/platform/graphics/transforms \
        -I$(srcdir)/Source/WebCore/platform/image-decoders \
@@ -4894,7 +4899,87 @@ endif  # END ENABLE_BLOB
 if ENABLE_WEBGL
 FEATURE_DEFINES += ENABLE_WEBGL=1
 webcore_cppflags += -DENABLE_WEBGL=1
+webcore_built_sources += \
+       DerivedSources/ANGLE/glslang.cpp \
+       DerivedSources/ANGLE/glslang_tab.cpp \
+       DerivedSources/ANGLE/glslang_tab.h
 webcore_sources += \
+       Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h \
+       Source/ThirdParty/ANGLE/src/compiler/BaseTypes.h \
+       Source/ThirdParty/ANGLE/src/compiler/CodeGenGLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/Common.h \
+       Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/ConstantUnion.h \
+       Source/ThirdParty/ANGLE/src/compiler/debug.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/debug.h \
+       Source/ThirdParty/ANGLE/src/compiler/InfoSink.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/InfoSink.h \
+       Source/ThirdParty/ANGLE/src/compiler/Initialize.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/InitializeDll.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/InitializeDll.h \
+       Source/ThirdParty/ANGLE/src/compiler/InitializeGlobals.h \
+       Source/ThirdParty/ANGLE/src/compiler/Initialize.h \
+       Source/ThirdParty/ANGLE/src/compiler/InitializeParseContext.h \
+       Source/ThirdParty/ANGLE/src/compiler/Intermediate.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/intermediate.h \
+       Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/IntermTraverse.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/localintermediate.h \
+       Source/ThirdParty/ANGLE/src/compiler/MMap.h \
+       Source/ThirdParty/ANGLE/src/compiler/osinclude.h \
+       Source/ThirdParty/ANGLE/src/compiler/ossource_posix.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/OutputGLSL.h \
+       Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/OutputHLSL.h \
+       Source/ThirdParty/ANGLE/src/compiler/parseConst.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/ParseHelper.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/ParseHelper.h \
+       Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/PoolAlloc.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/atom.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/atom.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/compile.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/cpp.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/cppstruct.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/memory.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/memory.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/parser.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/preprocess.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/scanner.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/slglobals.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/symbols.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/symbols.h \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.c \
+       Source/ThirdParty/ANGLE/src/compiler/preprocessor/tokens.h \
+       Source/ThirdParty/ANGLE/src/compiler/QualifierAlive.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/QualifierAlive.h \
+       Source/ThirdParty/ANGLE/src/compiler/RemoveTree.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/RemoveTree.h \
+       Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/SearchSymbol.h \
+       Source/ThirdParty/ANGLE/src/compiler/ShaderLang.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/ShHandle.h \
+       Source/ThirdParty/ANGLE/src/compiler/SymbolTable.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/SymbolTable.h \
+       Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h \
+       Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.h \
+       Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/TranslatorHLSL.h \
+       Source/ThirdParty/ANGLE/src/compiler/Types.h \
+       Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/UnfoldSelect.h \
+       Source/ThirdParty/ANGLE/src/compiler/util.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/util.h \
+       Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/ValidateLimitations.h \
+       Source/ThirdParty/ANGLE/src/compiler/VariableInfo.cpp \
+       Source/ThirdParty/ANGLE/src/compiler/VariableInfo.h \
        Source/WebCore/html/canvas/WebGLActiveInfo.h \
        Source/WebCore/html/canvas/WebGLBuffer.cpp \
        Source/WebCore/html/canvas/WebGLBuffer.h \
@@ -4922,6 +5007,8 @@ webcore_sources += \
        Source/WebCore/html/canvas/WebGLUniformLocation.h \
        Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp \
        Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h \
+       Source/WebCore/html/canvas/WebGLExtension.cpp \
+       Source/WebCore/html/canvas/WebGLExtension.h \
        Source/WebCore/html/canvas/OESStandardDerivatives.cpp \
        Source/WebCore/html/canvas/OESStandardDerivatives.h \
        Source/WebCore/html/canvas/OESTextureFloat.cpp \
@@ -4929,9 +5016,26 @@ webcore_sources += \
        Source/WebCore/html/canvas/OESVertexArrayObject.cpp \
        Source/WebCore/html/canvas/OESVertexArrayObject.h \
        Source/WebCore/html/canvas/WebKitLoseContext.cpp \
-       Source/WebCore/html/canvas/WebKitLoseContext.h
+       Source/WebCore/html/canvas/WebKitLoseContext.h \
+       Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp \
+       Source/WebCore/platform/graphics/ANGLEWebKitBridge.h \
+       Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp \
+       Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp \
+       Source/WebCore/platform/graphics/cairo/OpenGLShims.h \
+       Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp \
+       Source/WebCore/platform/graphics/gpu/DrawingBuffer.h \
+       Source/WebCore/platform/graphics/GraphicsContext3D.cpp \
+       Source/WebCore/platform/graphics/GraphicsContext3D.h \
+       Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp \
+       Source/WebCore/platform/graphics/gtk/GraphicsContext3DGtk.cpp \
+       Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.cpp \
+       Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.h \
+       Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp \
+       Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h \
+       Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
 endif  # END ENABLE_WEBGL
 
+
 DerivedSources/WebCore/CSSPropertyNames.cpp: DerivedSources/WebCore/CSSPropertyNames.h
 DerivedSources/WebCore/CSSPropertyNames.h: $(WEBCORE_CSS_PROPERTY_NAMES) $(WebCore)/css/makeprop.pl
        if sort $(WEBCORE_CSS_PROPERTY_NAMES) | uniq -d | grep -E '^[^#]'; then echo 'Duplicate value!'; exit 1; fi
@@ -5043,6 +5147,14 @@ DerivedSources/WebCore/InspectorBackendDispatcher.h: DerivedSources/WebCore/Insp
 DerivedSources/WebCore/InjectedScriptSource.h: $(WebCore)/inspector/InjectedScriptSource.js
        perl $(WebCore)/inspector/xxd.pl InjectedScriptSource_js $(WebCore)/inspector/InjectedScriptSource.js $(GENSOURCES_WEBCORE)/InjectedScriptSource.h
 
+# ANGLE tokenizer & parser
+DerivedSources/ANGLE/glslang.cpp: Source/ThirdParty/ANGLE/src/compiler/glslang.l
+       $(AM_V_GEN)$(FLEX) --noline --nounistd --outfile="$@" "$<"
+
+DerivedSources/ANGLE/glslang_tab.cpp: Source/ThirdParty/ANGLE/src/compiler/glslang.y
+       $(AM_V_GEN)$(BISON) --no-lines --defines="DerivedSources/ANGLE/glslang_tab.h" --skeleton=yacc.c --output="$@" $<
+DerivedSources/ANGLE/glslang_tab.h: DerivedSources/ANGLE/glslang_tab.cpp
+
 IDL_PATH := \
     $(WebCore)/bindings/js \
     $(WebCore)/css \
index fbedbf2..779122a 100644 (file)
@@ -175,7 +175,7 @@ CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type, Canvas
 #if ENABLE(WEBGL)    
     Settings* settings = document()->settings();
     if (settings && settings->webGLEnabled()
-#if !PLATFORM(CHROMIUM)
+#if !PLATFORM(CHROMIUM) && !PLATFORM(GTK)
         && settings->acceleratedCompositingEnabled()
 #endif
         ) {
index 7bddbf4..a9d2238 100644 (file)
 #ifndef ANGLEWebKitBridge_h
 #define ANGLEWebKitBridge_h
 
-#include "ANGLE/ShaderLang.h"
 #include "PlatformString.h"
-
 #include <wtf/text/CString.h>
 
+#if !PLATFORM(GTK)
+#include "ANGLE/ShaderLang.h"
+#else
+#include "ShaderLang.h"
+#endif
+
 namespace WebCore {
 
 enum ANGLEShaderType {
index 351b445..081f311 100644 (file)
 #undef VERSION
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(GTK)
 #include "ANGLEWebKitBridge.h"
+#endif
+
+#if PLATFORM(MAC)
 #include <OpenGL/OpenGL.h>
 #include <wtf/RetainPtr.h>
 #ifdef __OBJC__
@@ -60,6 +63,7 @@ class QPainter;
 class QRect;
 QT_END_NAMESPACE
 #elif PLATFORM(GTK)
+typedef struct _cairo cairo_t;
 typedef unsigned int GLuint;
 #endif
 
@@ -81,7 +85,7 @@ namespace WebCore {
 class CanvasRenderingContext;
 class DrawingBuffer;
 class Extensions3D;
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(GTK)
 class Extensions3DOpenGL;
 #endif
 class HostWindow;
@@ -95,7 +99,7 @@ struct ActiveInfo {
 };
 
 // FIXME: ideally this would be used on all platforms.
-#if PLATFORM(CHROMIUM) || PLATFORM(QT)
+#if PLATFORM(CHROMIUM) || PLATFORM(QT) || PLATFORM(GTK)
 class GraphicsContext3DInternal;
 #endif
 
@@ -465,6 +469,9 @@ public:
 #if USE(ACCELERATED_COMPOSITING)
     PlatformLayer* platformLayer() const;
 #endif
+#elif PLATFORM(GTK)
+    PlatformGraphicsContext3D platformGraphicsContext3D();
+    Platform3DObject platformTexture() const { return m_texture; }
 #else
     PlatformGraphicsContext3D platformGraphicsContext3D() const { return NullPlatformGraphicsContext3D; }
     Platform3DObject platformTexture() const { return NullPlatform3DObject; }
@@ -476,7 +483,7 @@ public:
 
     PassRefPtr<DrawingBuffer> createDrawingBuffer(const IntSize& = IntSize());
     
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(GTK)
     // With multisampling on, blit from multisampleFBO to regular FBO.
     void prepareTexture();
 #endif
@@ -756,6 +763,9 @@ public:
 #if PLATFORM(CG)
     void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
                        int canvasWidth, int canvasHeight, CGContextRef context);
+#elif PLATFORM(GTK)
+    void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
+                       int canvasWidth, int canvasHeight, cairo_t* context);
 #endif
 
     void markContextChanged();
@@ -769,6 +779,8 @@ public:
     bool paintsIntoCanvasBuffer() const { return true; }
 #elif PLATFORM(CHROMIUM)
     bool paintsIntoCanvasBuffer() const;
+#elif PLATFORM(GTK)
+    bool paintsIntoCanvasBuffer() const { return true; }
 #else
     bool paintsIntoCanvasBuffer() const { return false; }
 #endif
@@ -859,7 +871,7 @@ public:
                     AlphaOp alphaOp,
                     void* destinationData);
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(GTK)
     // Take into account the user's requested context creation attributes,
     // in particular stencil and antialias, and determine which could or
     // could not be honored based on the capabilities of the OpenGL
@@ -874,6 +886,11 @@ public:
     int m_currentWidth, m_currentHeight;
 
 #if PLATFORM(MAC)
+    CGLContextObj m_contextObj;
+    RetainPtr<WebGLLayer> m_webGLLayer;
+#endif
+
+#if PLATFORM(MAC) || PLATFORM(GTK)
     typedef struct {
         String source;
         String log;
@@ -889,8 +906,6 @@ public:
     Attributes m_attrs;
     Vector<Vector<float> > m_vertexArray;
 
-    CGLContextObj m_contextObj;
-    RetainPtr<WebGLLayer> m_webGLLayer;
     GC3Duint m_texture, m_compositorTexture;
     GC3Duint m_fbo;
     GC3Duint m_depthStencilBuffer;
@@ -912,7 +927,7 @@ public:
 #endif
 
     // FIXME: ideally this would be used on all platforms.
-#if PLATFORM(CHROMIUM) || PLATFORM(QT)
+#if PLATFORM(CHROMIUM) || PLATFORM(QT) || PLATFORM(GTK)
     friend class GraphicsContext3DInternal;
     OwnPtr<GraphicsContext3DInternal> m_internal;
 #endif
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
new file mode 100644 (file)
index 0000000..fd6090b
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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"
+#include "GraphicsContext3D.h"
+
+#if ENABLE(WEBGL)
+
+#include "Image.h"
+#include "RefPtrCairo.h"
+#include <cairo.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector)
+{
+    if (!image)
+        return false;
+    // We need this to stay in scope because the native image is just a shallow copy of the data.
+    ImageSource decoder(premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied,
+                        ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
+    AlphaOp alphaOp = AlphaDoNothing;
+    RefPtr<cairo_surface_t> imageSurface;
+    if (image->data()) {
+        decoder.setData(image->data(), true);
+        if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
+            return false;
+        imageSurface = decoder.createFrameAtIndex(0);
+    } else {
+        imageSurface = image->nativeImageForCurrentFrame();
+        if (!premultiplyAlpha)
+            alphaOp = AlphaDoUnmultiply;
+    }
+
+    if (!imageSurface)
+        return false;
+
+    int width = cairo_image_surface_get_width(imageSurface.get());
+    int height = cairo_image_surface_get_height(imageSurface.get());
+    if (!width || !height)
+        return false;
+
+    if (cairo_image_surface_get_format(imageSurface.get()) != CAIRO_FORMAT_ARGB32)
+        return false;
+
+    unsigned int srcUnpackAlignment = 1;
+    size_t bytesPerRow = cairo_image_surface_get_stride(imageSurface.get());
+    size_t bitsPerPixel = 32;
+    unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width;
+    if (padding) {
+        srcUnpackAlignment = padding + 1;
+        while (bytesPerRow % srcUnpackAlignment)
+            ++srcUnpackAlignment;
+    }
+
+    outputVector.resize(width * height * 4);
+    return packPixels(cairo_image_surface_get_data(imageSurface.get()), SourceFormatBGRA8,
+                      width, height, srcUnpackAlignment, format, type, alphaOp, outputVector.data());
+}
+
+void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, cairo_t* context)
+{
+    if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0 || !context)
+        return;
+
+    cairo_save(context);
+
+    cairo_rectangle(context, 0, 0, canvasWidth, canvasHeight);
+    cairo_set_operator(context, CAIRO_OPERATOR_CLEAR);
+    cairo_paint(context);
+
+    RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(
+        const_cast<unsigned char*>(imagePixels), CAIRO_FORMAT_ARGB32, imageWidth, imageHeight, imageWidth * 4));
+
+    // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
+    cairo_translate(context, 0, imageHeight);
+    cairo_scale(context, 1, -1);
+
+    cairo_set_operator(context, CAIRO_OPERATOR_OVER);
+    cairo_set_source_surface(context, imageSurface.get(), 0, 0);
+    cairo_rectangle(context, 0, 0, canvasWidth, -canvasHeight);
+
+    cairo_fill(context);
+    cairo_restore(context);
+}
+
+void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp b/Source/WebCore/platform/graphics/cairo/OpenGLShims.cpp
new file mode 100644 (file)
index 0000000..92d79f9
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ *  Copyright (C) 2011 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#if ENABLE(WEBGL)
+
+#define DISABLE_SHIMS
+#include "OpenGLShims.h"
+
+#include <dlfcn.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+#define ASSIGN_FUNCTION_TABLE_ENTRY(FunctionName, success) \
+    openGLFunctionTable()->FunctionName = reinterpret_cast<FunctionName##Type>(lookupOpenGLFunctionAddress(#FunctionName, success))
+
+namespace WebCore {
+
+typedef void* (*glGetProcAddressType) (const char* procName);
+static void* getProcAddress(const char* procName)
+{
+    static bool initialized = false;
+    static glGetProcAddressType getProcAddressFunction = 0;
+
+    if (!initialized) {
+        getProcAddressFunction = reinterpret_cast<glGetProcAddressType>(dlsym(RTLD_DEFAULT, "glXGetProcAddress"));
+        if (!getProcAddressFunction)
+            getProcAddressFunction = reinterpret_cast<glGetProcAddressType>(dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"));
+    }
+
+    if (!getProcAddressFunction)
+        return dlsym(RTLD_DEFAULT, procName);
+    return getProcAddressFunction(procName);
+}
+
+static void* lookupOpenGLFunctionAddress(const char* functionName, bool& success)
+{
+    if (!success)
+        return 0;
+
+    void* target = getProcAddress(functionName);
+    if (target)
+        return target;
+
+    String fullFunctionName(functionName);
+    fullFunctionName.append("ARB");
+    target = getProcAddress(fullFunctionName.utf8().data());
+    if (target)
+        return target;
+
+    fullFunctionName = functionName;
+    fullFunctionName.append("EXT");
+    target = getProcAddress(fullFunctionName.utf8().data());
+
+    // A null address is still a failure case.
+    if (!target)
+        success = false;
+
+    return target;
+}
+
+OpenGLFunctionTable* openGLFunctionTable()
+{
+    static OpenGLFunctionTable table;
+    return &table;
+}
+
+bool initializeOpenGLShims()
+{
+    static bool success = true;
+    static bool initialized = false;
+    if (initialized)
+        return success;
+
+    initialized = true;
+    ASSIGN_FUNCTION_TABLE_ENTRY(glActiveTexture, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glAttachShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBindAttribLocation, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBindBuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBindFramebuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBindRenderbuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBlendColor, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBlendEquation, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBlendEquationSeparate, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBlendFuncSeparate, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBlitFramebuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBufferData, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glBufferSubData, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glCheckFramebufferStatus, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glCompileShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glCreateProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glCreateShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteBuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteFramebuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteRenderbuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDetachShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glDisableVertexAttribArray, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glFramebufferRenderbuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glFramebufferTexture2D, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGenBuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGenerateMipmap, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGenFramebuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGenRenderbuffers, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetActiveAttrib, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetActiveUniform, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetAttachedShaders, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetAttribLocation, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetBufferParameteriv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetFramebufferAttachmentParameteriv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetProgramInfoLog, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetProgramiv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetRenderbufferParameteriv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderInfoLog, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderiv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderSource, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetUniformfv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetUniformiv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetUniformLocation, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetVertexAttribfv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetVertexAttribiv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glGetVertexAttribPointerv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glIsBuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glIsFramebuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glIsProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glIsRenderbuffer, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glIsShader, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glLinkProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glRenderbufferStorage, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glRenderbufferStorageMultisample, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glSampleCoverage, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glShaderSource, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glStencilFuncSeparate, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glStencilMaskSeparate, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glStencilOpSeparate, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform1f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform1fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform1i, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform1iv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform2f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform2fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform2i, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform2iv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform3f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform3fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform3i, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform3iv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform4f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform4fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform4i, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniform4iv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniformMatrix2fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniformMatrix3fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUniformMatrix4fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glUseProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glValidateProgram, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib1f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib1fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib2f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib2fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib3f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib3fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib4f, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttrib4fv, success);
+    ASSIGN_FUNCTION_TABLE_ENTRY(glVertexAttribPointer, success);
+
+    if (!success)
+        LOG_ERROR("Could not initialize OpenGL shims");
+    return success;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/cairo/OpenGLShims.h b/Source/WebCore/platform/graphics/cairo/OpenGLShims.h
new file mode 100644 (file)
index 0000000..a431b03
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ *  Copyright (C) 2010 Tieto Corporation.
+ *  Copyright (C) 2011 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <GL/gl.h>
+
+typedef struct _OpenGLFunctionTable OpenGLFunctionTable;
+
+namespace WebCore {
+bool initializeOpenGLShims();
+OpenGLFunctionTable* openGLFunctionTable();
+}
+
+typedef void (*glActiveTextureType) (GLenum);
+typedef void (*glAttachShaderType) (GLuint, GLuint);
+typedef void (*glBindAttribLocationType) (GLuint, GLuint, const char*);
+typedef void (*glBindBufferType) (GLenum, GLuint);
+typedef void (*glBindFramebufferType) (GLenum, GLuint);
+typedef void (*glBindRenderbufferType) (GLenum, GLuint);
+typedef void (*glBlendColorType) (GLclampf, GLclampf, GLclampf, GLclampf);
+typedef void (*glBlendEquationType) (GLenum);
+typedef void (*glBlendEquationSeparateType)(GLenum, GLenum);
+typedef void (*glBlendFuncSeparateType)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (*glBlitFramebufferType) (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
+typedef void (*glBufferDataType) (GLenum, GLsizeiptr, const GLvoid*, GLenum);
+typedef void (*glBufferSubDataType) (GLenum, GLintptr, GLsizeiptr, const GLvoid*);
+typedef GLenum (*glCheckFramebufferStatusType) (GLenum);
+typedef void (*glCompileShaderType) (GLuint);
+typedef GLuint (*glCreateProgramType) ();
+typedef GLuint (*glCreateShaderType) (GLenum);
+typedef void (*glDeleteBuffersType) (GLsizei, const GLuint*);
+typedef void (*glDeleteFramebuffersType) (GLsizei n, const GLuint*);
+typedef void (*glDeleteProgramType) (GLuint);
+typedef void (*glDeleteRenderbuffersType) (GLsizei n, const GLuint*);
+typedef void (*glDeleteShaderType) (GLuint);
+typedef void (*glDetachShaderType) (GLuint, GLuint);
+typedef void (*glDisableVertexAttribArrayType) (GLuint);
+typedef void (*glEnableVertexAttribArrayType) (GLuint);
+typedef void (*glFramebufferRenderbufferType) (GLenum, GLenum, GLenum, GLuint);
+typedef void (*glFramebufferTexture2DType) (GLenum, GLenum, GLenum, GLuint, GLint);
+typedef void (*glGenBuffersType) (GLsizei, GLuint*);
+typedef void (*glGenerateMipmapType) (GLenum target);
+typedef void (*glGenFramebuffersType) (GLsizei, GLuint*);
+typedef void (*glGenRenderbuffersType) (GLsizei, GLuint*);
+typedef void (*glGetActiveAttribType) (GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
+typedef void (*glGetActiveUniformType) (GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
+typedef void (*glGetAttachedShadersType) (GLuint, GLsizei, GLsizei*, GLuint*);
+typedef GLint (*glGetAttribLocationType) (GLuint, const char*);
+typedef void (*glGetBufferParameterivType) (GLenum, GLenum, GLint*);
+typedef void (*glGetFramebufferAttachmentParameterivType) (GLenum, GLenum, GLenum, GLint* params);
+typedef void (*glGetProgramInfoLogType) (GLuint, GLsizei, GLsizei*, char*);
+typedef void (*glGetProgramivType) (GLuint, GLenum, GLint*);
+typedef void (*glGetRenderbufferParameterivType) (GLenum, GLenum, GLint*);
+typedef void (*glGetShaderInfoLogType) (GLuint, GLsizei, GLsizei*, char*);
+typedef void (*glGetShaderivType) (GLuint, GLenum, GLint*);
+typedef void (*glGetShaderSourceType) (GLuint, GLsizei, GLsizei*, char*);
+typedef GLint (*glGetUniformLocationType) (GLuint, const char*);
+typedef void (*glGetUniformfvType) (GLuint, GLint, GLfloat*);
+typedef void (*glGetUniformivType) (GLuint, GLint, GLint*);
+typedef void (*glGetVertexAttribfvType) (GLuint, GLenum, GLfloat*);
+typedef void (*glGetVertexAttribivType) (GLuint, GLenum, GLint*);
+typedef void (*glGetVertexAttribPointervType) (GLuint, GLenum, GLvoid**);
+typedef GLboolean (*glIsBufferType) (GLuint);
+typedef GLboolean (*glIsFramebufferType) (GLuint);
+typedef GLboolean (*glIsProgramType) (GLuint);
+typedef GLboolean (*glIsRenderbufferType) (GLuint);
+typedef GLboolean (*glIsShaderType) (GLuint);
+typedef void (*glLinkProgramType) (GLuint);
+typedef void (*glRenderbufferStorageType) (GLenum, GLenum, GLsizei, GLsizei);
+typedef void (*glRenderbufferStorageMultisampleType) (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+typedef void (*glSampleCoverageType) (GLclampf, GLboolean);
+typedef void (*glShaderSourceType) (GLuint, GLsizei, const char**, const GLint*);
+typedef void (*glStencilFuncSeparateType) (GLenum, GLenum, GLint, GLuint);
+typedef void (*glStencilMaskSeparateType) (GLenum, GLuint);
+typedef void (*glStencilOpSeparateType) (GLenum, GLenum, GLenum, GLenum);
+typedef void (*glUniform1fType) (GLint, GLfloat);
+typedef void (*glUniform1fvType) (GLint, GLsizei, const GLfloat*);
+typedef void (*glUniform1iType) (GLint, GLint);
+typedef void (*glUniform1ivType) (GLint, GLsizei, const GLint*);
+typedef void (*glUniform2fType) (GLint, GLfloat, GLfloat);
+typedef void (*glUniform2fvType) (GLint, GLsizei, const GLfloat*);
+typedef void (*glUniform2iType) (GLint, GLint, GLint);
+typedef void (*glUniform2ivType) (GLint, GLsizei, const GLint*);
+typedef void (*glUniform3fType) (GLint, GLfloat, GLfloat, GLfloat);
+typedef void (*glUniform3fvType) (GLint, GLsizei, const GLfloat*);
+typedef void (*glUniform3iType) (GLint, GLint, GLint, GLint);
+typedef void (*glUniform3ivType) (GLint, GLsizei, const GLint*);
+typedef void (*glUniform4fType) (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+typedef void (*glUniform4fvType) (GLint, GLsizei, const GLfloat*);
+typedef void (*glUniform4iType) (GLint, GLint, GLint, GLint, GLint);
+typedef void (*glUniform4ivType) (GLint, GLsizei, const GLint*);
+typedef void (*glUniformMatrix2fvType) (GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (*glUniformMatrix3fvType) (GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (*glUniformMatrix4fvType) (GLint, GLsizei, GLboolean, const GLfloat*);
+typedef void (*glUseProgramType) (GLuint);
+typedef void (*glValidateProgramType) (GLuint);
+typedef void (*glVertexAttrib1fType) (GLuint, const GLfloat);
+typedef void (*glVertexAttrib1fvType) (GLuint, const GLfloat*);
+typedef void (*glVertexAttrib2fType) (GLuint, const GLfloat, const GLfloat);
+typedef void (*glVertexAttrib2fvType) (GLuint, const GLfloat*);
+typedef void (*glVertexAttrib3fType) (GLuint, const GLfloat, const GLfloat, const GLfloat);
+typedef void (*glVertexAttrib3fvType) (GLuint, const GLfloat*);
+typedef void (*glVertexAttrib4fType) (GLuint, const GLfloat, const GLfloat, const GLfloat, const GLfloat);
+typedef void (*glVertexAttrib4fvType) (GLuint, const GLfloat*);
+typedef void (*glVertexAttribPointerType) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*);
+
+#define FUNCTION_TABLE_ENTRY(FunctionName) FunctionName##Type FunctionName
+
+typedef struct _OpenGLFunctionTable {
+    FUNCTION_TABLE_ENTRY(glActiveTexture);
+    FUNCTION_TABLE_ENTRY(glAttachShader);
+    FUNCTION_TABLE_ENTRY(glBindAttribLocation);
+    FUNCTION_TABLE_ENTRY(glBindBuffer);
+    FUNCTION_TABLE_ENTRY(glBindFramebuffer);
+    FUNCTION_TABLE_ENTRY(glBindRenderbuffer);
+    FUNCTION_TABLE_ENTRY(glBlendColor);
+    FUNCTION_TABLE_ENTRY(glBlendEquation);
+    FUNCTION_TABLE_ENTRY(glBlendEquationSeparate);
+    FUNCTION_TABLE_ENTRY(glBlendFuncSeparate);
+    FUNCTION_TABLE_ENTRY(glBlitFramebuffer);
+    FUNCTION_TABLE_ENTRY(glBufferData);
+    FUNCTION_TABLE_ENTRY(glBufferSubData);
+    FUNCTION_TABLE_ENTRY(glCheckFramebufferStatus);
+    FUNCTION_TABLE_ENTRY(glCompileShader);
+    FUNCTION_TABLE_ENTRY(glCreateProgram);
+    FUNCTION_TABLE_ENTRY(glCreateShader);
+    FUNCTION_TABLE_ENTRY(glDeleteBuffers);
+    FUNCTION_TABLE_ENTRY(glDeleteFramebuffers);
+    FUNCTION_TABLE_ENTRY(glDeleteProgram);
+    FUNCTION_TABLE_ENTRY(glDeleteRenderbuffers);
+    FUNCTION_TABLE_ENTRY(glDeleteShader);
+    FUNCTION_TABLE_ENTRY(glDetachShader);
+    FUNCTION_TABLE_ENTRY(glDisableVertexAttribArray);
+    FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray);
+    FUNCTION_TABLE_ENTRY(glFramebufferRenderbuffer);
+    FUNCTION_TABLE_ENTRY(glFramebufferTexture2D);
+    FUNCTION_TABLE_ENTRY(glGenBuffers);
+    FUNCTION_TABLE_ENTRY(glGenerateMipmap);
+    FUNCTION_TABLE_ENTRY(glGenFramebuffers);
+    FUNCTION_TABLE_ENTRY(glGenRenderbuffers);
+    FUNCTION_TABLE_ENTRY(glGetActiveAttrib);
+    FUNCTION_TABLE_ENTRY(glGetActiveUniform);
+    FUNCTION_TABLE_ENTRY(glGetAttachedShaders);
+    FUNCTION_TABLE_ENTRY(glGetAttribLocation);
+    FUNCTION_TABLE_ENTRY(glGetBufferParameteriv);
+    FUNCTION_TABLE_ENTRY(glGetFramebufferAttachmentParameteriv);
+    FUNCTION_TABLE_ENTRY(glGetProgramInfoLog);
+    FUNCTION_TABLE_ENTRY(glGetProgramiv);
+    FUNCTION_TABLE_ENTRY(glGetRenderbufferParameteriv);
+    FUNCTION_TABLE_ENTRY(glGetShaderInfoLog);
+    FUNCTION_TABLE_ENTRY(glGetShaderiv);
+    FUNCTION_TABLE_ENTRY(glGetShaderSource);
+    FUNCTION_TABLE_ENTRY(glGetUniformfv);
+    FUNCTION_TABLE_ENTRY(glGetUniformiv);
+    FUNCTION_TABLE_ENTRY(glGetUniformLocation);
+    FUNCTION_TABLE_ENTRY(glGetVertexAttribfv);
+    FUNCTION_TABLE_ENTRY(glGetVertexAttribiv);
+    FUNCTION_TABLE_ENTRY(glGetVertexAttribPointerv);
+    FUNCTION_TABLE_ENTRY(glIsBuffer);
+    FUNCTION_TABLE_ENTRY(glIsFramebuffer);
+    FUNCTION_TABLE_ENTRY(glIsProgram);
+    FUNCTION_TABLE_ENTRY(glIsRenderbuffer);
+    FUNCTION_TABLE_ENTRY(glIsShader);
+    FUNCTION_TABLE_ENTRY(glLinkProgram);
+    FUNCTION_TABLE_ENTRY(glRenderbufferStorage);
+    FUNCTION_TABLE_ENTRY(glRenderbufferStorageMultisample);
+    FUNCTION_TABLE_ENTRY(glSampleCoverage);
+    FUNCTION_TABLE_ENTRY(glShaderSource);
+    FUNCTION_TABLE_ENTRY(glStencilFuncSeparate);
+    FUNCTION_TABLE_ENTRY(glStencilMaskSeparate);
+    FUNCTION_TABLE_ENTRY(glStencilOpSeparate);
+    FUNCTION_TABLE_ENTRY(glUniform1f);
+    FUNCTION_TABLE_ENTRY(glUniform1fv);
+    FUNCTION_TABLE_ENTRY(glUniform1i);
+    FUNCTION_TABLE_ENTRY(glUniform1iv);
+    FUNCTION_TABLE_ENTRY(glUniform2f);
+    FUNCTION_TABLE_ENTRY(glUniform2fv);
+    FUNCTION_TABLE_ENTRY(glUniform2i);
+    FUNCTION_TABLE_ENTRY(glUniform2iv);
+    FUNCTION_TABLE_ENTRY(glUniform3f);
+    FUNCTION_TABLE_ENTRY(glUniform3fv);
+    FUNCTION_TABLE_ENTRY(glUniform3i);
+    FUNCTION_TABLE_ENTRY(glUniform3iv);
+    FUNCTION_TABLE_ENTRY(glUniform4f);
+    FUNCTION_TABLE_ENTRY(glUniform4fv);
+    FUNCTION_TABLE_ENTRY(glUniform4i);
+    FUNCTION_TABLE_ENTRY(glUniform4iv);
+    FUNCTION_TABLE_ENTRY(glUniformMatrix2fv);
+    FUNCTION_TABLE_ENTRY(glUniformMatrix3fv);
+    FUNCTION_TABLE_ENTRY(glUniformMatrix4fv);
+    FUNCTION_TABLE_ENTRY(glUseProgram);
+    FUNCTION_TABLE_ENTRY(glValidateProgram);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib1f);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib1fv);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib2f);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib2fv);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib3f);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib3fv);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib4f);
+    FUNCTION_TABLE_ENTRY(glVertexAttrib4fv);
+    FUNCTION_TABLE_ENTRY(glVertexAttribPointer);
+} OpenGLFunctionTable;
+
+// We disable the shims for OpenGLShims.cpp, so that we can set them.
+#ifndef DISABLE_SHIMS
+#define LOOKUP_GL_FUNCTION(Function) WebCore::openGLFunctionTable()->Function
+#define glActiveTexture                        LOOKUP_GL_FUNCTION(glActiveTexture)
+#define glAttachShader                         LOOKUP_GL_FUNCTION(glAttachShader)
+#define glBindAttribLocation                   LOOKUP_GL_FUNCTION(glBindAttribLocation)
+#define glBindBuffer                           LOOKUP_GL_FUNCTION(glBindBuffer)
+#define glBindFramebufferEXT                   LOOKUP_GL_FUNCTION(glBindFramebuffer)
+#define glBindRenderbufferEXT                  LOOKUP_GL_FUNCTION(glBindRenderbuffer)
+#define glBlendColor                           LOOKUP_GL_FUNCTION(glBlendColor)
+#define glBlendEquation                        LOOKUP_GL_FUNCTION(glBlendEquation)
+#define glBlendEquationSeparate                LOOKUP_GL_FUNCTION(glBlendEquationSeparate)
+#define glBlendFuncSeparate                    LOOKUP_GL_FUNCTION(glBlendFuncSeparate)
+#define glBlitFramebufferEXT                   LOOKUP_GL_FUNCTION(glBlitFramebuffer)
+#define glBufferData                           LOOKUP_GL_FUNCTION(glBufferData)
+#define glBufferSubData                        LOOKUP_GL_FUNCTION(glBufferSubData)
+#define glCheckFramebufferStatusEXT            LOOKUP_GL_FUNCTION(glCheckFramebufferStatus)
+#define glCompileShader                        LOOKUP_GL_FUNCTION(glCompileShader)
+#define glCreateProgram                        LOOKUP_GL_FUNCTION(glCreateProgram)
+#define glCreateShader                         LOOKUP_GL_FUNCTION(glCreateShader)
+#define glDeleteBuffers                        LOOKUP_GL_FUNCTION(glDeleteBuffers)
+#define glDeleteFramebuffersEXT                LOOKUP_GL_FUNCTION(glDeleteFramebuffers)
+#define glDeleteProgram                        LOOKUP_GL_FUNCTION(glDeleteProgram)
+#define glDeleteRenderbuffersEXT               LOOKUP_GL_FUNCTION(glDeleteRenderbuffers)
+#define glDeleteShader                         LOOKUP_GL_FUNCTION(glDeleteShader)
+#define glDetachShader                         LOOKUP_GL_FUNCTION(glDetachShader)
+#define glDisableVertexAttribArray             LOOKUP_GL_FUNCTION(glDisableVertexAttribArray)
+#define glEnableVertexAttribArray              LOOKUP_GL_FUNCTION(glEnableVertexAttribArray)
+#define glFramebufferRenderbufferEXT           LOOKUP_GL_FUNCTION(glFramebufferRenderbuffer)
+#define glFramebufferTexture2DEXT              LOOKUP_GL_FUNCTION(glFramebufferTexture2D)
+#define glGenBuffers                           LOOKUP_GL_FUNCTION(glGenBuffers)
+#define glGenerateMipmapEXT                    LOOKUP_GL_FUNCTION(glGenerateMipmap)
+#define glGenFramebuffersEXT                   LOOKUP_GL_FUNCTION(glGenFramebuffers)
+#define glGenRenderbuffersEXT                  LOOKUP_GL_FUNCTION(glGenRenderbuffers)
+#define glGetActiveAttrib                      LOOKUP_GL_FUNCTION(glGetActiveAttrib)
+#define glGetActiveUniform                     LOOKUP_GL_FUNCTION(glGetActiveUniform)
+#define glGetAttachedShaders                   LOOKUP_GL_FUNCTION(glGetAttachedShaders)
+#define glGetAttribLocation                    LOOKUP_GL_FUNCTION(glGetAttribLocation)
+#define glGetBufferParameteriv                 LOOKUP_GL_FUNCTION(glGetBufferParameteriv)
+#define glGetBufferParameterivEXT              LOOKUP_GL_FUNCTION(glGetBufferParameteriv)
+#define glGetFramebufferAttachmentParameterivEXT LOOKUP_GL_FUNCTION(glGetFramebufferAttachmentParameteriv)
+#define glGetProgramInfoLog                    LOOKUP_GL_FUNCTION(glGetProgramInfoLog)
+#define glGetProgramiv                         LOOKUP_GL_FUNCTION(glGetProgramiv)
+#define glGetRenderbufferParameterivEXT        LOOKUP_GL_FUNCTION(glGetRenderbufferParameteriv)
+#define glGetShaderInfoLog                     LOOKUP_GL_FUNCTION(glGetShaderInfoLog)
+#define glGetShaderiv                          LOOKUP_GL_FUNCTION(glGetShaderiv)
+#define glGetShaderSource                      LOOKUP_GL_FUNCTION(glGetShaderSource)
+#define glGetUniformfv                         LOOKUP_GL_FUNCTION(glGetUniformfv)
+#define glGetUniformiv                         LOOKUP_GL_FUNCTION(glGetUniformiv)
+#define glGetUniformLocation                   LOOKUP_GL_FUNCTION(glGetUniformLocation)
+#define glGetVertexAttribfv                    LOOKUP_GL_FUNCTION(glGetVertexAttribfv)
+#define glGetVertexAttribiv                    LOOKUP_GL_FUNCTION(glGetVertexAttribiv)
+#define glGetVertexAttribPointerv              LOOKUP_GL_FUNCTION(glGetVertexAttribPointerv)
+#define glIsBuffer                             LOOKUP_GL_FUNCTION(glIsBuffer)
+#define glIsFramebufferEXT                     LOOKUP_GL_FUNCTION(glIsFramebuffer)
+#define glIsProgram                            LOOKUP_GL_FUNCTION(glIsProgram)
+#define glIsRenderbufferEXT                    LOOKUP_GL_FUNCTION(glIsRenderbuffer)
+#define glIsShader                             LOOKUP_GL_FUNCTION(glIsShader)
+#define glLinkProgram                          LOOKUP_GL_FUNCTION(glLinkProgram)
+#define glRenderbufferStorageEXT               LOOKUP_GL_FUNCTION(glRenderbufferStorage)
+#define glRenderbufferStorageMultisampleEXT    LOOKUP_GL_FUNCTION(glRenderbufferStorageMultisample)
+#define glSampleCoverage                       LOOKUP_GL_FUNCTION(glSampleCoverage)
+#define glShaderSource                         LOOKUP_GL_FUNCTION(glShaderSource)
+#define glStencilFuncSeparate                  LOOKUP_GL_FUNCTION(glStencilFuncSeparate)
+#define glStencilMaskSeparate                  LOOKUP_GL_FUNCTION(glStencilMaskSeparate)
+#define glStencilOpSeparate                    LOOKUP_GL_FUNCTION(glStencilOpSeparate)
+#define glUniform1f                            LOOKUP_GL_FUNCTION(glUniform1f)
+#define glUniform1fv                           LOOKUP_GL_FUNCTION(glUniform1fv)
+#define glUniform1i                            LOOKUP_GL_FUNCTION(glUniform1i)
+#define glUniform1iv                           LOOKUP_GL_FUNCTION(glUniform1iv)
+#define glUniform2f                            LOOKUP_GL_FUNCTION(glUniform2f)
+#define glUniform2fv                           LOOKUP_GL_FUNCTION(glUniform2fv)
+#define glUniform2i                            LOOKUP_GL_FUNCTION(glUniform2i)
+#define glUniform2iv                           LOOKUP_GL_FUNCTION(glUniform2iv)
+#define glUniform3f                            LOOKUP_GL_FUNCTION(glUniform3f)
+#define glUniform3fv                           LOOKUP_GL_FUNCTION(glUniform3fv)
+#define glUniform3i                            LOOKUP_GL_FUNCTION(glUniform3i)
+#define glUniform3iv                           LOOKUP_GL_FUNCTION(glUniform3iv)
+#define glUniform4f                            LOOKUP_GL_FUNCTION(glUniform4f)
+#define glUniform4fv                           LOOKUP_GL_FUNCTION(glUniform4fv)
+#define glUniform4i                            LOOKUP_GL_FUNCTION(glUniform4i)
+#define glUniform4iv                           LOOKUP_GL_FUNCTION(glUniform4iv)
+#define glUniformMatrix2fv                     LOOKUP_GL_FUNCTION(glUniformMatrix2fv)
+#define glUniformMatrix3fv                     LOOKUP_GL_FUNCTION(glUniformMatrix3fv)
+#define glUniformMatrix4fv                     LOOKUP_GL_FUNCTION(glUniformMatrix4fv)
+#define glUseProgram                           LOOKUP_GL_FUNCTION(glUseProgram)
+#define glValidateProgram                      LOOKUP_GL_FUNCTION(glValidateProgram)
+#define glVertexAttrib1f                       LOOKUP_GL_FUNCTION(glVertexAttrib1f)
+#define glVertexAttrib1fv                      LOOKUP_GL_FUNCTION(glVertexAttrib1fv)
+#define glVertexAttrib2f                       LOOKUP_GL_FUNCTION(glVertexAttrib2f)
+#define glVertexAttrib2fv                      LOOKUP_GL_FUNCTION(glVertexAttrib2fv)
+#define glVertexAttrib3f                       LOOKUP_GL_FUNCTION(glVertexAttrib3f)
+#define glVertexAttrib3fv                      LOOKUP_GL_FUNCTION(glVertexAttrib3fv)
+#define glVertexAttrib4f                       LOOKUP_GL_FUNCTION(glVertexAttrib4f)
+#define glVertexAttrib4fv                      LOOKUP_GL_FUNCTION(glVertexAttrib4fv)
+#define glVertexAttribPointer                  LOOKUP_GL_FUNCTION(glVertexAttribPointer)
+#endif
diff --git a/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp b/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp
new file mode 100644 (file)
index 0000000..17fc334
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 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(ACCELERATED_2D_CANVAS) || ENABLE(WEBGL)
+
+#include "DrawingBuffer.h"
+
+#include "Extensions3D.h"
+
+namespace WebCore {
+
+DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
+                             const IntSize& size,
+                             bool multisampleExtensionSupported,
+                             bool packedDepthStencilExtensionSupported)
+    : m_context(context)
+    , m_size(-1, -1)
+    , m_multisampleExtensionSupported(multisampleExtensionSupported)
+    , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
+    , m_fbo(context->createFramebuffer())
+    , m_colorBuffer(0)
+    , m_depthStencilBuffer(0)
+    , m_multisampleFBO(0)
+    , m_multisampleColorBuffer(0)
+{
+    ASSERT(m_fbo);
+    if (!m_fbo) {
+        clear();
+        return;
+    }
+        
+    // create a texture to render into
+    m_colorBuffer = context->createTexture();
+    context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
+    context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+    context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+    context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+    context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+    context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+    
+    // Create the FBO
+    m_fbo = context->createFramebuffer();
+    ASSERT(m_fbo);
+    if (!m_fbo) {
+        clear();
+        return;
+    }
+
+    createSecondaryBuffers();
+    reset(size);
+}
+
+DrawingBuffer::~DrawingBuffer()
+{
+    clear();
+}
+
+void DrawingBuffer::didReset()
+{
+}
+
+Platform3DObject DrawingBuffer::platformColorBuffer() const
+{
+    return m_colorBuffer;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/gtk/GraphicsContext3DGtk.cpp b/Source/WebCore/platform/graphics/gtk/GraphicsContext3DGtk.cpp
new file mode 100644 (file)
index 0000000..8e03ad7
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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"
+#include "GraphicsContext3D.h"
+
+#if ENABLE(WEBGL)
+
+#include "Extensions3DOpenGL.h"
+#include "GraphicsContext3DInternal.h"
+#include "OpenGLShims.h"
+#include "ShaderLang.h"
+#include <wtf/NotFound.h>
+
+namespace WebCore {
+
+PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+{
+    // This implementation doesn't currently support rendering directly to the HostWindow.
+    if (renderStyle == RenderDirectlyToHostWindow)
+        return 0;
+
+    GraphicsContext3DInternal* internal = GraphicsContext3DInternal::create();
+    if (!internal)
+        return 0;
+
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));
+    context->m_internal.set(internal);
+    return context.release();
+}
+
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool)
+    : m_currentWidth(0)
+    , m_currentHeight(0)
+    , m_attrs(attributes)
+    , m_texture(0)
+    , m_fbo(0)
+    , m_depthStencilBuffer(0)
+    , m_boundFBO(0)
+    , m_multisampleFBO(0)
+    , m_multisampleDepthStencilBuffer(0)
+    , m_multisampleColorBuffer(0)
+{
+    GraphicsContext3DInternal::addActiveGraphicsContext(this);
+
+    validateAttributes();
+
+    // Create a texture to render into.
+    ::glGenTextures(1, &m_texture);
+    ::glBindTexture(GL_TEXTURE_2D, m_texture);
+    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+    ::glBindTexture(GL_TEXTURE_2D, 0);
+
+    // Create an FBO.
+    ::glGenFramebuffersEXT(1, &m_fbo);
+    ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+
+    m_boundFBO = m_fbo;
+    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+        ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
+    
+    // Create a multisample FBO.
+    if (m_attrs.antialias) {
+        ::glGenFramebuffersEXT(1, &m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+        m_boundFBO = m_multisampleFBO;
+        ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
+        if (m_attrs.stencil || m_attrs.depth)
+            ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+    }
+
+    // ANGLE initialization.
+    ShBuiltInResources ANGLEResources;
+    ShInitBuiltInResources(&ANGLEResources);
+
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
+    getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
+    getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
+    getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
+    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);
+    ::glEnable(GL_POINT_SPRITE);
+    ::glClearColor(0, 0, 0, 0);
+}
+
+GraphicsContext3D::~GraphicsContext3D()
+{
+    GraphicsContext3DInternal::removeActiveGraphicsContext(this);
+    if (!m_internal->m_context)
+        return;
+
+    makeContextCurrent();
+    ::glDeleteTextures(1, &m_texture);
+    if (m_attrs.antialias) {
+        ::glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer);
+        if (m_attrs.stencil || m_attrs.depth)
+            ::glDeleteRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+        ::glDeleteFramebuffersEXT(1, &m_multisampleFBO);
+    } else {
+        if (m_attrs.stencil || m_attrs.depth)
+            ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer);
+    }
+    ::glDeleteFramebuffersEXT(1, &m_fbo);
+}
+
+void GraphicsContext3D::makeContextCurrent()
+{
+    if (!m_internal)
+        return;
+    m_internal->makeContextCurrent();
+}
+
+PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
+{
+    return m_internal->m_context;
+}
+
+bool GraphicsContext3D::isGLES2Compliant() const
+{
+    return false;
+}
+
+}
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.cpp b/Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.cpp
new file mode 100644 (file)
index 0000000..de24554
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "GraphicsContext3DInternal.h"
+
+#if ENABLE(WEBGL)
+
+#include "GraphicsContext3D.h"
+#include "OpenGLShims.h"
+#include <GL/glx.h>
+#include <dlfcn.h>
+
+// We do not want to call glXMakeContextCurrent using different Display pointers,
+// because it might lead to crashes in some drivers (fglrx). We use a shared display
+// pointer here.
+static Display* gSharedDisplay = 0;
+static Display* sharedDisplay()
+{
+    if (!gSharedDisplay)
+        gSharedDisplay = XOpenDisplay(0);
+    return gSharedDisplay;
+}
+
+namespace WebCore {
+
+// Because of driver bugs, exiting the program when there are active pbuffers
+// can crash the X server (this has been observed with the official Nvidia drivers).
+// We need to ensure that we clean everything up on exit. There are several reasons
+// that GraphicsContext3Ds will still be alive at exit, including user error (memory
+// leaks) and the page cache. In any case, we don't want the X server to crash.
+static bool cleaningUpAtExit = false;
+static Vector<GraphicsContext3D*>& activeGraphicsContexts()
+{
+    DEFINE_STATIC_LOCAL(Vector<GraphicsContext3D*>, contexts, ());
+    return contexts;
+}
+
+void GraphicsContext3DInternal::addActiveGraphicsContext(GraphicsContext3D* context)
+{
+    static bool addedAtExitHandler = false;
+    if (!addedAtExitHandler) {
+        atexit(&GraphicsContext3DInternal::cleanupActiveContextsAtExit);
+        addedAtExitHandler = true;
+    }
+    activeGraphicsContexts().append(context);
+}
+
+void GraphicsContext3DInternal::removeActiveGraphicsContext(GraphicsContext3D* context)
+{
+    if (cleaningUpAtExit)
+        return;
+
+    Vector<GraphicsContext3D*>& contexts = activeGraphicsContexts();
+    size_t location = contexts.find(context);
+    if (location != WTF::notFound)
+        contexts.remove(location);
+}
+
+void GraphicsContext3DInternal::cleanupActiveContextsAtExit()
+{
+    cleaningUpAtExit = true;
+
+    Vector<GraphicsContext3D*>& contexts = activeGraphicsContexts();
+    for (size_t i = 0; i < contexts.size(); i++)
+        contexts[i]->~GraphicsContext3D();
+
+    if (!gSharedDisplay)
+        return;
+    XCloseDisplay(gSharedDisplay);
+    gSharedDisplay = 0;
+}
+
+GraphicsContext3DInternal* GraphicsContext3DInternal::create()
+{
+    if (!sharedDisplay())
+        return 0;
+
+    static bool initialized = false;
+    static bool success = true;
+    if (!initialized) {
+        success = initializeOpenGLShims();
+        initialized = true;
+    }
+    if (!success)
+        return 0;
+
+    GraphicsContext3DInternal* internal = createPbufferContext();
+    if (!internal)
+        internal = createPixmapContext();
+    if (!internal)
+        return 0;
+
+    // The GraphicsContext3D constructor requires that this context is the current OpenGL context.
+    internal->makeContextCurrent();
+    return internal;
+}
+
+GraphicsContext3DInternal* GraphicsContext3DInternal::createPbufferContext()
+{
+    int fbConfigAttributes[] = {
+        GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
+        GLX_RENDER_TYPE, GLX_RGBA_BIT,
+        GLX_RED_SIZE, 1,
+        GLX_GREEN_SIZE, 1,
+        GLX_BLUE_SIZE, 1,
+        GLX_ALPHA_SIZE, 1,
+        GLX_DEPTH_SIZE, 1,
+        GLX_STENCIL_SIZE, 1,
+        GLX_SAMPLE_BUFFERS, 1,
+        GLX_DOUBLEBUFFER, GL_FALSE,
+        GLX_SAMPLES, 4,
+        0
+    };
+    int returnedElements;
+    GLXFBConfig* configs = glXChooseFBConfig(sharedDisplay(), 0, fbConfigAttributes, &returnedElements);
+    if (!configs) {
+        fbConfigAttributes[20] = 0; // Attempt without anti-aliasing.
+        configs = glXChooseFBConfig(sharedDisplay(), 0, fbConfigAttributes, &returnedElements);
+    }
+    if (!returnedElements) {
+        XFree(configs);
+        return 0;
+    }
+
+    // We will be rendering to a texture, so our pbuffer does not need to be large.
+    static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 };
+    GLXPbuffer pbuffer = glXCreatePbuffer(sharedDisplay(), configs[0], pbufferAttributes);
+    if (!pbuffer) {
+        XFree(configs);
+        return 0;
+    }
+
+    GLXContext context = glXCreateNewContext(sharedDisplay(), configs[0], GLX_RGBA_TYPE, 0, GL_TRUE);
+    XFree(configs);
+    if (!context)
+        return 0;
+    return new GraphicsContext3DInternal(context, pbuffer);
+}
+
+GraphicsContext3DInternal* GraphicsContext3DInternal::createPixmapContext()
+{
+    static int visualAttributes[] = {
+        GLX_RGBA,
+        GLX_RED_SIZE, 1,
+        GLX_GREEN_SIZE, 1,
+        GLX_BLUE_SIZE, 1,
+        GLX_ALPHA_SIZE, 1,
+        GLX_DOUBLEBUFFER,
+        0
+    };
+
+    XVisualInfo* visualInfo = glXChooseVisual(sharedDisplay(), DefaultScreen(sharedDisplay()), visualAttributes);
+    if (!visualInfo)
+        return 0;
+    GLXContext context = glXCreateContext(sharedDisplay(), visualInfo, 0, GL_TRUE);
+    if (!context) {
+        XFree(visualInfo);
+        return 0;
+    }
+
+    Pixmap pixmap = XCreatePixmap(sharedDisplay(), DefaultRootWindow(sharedDisplay()), 1, 1, visualInfo->depth);
+    if (!pixmap) {
+        XFree(visualInfo);
+        return 0;
+    }
+
+    GLXPixmap glxPixmap = glXCreateGLXPixmap(sharedDisplay(), visualInfo, pixmap);
+    if (!glxPixmap) {
+        XFreePixmap(sharedDisplay(), pixmap);
+        XFree(visualInfo);
+        return 0;
+    }
+
+    return new GraphicsContext3DInternal(context, pixmap, glxPixmap);
+}
+
+GraphicsContext3DInternal::GraphicsContext3DInternal(GLXContext context, GLXPbuffer pbuffer)
+    : m_context(context)
+    , m_pbuffer(pbuffer)
+    , m_pixmap(0)
+    , m_glxPixmap(0)
+{
+}
+
+GraphicsContext3DInternal::GraphicsContext3DInternal(GLXContext context, Pixmap pixmap, GLXPixmap glxPixmap)
+    : m_context(context)
+    , m_pbuffer(0)
+    , m_pixmap(pixmap)
+    , m_glxPixmap(glxPixmap)
+{
+}
+
+GraphicsContext3DInternal::~GraphicsContext3DInternal()
+{
+    if (m_context) {
+        // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
+        // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+        ::glXMakeContextCurrent(sharedDisplay(), 0, 0, 0);
+        ::glXDestroyContext(sharedDisplay(), m_context);
+        m_context = 0;
+    }
+
+    if (m_pbuffer) {
+        ::glXDestroyPbuffer(sharedDisplay(), m_pbuffer);
+        m_pbuffer = 0;
+    }
+    if (m_glxPixmap) {
+        glXDestroyGLXPixmap(sharedDisplay(), m_glxPixmap);
+        m_glxPixmap = 0;
+    }
+    if (m_pixmap) {
+        XFreePixmap(sharedDisplay(), m_pixmap);
+        m_pixmap = 0;
+    }
+}
+
+void GraphicsContext3DInternal::makeContextCurrent()
+{
+    if (::glXGetCurrentContext() == m_context)
+        return;
+    if (!m_context)
+        return;
+    if (m_pbuffer) {
+        ::glXMakeCurrent(sharedDisplay(), m_pbuffer, m_context);
+        return;
+    }
+
+    ASSERT(m_glxPixmap);
+    ::glXMakeCurrent(sharedDisplay(), m_glxPixmap, m_context);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE_WEBGL
diff --git a/Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.h b/Source/WebCore/platform/graphics/gtk/GraphicsContext3DInternal.h
new file mode 100644 (file)
index 0000000..f4a60d9
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#ifndef GraphicsContext3DInternal_h
+#define GraphicsContext3DInternal_h
+
+typedef struct __GLXcontextRec *GLXContext;
+typedef unsigned long GLXPbuffer;
+typedef unsigned long GLXPixmap;
+typedef unsigned char GLubyte;
+typedef unsigned long Pixmap;
+
+namespace WebCore {
+
+class GraphicsContext3D;
+
+class GraphicsContext3DInternal {
+    public:
+    static GraphicsContext3DInternal* create();
+    ~GraphicsContext3DInternal();
+    void makeContextCurrent();
+
+    private:
+    friend class GraphicsContext3D;
+    static GraphicsContext3DInternal* createPbufferContext();
+    static GraphicsContext3DInternal* createPixmapContext();
+    GraphicsContext3DInternal(GLXContext, GLXPbuffer);
+    GraphicsContext3DInternal(GLXContext, Pixmap, GLXPixmap);
+
+    static void addActiveGraphicsContext(GraphicsContext3D*);
+    static void removeActiveGraphicsContext(GraphicsContext3D*);
+    static void cleanupActiveContextsAtExit();
+
+    GLXContext m_context;
+    GLXPbuffer m_pbuffer;
+    Pixmap m_pixmap;
+    GLXPixmap m_glxPixmap;
+};
+
+}
+
+#endif // GraphicsContext3DIternal_h
index 997c976..2a469a7 100644 (file)
@@ -90,8 +90,8 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)
     : m_currentWidth(0)
     , m_currentHeight(0)
-    , m_attrs(attrs)
     , m_contextObj(0)
+    , m_attrs(attrs)
     , m_texture(0)
     , m_compositorTexture(0)
     , m_fbo(0)
index e09534e..3927e41 100644 (file)
@@ -35,6 +35,8 @@
 #if PLATFORM(MAC)
 #include "ANGLE/ShaderLang.h"
 #include <OpenGL/gl.h>
+#elif PLATFORM(GTK)
+#include "OpenGLShims.h"
 #endif
 
 namespace WebCore {
@@ -134,7 +136,7 @@ void Extensions3DOpenGL::renderbufferStorageMultisample(unsigned long target, un
 Platform3DObject Extensions3DOpenGL::createVertexArrayOES()
 {
     m_context->makeContextCurrent();
-#if defined GL_APPLE_vertex_array_object && GL_APPLE_vertex_array_object
+#if !PLATFORM(GTK) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
     GLuint array = 0;
     glGenVertexArraysAPPLE(1, &array);
     return array;
@@ -149,7 +151,7 @@ void Extensions3DOpenGL::deleteVertexArrayOES(Platform3DObject array)
         return;
     
     m_context->makeContextCurrent();
-#if defined GL_APPLE_vertex_array_object && GL_APPLE_vertex_array_object
+#if !PLATFORM(GTK) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
     glDeleteVertexArraysAPPLE(1, &array);
 #endif
 }
@@ -160,7 +162,7 @@ GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
         return GL_FALSE;
     
     m_context->makeContextCurrent();
-#if defined GL_APPLE_vertex_array_object && GL_APPLE_vertex_array_object
+#if !PLATFORM(GTK) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
     return glIsVertexArrayAPPLE(array);
 #else
     return GL_FALSE;
@@ -173,7 +175,7 @@ void Extensions3DOpenGL::bindVertexArrayOES(Platform3DObject array)
         return;
 
     m_context->makeContextCurrent();
-#if defined GL_APPLE_vertex_array_object && GL_APPLE_vertex_array_object
+#if !PLATFORM(GTK) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
     glBindVertexArrayAPPLE(array);
 #endif
 }
index f831550..af46293 100644 (file)
 #include "Int32Array.h"
 #include "NotImplemented.h"
 #include "Uint8Array.h"
+#include <cstring>
+#include <wtf/UnusedParam.h>
+#include <wtf/text/CString.h>
 
 #if PLATFORM(MAC)
 #include <OpenGL/gl.h>
+#elif PLATFORM(GTK)
+#include "OpenGLShims.h"
 #endif
 
-#include <wtf/UnusedParam.h>
-#include <wtf/text/CString.h>
-
 namespace WebCore {
 
 void GraphicsContext3D::validateAttributes()
@@ -163,7 +165,7 @@ PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData()
 
 void GraphicsContext3D::reshape(int width, int height)
 {
-    if (!m_contextObj)
+    if (!platformGraphicsContext3D())
         return;
 
     if (width == m_currentWidth && height == m_currentHeight)
index 52b406c..c3dc076 100644 (file)
@@ -1,3 +1,20 @@
+2011-04-04  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] WebGL support
+        https://bugs.webkit.org/show_bug.cgi?id=31517
+
+        Add support for toggling WebGL at runtime when it's enabled.
+
+        * webkit/webkitwebsettings.cpp: Add the enable-webgl property. When ENABLE_WEBGL
+        is not enabled, it's a no-op.
+        (webkit_web_settings_class_init): Update to support enable-webgl.
+        (webkit_web_settings_set_property): Ditto.
+        (webkit_web_settings_get_property): Ditto.
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_update_settings): Ditto.
+
 2011-04-04  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Dan Bernstein.
index 5ace519..20567cc 100644 (file)
@@ -98,6 +98,7 @@ libwebkitgtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIBA
        $(LIBSOUP_LIBS) \
        $(LIBXML_LIBS) \
        $(LIBXSLT_LIBS) \
+       $(OPENGL_LIBS) \
        $(PANGO_LIBS) \
        $(PNG_LIBS) \
        $(SQLITE3_LIBS) \
index 3b4cf57..e833de9 100644 (file)
@@ -113,6 +113,7 @@ struct _WebKitWebSettingsPrivate {
     gboolean enable_hyperlink_auditing;
     gboolean enable_fullscreen;
     gboolean enable_dns_prefetching;
+    gboolean enable_webgl;
 };
 
 #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -166,7 +167,8 @@ enum {
     PROP_ENABLE_JAVA_APPLET,
     PROP_ENABLE_HYPERLINK_AUDITING,
     PROP_ENABLE_FULLSCREEN,
-    PROP_ENABLE_DNS_PREFETCHING
+    PROP_ENABLE_DNS_PREFETCHING,
+    PROP_ENABLE_WEBGL
 };
 
 // Create a default user agent string
@@ -912,6 +914,22 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
                                                          _("Whether the Mozilla style API should be enabled."),
                                                          FALSE,
                                                          flags));
+    /**
+    * WebKitWebSettings:enable-webgl:
+    *
+    * Enable or disable support for WebGL on pages. WebGL is an experimental
+    * proposal for allowing web pages to use OpenGL ES-like calls directly. The
+    * standard is currently a work-in-progress by the Khronos Group.
+    *
+    * Since: 1.3.14
+    */
+    g_object_class_install_property(gobject_class,
+                                    PROP_ENABLE_WEBGL,
+                                    g_param_spec_boolean("enable-webgl",
+                                                         _("Enable WebGL"),
+                                                         _("Whether WebGL content should be rendered"),
+                                                         FALSE,
+                                                         flags));
 
     /**
     * WebKitWebSettings:enable-dns-prefetching
@@ -1117,6 +1135,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
     case PROP_ENABLE_DNS_PREFETCHING:
         priv->enable_dns_prefetching = g_value_get_boolean(value);
         break;
+    case PROP_ENABLE_WEBGL:
+        priv->enable_webgl = g_value_get_boolean(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -1270,6 +1291,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
     case PROP_ENABLE_DNS_PREFETCHING:
         g_value_set_boolean(value, priv->enable_dns_prefetching);
         break;
+    case PROP_ENABLE_WEBGL:
+        g_value_set_boolean(value, priv->enable_webgl);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
index 9c1a650..30b8764 100644 (file)
@@ -3248,7 +3248,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
         enableXSSAuditor, enableSpatialNavigation, enableFrameFlattening, javascriptCanOpenWindows,
         javaScriptCanAccessClipboard, enableOfflineWebAppCache,
         enableUniversalAccessFromFileURI, enableFileAccessFromFileURI,
-        enableDOMPaste, tabKeyCyclesThroughElements,
+        enableDOMPaste, tabKeyCyclesThroughElements, enableWebGL,
         enableSiteSpecificQuirks, usePageCache, enableJavaApplet,
         enableHyperlinkAuditing, enableFullscreen, enableDNSPrefetching;
 
@@ -3292,6 +3292,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
                  "spell-checking-languages", &defaultSpellCheckingLanguages,
                  "enable-fullscreen", &enableFullscreen,
                  "enable-dns-prefetching", &enableDNSPrefetching,
+                 "enable-webgl", &enableWebGL,
                  NULL);
 
     settings->setDefaultTextEncodingName(defaultEncoding);
@@ -3329,14 +3330,20 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
     settings->setUsesPageCache(usePageCache);
     settings->setJavaEnabled(enableJavaApplet);
     settings->setHyperlinkAuditingEnabled(enableHyperlinkAuditing);
+    settings->setDNSPrefetchingEnabled(enableDNSPrefetching);
+
 #if ENABLE(FULLSCREEN_API)
     settings->setFullScreenEnabled(enableFullscreen);
 #endif
+
 #if ENABLE(SPELLCHECK)
     WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient());
     static_cast<WebKit::TextCheckerClientEnchant*>(client->textChecker())->updateSpellCheckingLanguage(defaultSpellCheckingLanguages);
 #endif
-    settings->setDNSPrefetchingEnabled(enableDNSPrefetching);
+
+#if ENABLE(WEBGL)
+    settings->setWebGLEnabled(enableWebGL);
+#endif
 
     Page* page = core(webView);
     if (page)
@@ -3454,12 +3461,19 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
         settings->setJavaEnabled(g_value_get_boolean(&value));
     else if (name == g_intern_string("enable-hyperlink-auditing"))
         settings->setHyperlinkAuditingEnabled(g_value_get_boolean(&value));
+
 #if ENABLE(SPELLCHECK)
     else if (name == g_intern_string("spell-checking-languages")) {
         WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient());
         static_cast<WebKit::TextCheckerClientEnchant*>(client->textChecker())->updateSpellCheckingLanguage(g_value_get_string(&value));
     }
 #endif
+
+#if ENABLE(WEBGL)
+    else if (name == g_intern_string("enable-webgl"))
+        settings->setWebGLEnabled(g_value_get_boolean(&value));
+#endif
+
     else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name))
         g_warning("Unexpected setting '%s'", name);
     g_value_unset(&value);
index 7b8a2c2..de841b6 100644 (file)
@@ -1,3 +1,15 @@
+2011-04-04  Martin Robinson  <mrobinson@igalia.com>
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] WebGL support
+        https://bugs.webkit.org/show_bug.cgi?id=31517
+
+        Add support to the DRT for turning on WebGL when a layout tests requests it.
+
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::overridePreference): Allow turning on WebGL from tests.
+
 2011-04-04  Chang Shu  <cshu@webkit.org>
 
         Reviewed by Darin Adler.
index 0979dd5..29742be 100644 (file)
@@ -778,6 +778,8 @@ void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value
         propertyName = "enable-plugins";
     else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled"))
         propertyName = "enable-hyperlink-auditing";
+    else if (g_str_equal(originalName.get(), "WebKitWebGLEnabled"))
+        propertyName = "enable-webgl";
     else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
         DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
         return;
index ddddf0b..fe14adc 100644 (file)
@@ -371,6 +371,13 @@ AC_ARG_ENABLE(webgl,
               [], [enable_webgl="no"])
 AC_MSG_RESULT([$enable_webgl])
 
+if test "$enable_webgl" = "yes"; then
+    AC_CHECK_HEADERS([GL/gl.h], [], AC_MSG_ERROR([OpenGL header not found]))
+    AC_CHECK_HEADERS([GL/glx.h], [], AC_MSG_ERROR([GLX header not found]))
+    OPENGL_LIBS=-lGL
+fi
+AC_SUBST([OPENGL_LIBS])
+
 # check whether to enable channel messaging support
 AC_MSG_CHECKING([whether to enable HTML5 Channel Messaging support])
 AC_ARG_ENABLE(channel_messaging,