[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

cmarrin at apple.com cmarrin at apple.com
Wed Dec 22 13:00:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cc2cc3c0f1f82d2456bc99decff44f58dc06f4ad
Author: cmarrin at apple.com <cmarrin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 4 00:49:40 2010 +0000

    2010-09-03  Paul Sawaya  <psawaya at apple.com>
    
            Reviewed by Chris Marrin.
    
            Refactored out Mac specific code for platform/graphics/mac/GraphicsContext3D.mm file.
            Left general OpenGL code in platform/graphics/GraphicsContext3DOpenGL.cpp.
            https://bugs.webkit.org/show_bug.cgi?id=30625
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66781 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c8afbbb..1bc87b1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,159 @@
+2010-09-03  Paul Sawaya  <psawaya at apple.com>
+
+        Reviewed by Chris Marrin.
+
+        Refactored out Mac specific code for platform/graphics/mac/GraphicsContext3D.mm file.
+        Left general OpenGL code in platform/graphics/GraphicsContext3DOpenGL.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=30625
+
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/WebGLObject.cpp:
+        (WebCore::WebGLObject::deleteObject):
+        * platform/graphics/ANGLEWebKitBridge.h:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/GraphicsContext3DOpenGL.cpp: Copied from platform/graphics/mac/GraphicsContext3DMac.mm.
+        (WebCore::GraphicsContext3D::prepareTexture):
+        (WebCore::GraphicsContext3D::activeTexture):
+        (WebCore::GraphicsContext3D::attachShader):
+        (WebCore::GraphicsContext3D::bindAttribLocation):
+        (WebCore::GraphicsContext3D::bindBuffer):
+        (WebCore::GraphicsContext3D::bindFramebuffer):
+        (WebCore::GraphicsContext3D::bindRenderbuffer):
+        (WebCore::GraphicsContext3D::bindTexture):
+        (WebCore::GraphicsContext3D::blendColor):
+        (WebCore::GraphicsContext3D::blendEquation):
+        (WebCore::GraphicsContext3D::blendEquationSeparate):
+        (WebCore::GraphicsContext3D::blendFunc):
+        (WebCore::GraphicsContext3D::blendFuncSeparate):
+        (WebCore::GraphicsContext3D::bufferData):
+        (WebCore::GraphicsContext3D::bufferSubData):
+        (WebCore::GraphicsContext3D::checkFramebufferStatus):
+        (WebCore::GraphicsContext3D::clearColor):
+        (WebCore::GraphicsContext3D::clear):
+        (WebCore::GraphicsContext3D::clearDepth):
+        (WebCore::GraphicsContext3D::clearStencil):
+        (WebCore::GraphicsContext3D::colorMask):
+        (WebCore::GraphicsContext3D::compileShader):
+        (WebCore::GraphicsContext3D::copyTexImage2D):
+        (WebCore::GraphicsContext3D::copyTexSubImage2D):
+        (WebCore::GraphicsContext3D::cullFace):
+        (WebCore::GraphicsContext3D::depthFunc):
+        (WebCore::GraphicsContext3D::depthMask):
+        (WebCore::GraphicsContext3D::depthRange):
+        (WebCore::GraphicsContext3D::detachShader):
+        (WebCore::GraphicsContext3D::disable):
+        (WebCore::GraphicsContext3D::disableVertexAttribArray):
+        (WebCore::GraphicsContext3D::drawArrays):
+        (WebCore::GraphicsContext3D::drawElements):
+        (WebCore::GraphicsContext3D::enable):
+        (WebCore::GraphicsContext3D::enableVertexAttribArray):
+        (WebCore::GraphicsContext3D::finish):
+        (WebCore::GraphicsContext3D::flush):
+        (WebCore::GraphicsContext3D::framebufferRenderbuffer):
+        (WebCore::GraphicsContext3D::framebufferTexture2D):
+        (WebCore::GraphicsContext3D::frontFace):
+        (WebCore::GraphicsContext3D::generateMipmap):
+        (WebCore::GraphicsContext3D::getActiveAttrib):
+        (WebCore::GraphicsContext3D::getActiveUniform):
+        (WebCore::GraphicsContext3D::getAttachedShaders):
+        (WebCore::GraphicsContext3D::getAttribLocation):
+        (WebCore::GraphicsContext3D::getError):
+        (WebCore::GraphicsContext3D::getString):
+        (WebCore::GraphicsContext3D::hint):
+        (WebCore::GraphicsContext3D::isBuffer):
+        (WebCore::GraphicsContext3D::isEnabled):
+        (WebCore::GraphicsContext3D::isFramebuffer):
+        (WebCore::GraphicsContext3D::isProgram):
+        (WebCore::GraphicsContext3D::isRenderbuffer):
+        (WebCore::GraphicsContext3D::isShader):
+        (WebCore::GraphicsContext3D::isTexture):
+        (WebCore::GraphicsContext3D::lineWidth):
+        (WebCore::GraphicsContext3D::linkProgram):
+        (WebCore::GraphicsContext3D::pixelStorei):
+        (WebCore::GraphicsContext3D::polygonOffset):
+        (WebCore::GraphicsContext3D::readPixels):
+        (WebCore::GraphicsContext3D::releaseShaderCompiler):
+        (WebCore::GraphicsContext3D::renderbufferStorage):
+        (WebCore::GraphicsContext3D::sampleCoverage):
+        (WebCore::GraphicsContext3D::scissor):
+        (WebCore::GraphicsContext3D::shaderSource):
+        (WebCore::GraphicsContext3D::stencilFunc):
+        (WebCore::GraphicsContext3D::stencilFuncSeparate):
+        (WebCore::GraphicsContext3D::stencilMask):
+        (WebCore::GraphicsContext3D::stencilMaskSeparate):
+        (WebCore::GraphicsContext3D::stencilOp):
+        (WebCore::GraphicsContext3D::stencilOpSeparate):
+        (WebCore::GraphicsContext3D::texParameterf):
+        (WebCore::GraphicsContext3D::texParameteri):
+        (WebCore::GraphicsContext3D::uniform1f):
+        (WebCore::GraphicsContext3D::uniform1fv):
+        (WebCore::GraphicsContext3D::uniform2f):
+        (WebCore::GraphicsContext3D::uniform2fv):
+        (WebCore::GraphicsContext3D::uniform3f):
+        (WebCore::GraphicsContext3D::uniform3fv):
+        (WebCore::GraphicsContext3D::uniform4f):
+        (WebCore::GraphicsContext3D::uniform4fv):
+        (WebCore::GraphicsContext3D::uniform1i):
+        (WebCore::GraphicsContext3D::uniform1iv):
+        (WebCore::GraphicsContext3D::uniform2i):
+        (WebCore::GraphicsContext3D::uniform2iv):
+        (WebCore::GraphicsContext3D::uniform3i):
+        (WebCore::GraphicsContext3D::uniform3iv):
+        (WebCore::GraphicsContext3D::uniform4i):
+        (WebCore::GraphicsContext3D::uniform4iv):
+        (WebCore::GraphicsContext3D::uniformMatrix2fv):
+        (WebCore::GraphicsContext3D::uniformMatrix3fv):
+        (WebCore::GraphicsContext3D::uniformMatrix4fv):
+        (WebCore::GraphicsContext3D::useProgram):
+        (WebCore::GraphicsContext3D::validateProgram):
+        (WebCore::GraphicsContext3D::vertexAttrib1f):
+        (WebCore::GraphicsContext3D::vertexAttrib1fv):
+        (WebCore::GraphicsContext3D::vertexAttrib2f):
+        (WebCore::GraphicsContext3D::vertexAttrib2fv):
+        (WebCore::GraphicsContext3D::vertexAttrib3f):
+        (WebCore::GraphicsContext3D::vertexAttrib3fv):
+        (WebCore::GraphicsContext3D::vertexAttrib4f):
+        (WebCore::GraphicsContext3D::vertexAttrib4fv):
+        (WebCore::GraphicsContext3D::vertexAttribPointer):
+        (WebCore::GraphicsContext3D::viewport):
+        (WebCore::GraphicsContext3D::getBooleanv):
+        (WebCore::GraphicsContext3D::getBufferParameteriv):
+        (WebCore::GraphicsContext3D::getFloatv):
+        (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv):
+        (WebCore::GraphicsContext3D::getIntegerv):
+        (WebCore::GraphicsContext3D::getProgramiv):
+        (WebCore::GraphicsContext3D::getProgramInfoLog):
+        (WebCore::GraphicsContext3D::getRenderbufferParameteriv):
+        (WebCore::GraphicsContext3D::getShaderiv):
+        (WebCore::GraphicsContext3D::getShaderInfoLog):
+        (WebCore::GraphicsContext3D::getShaderSource):
+        (WebCore::GraphicsContext3D::getTexParameterfv):
+        (WebCore::GraphicsContext3D::getTexParameteriv):
+        (WebCore::GraphicsContext3D::getUniformfv):
+        (WebCore::GraphicsContext3D::getUniformiv):
+        (WebCore::GraphicsContext3D::getUniformLocation):
+        (WebCore::GraphicsContext3D::getVertexAttribfv):
+        (WebCore::GraphicsContext3D::getVertexAttribiv):
+        (WebCore::GraphicsContext3D::getVertexAttribOffset):
+        (WebCore::GraphicsContext3D::texImage2D):
+        (WebCore::GraphicsContext3D::texSubImage2D):
+        (WebCore::GraphicsContext3D::createBuffer):
+        (WebCore::GraphicsContext3D::createFramebuffer):
+        (WebCore::GraphicsContext3D::createProgram):
+        (WebCore::GraphicsContext3D::createRenderbuffer):
+        (WebCore::GraphicsContext3D::createShader):
+        (WebCore::GraphicsContext3D::createTexture):
+        (WebCore::GraphicsContext3D::deleteBuffer):
+        (WebCore::GraphicsContext3D::deleteFramebuffer):
+        (WebCore::GraphicsContext3D::deleteProgram):
+        (WebCore::GraphicsContext3D::deleteRenderbuffer):
+        (WebCore::GraphicsContext3D::deleteShader):
+        (WebCore::GraphicsContext3D::deleteTexture):
+        * platform/graphics/mac/GraphicsContext3DMac.mm:
+        (WebCore::GraphicsContext3D::ensureContext):
+        (WebCore::GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses):
+
 2010-09-03  James Robinson  <jamesr at chromium.org>
 
         Reviewed by Kenneth Russell.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 3321cbb..3497634 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2599,6 +2599,7 @@
             'platform/graphics/GraphicsContext.cpp',
             'platform/graphics/GraphicsContext.h',
             'platform/graphics/GraphicsContext3D.cpp',
+            'platform/graphics/GraphicsContext3DOpenGL.cpp',
             'platform/graphics/GraphicsContext3D.h',
             'platform/graphics/GraphicsContextPrivate.h',
             'platform/graphics/GraphicsLayer.cpp',
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index c8b88ec..9e5b103 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5369,6 +5369,7 @@
 		FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FC1059C21100D999DD /* MathMLNames.cpp */; };
 		FAC12CC41120DA6900DACC36 /* RenderMathMLSubSup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */; };
 		FAC12CC51120DA6900DACC36 /* RenderMathMLSubSup.h in Headers */ = {isa = PBXBuildFile; fileRef = FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */; };
+		FB58CB79122F153800878851 /* GraphicsContext3DOpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */; };
 		FE6FD4880F676E5700092873 /* Coordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD4850F676E5700092873 /* Coordinates.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FE6FD48D0F676E9300092873 /* JSCoordinates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */; };
 		FE6FD48E0F676E9300092873 /* JSCoordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD48C0F676E9300092873 /* JSCoordinates.h */; };
@@ -11240,6 +11241,7 @@
 		FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
 		FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLSubSup.cpp; sourceTree = "<group>"; };
 		FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSubSup.h; sourceTree = "<group>"; };
+		FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGL.cpp; sourceTree = "<group>"; };
 		FE49EF970DC51462004266E1 /* DashboardSupportCSSPropertyNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DashboardSupportCSSPropertyNames.in; sourceTree = "<group>"; };
 		FE6FD4850F676E5700092873 /* Coordinates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Coordinates.h; sourceTree = "<group>"; };
 		FE6FD4860F676E5700092873 /* Coordinates.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Coordinates.idl; sourceTree = "<group>"; };
@@ -15911,6 +15913,7 @@
 				B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
 				6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */,
 				49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */,
+				FB58CAEA1228586500878851 /* GraphicsContext3DOpenGL.cpp */,
 				A88FE3330E5EEE87008D8C0F /* GraphicsContextPrivate.h */,
 				0F580B090F12A2690051D689 /* GraphicsLayer.cpp */,
 				0F580B0A0F12A2690051D689 /* GraphicsLayer.h */,
@@ -20491,6 +20494,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
 			compatibilityVersion = "Xcode 2.4";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
@@ -22895,6 +22899,7 @@
 				898785B8122CA2A7003AABDA /* JSMetadataCallback.cpp in Sources */,
 				898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */,
 				898785F4122E1EAC003AABDA /* JSFileReaderSync.cpp in Sources */,
+				FB58CB79122F153800878851 /* GraphicsContext3DOpenGL.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/html/canvas/WebGLObject.cpp b/WebCore/html/canvas/WebGLObject.cpp
index 5fd5534..e83a968 100644
--- a/WebCore/html/canvas/WebGLObject.cpp
+++ b/WebCore/html/canvas/WebGLObject.cpp
@@ -60,7 +60,7 @@ void WebGLObject::deleteObject()
 {
     if (m_object) {
         if (m_context) {
-            m_context->graphicsContext3D()->makeContextCurrent();
+            m_context->graphicsContext3D()->ensureContext();
             deleteObjectImpl(m_object);
         }
         if (!m_attachmentCount)
diff --git a/WebCore/platform/graphics/ANGLEWebKitBridge.h b/WebCore/platform/graphics/ANGLEWebKitBridge.h
index d01de8f..2033c4d 100644
--- a/WebCore/platform/graphics/ANGLEWebKitBridge.h
+++ b/WebCore/platform/graphics/ANGLEWebKitBridge.h
@@ -38,6 +38,7 @@ enum ANGLEShaderType {
     SHADER_TYPE_FRAGMENT = EShLangFragment
 };
 
+
 class ANGLEWebKitBridge {
 public:
 
diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
index b583813..2092330 100644
--- a/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/WebCore/platform/graphics/GraphicsContext3D.h
@@ -451,7 +451,7 @@ public:
     PlatformLayer* platformLayer() const { return 0; }
 #endif
 #endif
-    void makeContextCurrent();
+    void ensureContext();
 
 #if PLATFORM(MAC) || PLATFORM(CHROMIUM)
     // With multisampling on, blit from multisampleFBO to regular FBO.
diff --git a/WebCore/platform/graphics/GraphicsContext3DOpenGL.cpp b/WebCore/platform/graphics/GraphicsContext3DOpenGL.cpp
new file mode 100644
index 0000000..b99d422
--- /dev/null
+++ b/WebCore/platform/graphics/GraphicsContext3DOpenGL.cpp
@@ -0,0 +1,1452 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "GraphicsContext3D.h"
+
+#include "ArrayBuffer.h"
+#include "ArrayBufferView.h"
+#include "CanvasRenderingContext.h"
+#include "Float32Array.h"
+#include "GraphicsContext.h"
+#include "HTMLCanvasElement.h"
+#include "ImageBuffer.h"
+#include "Int32Array.h"
+#include "NotImplemented.h"
+#include "Uint8Array.h"
+#include "WebGLObject.h"
+
+#if PLATFORM(MAC)
+#include <OpenGL/CGLRenderers.h>
+#include <OpenGL/gl.h>
+#endif
+
+#include <wtf/UnusedParam.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+void GraphicsContext3D::validateAttributes()
+{
+    const char* extensions = reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS));
+    if (m_attrs.stencil) {
+        if (std::strstr(extensions, "GL_EXT_packed_depth_stencil")) {
+            if (!m_attrs.depth)
+                m_attrs.depth = true;
+        } else
+            m_attrs.stencil = false;
+    }
+    if (m_attrs.antialias) {
+        bool isValidVendor = true;
+        // Currently in Mac we only turn on antialias if vendor is NVIDIA.
+        const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
+        if (!std::strstr(vendor, "NVIDIA"))
+            isValidVendor = false;
+        if (!isValidVendor || !std::strstr(extensions, "GL_EXT_framebuffer_multisample"))
+            m_attrs.antialias = false;
+    }
+    // FIXME: instead of enforcing premultipliedAlpha = true, implement the
+    // correct behavior when premultipliedAlpha = false is requested.
+    m_attrs.premultipliedAlpha = true;
+}
+
+void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context)
+{
+    HTMLCanvasElement* canvas = context->canvas();
+    ImageBuffer* imageBuffer = canvas->buffer();
+
+    int rowBytes = m_currentWidth * 4;
+    int totalBytes = rowBytes * m_currentHeight;
+
+    OwnArrayPtr<unsigned char> pixels(new unsigned char[totalBytes]);
+    if (!pixels)
+        return;
+
+    CGLSetCurrentContext(m_contextObj);
+
+    bool mustRestoreFBO = false;
+    if (m_attrs.antialias) {
+        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
+        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+        mustRestoreFBO = true;
+    } else {
+        if (m_boundFBO != m_fbo) {
+            mustRestoreFBO = true;
+            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+        }
+    }
+
+    GLint packAlignment = 4;
+    bool mustRestorePackAlignment = false;
+    ::glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
+    if (packAlignment > 4) {
+        ::glPixelStorei(GL_PACK_ALIGNMENT, 4);
+        mustRestorePackAlignment = true;
+    }
+
+    ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels.get());
+
+    if (mustRestorePackAlignment)
+        ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
+
+    if (mustRestoreFBO)
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
+
+    paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
+                  canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
+}
+
+void GraphicsContext3D::reshape(int width, int height)
+{
+    if (width == m_currentWidth && height == m_currentHeight || !m_contextObj)
+        return;
+    
+    m_currentWidth = width;
+    m_currentHeight = height;
+    
+    CGLSetCurrentContext(m_contextObj);
+    
+    GLuint internalColorFormat, colorFormat, internalDepthStencilFormat = 0;
+    if (m_attrs.alpha) {
+        internalColorFormat = GL_RGBA8;
+        colorFormat = GL_RGBA;
+    } else {
+        internalColorFormat = GL_RGB8;
+        colorFormat = GL_RGB;
+    }
+    if (m_attrs.stencil || m_attrs.depth) {
+        // We don't allow the logic where stencil is required and depth is not.
+        // See GraphicsContext3D constructor.
+        if (m_attrs.stencil && m_attrs.depth)
+            internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT;
+        else
+            internalDepthStencilFormat = GL_DEPTH_COMPONENT;
+    }
+
+    bool mustRestoreFBO = false;
+
+    // resize multisample FBO
+    if (m_attrs.antialias) {
+        GLint maxSampleCount;
+        ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
+        GLint sampleCount = std::min(8, maxSampleCount);
+        if (sampleCount > maxSampleCount)
+            sampleCount = maxSampleCount;
+        if (m_boundFBO != m_multisampleFBO) {
+            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+            mustRestoreFBO = true;
+        }
+        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
+        ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalColorFormat, width, height);
+        ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
+        if (m_attrs.stencil || m_attrs.depth) {
+            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
+            ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height);
+            if (m_attrs.stencil)
+                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
+            if (m_attrs.depth)
+                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
+        }
+        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+        if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
+            // FIXME: cleanup.
+            notImplemented();
+        }
+    }
+
+    // resize regular FBO
+    if (m_boundFBO != m_fbo) {
+        mustRestoreFBO = true;
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+    }
+    ::glBindTexture(GL_TEXTURE_2D, m_texture);
+    ::glTexImage2D(GL_TEXTURE_2D, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
+    ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
+    ::glBindTexture(GL_TEXTURE_2D, 0);
+    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
+        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
+        ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
+        if (m_attrs.stencil)
+            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
+        if (m_attrs.depth)
+            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
+        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+    }
+    if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
+        // FIXME: cleanup
+        notImplemented();
+    }
+
+    if (m_attrs.antialias) {
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+        if (m_boundFBO == m_multisampleFBO)
+            mustRestoreFBO = false;
+    }
+
+    // Initialize renderbuffers to 0.
+    GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE, stencilMask = GL_TRUE;
+    GLboolean isScissorEnabled = GL_FALSE;
+    GLboolean isDitherEnabled = GL_FALSE;
+    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
+    ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
+    ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+    if (m_attrs.depth) {
+        ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
+        ::glDepthMask(GL_TRUE);
+        clearMask |= GL_DEPTH_BUFFER_BIT;
+    }
+    if (m_attrs.stencil) {
+        ::glGetBooleanv(GL_STENCIL_WRITEMASK, &stencilMask);
+        ::glStencilMask(GL_TRUE);
+        clearMask |= GL_STENCIL_BUFFER_BIT;
+    }
+    isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST);
+    ::glDisable(GL_SCISSOR_TEST);
+    isDitherEnabled = ::glIsEnabled(GL_DITHER);
+    ::glDisable(GL_DITHER);
+
+    ::glClear(clearMask);
+
+    ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
+    if (m_attrs.depth)
+        ::glDepthMask(depthMask);
+    if (m_attrs.stencil)
+        ::glStencilMask(stencilMask);
+    if (isScissorEnabled)
+        ::glEnable(GL_SCISSOR_TEST);
+    else
+        ::glDisable(GL_SCISSOR_TEST);
+    if (isDitherEnabled)
+        ::glEnable(GL_DITHER);
+    else
+        ::glDisable(GL_DITHER);
+
+    if (mustRestoreFBO)
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
+
+    ::glFlush();
+}
+
+void GraphicsContext3D::prepareTexture()
+{
+    ensureContext();
+    if (m_attrs.antialias) {
+        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
+        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
+    }
+    ::glFinish();
+}
+
+void GraphicsContext3D::activeTexture(unsigned long texture)
+{
+    ensureContext();
+    ::glActiveTexture(texture);
+}
+
+void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader)
+{
+    ASSERT(program);
+    ASSERT(shader);
+    ensureContext();
+    ::glAttachShader((GLuint) program, (GLuint) shader);
+}
+
+void GraphicsContext3D::bindAttribLocation(Platform3DObject program, unsigned long index, const String& name)
+{
+    ASSERT(program);
+    ensureContext();
+    ::glBindAttribLocation((GLuint) program, index, name.utf8().data());
+}
+
+void GraphicsContext3D::bindBuffer(unsigned long target, Platform3DObject buffer)
+{
+    ensureContext();
+    ::glBindBuffer(target, (GLuint) buffer);
+}
+
+
+void GraphicsContext3D::bindFramebuffer(unsigned long target, Platform3DObject buffer)
+{
+    ensureContext();
+    GLuint fbo;
+    if (buffer)
+        fbo = (GLuint)buffer;
+    else
+        fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
+    if (fbo != m_boundFBO) {
+        ::glBindFramebufferEXT(target, fbo);
+        m_boundFBO = fbo;
+    }
+}
+
+void GraphicsContext3D::bindRenderbuffer(unsigned long target, Platform3DObject renderbuffer)
+{
+    ensureContext();
+    ::glBindRenderbufferEXT(target, (GLuint) renderbuffer);
+}
+
+
+void GraphicsContext3D::bindTexture(unsigned long target, Platform3DObject texture)
+{
+    ensureContext();
+    ::glBindTexture(target, (GLuint) texture);
+}
+
+void GraphicsContext3D::blendColor(double red, double green, double blue, double alpha)
+{
+    ensureContext();
+    ::glBlendColor(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
+}
+
+void GraphicsContext3D::blendEquation(unsigned long mode)
+{
+    ensureContext();
+    ::glBlendEquation(mode);
+}
+
+void GraphicsContext3D::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
+{
+    ensureContext();
+    ::glBlendEquationSeparate(modeRGB, modeAlpha);
+}
+
+
+void GraphicsContext3D::blendFunc(unsigned long sfactor, unsigned long dfactor)
+{
+    ensureContext();
+    ::glBlendFunc(sfactor, dfactor);
+}       
+
+void GraphicsContext3D::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha)
+{
+    ensureContext();
+    ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void GraphicsContext3D::bufferData(unsigned long target, int size, unsigned long usage)
+{
+    ensureContext();
+    ::glBufferData(target, size, 0, usage);
+}
+
+void GraphicsContext3D::bufferData(unsigned long target, int size, const void* data, unsigned long usage)
+{
+    ensureContext();
+    ::glBufferData(target, size, data, usage);
+}
+
+void GraphicsContext3D::bufferSubData(unsigned long target, long offset, int size, const void* data)
+{
+    ensureContext();
+    ::glBufferSubData(target, offset, size, data);
+}
+
+unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target)
+{
+    ensureContext();
+    return ::glCheckFramebufferStatusEXT(target);
+}
+
+void GraphicsContext3D::clearColor(double r, double g, double b, double a)
+{
+    ensureContext();
+    ::glClearColor(static_cast<float>(r), static_cast<float>(g), static_cast<float>(b), static_cast<float>(a));
+}
+
+void GraphicsContext3D::clear(unsigned long mask)
+{
+    ensureContext();
+    ::glClear(mask);
+}
+
+void GraphicsContext3D::clearDepth(double depth)
+{
+    ensureContext();
+    ::glClearDepth(depth);
+}
+
+void GraphicsContext3D::clearStencil(long s)
+{
+    ensureContext();
+    ::glClearStencil(s);
+}
+
+void GraphicsContext3D::colorMask(bool red, bool green, bool blue, bool alpha)
+{
+    ensureContext();
+    ::glColorMask(red, green, blue, alpha);
+}
+
+void GraphicsContext3D::compileShader(Platform3DObject shader)
+{
+    ASSERT(shader);
+    ensureContext();
+
+    int GLshaderType;
+    ANGLEShaderType shaderType;
+
+    glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
+    
+    if (GLshaderType == VERTEX_SHADER)
+        shaderType = SHADER_TYPE_VERTEX;
+    else if (GLshaderType == FRAGMENT_SHADER)
+        shaderType = SHADER_TYPE_FRAGMENT;
+    else
+        return; // Invalid shader type.
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
+        return;
+
+    ShaderSourceEntry& entry = result->second;
+
+    String translatedShaderSource;
+    String shaderInfoLog;
+
+    bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
+
+    entry.log = shaderInfoLog;
+    entry.isValid = isValid;
+
+    if (!isValid)
+        return; // Shader didn't validate, don't move forward with compiling translated source    
+
+    int translatedShaderLength = translatedShaderSource.length();
+
+    const CString& translatedShaderCString = translatedShaderSource.utf8();
+    const char* translatedShaderPtr = translatedShaderCString.data();
+    
+    ::glShaderSource((GLuint) shader, 1, &translatedShaderPtr, &translatedShaderLength);
+    
+    ::glCompileShader((GLuint) shader);
+    
+    int GLCompileSuccess;
+    
+    ::glGetShaderiv((GLuint) shader, COMPILE_STATUS, &GLCompileSuccess);
+    
+    // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
+    ASSERT(GLCompileSuccess == GL_TRUE);
+}
+
+void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
+{
+    ensureContext();
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
+        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+    }
+    ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+}
+
+void GraphicsContext3D::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
+{
+    ensureContext();
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
+        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+    }
+    ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+}
+
+void GraphicsContext3D::cullFace(unsigned long mode)
+{
+    ensureContext();
+    ::glCullFace(mode);
+}
+
+void GraphicsContext3D::depthFunc(unsigned long func)
+{
+    ensureContext();
+    ::glDepthFunc(func);
+}
+
+void GraphicsContext3D::depthMask(bool flag)
+{
+    ensureContext();
+    ::glDepthMask(flag);
+}
+
+void GraphicsContext3D::depthRange(double zNear, double zFar)
+{
+    ensureContext();
+    ::glDepthRange(zNear, zFar);
+}
+
+void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader)
+{
+    ASSERT(program);
+    ASSERT(shader);
+    ensureContext();
+    ::glDetachShader((GLuint) program, (GLuint) shader);
+}
+
+void GraphicsContext3D::disable(unsigned long cap)
+{
+    ensureContext();
+    ::glDisable(cap);
+}
+
+void GraphicsContext3D::disableVertexAttribArray(unsigned long index)
+{
+    ensureContext();
+    ::glDisableVertexAttribArray(index);
+}
+
+void GraphicsContext3D::drawArrays(unsigned long mode, long first, long count)
+{
+    ensureContext();
+    ::glDrawArrays(mode, first, count);
+}
+
+void GraphicsContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset)
+{
+    ensureContext();
+    ::glDrawElements(mode, count, type, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
+}
+
+void GraphicsContext3D::enable(unsigned long cap)
+{
+    ensureContext();
+    ::glEnable(cap);
+}
+
+void GraphicsContext3D::enableVertexAttribArray(unsigned long index)
+{
+    ensureContext();
+    ::glEnableVertexAttribArray(index);
+}
+
+void GraphicsContext3D::finish()
+{
+    ensureContext();
+    ::glFinish();
+}
+
+void GraphicsContext3D::flush()
+{
+    ensureContext();
+    ::glFlush();
+}
+
+void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject buffer)
+{
+    ensureContext();
+    GLuint renderbuffer = (GLuint) buffer;
+    if (attachment == DEPTH_STENCIL_ATTACHMENT) {
+        ::glFramebufferRenderbufferEXT(target, DEPTH_ATTACHMENT, renderbuffertarget, renderbuffer);
+        ::glFramebufferRenderbufferEXT(target, STENCIL_ATTACHMENT, renderbuffertarget, renderbuffer);
+    } else
+        ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
+}
+
+void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject texture, long level)
+{
+    ensureContext();
+    ::glFramebufferTexture2DEXT(target, attachment, textarget, (GLuint) texture, level);
+}
+
+void GraphicsContext3D::frontFace(unsigned long mode)
+{
+    ensureContext();
+    ::glFrontFace(mode);
+}
+
+void GraphicsContext3D::generateMipmap(unsigned long target)
+{
+    ensureContext();
+    ::glGenerateMipmapEXT(target);
+}
+
+bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo& info)
+{
+    if (!program) {
+        synthesizeGLError(INVALID_VALUE);
+        return false;
+    }
+    ensureContext();
+    GLint maxAttributeSize = 0;
+    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
+    GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination
+    GLsizei nameLength = 0;
+    GLint size = 0;
+    GLenum type = 0;
+    ::glGetActiveAttrib(static_cast<GLuint>(program), index, maxAttributeSize, &nameLength, &size, &type, name);
+    if (!nameLength)
+        return false;
+    info.name = String(name, nameLength);
+    info.type = type;
+    info.size = size;
+    return true;
+}
+    
+bool GraphicsContext3D::getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo& info)
+{
+    if (!program) {
+        synthesizeGLError(INVALID_VALUE);
+        return false;
+    }
+    ensureContext();
+    GLint maxUniformSize = 0;
+    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
+    GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination
+    GLsizei nameLength = 0;
+    GLint size = 0;
+    GLenum type = 0;
+    ::glGetActiveUniform(static_cast<GLuint>(program), index, maxUniformSize, &nameLength, &size, &type, name);
+    if (!nameLength)
+        return false;
+    info.name = String(name, nameLength);
+    info.type = type;
+    info.size = size;
+    return true;
+}
+
+void GraphicsContext3D::getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders)
+{
+    if (!program) {
+        synthesizeGLError(INVALID_VALUE);
+        return;
+    }
+    ensureContext();
+    ::glGetAttachedShaders(static_cast<GLuint>(program), maxCount, count, shaders);
+}
+
+int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name)
+{
+    if (!program)
+        return -1;
+
+    ensureContext();
+    return ::glGetAttribLocation((GLuint) program, name.utf8().data());
+}
+
+GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
+{
+    return m_attrs;
+}
+
+unsigned long GraphicsContext3D::getError()
+{
+    if (m_syntheticErrors.size() > 0) {
+        ListHashSet<unsigned long>::iterator iter = m_syntheticErrors.begin();
+        unsigned long err = *iter;
+        m_syntheticErrors.remove(iter);
+        return err;
+    }
+
+    ensureContext();
+    return ::glGetError();
+}
+
+String GraphicsContext3D::getString(unsigned long name)
+{
+    ensureContext();
+    return String((const char*) ::glGetString(name));
+}
+
+void GraphicsContext3D::hint(unsigned long target, unsigned long mode)
+{
+    ensureContext();
+    ::glHint(target, mode);
+}
+
+bool GraphicsContext3D::isBuffer(Platform3DObject buffer)
+{
+    if (!buffer)
+        return false;
+
+    ensureContext();
+    return ::glIsBuffer((GLuint) buffer);
+}
+
+bool GraphicsContext3D::isEnabled(unsigned long cap)
+{
+    ensureContext();
+    return ::glIsEnabled(cap);
+}
+
+bool GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer)
+{
+    if (!framebuffer)
+        return false;
+
+    ensureContext();
+    return ::glIsFramebufferEXT((GLuint) framebuffer);
+}
+
+bool GraphicsContext3D::isProgram(Platform3DObject program)
+{
+    if (!program)
+        return false;
+
+    ensureContext();
+    return ::glIsProgram((GLuint) program);
+}
+
+bool GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer)
+{
+    if (!renderbuffer)
+        return false;
+
+    ensureContext();
+    return ::glIsRenderbufferEXT((GLuint) renderbuffer);
+}
+
+bool GraphicsContext3D::isShader(Platform3DObject shader)
+{
+    if (!shader)
+        return false;
+
+    ensureContext();
+    return ::glIsShader((GLuint) shader);
+}
+
+bool GraphicsContext3D::isTexture(Platform3DObject texture)
+{
+    if (!texture)
+        return false;
+
+    ensureContext();
+    return ::glIsTexture((GLuint) texture);
+}
+
+void GraphicsContext3D::lineWidth(double width)
+{
+    ensureContext();
+    ::glLineWidth(static_cast<float>(width));
+}
+
+void GraphicsContext3D::linkProgram(Platform3DObject program)
+{
+    ASSERT(program);
+    ensureContext();
+    ::glLinkProgram((GLuint) program);
+}
+
+void GraphicsContext3D::pixelStorei(unsigned long pname, long param)
+{
+    ensureContext();
+    ::glPixelStorei(pname, param);
+}
+
+void GraphicsContext3D::polygonOffset(double factor, double units)
+{
+    ensureContext();
+    ::glPolygonOffset(static_cast<float>(factor), static_cast<float>(units));
+}
+
+void GraphicsContext3D::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data)
+{
+    // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
+    // all previous rendering calls should be done before reading pixels.
+    ensureContext();
+    ::glFlush();
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
+        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
+        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+        ::glFlush();
+    }
+    ::glReadPixels(x, y, width, height, format, type, data);
+    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+}
+
+void GraphicsContext3D::releaseShaderCompiler()
+{
+    // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants
+}
+
+void GraphicsContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
+{
+    ensureContext();
+    switch (internalformat) {
+    case DEPTH_STENCIL:
+        internalformat = GL_DEPTH24_STENCIL8_EXT;
+        break;
+    case DEPTH_COMPONENT16:
+        internalformat = GL_DEPTH_COMPONENT;
+        break;
+    case RGBA4:
+    case RGB5_A1:
+        internalformat = GL_RGBA;
+        break;
+    case RGB565:
+        internalformat = GL_RGB;
+        break;
+    }
+    ::glRenderbufferStorageEXT(target, internalformat, width, height);
+}
+
+void GraphicsContext3D::sampleCoverage(double value, bool invert)
+{
+    ensureContext();
+    ::glSampleCoverage(static_cast<float>(value), invert);
+}
+
+void GraphicsContext3D::scissor(long x, long y, unsigned long width, unsigned long height)
+{
+    ensureContext();
+    ::glScissor(x, y, width, height);
+}
+
+void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string)
+{
+    ASSERT(shader);
+
+    ensureContext();
+
+    ShaderSourceEntry entry;
+
+    entry.source = string;
+
+    m_shaderSourceMap.set(shader, entry);
+}
+
+void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
+{
+    ensureContext();
+    ::glStencilFunc(func, ref, mask);
+}
+
+void GraphicsContext3D::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask)
+{
+    ensureContext();
+    ::glStencilFuncSeparate(face, func, ref, mask);
+}
+
+void GraphicsContext3D::stencilMask(unsigned long mask)
+{
+    ensureContext();
+    ::glStencilMask(mask);
+}
+
+void GraphicsContext3D::stencilMaskSeparate(unsigned long face, unsigned long mask)
+{
+    ensureContext();
+    ::glStencilMaskSeparate(face, mask);
+}
+
+void GraphicsContext3D::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass)
+{
+    ensureContext();
+    ::glStencilOp(fail, zfail, zpass);
+}
+
+void GraphicsContext3D::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass)
+{
+    ensureContext();
+    ::glStencilOpSeparate(face, fail, zfail, zpass);
+}
+
+void GraphicsContext3D::texParameterf(unsigned target, unsigned pname, float value)
+{
+    ensureContext();
+    ::glTexParameterf(target, pname, static_cast<float>(value));
+}
+
+void GraphicsContext3D::texParameteri(unsigned target, unsigned pname, int value)
+{
+    ensureContext();
+    ::glTexParameteri(target, pname, static_cast<float>(value));
+}
+
+void GraphicsContext3D::uniform1f(long location, float v0)
+{
+    ensureContext();
+    ::glUniform1f(location, v0);
+}
+
+void GraphicsContext3D::uniform1fv(long location, float* array, int size)
+{
+    ensureContext();
+    ::glUniform1fv(location, size, array);
+}
+
+void GraphicsContext3D::uniform2f(long location, float v0, float v1)
+{
+    ensureContext();
+    ::glUniform2f(location, v0, v1);
+}
+
+void GraphicsContext3D::uniform2fv(long location, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 2
+    ensureContext();
+    ::glUniform2fv(location, size, array);
+}
+
+void GraphicsContext3D::uniform3f(long location, float v0, float v1, float v2)
+{
+    ensureContext();
+    ::glUniform3f(location, v0, v1, v2);
+}
+
+void GraphicsContext3D::uniform3fv(long location, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 3
+    ensureContext();
+    ::glUniform3fv(location, size, array);
+}
+
+void GraphicsContext3D::uniform4f(long location, float v0, float v1, float v2, float v3)
+{
+    ensureContext();
+    ::glUniform4f(location, v0, v1, v2, v3);
+}
+
+void GraphicsContext3D::uniform4fv(long location, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 4
+    ensureContext();
+    ::glUniform4fv(location, size, array);
+}
+
+void GraphicsContext3D::uniform1i(long location, int v0)
+{
+    ensureContext();
+    ::glUniform1i(location, v0);
+}
+
+void GraphicsContext3D::uniform1iv(long location, int* array, int size)
+{
+    ensureContext();
+    ::glUniform1iv(location, size, array);
+}
+
+void GraphicsContext3D::uniform2i(long location, int v0, int v1)
+{
+    ensureContext();
+    ::glUniform2i(location, v0, v1);
+}
+
+void GraphicsContext3D::uniform2iv(long location, int* array, int size)
+{
+    // FIXME: length needs to be a multiple of 2
+    ensureContext();
+    ::glUniform2iv(location, size, array);
+}
+
+void GraphicsContext3D::uniform3i(long location, int v0, int v1, int v2)
+{
+    ensureContext();
+    ::glUniform3i(location, v0, v1, v2);
+}
+
+void GraphicsContext3D::uniform3iv(long location, int* array, int size)
+{
+    // FIXME: length needs to be a multiple of 3
+    ensureContext();
+    ::glUniform3iv(location, size, array);
+}
+
+void GraphicsContext3D::uniform4i(long location, int v0, int v1, int v2, int v3)
+{
+    ensureContext();
+    ::glUniform4i(location, v0, v1, v2, v3);
+}
+
+void GraphicsContext3D::uniform4iv(long location, int* array, int size)
+{
+    // FIXME: length needs to be a multiple of 4
+    ensureContext();
+    ::glUniform4iv(location, size, array);
+}
+
+void GraphicsContext3D::uniformMatrix2fv(long location, bool transpose, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 4
+    ensureContext();
+    ::glUniformMatrix2fv(location, size, transpose, array);
+}
+
+void GraphicsContext3D::uniformMatrix3fv(long location, bool transpose, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 9
+    ensureContext();
+    ::glUniformMatrix3fv(location, size, transpose, array);
+}
+
+void GraphicsContext3D::uniformMatrix4fv(long location, bool transpose, float* array, int size)
+{
+    // FIXME: length needs to be a multiple of 16
+    ensureContext();
+    ::glUniformMatrix4fv(location, size, transpose, array);
+}
+
+void GraphicsContext3D::useProgram(Platform3DObject program)
+{
+    ensureContext();
+    ::glUseProgram((GLuint) program);
+}
+
+void GraphicsContext3D::validateProgram(Platform3DObject program)
+{
+    ASSERT(program);
+
+    ensureContext();
+    ::glValidateProgram((GLuint) program);
+}
+
+void GraphicsContext3D::vertexAttrib1f(unsigned long indx, float v0)
+{
+    ensureContext();
+    ::glVertexAttrib1f(indx, v0);
+}
+
+void GraphicsContext3D::vertexAttrib1fv(unsigned long indx, float* array)
+{
+    ensureContext();
+    ::glVertexAttrib1fv(indx, array);
+}
+
+void GraphicsContext3D::vertexAttrib2f(unsigned long indx, float v0, float v1)
+{
+    ensureContext();
+    ::glVertexAttrib2f(indx, v0, v1);
+}
+
+void GraphicsContext3D::vertexAttrib2fv(unsigned long indx, float* array)
+{
+    ensureContext();
+    ::glVertexAttrib2fv(indx, array);
+}
+
+void GraphicsContext3D::vertexAttrib3f(unsigned long indx, float v0, float v1, float v2)
+{
+    ensureContext();
+    ::glVertexAttrib3f(indx, v0, v1, v2);
+}
+
+void GraphicsContext3D::vertexAttrib3fv(unsigned long indx, float* array)
+{
+    ensureContext();
+    ::glVertexAttrib3fv(indx, array);
+}
+
+void GraphicsContext3D::vertexAttrib4f(unsigned long indx, float v0, float v1, float v2, float v3)
+{
+    ensureContext();
+    ::glVertexAttrib4f(indx, v0, v1, v2, v3);
+}
+
+void GraphicsContext3D::vertexAttrib4fv(unsigned long indx, float* array)
+{
+    ensureContext();
+    ::glVertexAttrib4fv(indx, array);
+}
+
+void GraphicsContext3D::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset)
+{
+    ensureContext();
+    ::glVertexAttribPointer(indx, size, type, normalized, stride, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
+}
+
+void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height)
+{
+    ensureContext();
+    ::glViewport(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
+}
+
+void GraphicsContext3D::getBooleanv(unsigned long pname, unsigned char* value)
+{
+    ensureContext();
+    ::glGetBooleanv(pname, value);
+}
+
+void GraphicsContext3D::getBufferParameteriv(unsigned long target, unsigned long pname, int* value)
+{
+    ensureContext();
+    ::glGetBufferParameteriv(target, pname, value);
+}
+
+void GraphicsContext3D::getFloatv(unsigned long pname, float* value)
+{
+    ensureContext();
+    ::glGetFloatv(pname, value);
+}
+
+void GraphicsContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value)
+{
+    ensureContext();
+    if (attachment == DEPTH_STENCIL_ATTACHMENT)
+        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
+    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
+}
+
+void GraphicsContext3D::getIntegerv(unsigned long pname, int* value)
+{
+    // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL.  Any valid
+    // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most
+    // useful for desktop WebGL users.
+    // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS
+    // because desktop GL's corresponding queries return the number of components
+    // whereas GLES2 return the number of vectors (each vector has 4 components).
+    // Therefore, the value returned by desktop GL needs to be divided by 4.
+    ensureContext();
+    switch (pname) {
+    case IMPLEMENTATION_COLOR_READ_FORMAT:
+        *value = GL_RGB;
+        break;
+    case IMPLEMENTATION_COLOR_READ_TYPE:
+        *value = GL_UNSIGNED_BYTE;
+        break;
+    case MAX_FRAGMENT_UNIFORM_VECTORS:
+        ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
+        *value /= 4;
+        break;
+    case MAX_VERTEX_UNIFORM_VECTORS:
+        ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
+        *value /= 4;
+        break;
+    case MAX_VARYING_VECTORS:
+        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
+        *value /= 4;
+        break;
+    default:
+        ::glGetIntegerv(pname, value);
+    }
+}
+
+void GraphicsContext3D::getProgramiv(Platform3DObject program, unsigned long pname, int* value)
+{
+    ensureContext();
+    ::glGetProgramiv((GLuint) program, pname, value);
+}
+
+String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
+{
+    ASSERT(program);
+
+    ensureContext();
+    GLint length;
+    ::glGetProgramiv((GLuint) program, GL_INFO_LOG_LENGTH, &length);
+    
+    GLsizei size;
+    GLchar* info = (GLchar*) fastMalloc(length);
+    if (!info)
+        return "";
+
+    ::glGetProgramInfoLog((GLuint) program, length, &size, info);
+    String s(info);
+    fastFree(info);
+    return s;
+}
+
+void GraphicsContext3D::getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value)
+{
+    ensureContext();
+    ::glGetRenderbufferParameterivEXT(target, pname, value);
+}
+
+void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname, int* value)
+{
+    ASSERT(shader);
+
+    ensureContext();
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+    
+    switch (pname) {
+    case DELETE_STATUS:
+    case SHADER_TYPE:
+        // Let OpenGL handle these.
+    
+        ::glGetShaderiv((GLuint) shader, pname, value);
+        break;
+    
+    case COMPILE_STATUS:
+        if (result == m_shaderSourceMap.end()) {
+            (*value) = static_cast<int>(false);
+            return;
+        }
+    
+        (*value) = static_cast<int>(result->second.isValid);
+        break;
+    
+    case INFO_LOG_LENGTH:
+        if (result == m_shaderSourceMap.end()) {
+            (*value) = 0;
+            return;
+        }
+    
+        (*value) = getShaderInfoLog(shader).length();
+        break;
+    
+    case SHADER_SOURCE_LENGTH:
+        (*value) = getShaderSource(shader).length();
+        break;
+    
+    default:
+        synthesizeGLError(INVALID_ENUM);
+    }
+}
+
+String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
+{
+    ASSERT(shader);
+
+    ensureContext();
+    GLint length;
+    ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
+         return "";
+
+     ShaderSourceEntry entry = result->second;
+
+     if (entry.isValid) {
+        GLint length;
+        ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
+
+        GLsizei size;
+        GLchar* info = (GLchar*) fastMalloc(length);
+        if (!info)
+            return "";
+
+        ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
+
+        String s(info);
+        fastFree(info);
+        return s;
+    }
+    
+    return entry.log;
+}
+
+String GraphicsContext3D::getShaderSource(Platform3DObject shader)
+{
+    ASSERT(shader);
+
+    ensureContext();
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
+        return "";
+
+    return result->second.source;
+}
+
+
+void GraphicsContext3D::getTexParameterfv(unsigned long target, unsigned long pname, float* value)
+{
+    ensureContext();
+    ::glGetTexParameterfv(target, pname, value);
+}
+
+void GraphicsContext3D::getTexParameteriv(unsigned long target, unsigned long pname, int* value)
+{
+    ensureContext();
+    ::glGetTexParameteriv(target, pname, value);
+}
+
+void GraphicsContext3D::getUniformfv(Platform3DObject program, long location, float* value)
+{
+    ensureContext();
+    ::glGetUniformfv((GLuint) program, location, value);
+}
+
+void GraphicsContext3D::getUniformiv(Platform3DObject program, long location, int* value)
+{
+    ensureContext();
+    ::glGetUniformiv((GLuint) program, location, value);
+}
+
+long GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
+{
+    ASSERT(program);
+
+    ensureContext();
+    return ::glGetUniformLocation((GLuint) program, name.utf8().data());
+}
+
+void GraphicsContext3D::getVertexAttribfv(unsigned long index, unsigned long pname, float* value)
+{
+    ensureContext();
+    ::glGetVertexAttribfv(index, pname, value);
+}
+
+void GraphicsContext3D::getVertexAttribiv(unsigned long index, unsigned long pname, int* value)
+{
+    ensureContext();
+    ::glGetVertexAttribiv(index, pname, value);
+}
+
+long GraphicsContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname)
+{
+    ensureContext();
+
+    void* pointer;
+    ::glGetVertexAttribPointerv(index, pname, &pointer);
+    return reinterpret_cast<long>(pointer);
+}
+
+int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels)
+{
+    ensureContext();
+
+    ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
+    return 0;
+}
+
+int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels)
+{
+    ensureContext();
+
+    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
+    ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels);
+    return 0;
+}
+
+unsigned GraphicsContext3D::createBuffer()
+{
+    ensureContext();
+    GLuint o;
+    glGenBuffers(1, &o);
+    return o;
+}
+
+unsigned GraphicsContext3D::createFramebuffer()
+{
+    ensureContext();
+    GLuint o;
+    glGenFramebuffersEXT(1, &o);
+    return o;
+}
+
+unsigned GraphicsContext3D::createProgram()
+{
+    ensureContext();
+    return glCreateProgram();
+}
+
+unsigned GraphicsContext3D::createRenderbuffer()
+{
+    ensureContext();
+    GLuint o;
+    glGenRenderbuffersEXT(1, &o);
+    return o;
+}
+
+unsigned GraphicsContext3D::createShader(unsigned long type)
+{
+    ensureContext();
+    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
+}
+
+unsigned GraphicsContext3D::createTexture()
+{
+    ensureContext();
+    GLuint o;
+    glGenTextures(1, &o);
+    return o;
+}
+
+void GraphicsContext3D::deleteBuffer(unsigned buffer)
+{
+    ensureContext();
+    glDeleteBuffers(1, &buffer);
+}
+
+void GraphicsContext3D::deleteFramebuffer(unsigned framebuffer)
+{
+    ensureContext();
+    glDeleteFramebuffersEXT(1, &framebuffer);
+}
+
+void GraphicsContext3D::deleteProgram(unsigned program)
+{
+    ensureContext();
+    glDeleteProgram(program);
+}
+
+void GraphicsContext3D::deleteRenderbuffer(unsigned renderbuffer)
+{
+    ensureContext();
+    glDeleteRenderbuffersEXT(1, &renderbuffer);
+}
+
+void GraphicsContext3D::deleteShader(unsigned shader)
+{
+    ensureContext();
+    glDeleteShader(shader);
+}
+
+void GraphicsContext3D::deleteTexture(unsigned texture)
+{
+    ensureContext();
+    glDeleteTextures(1, &texture);
+}
+
+int GraphicsContext3D::sizeInBytes(int type)
+{
+    switch (type) {
+    case GL_BYTE:
+        return sizeof(GLbyte);
+    case GL_UNSIGNED_BYTE:
+        return sizeof(GLubyte);
+    case GL_SHORT:
+        return sizeof(GLshort);
+    case GL_UNSIGNED_SHORT:
+        return sizeof(GLushort);
+    case GL_INT:
+        return sizeof(GLint);
+    case GL_UNSIGNED_INT:
+        return sizeof(GLuint);
+    case GL_FLOAT:
+        return sizeof(GLfloat);
+    default:
+        return 0;
+    }
+}
+
+void GraphicsContext3D::synthesizeGLError(unsigned long error)
+{
+    m_syntheticErrors.add(error);
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
index 54b261c..3cb3b55 100644
--- a/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
@@ -31,21 +31,22 @@
 
 #import "BlockExceptions.h"
 
+#include "ANGLE/ShaderLang.h"
 #include "ArrayBuffer.h"
 #include "ArrayBufferView.h"
-#include "WebGLObject.h"
 #include "CanvasRenderingContext.h"
+#include <CoreGraphics/CGBitmapContext.h>
 #include "Float32Array.h"
 #include "GraphicsContext.h"
 #include "HTMLCanvasElement.h"
 #include "ImageBuffer.h"
 #include "Int32Array.h"
 #include "NotImplemented.h"
-#include "Uint8Array.h"
-#include "WebGLLayer.h"
-#include <CoreGraphics/CGBitmapContext.h>
 #include <OpenGL/CGLRenderers.h>
 #include <OpenGL/gl.h>
+#include "Uint8Array.h"
+#include "WebGLLayer.h"
+#include "WebGLObject.h"
 #include <wtf/UnusedParam.h>
 #include <wtf/text/CString.h>
 
@@ -229,81 +230,14 @@ GraphicsContext3D::~GraphicsContext3D()
     }
 }
 
-void GraphicsContext3D::validateAttributes()
-{
-    const char* extensions = reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS));
-    if (m_attrs.stencil) {
-        if (std::strstr(extensions, "GL_EXT_packed_depth_stencil")) {
-            if (!m_attrs.depth)
-                m_attrs.depth = true;
-        } else
-            m_attrs.stencil = false;
-    }
-    if (m_attrs.antialias) {
-        bool isValidVendor = true;
-        // Currently in Mac we only turn on antialias if vendor is NVIDIA.
-        const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
-        if (!std::strstr(vendor, "NVIDIA"))
-            isValidVendor = false;
-        if (!isValidVendor || !std::strstr(extensions, "GL_EXT_framebuffer_multisample"))
-            m_attrs.antialias = false;
-    }
-    // FIXME: instead of enforcing premultipliedAlpha = true, implement the
-    // correct behavior when premultipliedAlpha = false is requested.
-    m_attrs.premultipliedAlpha = true;
-}
-
-void GraphicsContext3D::makeContextCurrent()
-{
-    CGLSetCurrentContext(m_contextObj);
-}
-
-void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context)
+void GraphicsContext3D::ensureContext()
 {
-    HTMLCanvasElement* canvas = context->canvas();
-    ImageBuffer* imageBuffer = canvas->buffer();
-
-    int rowBytes = m_currentWidth * 4;
-    int totalBytes = rowBytes * m_currentHeight;
-
-    OwnArrayPtr<unsigned char> pixels(new unsigned char[totalBytes]);
-    if (!pixels)
+    if (!m_contextObj)
         return;
 
-    CGLSetCurrentContext(m_contextObj);
-
-    bool mustRestoreFBO = false;
-    if (m_attrs.antialias) {
-        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
-        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-        mustRestoreFBO = true;
-    } else {
-        if (m_boundFBO != m_fbo) {
-            mustRestoreFBO = true;
-            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-        }
-    }
-
-    GLint packAlignment = 4;
-    bool mustRestorePackAlignment = false;
-    ::glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
-    if (packAlignment > 4) {
-        ::glPixelStorei(GL_PACK_ALIGNMENT, 4);
-        mustRestorePackAlignment = true;
-    }
-
-    ::glReadPixels(0, 0, m_currentWidth, m_currentHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels.get());
-
-    if (mustRestorePackAlignment)
-        ::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
-
-    if (mustRestoreFBO)
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
-
-    paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
-                  canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
+    CGLContextObj currentContext = CGLGetCurrentContext();
+    if (currentContext != m_contextObj)
+        CGLSetCurrentContext(m_contextObj);
 }
 
 bool GraphicsContext3D::isGLES2Compliant() const
@@ -320,1343 +254,7 @@ bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
 {
     return false;
 }
-
-void GraphicsContext3D::reshape(int width, int height)
-{
-    if (width == m_currentWidth && height == m_currentHeight || !m_contextObj)
-        return;
-    
-    m_currentWidth = width;
-    m_currentHeight = height;
-    
-    CGLSetCurrentContext(m_contextObj);
-    
-    GLuint internalColorFormat, colorFormat, internalDepthStencilFormat = 0;
-    if (m_attrs.alpha) {
-        internalColorFormat = GL_RGBA8;
-        colorFormat = GL_RGBA;
-    } else {
-        internalColorFormat = GL_RGB8;
-        colorFormat = GL_RGB;
-    }
-    if (m_attrs.stencil || m_attrs.depth) {
-        // We don't allow the logic where stencil is required and depth is not.
-        // See GraphicsContext3D constructor.
-        if (m_attrs.stencil && m_attrs.depth)
-            internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT;
-        else
-            internalDepthStencilFormat = GL_DEPTH_COMPONENT;
-    }
-
-    bool mustRestoreFBO = false;
-
-    // resize multisample FBO
-    if (m_attrs.antialias) {
-        GLint maxSampleCount;
-        ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
-        GLint sampleCount = std::min(8, maxSampleCount);
-        if (sampleCount > maxSampleCount)
-            sampleCount = maxSampleCount;
-        if (m_boundFBO != m_multisampleFBO) {
-            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-            mustRestoreFBO = true;
-        }
-        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
-        ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalColorFormat, width, height);
-        ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth) {
-            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
-            ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height);
-            if (m_attrs.stencil)
-                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
-            if (m_attrs.depth)
-                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
-        }
-        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-        if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
-            // FIXME: cleanup.
-            notImplemented();
-        }
-    }
-
-    // resize regular FBO
-    if (m_boundFBO != m_fbo) {
-        mustRestoreFBO = true;
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-    }
-    ::glBindTexture(GL_TEXTURE_2D, m_texture);
-    ::glTexImage2D(GL_TEXTURE_2D, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0);
-    ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);
-    ::glBindTexture(GL_TEXTURE_2D, 0);
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
-        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
-        ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
-        if (m_attrs.stencil)
-            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
-        if (m_attrs.depth)
-            ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
-        ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-    }
-    if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
-        // FIXME: cleanup
-        notImplemented();
-    }
-
-    if (m_attrs.antialias) {
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-        if (m_boundFBO == m_multisampleFBO)
-            mustRestoreFBO = false;
-    }
-
-    // Initialize renderbuffers to 0.
-    GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE, stencilMask = GL_TRUE;
-    GLboolean isScissorEnabled = GL_FALSE;
-    GLboolean isDitherEnabled = GL_FALSE;
-    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
-    ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
-    ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    if (m_attrs.depth) {
-        ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
-        ::glDepthMask(GL_TRUE);
-        clearMask |= GL_DEPTH_BUFFER_BIT;
-    }
-    if (m_attrs.stencil) {
-        ::glGetBooleanv(GL_STENCIL_WRITEMASK, &stencilMask);
-        ::glStencilMask(GL_TRUE);
-        clearMask |= GL_STENCIL_BUFFER_BIT;
-    }
-    isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST);
-    ::glDisable(GL_SCISSOR_TEST);
-    isDitherEnabled = ::glIsEnabled(GL_DITHER);
-    ::glDisable(GL_DITHER);
-
-    ::glClear(clearMask);
-
-    ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
-    if (m_attrs.depth)
-        ::glDepthMask(depthMask);
-    if (m_attrs.stencil)
-        ::glStencilMask(stencilMask);
-    if (isScissorEnabled)
-        ::glEnable(GL_SCISSOR_TEST);
-    else
-        ::glDisable(GL_SCISSOR_TEST);
-    if (isDitherEnabled)
-        ::glEnable(GL_DITHER);
-    else
-        ::glDisable(GL_DITHER);
-
-    if (mustRestoreFBO)
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
-
-    ::glFlush();
-}
-
-static inline void ensureContext(CGLContextObj context)
-{
-    if (!context)
-        return;
-        
-    CGLContextObj currentContext = CGLGetCurrentContext();
-    if (currentContext != context)
-        CGLSetCurrentContext(context);
-}
-
-void GraphicsContext3D::prepareTexture()
-{
-    ensureContext(m_contextObj);
-    if (m_attrs.antialias) {
-        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
-        ::glBlitFramebufferEXT(0, 0, m_currentWidth, m_currentHeight, 0, 0, m_currentWidth, m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);
-    }
-    ::glFinish();
-}
-
-void GraphicsContext3D::activeTexture(unsigned long texture)
-{
-    ensureContext(m_contextObj);
-    ::glActiveTexture(texture);
-}
-
-void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader)
-{
-    ASSERT(program);
-    ASSERT(shader);
-    ensureContext(m_contextObj);
-    ::glAttachShader((GLuint) program, (GLuint) shader);
-}
-
-void GraphicsContext3D::bindAttribLocation(Platform3DObject program, unsigned long index, const String& name)
-{
-    ASSERT(program);
-    ensureContext(m_contextObj);
-    ::glBindAttribLocation((GLuint) program, index, name.utf8().data());
-}
-
-void GraphicsContext3D::bindBuffer(unsigned long target, Platform3DObject buffer)
-{
-    ensureContext(m_contextObj);
-    ::glBindBuffer(target, (GLuint) buffer);
-}
-
-
-void GraphicsContext3D::bindFramebuffer(unsigned long target, Platform3DObject buffer)
-{
-    ensureContext(m_contextObj);
-    GLuint fbo;
-    if (buffer)
-        fbo = (GLuint)buffer;
-    else
-        fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
-    if (fbo != m_boundFBO) {
-        ::glBindFramebufferEXT(target, fbo);
-        m_boundFBO = fbo;
-    }
-}
-
-void GraphicsContext3D::bindRenderbuffer(unsigned long target, Platform3DObject renderbuffer)
-{
-    ensureContext(m_contextObj);
-    ::glBindRenderbufferEXT(target, (GLuint) renderbuffer);
-}
-
-
-void GraphicsContext3D::bindTexture(unsigned long target, Platform3DObject texture)
-{
-    ensureContext(m_contextObj);
-    ::glBindTexture(target, (GLuint) texture);
-}
-
-void GraphicsContext3D::blendColor(double red, double green, double blue, double alpha)
-{
-    ensureContext(m_contextObj);
-    ::glBlendColor(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
-}
-
-void GraphicsContext3D::blendEquation( unsigned long mode )
-{
-    ensureContext(m_contextObj);
-    ::glBlendEquation(mode);
-}
-
-void GraphicsContext3D::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha)
-{
-    ensureContext(m_contextObj);
-    ::glBlendEquationSeparate(modeRGB, modeAlpha);
-}
-
-
-void GraphicsContext3D::blendFunc(unsigned long sfactor, unsigned long dfactor)
-{
-    ensureContext(m_contextObj);
-    ::glBlendFunc(sfactor, dfactor);
-}       
-
-void GraphicsContext3D::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha)
-{
-    ensureContext(m_contextObj);
-    ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
-}
-
-void GraphicsContext3D::bufferData(unsigned long target, int size, unsigned long usage)
-{
-    ensureContext(m_contextObj);
-    ::glBufferData(target, size, 0, usage);
-}
-
-void GraphicsContext3D::bufferData(unsigned long target, int size, const void* data, unsigned long usage)
-{
-    ensureContext(m_contextObj);
-    ::glBufferData(target, size, data, usage);
-}
-
-void GraphicsContext3D::bufferSubData(unsigned long target, long offset, int size, const void* data)
-{
-    ensureContext(m_contextObj);
-    ::glBufferSubData(target, offset, size, data);
-}
-
-unsigned long GraphicsContext3D::checkFramebufferStatus(unsigned long target)
-{
-    ensureContext(m_contextObj);
-    return ::glCheckFramebufferStatusEXT(target);
-}
-
-void GraphicsContext3D::clearColor(double r, double g, double b, double a)
-{
-    ensureContext(m_contextObj);
-    ::glClearColor(static_cast<float>(r), static_cast<float>(g), static_cast<float>(b), static_cast<float>(a));
-}
-
-void GraphicsContext3D::clear(unsigned long mask)
-{
-    ensureContext(m_contextObj);
-    ::glClear(mask);
-}
-
-void GraphicsContext3D::clearDepth(double depth)
-{
-    ensureContext(m_contextObj);
-    ::glClearDepth(depth);
-}
-
-void GraphicsContext3D::clearStencil(long s)
-{
-    ensureContext(m_contextObj);
-    ::glClearStencil(s);
-}
-
-void GraphicsContext3D::colorMask(bool red, bool green, bool blue, bool alpha)
-{
-    ensureContext(m_contextObj);
-    ::glColorMask(red, green, blue, alpha);
-}
-
-void GraphicsContext3D::compileShader(Platform3DObject shader)
-{
-    ASSERT(shader);
-    ensureContext(m_contextObj);
-
-    int GLshaderType;
-    ANGLEShaderType shaderType;
-
-    glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
-    
-    if (GLshaderType == VERTEX_SHADER)
-        shaderType = SHADER_TYPE_VERTEX;
-    else if (GLshaderType == FRAGMENT_SHADER)
-        shaderType = SHADER_TYPE_FRAGMENT;
-    else
-        return; // Invalid shader type.
-
-    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
-
-    if (result == m_shaderSourceMap.end())
-        return;
-
-    ShaderSourceEntry& entry = result->second;
-
-    String translatedShaderSource;
-    String shaderInfoLog;
-
-    bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
-
-    entry.log = shaderInfoLog;
-    entry.isValid = isValid;
-
-    if (!isValid)
-        return; // Shader didn't validate, don't move forward with compiling translated source    
-
-    int translatedShaderLength = translatedShaderSource.length();
-
-    const CString& translatedShaderCString = translatedShaderSource.utf8();
-    const char* translatedShaderPtr = translatedShaderCString.data();
-    
-    ::glShaderSource((GLuint) shader, 1, &translatedShaderPtr, &translatedShaderLength);
-    
-    ::glCompileShader((GLuint) shader);
-    
-    int GLCompileSuccess;
-    
-    ::glGetShaderiv((GLuint) shader, COMPILE_STATUS, &GLCompileSuccess);
-    
-    // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
-    ASSERT(GLCompileSuccess == GL_TRUE);
-}
-
-void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
-{
-    ensureContext(m_contextObj);
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
-        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
-        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-    }
-    ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-}
-
-void GraphicsContext3D::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height)
-{
-    ensureContext(m_contextObj);
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
-        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
-        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-    }
-    ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-}
-
-void GraphicsContext3D::cullFace(unsigned long mode)
-{
-    ensureContext(m_contextObj);
-    ::glCullFace(mode);
-}
-
-void GraphicsContext3D::depthFunc(unsigned long func)
-{
-    ensureContext(m_contextObj);
-    ::glDepthFunc(func);
-}
-
-void GraphicsContext3D::depthMask(bool flag)
-{
-    ensureContext(m_contextObj);
-    ::glDepthMask(flag);
-}
-
-void GraphicsContext3D::depthRange(double zNear, double zFar)
-{
-    ensureContext(m_contextObj);
-    ::glDepthRange(zNear, zFar);
-}
-
-void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader)
-{
-    ASSERT(program);
-    ASSERT(shader);
-    ensureContext(m_contextObj);
-    ::glDetachShader((GLuint) program, (GLuint) shader);
-}
-
-void GraphicsContext3D::disable(unsigned long cap)
-{
-    ensureContext(m_contextObj);
-    ::glDisable(cap);
-}
-
-void GraphicsContext3D::disableVertexAttribArray(unsigned long index)
-{
-    ensureContext(m_contextObj);
-    ::glDisableVertexAttribArray(index);
-}
-
-void GraphicsContext3D::drawArrays(unsigned long mode, long first, long count)
-{
-    ensureContext(m_contextObj);
-    ::glDrawArrays(mode, first, count);
-}
-
-void GraphicsContext3D::drawElements(unsigned long mode, unsigned long count, unsigned long type, long offset)
-{
-    ensureContext(m_contextObj);
-    ::glDrawElements(mode, count, type, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-void GraphicsContext3D::enable(unsigned long cap)
-{
-    ensureContext(m_contextObj);
-    ::glEnable(cap);
-}
-
-void GraphicsContext3D::enableVertexAttribArray(unsigned long index)
-{
-    ensureContext(m_contextObj);
-    ::glEnableVertexAttribArray(index);
-}
-
-void GraphicsContext3D::finish()
-{
-    ensureContext(m_contextObj);
-    ::glFinish();
-}
-
-void GraphicsContext3D::flush()
-{
-    ensureContext(m_contextObj);
-    ::glFlush();
-}
-
-void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, Platform3DObject buffer)
-{
-    ensureContext(m_contextObj);
-    GLuint renderbuffer = (GLuint) buffer;
-    if (attachment == DEPTH_STENCIL_ATTACHMENT) {
-        ::glFramebufferRenderbufferEXT(target, DEPTH_ATTACHMENT, renderbuffertarget, renderbuffer);
-        ::glFramebufferRenderbufferEXT(target, STENCIL_ATTACHMENT, renderbuffertarget, renderbuffer);
-    } else
-        ::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
-}
-
-void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, Platform3DObject texture, long level)
-{
-    ensureContext(m_contextObj);
-    ::glFramebufferTexture2DEXT(target, attachment, textarget, (GLuint) texture, level);
-}
-
-void GraphicsContext3D::frontFace(unsigned long mode)
-{
-    ensureContext(m_contextObj);
-    ::glFrontFace(mode);
-}
-
-void GraphicsContext3D::generateMipmap(unsigned long target)
-{
-    ensureContext(m_contextObj);
-    ::glGenerateMipmapEXT(target);
-}
-
-bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, unsigned long index, ActiveInfo& info)
-{
-    if (!program) {
-        synthesizeGLError(INVALID_VALUE);
-        return false;
-    }
-    ensureContext(m_contextObj);
-    GLint maxAttributeSize = 0;
-    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize);
-    GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination
-    GLsizei nameLength = 0;
-    GLint size = 0;
-    GLenum type = 0;
-    ::glGetActiveAttrib(static_cast<GLuint>(program), index, maxAttributeSize, &nameLength, &size, &type, name);
-    if (!nameLength)
-        return false;
-    info.name = String(name, nameLength);
-    info.type = type;
-    info.size = size;
-    return true;
-}
-    
-bool GraphicsContext3D::getActiveUniform(Platform3DObject program, unsigned long index, ActiveInfo& info)
-{
-    if (!program) {
-        synthesizeGLError(INVALID_VALUE);
-        return false;
-    }
-    ensureContext(m_contextObj);
-    GLint maxUniformSize = 0;
-    ::glGetProgramiv(static_cast<GLuint>(program), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
-    GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination
-    GLsizei nameLength = 0;
-    GLint size = 0;
-    GLenum type = 0;
-    ::glGetActiveUniform(static_cast<GLuint>(program), index, maxUniformSize, &nameLength, &size, &type, name);
-    if (!nameLength)
-        return false;
-    info.name = String(name, nameLength);
-    info.type = type;
-    info.size = size;
-    return true;
-}
-
-void GraphicsContext3D::getAttachedShaders(Platform3DObject program, int maxCount, int* count, unsigned int* shaders)
-{
-    if (!program) {
-        synthesizeGLError(INVALID_VALUE);
-        return;
-    }
-    ensureContext(m_contextObj);
-    ::glGetAttachedShaders(static_cast<GLuint>(program), maxCount, count, shaders);
-}
-
-int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name)
-{
-    if (!program)
-        return -1;
-    
-    ensureContext(m_contextObj);
-    return ::glGetAttribLocation((GLuint) program, name.utf8().data());
-}
-
-GraphicsContext3D::Attributes GraphicsContext3D::getContextAttributes()
-{
-    return m_attrs;
-}
-
-unsigned long GraphicsContext3D::getError()
-{
-    if (m_syntheticErrors.size() > 0) {
-        ListHashSet<unsigned long>::iterator iter = m_syntheticErrors.begin();
-        unsigned long err = *iter;
-        m_syntheticErrors.remove(iter);
-        return err;
-    }
-
-    ensureContext(m_contextObj);
-    return ::glGetError();
-}
-
-String GraphicsContext3D::getString(unsigned long name)
-{
-    ensureContext(m_contextObj);
-    return String((const char*) ::glGetString(name));
-}
-
-void GraphicsContext3D::hint(unsigned long target, unsigned long mode)
-{
-    ensureContext(m_contextObj);
-    ::glHint(target, mode);
-}
-
-bool GraphicsContext3D::isBuffer(Platform3DObject buffer)
-{
-    if (!buffer)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsBuffer((GLuint) buffer);
-}
-
-bool GraphicsContext3D::isEnabled(unsigned long cap)
-{
-    ensureContext(m_contextObj);
-    return ::glIsEnabled(cap);
-}
-
-bool GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer)
-{
-    if (!framebuffer)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsFramebufferEXT((GLuint) framebuffer);
-}
-
-bool GraphicsContext3D::isProgram(Platform3DObject program)
-{
-    if (!program)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsProgram((GLuint) program);
-}
-
-bool GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer)
-{
-    if (!renderbuffer)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsRenderbufferEXT((GLuint) renderbuffer);
-}
-
-bool GraphicsContext3D::isShader(Platform3DObject shader)
-{
-    if (!shader)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsShader((GLuint) shader);
-}
-
-bool GraphicsContext3D::isTexture(Platform3DObject texture)
-{
-    if (!texture)
-        return false;
-    
-    ensureContext(m_contextObj);
-    return ::glIsTexture((GLuint) texture);
-}
-
-void GraphicsContext3D::lineWidth(double width)
-{
-    ensureContext(m_contextObj);
-    ::glLineWidth(static_cast<float>(width));
-}
-
-void GraphicsContext3D::linkProgram(Platform3DObject program)
-{
-    ASSERT(program);
-    ensureContext(m_contextObj);
-    ::glLinkProgram((GLuint) program);
-}
-
-void GraphicsContext3D::pixelStorei(unsigned long pname, long param)
-{
-    ensureContext(m_contextObj);
-    ::glPixelStorei(pname, param);
-}
-
-void GraphicsContext3D::polygonOffset(double factor, double units)
-{
-    ensureContext(m_contextObj);
-    ::glPolygonOffset(static_cast<float>(factor), static_cast<float>(units));
-}
-
-void GraphicsContext3D::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type, void* data)
-{
-    // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
-    // all previous rendering calls should be done before reading pixels.
-    ensureContext(m_contextObj);
-    ::glFlush();
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
-        ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
-        ::glBlitFramebufferEXT(x, y, x + width, y + height, x, y, x + width, y + height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-        ::glFlush();
-    }
-    ::glReadPixels(x, y, width, height, format, type, data);
-    if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-}
-
-void GraphicsContext3D::releaseShaderCompiler()
-{
-    // FIXME: This is not implemented on desktop OpenGL. We need to have ifdefs for the different GL variants
-    ensureContext(m_contextObj);
-    //::glReleaseShaderCompiler();
-}
-
-void GraphicsContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
-{
-    ensureContext(m_contextObj);
-    switch (internalformat) {
-    case DEPTH_STENCIL:
-        internalformat = GL_DEPTH24_STENCIL8_EXT;
-        break;
-    case DEPTH_COMPONENT16:
-        internalformat = GL_DEPTH_COMPONENT;
-        break;
-    case RGBA4:
-    case RGB5_A1:
-        internalformat = GL_RGBA;
-        break;
-    case RGB565:
-        internalformat = GL_RGB;
-        break;
-    }
-    ::glRenderbufferStorageEXT(target, internalformat, width, height);
-}
-
-void GraphicsContext3D::sampleCoverage(double value, bool invert)
-{
-    ensureContext(m_contextObj);
-    ::glSampleCoverage(static_cast<float>(value), invert);
-}
-
-void GraphicsContext3D::scissor(long x, long y, unsigned long width, unsigned long height)
-{
-    ensureContext(m_contextObj);
-    ::glScissor(x, y, width, height);
-}
-
-void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string)
-{
-    ASSERT(shader);
-    
-    ensureContext(m_contextObj);
-
-    ShaderSourceEntry entry;
-
-    entry.source = string;
-
-    m_shaderSourceMap.set(shader, entry);
-}
-
-void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
-{
-    ensureContext(m_contextObj);
-    ::glStencilFunc(func, ref, mask);
-}
-
-void GraphicsContext3D::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask)
-{
-    ensureContext(m_contextObj);
-    ::glStencilFuncSeparate(face, func, ref, mask);
-}
-
-void GraphicsContext3D::stencilMask(unsigned long mask)
-{
-    ensureContext(m_contextObj);
-    ::glStencilMask(mask);
-}
-
-void GraphicsContext3D::stencilMaskSeparate(unsigned long face, unsigned long mask)
-{
-    ensureContext(m_contextObj);
-    ::glStencilMaskSeparate(face, mask);
-}
-
-void GraphicsContext3D::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass)
-{
-    ensureContext(m_contextObj);
-    ::glStencilOp(fail, zfail, zpass);
-}
-
-void GraphicsContext3D::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass)
-{
-    ensureContext(m_contextObj);
-    ::glStencilOpSeparate(face, fail, zfail, zpass);
-}
-
-void GraphicsContext3D::texParameterf(unsigned target, unsigned pname, float value)
-{
-    ensureContext(m_contextObj);
-    ::glTexParameterf(target, pname, static_cast<float>(value));
-}
-
-void GraphicsContext3D::texParameteri(unsigned target, unsigned pname, int value)
-{
-    ensureContext(m_contextObj);
-    ::glTexParameteri(target, pname, static_cast<float>(value));
-}
-
-void GraphicsContext3D::uniform1f(long location, float v0)
-{
-    ensureContext(m_contextObj);
-    ::glUniform1f(location, v0);
-}
-
-void GraphicsContext3D::uniform1fv(long location, float* array, int size)
-{
-    ensureContext(m_contextObj);
-    ::glUniform1fv(location, size, array);
-}
-
-void GraphicsContext3D::uniform2f(long location, float v0, float v1)
-{
-    ensureContext(m_contextObj);
-    ::glUniform2f(location, v0, v1);
-}
-
-void GraphicsContext3D::uniform2fv(long location, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 2
-    ensureContext(m_contextObj);
-    ::glUniform2fv(location, size, array);
-}
-
-void GraphicsContext3D::uniform3f(long location, float v0, float v1, float v2)
-{
-    ensureContext(m_contextObj);
-    ::glUniform3f(location, v0, v1, v2);
-}
-
-void GraphicsContext3D::uniform3fv(long location, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 3
-    ensureContext(m_contextObj);
-    ::glUniform3fv(location, size, array);
-}
-
-void GraphicsContext3D::uniform4f(long location, float v0, float v1, float v2, float v3)
-{
-    ensureContext(m_contextObj);
-    ::glUniform4f(location, v0, v1, v2, v3);
-}
-
-void GraphicsContext3D::uniform4fv(long location, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 4
-    ensureContext(m_contextObj);
-    ::glUniform4fv(location, size, array);
-}
-
-void GraphicsContext3D::uniform1i(long location, int v0)
-{
-    ensureContext(m_contextObj);
-    ::glUniform1i(location, v0);
-}
-
-void GraphicsContext3D::uniform1iv(long location, int* array, int size)
-{
-    ensureContext(m_contextObj);
-    ::glUniform1iv(location, size, array);
-}
-
-void GraphicsContext3D::uniform2i(long location, int v0, int v1)
-{
-    ensureContext(m_contextObj);
-    ::glUniform2i(location, v0, v1);
-}
-
-void GraphicsContext3D::uniform2iv(long location, int* array, int size)
-{
-    // FIXME: length needs to be a multiple of 2
-    ensureContext(m_contextObj);
-    ::glUniform2iv(location, size, array);
-}
-
-void GraphicsContext3D::uniform3i(long location, int v0, int v1, int v2)
-{
-    ensureContext(m_contextObj);
-    ::glUniform3i(location, v0, v1, v2);
-}
-
-void GraphicsContext3D::uniform3iv(long location, int* array, int size)
-{
-    // FIXME: length needs to be a multiple of 3
-    ensureContext(m_contextObj);
-    ::glUniform3iv(location, size, array);
-}
-
-void GraphicsContext3D::uniform4i(long location, int v0, int v1, int v2, int v3)
-{
-    ensureContext(m_contextObj);
-    ::glUniform4i(location, v0, v1, v2, v3);
-}
-
-void GraphicsContext3D::uniform4iv(long location, int* array, int size)
-{
-    // FIXME: length needs to be a multiple of 4
-    ensureContext(m_contextObj);
-    ::glUniform4iv(location, size, array);
-}
-
-void GraphicsContext3D::uniformMatrix2fv(long location, bool transpose, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 4
-    ensureContext(m_contextObj);
-    ::glUniformMatrix2fv(location, size, transpose, array);
-}
-
-void GraphicsContext3D::uniformMatrix3fv(long location, bool transpose, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 9
-    ensureContext(m_contextObj);
-    ::glUniformMatrix3fv(location, size, transpose, array);
-}
-
-void GraphicsContext3D::uniformMatrix4fv(long location, bool transpose, float* array, int size)
-{
-    // FIXME: length needs to be a multiple of 16
-    ensureContext(m_contextObj);
-    ::glUniformMatrix4fv(location, size, transpose, array);
-}
-
-void GraphicsContext3D::useProgram(Platform3DObject program)
-{
-    ensureContext(m_contextObj);
-    ::glUseProgram((GLuint) program);
-}
-
-void GraphicsContext3D::validateProgram(Platform3DObject program)
-{
-    ASSERT(program);
     
-    ensureContext(m_contextObj);
-    ::glValidateProgram((GLuint) program);
-}
-
-void GraphicsContext3D::vertexAttrib1f(unsigned long indx, float v0)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib1f(indx, v0);
-}
-
-void GraphicsContext3D::vertexAttrib1fv(unsigned long indx, float* array)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib1fv(indx, array);
-}
-
-void GraphicsContext3D::vertexAttrib2f(unsigned long indx, float v0, float v1)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib2f(indx, v0, v1);
-}
-
-void GraphicsContext3D::vertexAttrib2fv(unsigned long indx, float* array)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib2fv(indx, array);
-}
-
-void GraphicsContext3D::vertexAttrib3f(unsigned long indx, float v0, float v1, float v2)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib3f(indx, v0, v1, v2);
-}
-
-void GraphicsContext3D::vertexAttrib3fv(unsigned long indx, float* array)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib3fv(indx, array);
-}
-
-void GraphicsContext3D::vertexAttrib4f(unsigned long indx, float v0, float v1, float v2, float v3)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib4f(indx, v0, v1, v2, v3);
-}
-
-void GraphicsContext3D::vertexAttrib4fv(unsigned long indx, float* array)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttrib4fv(indx, array);
-}
-
-void GraphicsContext3D::vertexAttribPointer(unsigned long indx, int size, int type, bool normalized, unsigned long stride, unsigned long offset)
-{
-    ensureContext(m_contextObj);
-    ::glVertexAttribPointer(indx, size, type, normalized, stride, reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-void GraphicsContext3D::viewport(long x, long y, unsigned long width, unsigned long height)
-{
-    ensureContext(m_contextObj);
-    ::glViewport(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
-}
-
-void GraphicsContext3D::getBooleanv(unsigned long pname, unsigned char* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetBooleanv(pname, value);
-}
-
-void GraphicsContext3D::getBufferParameteriv(unsigned long target, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetBufferParameteriv(target, pname, value);
-}
-
-void GraphicsContext3D::getFloatv(unsigned long pname, float* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetFloatv(pname, value);
-}
-
-void GraphicsContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    if (attachment == DEPTH_STENCIL_ATTACHMENT)
-        attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
-    ::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
-}
-
-void GraphicsContext3D::getIntegerv(unsigned long pname, int* value)
-{
-    // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL.  Any valid
-    // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most
-    // useful for desktop WebGL users.
-    // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS
-    // because desktop GL's corresponding queries return the number of components
-    // whereas GLES2 return the number of vectors (each vector has 4 components).
-    // Therefore, the value returned by desktop GL needs to be divided by 4.
-    ensureContext(m_contextObj);
-    switch (pname) {
-    case IMPLEMENTATION_COLOR_READ_FORMAT:
-        *value = GL_RGB;
-        break;
-    case IMPLEMENTATION_COLOR_READ_TYPE:
-        *value = GL_UNSIGNED_BYTE;
-        break;
-    case MAX_FRAGMENT_UNIFORM_VECTORS:
-        ::glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, value);
-        *value /= 4;
-        break;
-    case MAX_VERTEX_UNIFORM_VECTORS:
-        ::glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, value);
-        *value /= 4;
-        break;
-    case MAX_VARYING_VECTORS:
-        ::glGetIntegerv(GL_MAX_VARYING_FLOATS, value);
-        *value /= 4;
-        break;
-    default:
-        ::glGetIntegerv(pname, value);
-    }
-}
-
-void GraphicsContext3D::getProgramiv(Platform3DObject program, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetProgramiv((GLuint) program, pname, value);
-}
-
-String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)
-{
-    ASSERT(program);
-    
-    ensureContext(m_contextObj);
-    GLint length;
-    ::glGetProgramiv((GLuint) program, GL_INFO_LOG_LENGTH, &length);
-    
-    GLsizei size;
-    GLchar* info = (GLchar*) fastMalloc(length);
-    if (!info)
-        return "";
-
-    ::glGetProgramInfoLog((GLuint) program, length, &size, info);
-    String s(info);
-    fastFree(info);
-    return s;
-}
-
-void GraphicsContext3D::getRenderbufferParameteriv(unsigned long target, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetRenderbufferParameterivEXT(target, pname, value);
-}
-
-void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname, int* value)
-{
-    ASSERT(shader);
-    
-    ensureContext(m_contextObj);
-    
-    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
-    
-    switch (pname) {
-        case DELETE_STATUS:
-        case SHADER_TYPE:
-            // Let OpenGL handle these.
-        
-            ::glGetShaderiv((GLuint) shader, pname, value);
-            break;
-
-        case COMPILE_STATUS:
-            if (result == m_shaderSourceMap.end()) {
-                (*value) = static_cast<int>(false);
-                return;
-            }
-                
-            (*value) = static_cast<int>(result->second.isValid);
-            break;
-            
-        case INFO_LOG_LENGTH:
-            if (result == m_shaderSourceMap.end()) {
-                (*value) = 0;
-                return;
-            }
-            
-            (*value) = getShaderInfoLog(shader).length();
-            break;
-            
-        case SHADER_SOURCE_LENGTH:
-            (*value) = getShaderSource(shader).length();
-            break;
-        
-        default:
-            synthesizeGLError(INVALID_ENUM);
-    }
-}
-
-String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
-{
-    ASSERT(shader);
-
-    ensureContext(m_contextObj);
-    GLint length;
-    ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
-
-    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
-
-    if (result == m_shaderSourceMap.end())
-         return "";
-
-     ShaderSourceEntry entry = result->second;
-
-     if (entry.isValid) {
-         GLint length;
-         ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
-
-         GLsizei size;
-         GLchar* info = (GLchar*) fastMalloc(length);
-         if (!info)
-             return "";
-
-         ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
-
-         String s(info);
-         fastFree(info);
-         return s;
-     }
-     else {
-         return entry.log;
-     }
-}
-
-String GraphicsContext3D::getShaderSource(Platform3DObject shader)
-{
-    ASSERT(shader);
-
-    ensureContext(m_contextObj);
-
-    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
-
-    if (result == m_shaderSourceMap.end())
-        return "";
-
-    return result->second.source;
-}
-
-
-void GraphicsContext3D::getTexParameterfv(unsigned long target, unsigned long pname, float* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetTexParameterfv(target, pname, value);
-}
-
-void GraphicsContext3D::getTexParameteriv(unsigned long target, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetTexParameteriv(target, pname, value);
-}
-
-void GraphicsContext3D::getUniformfv(Platform3DObject program, long location, float* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetUniformfv((GLuint) program, location, value);
-}
-
-void GraphicsContext3D::getUniformiv(Platform3DObject program, long location, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetUniformiv((GLuint) program, location, value);
-}
-
-long GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
-{
-    ASSERT(program);
-    
-    ensureContext(m_contextObj);
-    return ::glGetUniformLocation((GLuint) program, name.utf8().data());
-}
-
-void GraphicsContext3D::getVertexAttribfv(unsigned long index, unsigned long pname, float* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetVertexAttribfv(index, pname, value);
-}
-
-void GraphicsContext3D::getVertexAttribiv(unsigned long index, unsigned long pname, int* value)
-{
-    ensureContext(m_contextObj);
-    ::glGetVertexAttribiv(index, pname, value);
-}
-
-long GraphicsContext3D::getVertexAttribOffset(unsigned long index, unsigned long pname)
-{
-    ensureContext(m_contextObj);
-    
-    void* pointer;
-    ::glGetVertexAttribPointerv(index, pname, &pointer);
-    return reinterpret_cast<long>(pointer);
-}
-
-int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, void* pixels)
-{
-    ensureContext(m_contextObj);
-
-    ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
-    return 0;
-}
-
-int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, unsigned format, unsigned type, void* pixels)
-{
-    ensureContext(m_contextObj);
-
-    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
-    ::glTexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels);
-    return 0;
-}
-
-unsigned GraphicsContext3D::createBuffer()
-{
-    ensureContext(m_contextObj);
-    GLuint o;
-    glGenBuffers(1, &o);
-    return o;
-}
-
-unsigned GraphicsContext3D::createFramebuffer()
-{
-    ensureContext(m_contextObj);
-    GLuint o;
-    glGenFramebuffersEXT(1, &o);
-    return o;
-}
-
-unsigned GraphicsContext3D::createProgram()
-{
-    ensureContext(m_contextObj);
-    return glCreateProgram();
-}
-
-unsigned GraphicsContext3D::createRenderbuffer()
-{
-    ensureContext(m_contextObj);
-    GLuint o;
-    glGenRenderbuffersEXT(1, &o);
-    return o;
-}
-
-unsigned GraphicsContext3D::createShader(unsigned long type)
-{
-    ensureContext(m_contextObj);
-    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
-}
-
-unsigned GraphicsContext3D::createTexture()
-{
-    ensureContext(m_contextObj);
-    GLuint o;
-    glGenTextures(1, &o);
-    return o;
-}
-
-void GraphicsContext3D::deleteBuffer(unsigned buffer)
-{
-    ensureContext(m_contextObj);
-    glDeleteBuffers(1, &buffer);
-}
-
-void GraphicsContext3D::deleteFramebuffer(unsigned framebuffer)
-{
-    ensureContext(m_contextObj);
-    glDeleteFramebuffersEXT(1, &framebuffer);
-}
-
-void GraphicsContext3D::deleteProgram(unsigned program)
-{
-    ensureContext(m_contextObj);
-    glDeleteProgram(program);
-}
-
-void GraphicsContext3D::deleteRenderbuffer(unsigned renderbuffer)
-{
-    ensureContext(m_contextObj);
-    glDeleteRenderbuffersEXT(1, &renderbuffer);
-}
-
-void GraphicsContext3D::deleteShader(unsigned shader)
-{
-    ensureContext(m_contextObj);
-    glDeleteShader(shader);
-}
-
-void GraphicsContext3D::deleteTexture(unsigned texture)
-{
-    ensureContext(m_contextObj);
-    glDeleteTextures(1, &texture);
-}
-
-int GraphicsContext3D::sizeInBytes(int type)
-{
-    switch (type) {
-        case GL_BYTE:
-            return sizeof(GLbyte);
-        case GL_UNSIGNED_BYTE:
-            return sizeof(GLubyte);
-        case GL_SHORT:
-            return sizeof(GLshort);
-        case GL_UNSIGNED_SHORT:
-            return sizeof(GLushort);
-        case GL_INT:
-            return sizeof(GLint);
-        case GL_UNSIGNED_INT:
-            return sizeof(GLuint);
-        case GL_FLOAT:
-            return sizeof(GLfloat);
-        default:
-            return 0;
-    }
-}
-
-void GraphicsContext3D::synthesizeGLError(unsigned long error)
-{
-    m_syntheticErrors.add(error);
-}
 
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list