[WebGL] Add a pure virtual base class for GraphicsContext3D
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Dec 2019 21:43:12 +0000 (21:43 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Dec 2019 21:43:12 +0000 (21:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205604

Reviewed by Sam Weinig.

Source/WebCore:

This is the first step in a series of patches to allow multiple versions
of GraphicsContext3D to exist, each using a different backend rendering
system. I've added a GraphicsContext3DBase class (that will eventually
be named GraphicsContext3D) holding all the WebGL entry points as well
as some common helper functions.

I also took the chance to move some enums into enum classes, which
makes it more obvious where things come from. I also removed some
unused interfaces: WebGLRenderingContextErrorMessageCallback and
WebGLRenderingContextLostMessageCallback.

The existing GraphicsContext3D now inherits from the base class,
but is otherwise nearly identical. The next step will be to make
different instances rather than the mix of #if macros we have now.
The virtual functions are marked "override" for now, but will become
"final" in the instances.

There should be no change in functionality.

* Headers.cmake:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::cacheActiveAttribLocations):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::initializeNewContext):
(WebCore::WebGLRenderingContextBase::destroyGraphicsContext3D):
(WebCore::WebGLRenderingContextBase::getActiveAttrib):
(WebCore::WebGLRenderingContextBase::getActiveUniform):
(WebCore::WebGLRenderingContextBase::getContextAttributes):
(WebCore::WebGLRenderingContextBase::getUniformLocation):
(WebCore::WebGLRenderingContextBase::texImage2DImpl):
(WebCore::WebGLRenderingContextBase::texSubImage2DImpl):
(WebCore::WebGLRenderingContextBase::texSubImage2D):
(WebCore::WebGLRenderingContextBase::texImage2D):
(WebCore::WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid):
(WebCore::WebGLRenderingContextLostCallback::WebGLRenderingContextLostCallback): Deleted.
(WebCore::WebGLRenderingContextErrorMessageCallback::WebGLRenderingContextErrorMessageCallback): Deleted.
* html/canvas/WebGLRenderingContextBase.h:
* platform/graphics/FormatConverter.cpp:
(WebCore::uint8_t>):
(WebCore::float>):
(WebCore::uint16_t>):
(WebCore::FormatConverter::convert):
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::ImageExtractor):
(WebCore::GraphicsContext3D::extractImageData):
(WebCore::GraphicsContext3D::extractTextureData):
(WebCore::TexelBytesForFormat):
(WebCore::GraphicsContext3D::packPixels):
(WebCore::GraphicsContext3D::getClearBitsByAttachmentType): Deleted.
(WebCore::GraphicsContext3D::getClearBitsByFormat): Deleted.
(WebCore::GraphicsContext3D::getChannelBitsByFormat): Deleted.
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::ImageExtractor::imageHtmlDomSource):
(WebCore::GraphicsContext3D::platformGraphicsContext3D const): Deleted.
(WebCore::GraphicsContext3D::platformTexture const): Deleted.
(WebCore::GraphicsContext3D::platformLayer const): Deleted.
(WebCore::GraphicsContext3D::hasAlpha): Deleted.
(WebCore::GraphicsContext3D::hasColor): Deleted.
(WebCore::GraphicsContext3D::srcFormatComesFromDOMElementOrImageData): Deleted.
* platform/graphics/GraphicsTypes3D.h:
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
(WebCore::GraphicsContext3D::readPixels):
(WebCore::GraphicsContext3D::validateDepthStencil):
(WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
(WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
(WebCore::GraphicsContext3D::prepareTexture):
(WebCore::GraphicsContext3D::readRenderingResults):
(WebCore::GraphicsContext3D::reshape):
(WebCore::GraphicsContext3D::bindFramebuffer):
(WebCore::GraphicsContext3D::copyTexImage2D):
(WebCore::GraphicsContext3D::copyTexSubImage2D):
(WebCore::GraphicsContext3D::getContextAttributes): Deleted.
* platform/graphics/cg/GraphicsContext3DCG.cpp:
(WebCore::getSourceDataFormat):
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::create):
(WebCore::GraphicsContext3D::createShared):
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
(WebCore::GraphicsContext3D::setRenderbufferStorageFromDrawable):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::checkGPUStatus):
(WebCore::GraphicsContext3D::presentRenderbuffer):
(WebCore::GraphicsContext3D::texImageIOSurface2D):
(WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
(WebCore::GraphicsContext3D::updateCGLContext):
(WebCore::GraphicsContext3D::screenDidChange):
(WebCore::GraphicsContext3D::setContextLostCallback): Deleted.
(WebCore::GraphicsContext3D::setErrorMessageCallback): Deleted.
* platform/graphics/cocoa/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]):
(-[WebGLLayer copyImageSnapshotWithColorSpace:]):
(-[WebGLLayer bindFramebufferToNextAvailableSurface]):
* platform/graphics/cv/TextureCacheCV.mm:
(WebCore::TextureCacheCV::create):
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
(WebCore::GraphicsContext3D::readPixels):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::validateDepthStencil):
(WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
(WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
(WebCore::GraphicsContext3D::prepareTexture):
(WebCore::GraphicsContext3D::readRenderingResults):
(WebCore::GraphicsContext3D::reshape):
(WebCore::GraphicsContext3D::bindFramebuffer):
(WebCore::GraphicsContext3D::copyTexImage2D):
(WebCore::GraphicsContext3D::copyTexSubImage2D):
(WebCore::GraphicsContext3D::getContextAttributes): Deleted.

LayoutTests:

Remove a test that has existing coverage in the WebGL test suite.

* fast/canvas/webgl/framebuffer-object-attachment-expected.txt: Removed.
* fast/canvas/webgl/framebuffer-object-attachment.html: Removed.

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

39 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/framebuffer-object-attachment-expected.txt [deleted file]
LayoutTests/fast/canvas/webgl/framebuffer-object-attachment.html [deleted file]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Headers.cmake
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/canvas/WebGLProgram.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/platform/graphics/FormatConverter.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/GraphicsContext3DBase.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsContext3DBase.h [new file with mode: 0644]
Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/GraphicsTypes3D.h
Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm
Source/WebCore/platform/graphics/cv/TextureCacheCV.mm
Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.cpp
Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DANGLELayer.h
Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp
Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGC3DLayer.h
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h

index e2a5c53..d773027 100644 (file)
@@ -1,3 +1,15 @@
+2019-12-27  Dean Jackson  <dino@apple.com>
+
+        [WebGL] Add a pure virtual base class for GraphicsContext3D
+        https://bugs.webkit.org/show_bug.cgi?id=205604
+
+        Reviewed by Sam Weinig.
+
+        Remove a test that has existing coverage in the WebGL test suite.
+
+        * fast/canvas/webgl/framebuffer-object-attachment-expected.txt: Removed.
+        * fast/canvas/webgl/framebuffer-object-attachment.html: Removed.
+
 2019-12-25  Dean Jackson  <dino@apple.com>
 
         [WebGL] Enable ANGLE by default for Cocoa platforms (except simulator)
diff --git a/LayoutTests/fast/canvas/webgl/framebuffer-object-attachment-expected.txt b/LayoutTests/fast/canvas/webgl/framebuffer-object-attachment-expected.txt
deleted file mode 100644 (file)
index 8e7fdfe..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-Test framebuffer object attachment behaviors
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Dimensions 0 x 0
-Create renderbuffers
-PASS gl = create3DContext() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS stencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-Attach depth using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depth, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach color renderbuffer with internalformat == RGBA4
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB5_A1
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB565
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Create and attach depthStencil renderbuffer
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH) is width
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT) is height
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT) is gl.DEPTH_STENCIL
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE) is 0
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-
-Dimensions 0 x 2
-Create renderbuffers
-PASS gl = create3DContext() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS stencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-Attach depth using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depth, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach color renderbuffer with internalformat == RGBA4
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB5_A1
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB565
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Create and attach depthStencil renderbuffer
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH) is width
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT) is gl.DEPTH_STENCIL
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE) is 0
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-
-Dimensions 2 x 0
-Create renderbuffers
-PASS gl = create3DContext() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS stencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-Attach depth using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depth, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach stencil, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach depthStencil, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-Attach color renderbuffer with internalformat == RGBA4
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB5_A1
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach color renderbuffer with internalformat == RGB565
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Create and attach depthStencil renderbuffer
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT) is height
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT) is gl.DEPTH_STENCIL
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE) is 0
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-
-Dimensions 2 x 2
-Create renderbuffers
-PASS gl = create3DContext() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS stencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-Attach depth using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true
-PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true
-Attach depth using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach stencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach stencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using DEPTH_STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true
-PASS gl.getParameter(gl.STENCIL_BITS) >= 8 is true
-Attach depthStencil using DEPTH_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depthStencil using STENCIL_ATTACHMENT
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36054
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : 
-Attach depth, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach stencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach depth, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach depthStencil, then depth, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach stencil, then depthStencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach depthStencil, then stencil, causing conflict
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36061
-Attach color renderbuffer with internalformat == RGBA4
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true
-PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true
-Attach color renderbuffer with internalformat == RGB5_A1
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true
-PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true
-Attach color renderbuffer with internalformat == RGB565
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) == 0 is true
-PASS gl.getParameter(gl.STENCIL_BITS) == 0 is true
-Create and attach depthStencil renderbuffer
-PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH) is width
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT) is height
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT) is gl.DEPTH_STENCIL
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE) is 0
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_DEPTH_SIZE) > 0 is true
-PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_STENCIL_SIZE) > 0 is true
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned 36053
-PASS gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 is true
-PASS gl.getParameter(gl.DEPTH_BITS) >= 16 is true
-PASS gl.getParameter(gl.STENCIL_BITS) >= 8 is true
-
-test: DEPTH_COMPONENT16 vs DEPTH_STENCIL with delete
-PASS should be green
-test deleting second renderbuffer
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS should be green
-
-test: DEPTH_COMPONENT16 vs DEPTH_STENCIL with unbind
-PASS should be green
-test unbinding second renderbuffer
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS should be green
-
-test: DEPTH_STENCIL vs DEPTH_COMPONENT16 with delete
-PASS should be green
-test deleting second renderbuffer
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS should be green
-
-test: DEPTH_STENCIL vs DEPTH_COMPONENT16 with unbind
-PASS should be green
-test unbinding second renderbuffer
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS should be green
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-
-Attachments of different sizes should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS (OpenGL ES 2.0 4.4.5)
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS was FRAMEBUFFER_INCOMPLETE_DIMENSIONS or FRAMEBUFFER_UNSUPPORTED
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS was FRAMEBUFFER_INCOMPLETE_DIMENSIONS or FRAMEBUFFER_UNSUPPORTED
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS was FRAMEBUFFER_INCOMPLETE_DIMENSIONS or FRAMEBUFFER_UNSUPPORTED
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS getError was expected value: NO_ERROR : 
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-
-Wrong storage type for type of attachment be FRAMEBUFFER_INCOMPLETE_ATTACHMENT (OpenGL ES 2.0 4.4.5)
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_ATTACHMENT was FRAMEBUFFER_INCOMPLETE_ATTACHMENT or FRAMEBUFFER_UNSUPPORTED
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-
-0 size attachment should be FRAMEBUFFER_INCOMPLETE_ATTACHMENT (OpenGL ES 2.0 4.4.5)
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_ATTACHMENT was FRAMEBUFFER_INCOMPLETE_ATTACHMENT or FRAMEBUFFER_UNSUPPORTED
-PASS getError was expected value: NO_ERROR : 
-
-No attachments should be INCOMPLETE_FRAMEBUFFER_MISSING_ATTACHMENT (OpenGL ES 2.0 4.4.5)
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT was FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT or FRAMEBUFFER_UNSUPPORTED
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT was FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT or FRAMEBUFFER_UNSUPPORTED
-PASS getError was expected value: NO_ERROR : 
-
-Test drawing or reading from an incomplete framebuffer
-PASS fbo = gl.createFramebuffer() is non-null.
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-PASS depthBuffer = gl.createRenderbuffer() is non-null.
-PASS getError was expected value: NO_ERROR : 
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_COMPLETE was FRAMEBUFFER_COMPLETE
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS was FRAMEBUFFER_INCOMPLETE_DIMENSIONS or FRAMEBUFFER_UNSUPPORTED
-
-Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : drawArrays with incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : readPixels from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : copyTexImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : copyTexSubImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : clear with incomplete framebuffer
-PASS fbo2 = gl.createFramebuffer() is non-null.
-PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT was FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT or FRAMEBUFFER_UNSUPPORTED
-
-Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : drawArrays with incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : readPixels from incomplete framebuffer
-PASS getError was expected value: INVALID_OPERATION : copyTexImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_OPERATION : copyTexSubImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : clear with incomplete framebuffer
-PASS colorBuffer = gl.createRenderbuffer() is non-null.
-
-Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION
-PASS getError was expected value: NO_ERROR : 
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : drawArrays with incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : readPixels from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : copyTexImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : copyTexSubImage2D from incomplete framebuffer
-PASS getError was expected value: INVALID_FRAMEBUFFER_OPERATION : clear with incomplete framebuffer
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/canvas/webgl/framebuffer-object-attachment.html b/LayoutTests/fast/canvas/webgl/framebuffer-object-attachment.html
deleted file mode 100644 (file)
index b52da15..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src="../../../resources/js-test.js"></script>
-<script src="resources/webgl-test.js"></script>
-<script src="resources/webgl-test-utils.js"></script>
-</head>
-<body>
-<div id="description"></div>
-<div id="console"></div>
-
-<script>
-if (window.internals)
-    window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
-
-var wtu = WebGLTestUtils;
-var gl;
-var fbo;
-var depthBuffer;
-var stencilBuffer;
-var depthStencilBuffer;
-var colorBuffer;
-var width;
-var height;
-
-const ALLOW_COMPLETE              = 0x01;
-const ALLOW_UNSUPPORTED           = 0x02;
-const ALLOW_INCOMPLETE_ATTACHMENT = 0x04;
-
-function checkFramebufferForAllowedStatuses(allowedStatuses)
-{
-    // If the framebuffer is in an error state for multiple reasons,
-    // we can't guarantee which one will be reported.
-    var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
-    var statusAllowed = ((allowedStatuses & ALLOW_COMPLETE) && (status == gl.FRAMEBUFFER_COMPLETE)) ||
-                        ((allowedStatuses & ALLOW_UNSUPPORTED) && (status == gl.FRAMEBUFFER_UNSUPPORTED)) ||
-                        ((allowedStatuses & ALLOW_INCOMPLETE_ATTACHMENT) && (status == gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT));
-    var msg = "gl.checkFramebufferStatus(gl.FRAMEBUFFER) returned " + status;
-    if (statusAllowed)
-        testPassed(msg);
-    else
-        testFailed(msg);
-}
-
-function checkBufferBits(attachment0, attachment1)
-{
-    if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE)
-      return;
-
-    var haveDepthBuffer = attachment0 == gl.DEPTH_ATTACHMENT ||
-                          attachment0 == gl.DEPTH_STENCIL_ATTACHMENT ||
-                          attachment1 == gl.DEPTH_ATTACHMENT ||
-                          attachment1 == gl.DEPTH_STENCIL_ATTACHMENT;
-    var haveStencilBuffer = attachment0 == gl.STENCIL_ATTACHMENT ||
-                            attachment0 == gl.DEPTH_STENCIL_ATTACHMENT ||
-                            attachment1 == gl.STENCIL_ATTACHMENT ||
-                            attachment1 == gl.DEPTH_STENCIL_ATTACHMENT;
-
-    shouldBeTrue("gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16");
-
-    if (haveDepthBuffer)
-      shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16");
-    else
-      shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
-
-    if (haveStencilBuffer)
-      shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) >= 8");
-    else
-      shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
-}
-
-function testAttachment(attachment, buffer, allowedStatuses)
-{
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, buffer);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    checkFramebufferForAllowedStatuses(allowedStatuses);
-    if ((allowedStatuses & ALLOW_COMPLETE) == 0) {
-        gl.clear(gl.COLOR_BUFFER_BIT);
-        glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION);
-        gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(width * height * 4));
-        glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION);
-    }
-    checkBufferBits(attachment);
-    gl.deleteFramebuffer(fbo);
-}
-
-function testAttachments(attachment0, buffer0, attachment1, buffer1, allowedStatuses)
-{
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment0, gl.RENDERBUFFER, buffer0);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment1, gl.RENDERBUFFER, buffer1);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    checkFramebufferForAllowedStatuses(allowedStatuses);
-    checkBufferBits(attachment0, attachment1);
-    gl.deleteFramebuffer(fbo);
-}
-
-function testColorRenderbuffer(internalformat, allowedStatuses)
-{
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, internalformat, width, height);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    testAttachment(gl.COLOR_ATTACHMENT0, colorBuffer, allowedStatuses);
-}
-
-function testDepthStencilRenderbuffer(allowedStatuses)
-{
-    shouldBeNonNull("depthStencilBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-
-    // OpenGL itself doesn't seem to guarantee that e.g. a 2 x 0
-    // renderbuffer will report 2 for its width when queried.
-    if (!(height == 0 && width > 0))
-        shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH)", "width");
-    if (!(width == 0 && height > 0))
-        shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT)", "height");
-    shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_INTERNAL_FORMAT)", "gl.DEPTH_STENCIL");
-    shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_RED_SIZE)", "0");
-    shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_GREEN_SIZE)", "0");
-    shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_BLUE_SIZE)", "0");
-    shouldBe("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_ALPHA_SIZE)", "0");
-    // Avoid verifying these for zero-sized renderbuffers for the time
-    // being since it appears that even OpenGL doesn't guarantee them.
-    if (width > 0 && height > 0) {
-        shouldBeTrue("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_DEPTH_SIZE) > 0");
-        shouldBeTrue("gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_STENCIL_SIZE) > 0");
-    }
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, allowedStatuses);
-    testDepthStencilDepthStencil();
-}
-
-function testDepthStencilDepthStencil()
-{
-    if (!width || !height) {
-        return;
-    }
-
-    var tests = [
-        {   firstFormat: gl.DEPTH_COMPONENT16,
-            firstAttach: gl.DEPTH_ATTACHMENT,
-            secondFormat: gl.DEPTH_STENCIL,
-            secondAttach: gl.DEPTH_STENCIL_ATTACHMENT
-        },
-        {   firstFormat: gl.DEPTH_STENCIL,
-            firstAttach: gl.DEPTH_STENCIL_ATTACHMENT,
-            secondFormat: gl.DEPTH_COMPONENT16,
-            secondAttach: gl.DEPTH_ATTACHMENT
-        }
-    ];
-    for (var ii = 0; ii < tests.length; ++ii) {
-        var test = tests[ii];
-        for (var jj = 0; jj < 2; ++jj) {
-            var fbo = gl.createFramebuffer();
-            var tex = gl.createTexture();
-            var firstRb = gl.createRenderbuffer();
-
-            debug("");
-            debug("test: " + wtu.glEnumToString(gl, test.firstFormat) + " vs " + wtu.glEnumToString(gl, test.secondFormat) + " with " + (jj ? "unbind" : "delete"));
-
-            gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-            // attach texture as color
-            gl.bindTexture(gl.TEXTURE_2D, tex);
-            gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-            gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
-
-            // attach first
-            gl.bindRenderbuffer(gl.RENDERBUFFER, firstRb);
-            gl.renderbufferStorage(gl.RENDERBUFFER, test.firstFormat, width, height);
-            gl.framebufferRenderbuffer(gl.FRAMEBUFFER, test.firstAttach, gl.RENDERBUFFER, firstRb);
-
-            if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE) {
-                gl.enable(gl.DEPTH_TEST);
-                var program = wtu.setupColorQuad(gl);
-                // Test it works
-                wtu.drawUByteColorQuad(gl, [0, 255, 0, 255]);
-                wtu.drawUByteColorQuad(gl, [255, 0, 0, 255]);  // should not draw since DEPTH_FUNC == LESS
-                wtu.checkCanvasRect(gl, 0, 0, width, height, [0, 255, 0, 255], "should be green");
-
-                var secondRb = gl.createRenderbuffer();
-
-                // attach second
-                gl.bindRenderbuffer(gl.RENDERBUFFER, secondRb);
-                gl.renderbufferStorage(gl.RENDERBUFFER, test.secondFormat, width, height);
-                gl.framebufferRenderbuffer(gl.FRAMEBUFFER, test.secondAttach, gl.RENDERBUFFER, secondRb);
-
-                if (jj == 0) {
-                  // now delete it
-                  debug("test deleting second renderbuffer");
-                  gl.deleteRenderbuffer(secondRb);
-                } else {
-                  // unbind it
-                  debug("test unbinding second renderbuffer");
-                  gl.framebufferRenderbuffer(gl.FRAMEBUFFER, test.secondAttach, gl.RENDERBUFFER, null);
-                }
-
-                // If the first attachment is not restored this may fail
-                shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
-                glErrorShouldBe(gl, gl.NO_ERROR);
-
-                // If the first attachment is not restored this may fail.
-                gl.clear(gl.DEPTH_BUFFER_BIT);
-                wtu.drawUByteColorQuad(gl, [0, 255, 0, 255]);
-                wtu.drawUByteColorQuad(gl, [255, 0, 0, 255]);  // should not draw since DEPTH_FUNC == LESS
-                wtu.checkCanvasRect(gl, 0, 0, width, height, [0, 255, 0, 255], "should be green");
-                gl.disable(gl.DEPTH_TEST);
-
-                if (jj == 1) {
-                  gl.deleteRenderbuffer(secondRb);
-                }
-            }
-
-            gl.deleteRenderbuffer(secondRb);
-            gl.deleteFramebuffer(fbo);
-        }
-    }
-    glErrorShouldBe(gl, gl.NO_ERROR);
-}
-
-description("Test framebuffer object attachment behaviors");
-
-for (width = 0; width <= 2; width += 2)
-{
-    for (height = 0; height <= 2; height += 2)
-    {
-        debug("");
-        debug("Dimensions " + width + " x " + height);
-
-        debug("Create renderbuffers");
-        shouldBeNonNull("gl = create3DContext()");
-        shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-        gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, width, height);
-        glErrorShouldBe(gl, gl.NO_ERROR);
-        shouldBeNonNull("depthBuffer = gl.createRenderbuffer()");
-        gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
-        glErrorShouldBe(gl, gl.NO_ERROR);
-        shouldBeNonNull("stencilBuffer = gl.createRenderbuffer()");
-        gl.bindRenderbuffer(gl.RENDERBUFFER, stencilBuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, width, height);
-        glErrorShouldBe(gl, gl.NO_ERROR);
-        shouldBeNonNull("depthStencilBuffer = gl.createRenderbuffer()");
-        gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
-        glErrorShouldBe(gl, gl.NO_ERROR);
-
-        var allowedStatusForGoodCase
-            = (width == 0 || height == 0) ? ALLOW_INCOMPLETE_ATTACHMENT : ALLOW_COMPLETE;
-
-        // some cases involving stencil seem to be implementation-dependent
-        var allowedStatusForImplDependentCase = allowedStatusForGoodCase | ALLOW_UNSUPPORTED;
-
-        debug("Attach depth using DEPTH_ATTACHMENT");
-        testAttachment(gl.DEPTH_ATTACHMENT, depthBuffer, allowedStatusForGoodCase);
-        debug("Attach depth using STENCIL_ATTACHMENT");
-        testAttachment(gl.STENCIL_ATTACHMENT, depthBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-        debug("Attach depth using DEPTH_STENCIL_ATTACHMENT");
-        testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, depthBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-        debug("Attach stencil using STENCIL_ATTACHMENT");
-        testAttachment(gl.STENCIL_ATTACHMENT, stencilBuffer, allowedStatusForImplDependentCase);
-        debug("Attach stencil using DEPTH_ATTACHMENT");
-        testAttachment(gl.DEPTH_ATTACHMENT, stencilBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-        debug("Attach stencil using DEPTH_STENCIL_ATTACHMENT");
-        testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, stencilBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-        debug("Attach depthStencil using DEPTH_STENCIL_ATTACHMENT");
-        testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, allowedStatusForGoodCase);
-        debug("Attach depthStencil using DEPTH_ATTACHMENT");
-        testAttachment(gl.DEPTH_ATTACHMENT, depthStencilBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-        debug("Attach depthStencil using STENCIL_ATTACHMENT");
-        testAttachment(gl.STENCIL_ATTACHMENT, depthStencilBuffer, ALLOW_INCOMPLETE_ATTACHMENT);
-
-        var allowedStatusForConflictedAttachment
-            = (width == 0 || height == 0) ? ALLOW_UNSUPPORTED | ALLOW_INCOMPLETE_ATTACHMENT
-                                          : ALLOW_UNSUPPORTED;
-
-        debug("Attach depth, then stencil, causing conflict");
-        testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.STENCIL_ATTACHMENT, stencilBuffer, allowedStatusForConflictedAttachment);
-        debug("Attach stencil, then depth, causing conflict");
-        testAttachments(gl.STENCIL_ATTACHMENT, stencilBuffer, gl.DEPTH_ATTACHMENT, depthBuffer, allowedStatusForConflictedAttachment);
-        debug("Attach depth, then depthStencil, causing conflict");
-        testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, allowedStatusForConflictedAttachment);
-        debug("Attach depthStencil, then depth, causing conflict");
-        testAttachments(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, gl.DEPTH_ATTACHMENT, depthBuffer, allowedStatusForConflictedAttachment);
-        debug("Attach stencil, then depthStencil, causing conflict");
-        testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, allowedStatusForConflictedAttachment);
-        debug("Attach depthStencil, then stencil, causing conflict");
-        testAttachments(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, gl.STENCIL_ATTACHMENT, stencilBuffer, allowedStatusForConflictedAttachment);
-
-        debug("Attach color renderbuffer with internalformat == RGBA4");
-        testColorRenderbuffer(gl.RGBA4, allowedStatusForGoodCase);
-
-        debug("Attach color renderbuffer with internalformat == RGB5_A1");
-        testColorRenderbuffer(gl.RGB5_A1, allowedStatusForGoodCase);
-
-        debug("Attach color renderbuffer with internalformat == RGB565");
-        testColorRenderbuffer(gl.RGB565, allowedStatusForGoodCase);
-
-        debug("Create and attach depthStencil renderbuffer");
-        testDepthStencilRenderbuffer(allowedStatusForGoodCase);
-    }
-}
-
-// Determine if we can attach both color and depth or color and depth_stencil
-var depthFormat;
-var depthAttachment;
-
-function checkValidColorDepthCombination() {
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-
-    shouldBeNonNull("depthBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
-
-    return tryDepth(gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) || tryDepth(gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT);
-
-    function tryDepth(try_format, try_attachment) {
-        if (depthAttachment) {
-            // If we've tried once unattach the old one.
-            gl.framebufferRenderbuffer(
-                gl.FRAMEBUFFER, depthAttachment, gl.RENDERBUFFER, null);
-        }
-        depthFormat = try_format;
-        depthAttachment = try_attachment;
-        gl.framebufferRenderbuffer(
-            gl.FRAMEBUFFER, depthAttachment, gl.RENDERBUFFER, depthBuffer);
-        gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 16, 16);
-        glErrorShouldBe(gl, gl.NO_ERROR);
-        return gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
-    }
-}
-
-if (checkValidColorDepthCombination()) {
-    testFramebufferIncompleteDimensions();
-    testFramebufferIncompleteAttachment();
-    testFramebufferIncompleteMissingAttachment();
-    testUsingIncompleteFramebuffer();
-}
-
-function checkFramebuffer(expected) {
-    var actual = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
-    var msg = "gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be " + wtu.glEnumToString(gl, expected) + " was " + wtu.glEnumToString(gl, actual);
-    if (expected != gl.FRAMEBUFFER_COMPLETE) {
-        msg += " or FRAMEBUFFER_UNSUPPORTED";
-    }
-    if (actual == expected ||
-        (expected != gl.FRAMEBUFFER_COMPLETE &&
-         actual == gl.FRAMBUFFER_UNSUPPORTED)) {
-        testPassed(msg);
-    } else {
-        testFailed(msg);
-    }
-}
-
-function testUsingIncompleteFramebuffer() {
-    debug("");
-    debug("Test drawing or reading from an incomplete framebuffer");
-    var program = wtu.setupTexturedQuad(gl);
-    var tex = gl.createTexture();
-    wtu.fillTexture(gl, tex, 1, 1, [0,255,0,255]);
-
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-
-    shouldBeNonNull("depthBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, depthAttachment, gl.RENDERBUFFER, depthBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 16, 16);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    // We pick this combination because it works on desktop OpenGL but should not work on OpenGL ES 2.0
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 32, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS);
-    debug("");
-    debug("Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION");
-    testRenderingAndReading();
-
-    shouldBeNonNull("fbo2 = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo2);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
-    debug("");
-    debug("Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION");
-    testRenderingAndReading();
-
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 0, 0);
-    debug("");
-    debug("Drawing or reading from an incomplete framebuffer should generate INVALID_FRAMEBUFFER_OPERATION");
-    testRenderingAndReading();
-
-    function testRenderingAndReading() {
-        glErrorShouldBe(gl, gl.NO_ERROR);
-        wtu.drawQuad(gl);
-        glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION, "drawArrays with incomplete framebuffer");
-        gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4));
-        glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION, "readPixels from incomplete framebuffer");
-        // copyTexImage and copyTexSubImage can be either INVALID_FRAMEBUFFER_OPERATION because
-        // the framebuffer is invalid OR INVALID_OPERATION because in the case of no attachments
-        // the framebuffer is not of a compatible type.
-        gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
-        glErrorShouldBe(gl, [gl.INVALID_FRAMEBUFFER_OPERATION, gl.INVALID_OPERATION], "copyTexImage2D from incomplete framebuffer");
-        gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 1, 1, 0);
-        glErrorShouldBe(gl, [gl.INVALID_FRAMEBUFFER_OPERATION, gl.INVALID_OPERATION], "copyTexSubImage2D from incomplete framebuffer");
-        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-        glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION, "clear with incomplete framebuffer");
-    }
-}
-
-function testFramebufferIncompleteAttachment() {
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    debug("");
-    debug("Wrong storage type for type of attachment be FRAMEBUFFER_INCOMPLETE_ATTACHMENT (OpenGL ES 2.0 4.4.5)");
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
-
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    debug("");
-    debug("0 size attachment should be FRAMEBUFFER_INCOMPLETE_ATTACHMENT (OpenGL ES 2.0 4.4.5)");
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 0, 0);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
-
-    glErrorShouldBe(gl, gl.NO_ERROR);
-}
-
-function testFramebufferIncompleteMissingAttachment() {
-    debug("");
-    debug("No attachments should be INCOMPLETE_FRAMEBUFFER_MISSING_ATTACHMENT (OpenGL ES 2.0 4.4.5)");
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
-
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, null);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
-
-    glErrorShouldBe(gl, gl.NO_ERROR);
-}
-
-function testFramebufferIncompleteDimensions() {
-    debug("");
-    debug("Attachments of different sizes should be FRAMEBUFFER_INCOMPLETE_DIMENSIONS (OpenGL ES 2.0 4.4.5)");
-
-    shouldBeNonNull("fbo = gl.createFramebuffer()");
-    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-    shouldBeNonNull("colorBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-
-    shouldBeNonNull("depthBuffer = gl.createRenderbuffer()");
-    gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
-    gl.framebufferRenderbuffer(
-        gl.FRAMEBUFFER, depthAttachment, gl.RENDERBUFFER, depthBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 16, 16);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 32, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS);
-    gl.renderbufferStorage(gl.RENDERBUFFER, depthFormat, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-    gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 32);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 16, 16);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-
-    var tex = gl.createTexture();
-    gl.bindTexture(gl.TEXTURE_2D, tex);
-    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
-    glErrorShouldBe(gl, gl.NO_ERROR);
-    if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
-        return;
-    }
-
-    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-    checkFramebuffer(gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS);
-    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 16, 16, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-    checkFramebuffer(gl.FRAMEBUFFER_COMPLETE);
-
-    glErrorShouldBe(gl, gl.NO_ERROR);
-}
-</script>
-</body>
-</html>
index 071a868..06f5002 100644 (file)
@@ -434,7 +434,6 @@ webkit.org/b/169918 compositing/video/video-background-color.html [ Missing Cras
 # WebGL related failures
 webkit.org/b/169917 fast/canvas/webgl/antialiasing-enabled.html [ Failure Pass ]
 webkit.org/b/169917 fast/canvas/webgl/copyBufferSubData.html [ Failure ]
-webkit.org/b/169917 fast/canvas/webgl/framebuffer-object-attachment.html [ Failure ]
 webkit.org/b/169917 fast/canvas/webgl/getBufferSubData-webgl1.html [ Failure ]
 webkit.org/b/169917 fast/canvas/webgl/premultiplyalpha-test.html [ Failure ]
 webkit.org/b/169917 fast/canvas/webgl/read-pixels-test.html [ Failure Pass ]
index cdf04d6..006dbe1 100644 (file)
@@ -2740,6 +2740,7 @@ webkit.org/b/171617 perf/object-keys.html [ Pass Failure ]
 
 # WebGL tests which need triaging https://bugs.webkit.org/b/174100
 fast/canvas/webgl/framebuffer-object-attachment.html [ Failure ]
+fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html [ Failure ]
 fast/canvas/webgl/oes-texture-float-linear.html [ Failure ]
 fast/canvas/webgl/tex-image-and-sub-image-2d-with-potentially-subsampled-image.html [ Failure ]
 fast/canvas/webgl/webgl-compressed-texture-size-limit.html [ Failure ]
index af7caa6..2631021 100644 (file)
@@ -294,8 +294,6 @@ webkit.org/b/82665 webarchive/test-css-url-resources-inline-styles.html [ Failur
 
 webkit.org/b/82762 fast/animation/request-animation-frame-during-modal.html
 
-webkit.org/b/82805 fast/canvas/webgl/framebuffer-object-attachment.html [ Failure ]
-
 webkit.org/b/82972 plugins/keyboard-events.html [ Pass Failure ]
 webkit.org/b/82972 plugins/layout-in-beforeload-listener-affects-plugin-loading.html [ Pass Failure ]
 webkit.org/b/82972 plugins/mouse-events-fixedpos.html [ Pass Failure ]
index 5125001..e32abda 100644 (file)
@@ -1,3 +1,128 @@
+2019-12-27  Dean Jackson  <dino@apple.com>
+
+        [WebGL] Add a pure virtual base class for GraphicsContext3D
+        https://bugs.webkit.org/show_bug.cgi?id=205604
+
+        Reviewed by Sam Weinig.
+
+        This is the first step in a series of patches to allow multiple versions
+        of GraphicsContext3D to exist, each using a different backend rendering
+        system. I've added a GraphicsContext3DBase class (that will eventually
+        be named GraphicsContext3D) holding all the WebGL entry points as well
+        as some common helper functions.
+
+        I also took the chance to move some enums into enum classes, which
+        makes it more obvious where things come from. I also removed some
+        unused interfaces: WebGLRenderingContextErrorMessageCallback and
+        WebGLRenderingContextLostMessageCallback.
+
+        The existing GraphicsContext3D now inherits from the base class,
+        but is otherwise nearly identical. The next step will be to make
+        different instances rather than the mix of #if macros we have now.
+        The virtual functions are marked "override" for now, but will become
+        "final" in the instances.
+
+        There should be no change in functionality.
+
+        * Headers.cmake:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/WebGLProgram.cpp:
+        (WebCore::WebGLProgram::cacheActiveAttribLocations):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::initializeNewContext):
+        (WebCore::WebGLRenderingContextBase::destroyGraphicsContext3D):
+        (WebCore::WebGLRenderingContextBase::getActiveAttrib):
+        (WebCore::WebGLRenderingContextBase::getActiveUniform):
+        (WebCore::WebGLRenderingContextBase::getContextAttributes):
+        (WebCore::WebGLRenderingContextBase::getUniformLocation):
+        (WebCore::WebGLRenderingContextBase::texImage2DImpl):
+        (WebCore::WebGLRenderingContextBase::texSubImage2DImpl):
+        (WebCore::WebGLRenderingContextBase::texSubImage2D):
+        (WebCore::WebGLRenderingContextBase::texImage2D):
+        (WebCore::WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid):
+        (WebCore::WebGLRenderingContextLostCallback::WebGLRenderingContextLostCallback): Deleted.
+        (WebCore::WebGLRenderingContextErrorMessageCallback::WebGLRenderingContextErrorMessageCallback): Deleted.
+        * html/canvas/WebGLRenderingContextBase.h:
+        * platform/graphics/FormatConverter.cpp:
+        (WebCore::uint8_t>):
+        (WebCore::float>):
+        (WebCore::uint16_t>):
+        (WebCore::FormatConverter::convert):
+        * platform/graphics/GraphicsContext3D.cpp:
+        (WebCore::GraphicsContext3D::ImageExtractor::ImageExtractor):
+        (WebCore::GraphicsContext3D::extractImageData):
+        (WebCore::GraphicsContext3D::extractTextureData):
+        (WebCore::TexelBytesForFormat):
+        (WebCore::GraphicsContext3D::packPixels):
+        (WebCore::GraphicsContext3D::getClearBitsByAttachmentType): Deleted.
+        (WebCore::GraphicsContext3D::getClearBitsByFormat): Deleted.
+        (WebCore::GraphicsContext3D::getChannelBitsByFormat): Deleted.
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::ImageExtractor::imageHtmlDomSource):
+        (WebCore::GraphicsContext3D::platformGraphicsContext3D const): Deleted.
+        (WebCore::GraphicsContext3D::platformTexture const): Deleted.
+        (WebCore::GraphicsContext3D::platformLayer const): Deleted.
+        (WebCore::GraphicsContext3D::hasAlpha): Deleted.
+        (WebCore::GraphicsContext3D::hasColor): Deleted.
+        (WebCore::GraphicsContext3D::srcFormatComesFromDOMElementOrImageData): Deleted.
+        * platform/graphics/GraphicsTypes3D.h:
+        * platform/graphics/angle/GraphicsContext3DANGLE.cpp:
+        (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
+        (WebCore::GraphicsContext3D::readPixels):
+        (WebCore::GraphicsContext3D::validateDepthStencil):
+        (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
+        (WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
+        (WebCore::GraphicsContext3D::prepareTexture):
+        (WebCore::GraphicsContext3D::readRenderingResults):
+        (WebCore::GraphicsContext3D::reshape):
+        (WebCore::GraphicsContext3D::bindFramebuffer):
+        (WebCore::GraphicsContext3D::copyTexImage2D):
+        (WebCore::GraphicsContext3D::copyTexSubImage2D):
+        (WebCore::GraphicsContext3D::getContextAttributes): Deleted.
+        * platform/graphics/cg/GraphicsContext3DCG.cpp:
+        (WebCore::getSourceDataFormat):
+        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::create):
+        (WebCore::GraphicsContext3D::createShared):
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::~GraphicsContext3D):
+        (WebCore::GraphicsContext3D::setRenderbufferStorageFromDrawable):
+        (WebCore::GraphicsContext3D::makeContextCurrent):
+        (WebCore::GraphicsContext3D::checkGPUStatus):
+        (WebCore::GraphicsContext3D::presentRenderbuffer):
+        (WebCore::GraphicsContext3D::texImageIOSurface2D):
+        (WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
+        (WebCore::GraphicsContext3D::updateCGLContext):
+        (WebCore::GraphicsContext3D::screenDidChange):
+        (WebCore::GraphicsContext3D::setContextLostCallback): Deleted.
+        (WebCore::GraphicsContext3D::setErrorMessageCallback): Deleted.
+        * platform/graphics/cocoa/WebGLLayer.mm:
+        (-[WebGLLayer initWithGraphicsContext3D:]):
+        (-[WebGLLayer copyImageSnapshotWithColorSpace:]):
+        (-[WebGLLayer bindFramebufferToNextAvailableSurface]):
+        * platform/graphics/cv/TextureCacheCV.mm:
+        (WebCore::TextureCacheCV::create):
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary):
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
+        (WebCore::GraphicsContext3D::readPixels):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::validateDepthStencil):
+        (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
+        (WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
+        (WebCore::GraphicsContext3D::prepareTexture):
+        (WebCore::GraphicsContext3D::readRenderingResults):
+        (WebCore::GraphicsContext3D::reshape):
+        (WebCore::GraphicsContext3D::bindFramebuffer):
+        (WebCore::GraphicsContext3D::copyTexImage2D):
+        (WebCore::GraphicsContext3D::copyTexSubImage2D):
+        (WebCore::GraphicsContext3D::getContextAttributes): Deleted.
+
 2019-12-29  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Implement LineBuilder::revert
index 4583625..a419470 100644 (file)
@@ -1057,6 +1057,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
     platform/graphics/Gradient.h
     platform/graphics/GraphicsContext.h
     platform/graphics/GraphicsContext3D.h
+    platform/graphics/GraphicsContext3DBase.h
     platform/graphics/GraphicsContext3DAttributes.h
     platform/graphics/GraphicsContext3DManager.h
     platform/graphics/GraphicsContextImpl.h
index c968189..565226e 100644 (file)
@@ -1856,6 +1856,7 @@ platform/graphics/GeometryUtilities.cpp
 platform/graphics/Gradient.cpp
 platform/graphics/GradientImage.cpp
 platform/graphics/GraphicsContext.cpp
+platform/graphics/GraphicsContext3DBase.cpp
 platform/graphics/GraphicsContext3DManager.cpp
 platform/graphics/GraphicsContextImpl.cpp
 platform/graphics/GraphicsLayer.cpp
index bce6cd2..f04bf31 100644 (file)
                3135910A1E7DDC7300F30630 /* RTCSdpType.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591041E7DDC6000F30630 /* RTCSdpType.h */; };
                3135910B1E7DDC7300F30630 /* RTCSignalingState.h in Headers */ = {isa = PBXBuildFile; fileRef = 313591051E7DDC6000F30630 /* RTCSignalingState.h */; };
                313BCE1C235E3BE500FC39E5 /* ElementContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE1B235E3BDB00FC39E5 /* ElementContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               313DE87023A96973008FC47B /* GraphicsContext3DBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 313DE86F23A96967008FC47B /* GraphicsContext3DBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                3140379B124BEA7F00AF40E4 /* WebCoreMotionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                3140379D124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */; };
                3140C5201FDF151A00D2A873 /* OffscreenCanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 3140C51E1FDF151A00D2A873 /* OffscreenCanvasRenderingContext2D.h */; };
                313591051E7DDC6000F30630 /* RTCSignalingState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCSignalingState.h; sourceTree = "<group>"; };
                3135910C1E7DDCB600F30630 /* RTCBundlePolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCBundlePolicy.h; sourceTree = "<group>"; };
                313BCE1B235E3BDB00FC39E5 /* ElementContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementContext.h; sourceTree = "<group>"; };
+               313DE86D23A96966008FC47B /* GraphicsContext3DBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DBase.cpp; sourceTree = "<group>"; };
+               313DE86F23A96967008FC47B /* GraphicsContext3DBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContext3DBase.h; sourceTree = "<group>"; };
                31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreMotionManager.h; sourceTree = "<group>"; };
                31403798124BEA7F00AF40E4 /* WebCoreMotionManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreMotionManager.mm; sourceTree = "<group>"; };
                31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationClientIOS.h; sourceTree = "<group>"; };
                                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */,
                                49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */,
                                7C330A011DF8FAC600D3395C /* GraphicsContext3DAttributes.h */,
+                               313DE86D23A96966008FC47B /* GraphicsContext3DBase.cpp */,
+                               313DE86F23A96967008FC47B /* GraphicsContext3DBase.h */,
                                D0843A4C20FEC16500FE860E /* GraphicsContext3DManager.cpp */,
                                D0843A4A20FEBE3D00FE860E /* GraphicsContext3DManager.h */,
                                0F0012401FAD881000531D76 /* GraphicsContextImpl.cpp */,
                                B2A015A90AF6CD53006BCE0E /* GraphicsContext.h in Headers */,
                                49C7B9FC1042D3650009D447 /* GraphicsContext3D.h in Headers */,
                                7C330A021DF8FAC600D3395C /* GraphicsContext3DAttributes.h in Headers */,
+                               313DE87023A96973008FC47B /* GraphicsContext3DBase.h in Headers */,
                                31AB5000122878A2001A7DB0 /* GraphicsContext3DIOS.h in Headers */,
                                D0843A4B20FEBE3D00FE860E /* GraphicsContext3DManager.h in Headers */,
                                934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */,
index 61f8893..deeac75 100644 (file)
@@ -208,7 +208,7 @@ void WebGLProgram::cacheActiveAttribLocations(GraphicsContext3D* context3d)
     context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &numAttribs);
     m_activeAttribLocations.resize(static_cast<size_t>(numAttribs));
     for (int i = 0; i < numAttribs; ++i) {
-        ActiveInfo info;
+        GraphicsContext3D::ActiveInfo info;
         context3d->getActiveAttribImpl(object(), i, info);
         m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info.name);
     }
index 4e804c7..79a55e2 100644 (file)
@@ -373,32 +373,6 @@ static bool clip2D(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height,
     return (*clippedX != x || *clippedY != y || *clippedWidth != width || *clippedHeight != height);
 }
 
-class WebGLRenderingContextLostCallback : public GraphicsContext3D::ContextLostCallback {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit WebGLRenderingContextLostCallback(WebGLRenderingContextBase* cb) : m_context(cb) { }
-    virtual ~WebGLRenderingContextLostCallback() = default;
-
-    void onContextLost() override { m_context->forceLostContext(WebGLRenderingContext::RealLostContext); }
-private:
-    WebGLRenderingContextBase* m_context;
-};
-
-class WebGLRenderingContextErrorMessageCallback : public GraphicsContext3D::ErrorMessageCallback {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase* cb) : m_context(cb) { }
-    virtual ~WebGLRenderingContextErrorMessageCallback() = default;
-
-    void onErrorMessage(const String& message, GC3Dint) override
-    {
-        if (m_context->m_synthesizedErrorsToConsole)
-            m_context->printToConsole(MessageLevel::Error, message);
-    }
-private:
-    WebGLRenderingContextBase* m_context;
-};
-
 class InspectorScopedShaderProgramHighlight {
 public:
     InspectorScopedShaderProgramHighlight(WebGLRenderingContextBase& context, WebGLProgram* program)
@@ -809,9 +783,6 @@ void WebGLRenderingContextBase::initializeNewContext()
     m_context->reshape(canvasSize.width(), canvasSize.height());
     m_context->viewport(0, 0, canvasSize.width(), canvasSize.height());
     m_context->scissor(0, 0, canvasSize.width(), canvasSize.height());
-
-    m_context->setContextLostCallback(makeUnique<WebGLRenderingContextLostCallback>(this));
-    m_context->setErrorMessageCallback(makeUnique<WebGLRenderingContextErrorMessageCallback>(this));
 }
 
 void WebGLRenderingContextBase::setupFlags()
@@ -921,8 +892,6 @@ void WebGLRenderingContextBase::destroyGraphicsContext3D()
 
     if (m_context) {
         m_context->removeClient(*this);
-        m_context->setContextLostCallback(nullptr);
-        m_context->setErrorMessageCallback(nullptr);
         m_context = nullptr;
     }
 }
@@ -2535,7 +2504,7 @@ RefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProgram*
 {
     if (isContextLostOrPending() || !validateWebGLObject("getActiveAttrib", program))
         return nullptr;
-    ActiveInfo info;
+    GraphicsContext3D::ActiveInfo info;
     if (!m_context->getActiveAttrib(objectOrZero(program), index, info))
         return nullptr;
 
@@ -2548,7 +2517,7 @@ RefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLProgram
 {
     if (isContextLostOrPending() || !validateWebGLObject("getActiveUniform", program))
         return nullptr;
-    ActiveInfo info;
+    GraphicsContext3D::ActiveInfo info;
     if (!m_context->getActiveUniform(objectOrZero(program), index, info))
         return nullptr;
     if (!isGLES2Compliant())
@@ -2642,7 +2611,7 @@ Optional<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttributes
     // and stencil, regardless of the properties of the underlying
     // GraphicsContext3D.
 
-    auto attributes = m_context->getContextAttributes();
+    auto attributes = m_context->contextAttributes();
     if (!m_attributes.depth)
         attributes.depth = false;
     if (!m_attributes.stencil)
@@ -3006,7 +2975,7 @@ RefPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUniformLocation(WebGL
     m_context->getNonBuiltInActiveSymbolCount(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms);
 #endif
     for (GC3Dint i = 0; i < activeUniforms; i++) {
-        ActiveInfo info;
+        GraphicsContext3D::ActiveInfo info;
         if (!m_context->getActiveUniform(objectOrZero(program), i, info))
             return nullptr;
         // Strip "[0]" from the name if it's an array.
@@ -3773,7 +3742,7 @@ void WebGLRenderingContextBase::texImage2DBase(GC3Denum target, GC3Dint level, G
     tex->setLevelInfo(target, level, internalFormat, width, height, type);
 }
 
-void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha)
+void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::DOMSource domSource, bool flipY, bool premultiplyAlpha)
 {
     Vector<uint8_t> data;
     GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
@@ -3786,7 +3755,7 @@ void WebGLRenderingContextBase::texImage2DImpl(GC3Denum target, GC3Dint level, G
     const void* imagePixelData = imageExtractor.imagePixelData();
 
     bool needConversion = true;
-    if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == GraphicsContext3D::AlphaDoNothing && !flipY)
+    if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataFormat::RGBA8 && format == GraphicsContext3D::RGBA && alphaOp == GraphicsContext3D::AlphaOp::DoNothing && !flipY)
         needConversion = false;
     else {
         if (!m_context->packImageData(image, imagePixelData, format, type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) {
@@ -3872,7 +3841,7 @@ void WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint level, GC3De
         m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
 }
 
-void WebGLRenderingContextBase::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha)
+void WebGLRenderingContextBase::texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image* image, GraphicsContext3D::DOMSource domSource, bool flipY, bool premultiplyAlpha)
 {
     Vector<uint8_t> data;
     GraphicsContext3D::ImageExtractor imageExtractor(image, domSource, premultiplyAlpha, m_unpackColorspaceConversion == GraphicsContext3D::NONE);
@@ -3885,7 +3854,7 @@ void WebGLRenderingContextBase::texSubImage2DImpl(GC3Denum target, GC3Dint level
     const void* imagePixelData = imageExtractor.imagePixelData();
     
     bool needConversion = true;
-    if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataFormatRGBA8 && format == GraphicsContext3D::RGBA && alphaOp == GraphicsContext3D::AlphaDoNothing && !flipY)
+    if (type == GraphicsContext3D::UNSIGNED_BYTE && sourceDataFormat == GraphicsContext3D::DataFormat::RGBA8 && format == GraphicsContext3D::RGBA && alphaOp == GraphicsContext3D::AlphaOp::DoNothing && !flipY)
         needConversion = false;
     else {
         if (!m_context->packImageData(image, imagePixelData, format, type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtractor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) {
@@ -3972,7 +3941,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3D
 
         RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
         if (image)
-            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
+            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }, [&](const RefPtr<ImageData>& pixels) -> ExceptionOr<void> {
         auto texture = validateTextureBinding("texSubImage2D", target, true);
@@ -4038,7 +4007,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3D
         if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, internalFormat, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
             return { };
 
-        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
+        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }, [&](const RefPtr<HTMLCanvasElement>& canvas) -> ExceptionOr<void> {
         if (isContextLostOrPending())
@@ -4066,7 +4035,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3D
         if (imageData)
             texSubImage2D(target, level, xoffset, yoffset, format, type, TexImageSource(imageData.get()));
         else
-            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
+            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::DOMSource::Canvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }
 #if ENABLE(VIDEO)
@@ -4095,7 +4064,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texSubImage2D(GC3Denum target, GC3D
         RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
         if (!image)
             return { };
-        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
+        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }
 #endif
@@ -4541,7 +4510,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint
         // Normal pure SW path.
         RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
         if (image)
-            texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
+            texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }, [&](const RefPtr<ImageData>& pixels) -> ExceptionOr<void> {
         if (isContextLostOrPending() || !validateTexFunc("texImage2D", TexImage, SourceImageData, target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, 0, 0))
@@ -4583,7 +4552,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint
         if (!imageForRender || !validateTexFunc("texImage2D", TexImage, SourceHTMLImageElement, target, level, internalformat, imageForRender->width(), imageForRender->height(), 0, format, type, 0, 0))
             return { };
 
-        texImage2DImpl(target, level, internalformat, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
+        texImage2DImpl(target, level, internalformat, format, type, imageForRender.get(), GraphicsContext3D::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }, [&](const RefPtr<HTMLCanvasElement>& canvas) -> ExceptionOr<void> {
         if (isContextLostOrPending())
@@ -4619,7 +4588,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint
         if (imageData)
             texImage2D(target, level, internalformat, format, type, TexImageSource(imageData.get()));
         else
-            texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
+            texImage2DImpl(target, level, internalformat, format, type, canvas->copiedImage(), GraphicsContext3D::DOMSource::Canvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }
 #if ENABLE(VIDEO)
@@ -4656,7 +4625,7 @@ ExceptionOr<void> WebGLRenderingContextBase::texImage2D(GC3Denum target, GC3Dint
         RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
         if (!image)
             return { };
-        texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
+        texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContext3D::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
     }
 #endif
@@ -5394,11 +5363,10 @@ void WebGLRenderingContextBase::createFallbackBlackTextures1x1()
     m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0);
 }
 
-bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat,
-                                                                           GC3Denum colorBufferFormat)
+bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(GC3Denum texInternalFormat, GC3Denum colorBufferFormat)
 {
-    unsigned need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat);
-    unsigned have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat);
+    auto need = GraphicsContext3D::getChannelBitsByFormat(texInternalFormat);
+    auto have = GraphicsContext3D::getChannelBitsByFormat(colorBufferFormat);
     return (need & have) == need;
 }
 
index 59a0c07..cb872e1 100644 (file)
@@ -644,9 +644,9 @@ protected:
     void restoreStateAfterClear();
 
     void texImage2DBase(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
-    void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha);
+    void texImage2DImpl(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::DOMSource, bool flipY, bool premultiplyAlpha);
     void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum internalformat, GC3Denum format, GC3Denum type, const void* pixels);
-    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha);
+    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::DOMSource, bool flipY, bool premultiplyAlpha);
 
     bool checkTextureCompleteness(const char*, bool);
 
index 10e0d17..09eec78 100644 (file)
@@ -173,13 +173,13 @@ inline unsigned short convertFloatToHalfFloat(float f)
 
 //----------------------------------------------------------------------
 // Pixel unpacking routines.
-template<int format, typename SourceType, typename DstType>
+template<GraphicsContext3D::DataFormat format, typename SourceType, typename DstType>
 ALWAYS_INLINE void unpack(const SourceType*, DstType*, unsigned)
 {
     ASSERT_NOT_REACHED();
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -191,7 +191,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::BGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[2];
@@ -203,7 +203,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::ARGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[1];
@@ -215,7 +215,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::ABGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[3];
@@ -227,7 +227,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::BGRA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     const uint32_t* source32 = reinterpret_cast_ptr<const uint32_t*>(source);
     uint32_t* destination32 = reinterpret_cast_ptr<uint32_t*>(destination);
@@ -245,7 +245,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA5551, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGBA5551, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow);
@@ -264,7 +264,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA5551, uint
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA4444, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGBA4444, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow);
@@ -284,7 +284,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA4444, uint
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB565, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGB565, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow);
@@ -303,7 +303,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB565, uint16
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::R8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -315,7 +315,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR8, uint8_t, u
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -327,7 +327,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatAR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::AR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[1];
@@ -339,7 +339,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatAR8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::A8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = 0x0;
@@ -351,7 +351,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA8, uint8_t, u
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGBA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
@@ -364,7 +364,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::BGRA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
@@ -377,7 +377,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::ABGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
@@ -390,7 +390,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::ARGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
@@ -403,7 +403,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
@@ -416,7 +416,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::BGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
 {
     const float scaleFactor = 1.0f / 255.0f;
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
@@ -429,7 +429,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RGB32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -441,7 +441,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB32F, float,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::R32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -453,7 +453,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR32F, float, f
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::RA32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -465,7 +465,7 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA32F, float,
     }
 }
 
-template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormat::A32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = 0;
@@ -481,13 +481,13 @@ template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA32F, float, f
 // Pixel packing routines.
 //
 
-template<int format, int alphaOp, typename SourceType, typename DstType>
+template<GraphicsContext3D::DataFormat format, int alphaOp, typename SourceType, typename DstType>
 ALWAYS_INLINE void pack(const SourceType*, DstType*, unsigned)
 {
     ASSERT_NOT_REACHED();
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::A8, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[3];
@@ -496,7 +496,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA8, GraphicsCont
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R8, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -505,7 +505,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsCont
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R8, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -517,7 +517,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsCont
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R8, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -528,7 +528,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsCont
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA8, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -538,7 +538,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsCon
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA8, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -551,7 +551,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsCon
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA8, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -563,7 +563,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsCon
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB8, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -574,7 +574,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB8, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -590,7 +590,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsCo
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB8, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -606,12 +606,12 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsCo
 }
 
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA8, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     memcpy(destination, source, pixelsPerRow * 4);
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA8, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -628,7 +628,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsC
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA8, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -644,7 +644,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA4444, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow);
@@ -659,7 +659,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, Graphi
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA4444, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -676,7 +676,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, Graphi
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA4444, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -692,7 +692,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, Graphi
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA5551, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow);
@@ -707,7 +707,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, Graphi
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA5551, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -724,7 +724,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, Graphi
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA5551, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -740,7 +740,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, Graphi
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB565, GraphicsContext3D::AlphaOp::DoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow);
@@ -754,7 +754,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB565, GraphicsContext3D::AlphaOp::DoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] / 255.0f;
@@ -770,7 +770,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, Graphics
 }
 
 // FIXME: this routine is lossy and must be removed.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB565, GraphicsContext3D::AlphaOp::DoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
@@ -785,7 +785,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB32F, GraphicsContext3D::AlphaOp::DoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -796,7 +796,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB32F, GraphicsContext3D::AlphaOp::DoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -808,7 +808,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB32F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -821,12 +821,12 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, Graphics
 }
 
 // Used only during RGBA8 or BGRA8 -> floating-point uploads.
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA32F, GraphicsContext3D::AlphaOp::DoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     memcpy(destination, source, pixelsPerRow * 4 * sizeof(float));
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA32F, GraphicsContext3D::AlphaOp::DoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -839,7 +839,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, Graphic
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA32F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -852,7 +852,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, Graphic
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::A32F, GraphicsContext3D::AlphaOp::DoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[3];
@@ -861,7 +861,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA32F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R32F, GraphicsContext3D::AlphaOp::DoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -870,7 +870,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R32F, GraphicsContext3D::AlphaOp::DoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -880,7 +880,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R32F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -890,7 +890,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA32F, GraphicsContext3D::AlphaOp::DoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         destination[0] = source[0];
@@ -900,7 +900,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA32F, GraphicsContext3D::AlphaOp::DoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -911,7 +911,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA32F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
 {
     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -922,7 +922,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA16F, GraphicsContext3D::AlphaOp::DoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertFloatToHalfFloat(source[0]);
@@ -934,7 +934,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, Graphic
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA16F, GraphicsContext3D::AlphaOp::DoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -947,7 +947,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, Graphic
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGBA16F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -960,7 +960,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA16F, Graphic
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB16F, GraphicsContext3D::AlphaOp::DoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertFloatToHalfFloat(source[0]);
@@ -971,7 +971,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB16F, GraphicsContext3D::AlphaOp::DoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -983,7 +983,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RGB16F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -995,7 +995,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB16F, Graphics
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA16F, GraphicsContext3D::AlphaOp::DoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertFloatToHalfFloat(source[0]);
@@ -1005,7 +1005,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA16F, GraphicsContext3D::AlphaOp::DoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -1016,7 +1016,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::RA16F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1027,7 +1027,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA16F, GraphicsC
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R16F, GraphicsContext3D::AlphaOp::DoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertFloatToHalfFloat(source[0]);
@@ -1036,7 +1036,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R16F, GraphicsContext3D::AlphaOp::DoPremultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3];
@@ -1046,7 +1046,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsContext3D::AlphaDoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::R16F, GraphicsContext3D::AlphaOp::DoUnmultiply, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1056,7 +1056,7 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR16F, GraphicsCo
     }
 }
 
-template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA16F, GraphicsContext3D::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormat::A16F, GraphicsContext3D::AlphaOp::DoNothing, float, uint16_t>(const float* source, uint16_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertFloatToHalfFloat(source[3]);
@@ -1065,57 +1065,57 @@ template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA16F, GraphicsCo
     }
 }
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct IsFloatFormat {
     static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA32F
-        || Format == GraphicsContext3D::DataFormatRGB32F
-        || Format == GraphicsContext3D::DataFormatRA32F
-        || Format == GraphicsContext3D::DataFormatR32F
-        || Format == GraphicsContext3D::DataFormatA32F;
+        Format == GraphicsContext3D::DataFormat::RGBA32F
+        || Format == GraphicsContext3D::DataFormat::RGB32F
+        || Format == GraphicsContext3D::DataFormat::RA32F
+        || Format == GraphicsContext3D::DataFormat::R32F
+        || Format == GraphicsContext3D::DataFormat::A32F;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct IsHalfFloatFormat {
     static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA16F
-        || Format == GraphicsContext3D::DataFormatRGB16F
-        || Format == GraphicsContext3D::DataFormatRA16F
-        || Format == GraphicsContext3D::DataFormatR16F
-        || Format == GraphicsContext3D::DataFormatA16F;
+        Format == GraphicsContext3D::DataFormat::RGBA16F
+        || Format == GraphicsContext3D::DataFormat::RGB16F
+        || Format == GraphicsContext3D::DataFormat::RA16F
+        || Format == GraphicsContext3D::DataFormat::R16F
+        || Format == GraphicsContext3D::DataFormat::A16F;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct Is16bppFormat {
     static const bool Value =
-        Format == GraphicsContext3D::DataFormatRGBA5551
-        || Format == GraphicsContext3D::DataFormatRGBA4444
-        || Format == GraphicsContext3D::DataFormatRGB565;
+        Format == GraphicsContext3D::DataFormat::RGBA5551
+        || Format == GraphicsContext3D::DataFormat::RGBA4444
+        || Format == GraphicsContext3D::DataFormat::RGB565;
 };
 
-template<int Format, bool IsFloat = IsFloatFormat<Format>::Value, bool IsHalfFloat = IsHalfFloatFormat<Format>::Value, bool Is16bpp = Is16bppFormat<Format>::Value>
+template<GraphicsContext3D::DataFormat Format, bool IsFloat = IsFloatFormat<Format>::Value, bool IsHalfFloat = IsHalfFloatFormat<Format>::Value, bool Is16bpp = Is16bppFormat<Format>::Value>
 struct DataTypeForFormat {
     typedef uint8_t Type;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct DataTypeForFormat<Format, true, false, false> {
     typedef float Type;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct DataTypeForFormat<Format, false, true, false> {
     typedef uint16_t Type;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct DataTypeForFormat<Format, false, false, true> {
     typedef uint16_t Type;
 };
 
-template<int Format>
+template<GraphicsContext3D::DataFormat Format>
 struct IntermediateFormat {
-    static const int Value = (IsFloatFormat<Format>::Value || IsHalfFloatFormat<Format>::Value) ? GraphicsContext3D::DataFormatRGBA32F : GraphicsContext3D::DataFormatRGBA8;
+    static const GraphicsContext3D::DataFormat Value = (IsFloatFormat<Format>::Value || IsHalfFloatFormat<Format>::Value) ? GraphicsContext3D::DataFormat::RGBA32F : GraphicsContext3D::DataFormat::RGBA8;
 };
 
 
@@ -1128,24 +1128,24 @@ void FormatConverter::convert(GraphicsContext3D::DataFormat srcFormat, GraphicsC
         return convert<SrcFormat>(dstFormat, alphaOp);
 
         switch (srcFormat) {
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB565)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB32F)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatARGB8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatABGR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatAR8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGRA8)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA5551)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA4444)
-            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::R8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::A8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::R32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::A32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RA32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGB8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::BGR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGB565)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGB32F)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGBA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::ARGB8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::ABGR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::AR8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::BGRA8)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGBA5551)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGBA4444)
+            FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormat::RGBA32F)
         default:
             ASSERT_NOT_REACHED();
         }
@@ -1160,24 +1160,24 @@ ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::DataFormat dstFor
         return convert<SrcFormat, DstFormat>(alphaOp);
 
         switch (dstFormat) {
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB565)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB32F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA8)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA5551)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA4444)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA16F)
-            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::R8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::R16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::R32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::A8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::A16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::A32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RA8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RA16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RA32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGB8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGB565)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGB16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGB32F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGBA8)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGBA5551)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGBA4444)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGBA16F)
+            FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormat::RGBA32F)
         default:
             ASSERT_NOT_REACHED();
         }
@@ -1193,9 +1193,9 @@ ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::AlphaOp alphaOp)
         return convert<SrcFormat, DstFormat, alphaOp>();
 
         switch (alphaOp) {
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoNothing)
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoPremultiply)
-            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoUnmultiply)
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaOp::DoNothing)
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaOp::DoPremultiply)
+            FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaOp::DoUnmultiply)
         default:
             ASSERT_NOT_REACHED();
         }
@@ -1208,7 +1208,7 @@ ALWAYS_INLINE_EXCEPT_MSVC void FormatConverter::convert()
 {
     // Many instantiations of this template function will never be entered, so we try
     // to return immediately in these cases to avoid the compiler to generate useless code.
-    if (SrcFormat == DstFormat && alphaOp == GraphicsContext3D::AlphaDoNothing) {
+    if (SrcFormat == DstFormat && alphaOp == GraphicsContext3D::AlphaOp::DoNothing) {
         ASSERT_NOT_REACHED();
         return;
     }
@@ -1224,23 +1224,23 @@ ALWAYS_INLINE_EXCEPT_MSVC void FormatConverter::convert()
         return;
     }
     // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied.
-    if (!srcFormatComesFromDOMElementOrImageData && alphaOp == GraphicsContext3D::AlphaDoUnmultiply) {
+    if (!srcFormatComesFromDOMElementOrImageData && alphaOp == GraphicsContext3D::AlphaOp::DoUnmultiply) {
         ASSERT_NOT_REACHED();
         return;
     }
-    if ((!GraphicsContext3D::hasAlpha(SrcFormat) || !GraphicsContext3D::hasColor(SrcFormat) || !GraphicsContext3D::hasColor(DstFormat)) && alphaOp != GraphicsContext3D::AlphaDoNothing) {
+    if ((!GraphicsContext3D::hasAlpha(SrcFormat) || !GraphicsContext3D::hasColor(SrcFormat) || !GraphicsContext3D::hasColor(DstFormat)) && alphaOp != GraphicsContext3D::AlphaOp::DoNothing) {
         ASSERT_NOT_REACHED();
         return;
     }
 
     typedef typename DataTypeForFormat<SrcFormat>::Type SrcType;
     typedef typename DataTypeForFormat<DstFormat>::Type DstType;
-    const int IntermediateSrcFormat = IntermediateFormat<DstFormat>::Value;
+    const GraphicsContext3D::DataFormat IntermediateSrcFormat = IntermediateFormat<DstFormat>::Value;
     typedef typename DataTypeForFormat<IntermediateSrcFormat>::Type IntermediateSrcType;
     const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType);
     const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType);
-    const bool trivialUnpack = (SrcFormat == GraphicsContext3D::DataFormatRGBA8 && !IsFloatFormat<DstFormat>::Value && !IsHalfFloatFormat<DstFormat>::Value) || SrcFormat == GraphicsContext3D::DataFormatRGBA32F;
-    const bool trivialPack = (DstFormat == GraphicsContext3D::DataFormatRGBA8 || DstFormat == GraphicsContext3D::DataFormatRGBA32F) && alphaOp == GraphicsContext3D::AlphaDoNothing && m_dstStride > 0;
+    const bool trivialUnpack = (SrcFormat == GraphicsContext3D::DataFormat::RGBA8 && !IsFloatFormat<DstFormat>::Value && !IsHalfFloatFormat<DstFormat>::Value) || SrcFormat == GraphicsContext3D::DataFormat::RGBA32F;
+    const bool trivialPack = (DstFormat == GraphicsContext3D::DataFormat::RGBA8 || DstFormat == GraphicsContext3D::DataFormat::RGBA32F) && alphaOp == GraphicsContext3D::AlphaOp::DoNothing && m_dstStride > 0;
     ASSERT(!trivialUnpack || !trivialPack);
 
     const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart);
@@ -1263,9 +1263,9 @@ ALWAYS_INLINE_EXCEPT_MSVC void FormatConverter::convert()
         }
     } else {
 #if USE(ACCELERATE)
-        if (SrcFormat == GraphicsContext3D::DataFormatRGBA8
-            && DstFormat == GraphicsContext3D::DataFormatRGBA8
-            && alphaOp == GraphicsContext3D::AlphaDoUnmultiply) {
+        if (SrcFormat == GraphicsContext3D::DataFormat::RGBA8
+            && DstFormat == GraphicsContext3D::DataFormat::RGBA8
+            && alphaOp == GraphicsContext3D::AlphaOp::DoUnmultiply) {
             vImage_Buffer src;
             src.width = m_width;
             src.height = m_height;
index 4894747..461c571 100644 (file)
@@ -44,66 +44,66 @@ namespace {
 
 GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType)
 {
-    GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8;
+    GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormat::RGBA8;
     switch (destinationType) {
     case GraphicsContext3D::UNSIGNED_BYTE:
         switch (destinationFormat) {
         case GraphicsContext3D::RGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB8;
+            dstFormat = GraphicsContext3D::DataFormat::RGB8;
             break;
         case GraphicsContext3D::RGBA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA8;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA8;
             break;
         case GraphicsContext3D::ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatA8;
+            dstFormat = GraphicsContext3D::DataFormat::A8;
             break;
         case GraphicsContext3D::LUMINANCE:
-            dstFormat = GraphicsContext3D::DataFormatR8;
+            dstFormat = GraphicsContext3D::DataFormat::R8;
             break;
         case GraphicsContext3D::LUMINANCE_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRA8;
+            dstFormat = GraphicsContext3D::DataFormat::RA8;
             break;
         case GraphicsContext3D::SRGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB8;
+            dstFormat = GraphicsContext3D::DataFormat::RGB8;
             break;
         case GraphicsContext3D::SRGB_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA8;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA8;
             break;
         default:
             ASSERT_NOT_REACHED();
         }
         break;
     case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4:
-        dstFormat = GraphicsContext3D::DataFormatRGBA4444;
+        dstFormat = GraphicsContext3D::DataFormat::RGBA4444;
         break;
     case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
-        dstFormat = GraphicsContext3D::DataFormatRGBA5551;
+        dstFormat = GraphicsContext3D::DataFormat::RGBA5551;
         break;
     case GraphicsContext3D::UNSIGNED_SHORT_5_6_5:
-        dstFormat = GraphicsContext3D::DataFormatRGB565;
+        dstFormat = GraphicsContext3D::DataFormat::RGB565;
         break;
     case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float
         switch (destinationFormat) {
         case GraphicsContext3D::RGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB16F;
+            dstFormat = GraphicsContext3D::DataFormat::RGB16F;
             break;
         case GraphicsContext3D::RGBA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA16F;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA16F;
             break;
         case GraphicsContext3D::ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatA16F;
+            dstFormat = GraphicsContext3D::DataFormat::A16F;
             break;
         case GraphicsContext3D::LUMINANCE:
-            dstFormat = GraphicsContext3D::DataFormatR16F;
+            dstFormat = GraphicsContext3D::DataFormat::R16F;
             break;
         case GraphicsContext3D::LUMINANCE_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRA16F;
+            dstFormat = GraphicsContext3D::DataFormat::RA16F;
             break;
         case GraphicsContext3D::SRGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB16F;
+            dstFormat = GraphicsContext3D::DataFormat::RGB16F;
             break;
         case GraphicsContext3D::SRGB_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA16F;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA16F;
             break;
         default:
             ASSERT_NOT_REACHED();
@@ -112,25 +112,25 @@ GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum
     case GraphicsContext3D::FLOAT: // OES_texture_float
         switch (destinationFormat) {
         case GraphicsContext3D::RGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB32F;
+            dstFormat = GraphicsContext3D::DataFormat::RGB32F;
             break;
         case GraphicsContext3D::RGBA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA32F;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA32F;
             break;
         case GraphicsContext3D::ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatA32F;
+            dstFormat = GraphicsContext3D::DataFormat::A32F;
             break;
         case GraphicsContext3D::LUMINANCE:
-            dstFormat = GraphicsContext3D::DataFormatR32F;
+            dstFormat = GraphicsContext3D::DataFormat::R32F;
             break;
         case GraphicsContext3D::LUMINANCE_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRA32F;
+            dstFormat = GraphicsContext3D::DataFormat::RA32F;
             break;
         case GraphicsContext3D::SRGB:
-            dstFormat = GraphicsContext3D::DataFormatRGB32F;
+            dstFormat = GraphicsContext3D::DataFormat::RGB32F;
             break;
         case GraphicsContext3D::SRGB_ALPHA:
-            dstFormat = GraphicsContext3D::DataFormatRGBA32F;
+            dstFormat = GraphicsContext3D::DataFormat::RGBA32F;
             break;
         default:
             ASSERT_NOT_REACHED();
@@ -360,7 +360,7 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
     return GraphicsContext3D::NO_ERROR;
 }
 
-GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSource imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, DOMSource imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
 {
     m_image = image;
     m_imageHtmlDomSource = imageHtmlDomSource;
@@ -398,7 +398,7 @@ bool GraphicsContext3D::extractImageData(ImageData* imageData, GC3Denum format,
         return false;
     data.resize(packedSize);
 
-    if (!packPixels(imageData->data()->data(), DataFormatRGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY))
+    if (!packPixels(imageData->data()->data(), GraphicsContext3D::DataFormat::RGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaOp::DoPremultiply : AlphaOp::DoNothing, data.data(), flipY))
         return false;
 
     return true;
@@ -416,7 +416,7 @@ bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int heig
     unsigned int bytesPerPixel = componentsPerPixel * bytesPerComponent;
     data.resize(width * height * bytesPerPixel);
 
-    if (!packPixels(static_cast<const uint8_t*>(pixels), sourceDataFormat, width, height, unpackAlignment, format, type, (premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing), data.data(), flipY))
+    if (!packPixels(static_cast<const uint8_t*>(pixels), sourceDataFormat, width, height, unpackAlignment, format, type, (premultiplyAlpha ? AlphaOp::DoPremultiply : AlphaOp::DoNothing), data.data(), flipY))
         return false;
 
     return true;
@@ -425,36 +425,36 @@ bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int heig
 ALWAYS_INLINE unsigned TexelBytesForFormat(GraphicsContext3D::DataFormat format)
 {
     switch (format) {
-    case GraphicsContext3D::DataFormatR8:
-    case GraphicsContext3D::DataFormatA8:
+    case GraphicsContext3D::DataFormat::R8:
+    case GraphicsContext3D::DataFormat::A8:
         return 1;
-    case GraphicsContext3D::DataFormatRA8:
-    case GraphicsContext3D::DataFormatAR8:
-    case GraphicsContext3D::DataFormatRGBA5551:
-    case GraphicsContext3D::DataFormatRGBA4444:
-    case GraphicsContext3D::DataFormatRGB565:
-    case GraphicsContext3D::DataFormatA16F:
-    case GraphicsContext3D::DataFormatR16F:
+    case GraphicsContext3D::DataFormat::RA8:
+    case GraphicsContext3D::DataFormat::AR8:
+    case GraphicsContext3D::DataFormat::RGBA5551:
+    case GraphicsContext3D::DataFormat::RGBA4444:
+    case GraphicsContext3D::DataFormat::RGB565:
+    case GraphicsContext3D::DataFormat::A16F:
+    case GraphicsContext3D::DataFormat::R16F:
         return 2;
-    case GraphicsContext3D::DataFormatRGB8:
-    case GraphicsContext3D::DataFormatBGR8:
+    case GraphicsContext3D::DataFormat::RGB8:
+    case GraphicsContext3D::DataFormat::BGR8:
         return 3;
-    case GraphicsContext3D::DataFormatRGBA8:
-    case GraphicsContext3D::DataFormatARGB8:
-    case GraphicsContext3D::DataFormatABGR8:
-    case GraphicsContext3D::DataFormatBGRA8:
-    case GraphicsContext3D::DataFormatR32F:
-    case GraphicsContext3D::DataFormatA32F:
-    case GraphicsContext3D::DataFormatRA16F:
+    case GraphicsContext3D::DataFormat::RGBA8:
+    case GraphicsContext3D::DataFormat::ARGB8:
+    case GraphicsContext3D::DataFormat::ABGR8:
+    case GraphicsContext3D::DataFormat::BGRA8:
+    case GraphicsContext3D::DataFormat::R32F:
+    case GraphicsContext3D::DataFormat::A32F:
+    case GraphicsContext3D::DataFormat::RA16F:
         return 4;
-    case GraphicsContext3D::DataFormatRGB16F:
+    case GraphicsContext3D::DataFormat::RGB16F:
         return 6;
-    case GraphicsContext3D::DataFormatRA32F:
-    case GraphicsContext3D::DataFormatRGBA16F:
+    case GraphicsContext3D::DataFormat::RA32F:
+    case GraphicsContext3D::DataFormat::RGBA16F:
         return 8;
-    case GraphicsContext3D::DataFormatRGB32F:
+    case GraphicsContext3D::DataFormat::RGB32F:
         return 12;
-    case GraphicsContext3D::DataFormatRGBA32F:
+    case GraphicsContext3D::DataFormat::RGBA32F:
         return 16;
     default:
         return 0;
@@ -497,9 +497,9 @@ bool GraphicsContext3D::packPixels(const uint8_t* sourceData, DataFormat sourceD
         dstStride = -dstStride;
     }
     if (!hasAlpha(sourceDataFormat) || !hasColor(sourceDataFormat) || !hasColor(dstDataFormat))
-        alphaOp = AlphaDoNothing;
+        alphaOp = AlphaOp::DoNothing;
 
-    if (sourceDataFormat == dstDataFormat && alphaOp == AlphaDoNothing) {
+    if (sourceDataFormat == dstDataFormat && alphaOp == AlphaOp::DoNothing) {
         const uint8_t* ptr = sourceData;
         const uint8_t* ptrEnd = sourceData + srcStride * height;
         unsigned rowSize = (dstStride > 0) ? dstStride: -dstStride;
@@ -519,143 +519,6 @@ bool GraphicsContext3D::packPixels(const uint8_t* sourceData, DataFormat sourceD
     return true;
 }
 
-unsigned GraphicsContext3D::getClearBitsByAttachmentType(GC3Denum attachment)
-{
-    switch (attachment) {
-    case GraphicsContext3D::COLOR_ATTACHMENT0:
-    case Extensions3D::COLOR_ATTACHMENT1_EXT:
-    case Extensions3D::COLOR_ATTACHMENT2_EXT:
-    case Extensions3D::COLOR_ATTACHMENT3_EXT:
-    case Extensions3D::COLOR_ATTACHMENT4_EXT:
-    case Extensions3D::COLOR_ATTACHMENT5_EXT:
-    case Extensions3D::COLOR_ATTACHMENT6_EXT:
-    case Extensions3D::COLOR_ATTACHMENT7_EXT:
-    case Extensions3D::COLOR_ATTACHMENT8_EXT:
-    case Extensions3D::COLOR_ATTACHMENT9_EXT:
-    case Extensions3D::COLOR_ATTACHMENT10_EXT:
-    case Extensions3D::COLOR_ATTACHMENT11_EXT:
-    case Extensions3D::COLOR_ATTACHMENT12_EXT:
-    case Extensions3D::COLOR_ATTACHMENT13_EXT:
-    case Extensions3D::COLOR_ATTACHMENT14_EXT:
-    case Extensions3D::COLOR_ATTACHMENT15_EXT:
-        return GraphicsContext3D::COLOR_BUFFER_BIT;
-    case GraphicsContext3D::DEPTH_ATTACHMENT:
-        return GraphicsContext3D::DEPTH_BUFFER_BIT;
-    case GraphicsContext3D::STENCIL_ATTACHMENT:
-        return GraphicsContext3D::STENCIL_BUFFER_BIT;
-    case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
-        return GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT;
-    default:
-        return 0;
-    }
-}
-
-unsigned GraphicsContext3D::getClearBitsByFormat(GC3Denum format)
-{
-    switch (format) {
-    case GraphicsContext3D::RGB:
-    case GraphicsContext3D::RGBA:
-    case GraphicsContext3D::LUMINANCE_ALPHA:
-    case GraphicsContext3D::LUMINANCE:
-    case GraphicsContext3D::ALPHA:
-    case GraphicsContext3D::R8:
-    case GraphicsContext3D::R8_SNORM:
-    case GraphicsContext3D::R16F:
-    case GraphicsContext3D::R32F:
-    case GraphicsContext3D::R8UI:
-    case GraphicsContext3D::R8I:
-    case GraphicsContext3D::R16UI:
-    case GraphicsContext3D::R16I:
-    case GraphicsContext3D::R32UI:
-    case GraphicsContext3D::R32I:
-    case GraphicsContext3D::RG8:
-    case GraphicsContext3D::RG8_SNORM:
-    case GraphicsContext3D::RG16F:
-    case GraphicsContext3D::RG32F:
-    case GraphicsContext3D::RG8UI:
-    case GraphicsContext3D::RG8I:
-    case GraphicsContext3D::RG16UI:
-    case GraphicsContext3D::RG16I:
-    case GraphicsContext3D::RG32UI:
-    case GraphicsContext3D::RG32I:
-    case GraphicsContext3D::RGB8:
-    case GraphicsContext3D::SRGB8:
-    case GraphicsContext3D::RGB565:
-    case GraphicsContext3D::RGB8_SNORM:
-    case GraphicsContext3D::R11F_G11F_B10F:
-    case GraphicsContext3D::RGB9_E5:
-    case GraphicsContext3D::RGB16F:
-    case GraphicsContext3D::RGB32F:
-    case GraphicsContext3D::RGB8UI:
-    case GraphicsContext3D::RGB8I:
-    case GraphicsContext3D::RGB16UI:
-    case GraphicsContext3D::RGB16I:
-    case GraphicsContext3D::RGB32UI:
-    case GraphicsContext3D::RGB32I:
-    case GraphicsContext3D::RGBA8:
-    case GraphicsContext3D::SRGB8_ALPHA8:
-    case GraphicsContext3D::RGBA8_SNORM:
-    case GraphicsContext3D::RGB5_A1:
-    case GraphicsContext3D::RGBA4:
-    case GraphicsContext3D::RGB10_A2:
-    case GraphicsContext3D::RGBA16F:
-    case GraphicsContext3D::RGBA32F:
-    case GraphicsContext3D::RGBA8UI:
-    case GraphicsContext3D::RGBA8I:
-    case GraphicsContext3D::RGB10_A2UI:
-    case GraphicsContext3D::RGBA16UI:
-    case GraphicsContext3D::RGBA16I:
-    case GraphicsContext3D::RGBA32I:
-    case GraphicsContext3D::RGBA32UI:
-    case Extensions3D::SRGB_EXT:
-    case Extensions3D::SRGB_ALPHA_EXT:
-        return GraphicsContext3D::COLOR_BUFFER_BIT;
-    case GraphicsContext3D::DEPTH_COMPONENT16:
-    case GraphicsContext3D::DEPTH_COMPONENT24:
-    case GraphicsContext3D::DEPTH_COMPONENT32F:
-    case GraphicsContext3D::DEPTH_COMPONENT:
-        return GraphicsContext3D::DEPTH_BUFFER_BIT;
-    case GraphicsContext3D::STENCIL_INDEX8:
-        return GraphicsContext3D::STENCIL_BUFFER_BIT;
-    case GraphicsContext3D::DEPTH_STENCIL:
-    case GraphicsContext3D::DEPTH24_STENCIL8:
-    case GraphicsContext3D::DEPTH32F_STENCIL8:
-        return GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT;
-    default:
-        return 0;
-    }
-}
-
-unsigned GraphicsContext3D::getChannelBitsByFormat(GC3Denum format)
-{
-    switch (format) {
-    case GraphicsContext3D::ALPHA:
-        return ChannelAlpha;
-    case GraphicsContext3D::LUMINANCE:
-        return ChannelRGB;
-    case GraphicsContext3D::LUMINANCE_ALPHA:
-        return ChannelRGBA;
-    case GraphicsContext3D::RGB:
-    case GraphicsContext3D::RGB565:
-    case Extensions3D::SRGB_EXT:
-        return ChannelRGB;
-    case GraphicsContext3D::RGBA:
-    case GraphicsContext3D::RGBA4:
-    case GraphicsContext3D::RGB5_A1:
-    case Extensions3D::SRGB_ALPHA_EXT:
-        return ChannelRGBA;
-    case GraphicsContext3D::DEPTH_COMPONENT16:
-    case GraphicsContext3D::DEPTH_COMPONENT:
-        return ChannelDepth;
-    case GraphicsContext3D::STENCIL_INDEX8:
-        return ChannelStencil;
-    case GraphicsContext3D::DEPTH_STENCIL:
-        return ChannelDepth | ChannelStencil;
-    default:
-        return 0;
-    }
-}
-
 #if !(PLATFORM(COCOA) && (USE(OPENGL) || USE(ANGLE)))
 void GraphicsContext3D::setContextVisibility(bool)
 {
index a3d1de2..016f4f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2014-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #if ENABLE(WEBGL)
 
 #include "ANGLEWebKitBridge.h"
-#include "GraphicsContext3DAttributes.h"
-#include "GraphicsTypes3D.h"
-#include "Image.h"
-#include "IntRect.h"
-#include "PlatformLayer.h"
+#include "GraphicsContext3DBase.h"
 #include <memory>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashMap.h>
 #include <wtf/ListHashSet.h>
-#include <wtf/RefCounted.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/UniqueArray.h>
-#include <wtf/text/WTFString.h>
 
 #if USE(CA)
 #include "PlatformCALayer.h"
 #endif
 
 #if PLATFORM(COCOA)
-
 #if USE(OPENGL_ES)
 #include <OpenGLES/ES2/gl.h>
 #ifdef __OBJC__
 #import <OpenGLES/EAGL.h>
-typedef EAGLContext* PlatformGraphicsContext3D;
-#else
-typedef void* PlatformGraphicsContext3D;
 #endif // __OBJC__
 #endif // USE(OPENGL_ES)
-
-#if USE(OPENGL)
-typedef struct _CGLContextObject *CGLContextObj;
-typedef CGLContextObj PlatformGraphicsContext3D;
-#endif // USE(OPENGL)
-
-#if USE(ANGLE)
-typedef void* PlatformGraphicsContext3D;
-typedef void* PlatformGraphicsContext3DDisplay;
-typedef void* PlatformGraphicsContext3DSurface;
-typedef void* PlatformGraphicsContext3DConfig;
-#endif // USE(ANGLE)
-
 OBJC_CLASS CALayer;
 OBJC_CLASS WebGLLayer;
 typedef struct __IOSurface* IOSurfaceRef;
@@ -89,16 +66,6 @@ class GC3DLayer;
 }
 #endif
 
-#if !PLATFORM(COCOA)
-typedef unsigned GLuint;
-typedef void* PlatformGraphicsContext3D;
-typedef void* PlatformGraphicsSurface3D;
-#endif // !PLATFORM(COCOA)
-
-// These are currently the same among all implementations.
-const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0;
-const Platform3DObject NullPlatform3DObject = 0;
-
 namespace WebCore {
 class Extensions3D;
 #if USE(ANGLE)
@@ -109,27 +76,17 @@ class Extensions3DOpenGLES;
 class Extensions3DOpenGL;
 #endif
 class HostWindow;
-class Image;
 class ImageBuffer;
 class ImageData;
-class IntRect;
-class IntSize;
-class WebGLRenderingContextBase;
 #if USE(TEXTURE_MAPPER)
 class TextureMapperGC3DPlatformLayer;
 #endif
 
 typedef WTF::HashMap<CString, uint64_t> ShaderNameHash;
 
-struct ActiveInfo {
-    String name;
-    GC3Denum type;
-    GC3Dint size;
-};
-
 class GraphicsContext3DPrivate;
 
-class GraphicsContext3D : public RefCounted<GraphicsContext3D> {
+class GraphicsContext3D : public GraphicsContext3DBase {
 public:
     class Client {
     public:
@@ -140,654 +97,25 @@ public:
         virtual void dispatchContextChangedNotification() = 0;
     };
 
-    enum {
-        // WebGL 1 constants
-        DEPTH_BUFFER_BIT = 0x00000100,
-        STENCIL_BUFFER_BIT = 0x00000400,
-        COLOR_BUFFER_BIT = 0x00004000,
-        POINTS = 0x0000,
-        LINES = 0x0001,
-        LINE_LOOP = 0x0002,
-        LINE_STRIP = 0x0003,
-        TRIANGLES = 0x0004,
-        TRIANGLE_STRIP = 0x0005,
-        TRIANGLE_FAN = 0x0006,
-        ZERO = 0,
-        ONE = 1,
-        SRC_COLOR = 0x0300,
-        ONE_MINUS_SRC_COLOR = 0x0301,
-        SRC_ALPHA = 0x0302,
-        ONE_MINUS_SRC_ALPHA = 0x0303,
-        DST_ALPHA = 0x0304,
-        ONE_MINUS_DST_ALPHA = 0x0305,
-        DST_COLOR = 0x0306,
-        ONE_MINUS_DST_COLOR = 0x0307,
-        SRC_ALPHA_SATURATE = 0x0308,
-        FUNC_ADD = 0x8006,
-        BLEND_EQUATION = 0x8009,
-        BLEND_EQUATION_RGB = 0x8009,
-        BLEND_EQUATION_ALPHA = 0x883D,
-        FUNC_SUBTRACT = 0x800A,
-        FUNC_REVERSE_SUBTRACT = 0x800B,
-        BLEND_DST_RGB = 0x80C8,
-        BLEND_SRC_RGB = 0x80C9,
-        BLEND_DST_ALPHA = 0x80CA,
-        BLEND_SRC_ALPHA = 0x80CB,
-        CONSTANT_COLOR = 0x8001,
-        ONE_MINUS_CONSTANT_COLOR = 0x8002,
-        CONSTANT_ALPHA = 0x8003,
-        ONE_MINUS_CONSTANT_ALPHA = 0x8004,
-        BLEND_COLOR = 0x8005,
-        ARRAY_BUFFER = 0x8892,
-        ELEMENT_ARRAY_BUFFER = 0x8893,
-        ARRAY_BUFFER_BINDING = 0x8894,
-        ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
-        STREAM_DRAW = 0x88E0,
-        STATIC_DRAW = 0x88E4,
-        DYNAMIC_DRAW = 0x88E8,
-        BUFFER_SIZE = 0x8764,
-        BUFFER_USAGE = 0x8765,
-        CURRENT_VERTEX_ATTRIB = 0x8626,
-        FRONT = 0x0404,
-        BACK = 0x0405,
-        FRONT_AND_BACK = 0x0408,
-        TEXTURE_2D = 0x0DE1,
-        CULL_FACE = 0x0B44,
-        BLEND = 0x0BE2,
-        DITHER = 0x0BD0,
-        STENCIL_TEST = 0x0B90,
-        DEPTH_TEST = 0x0B71,
-        SCISSOR_TEST = 0x0C11,
-        POLYGON_OFFSET_FILL = 0x8037,
-        SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
-        SAMPLE_COVERAGE = 0x80A0,
-        NO_ERROR = 0,
-        INVALID_ENUM = 0x0500,
-        INVALID_VALUE = 0x0501,
-        INVALID_OPERATION = 0x0502,
-        OUT_OF_MEMORY = 0x0505,
-        CW = 0x0900,
-        CCW = 0x0901,
-        LINE_WIDTH = 0x0B21,
-        ALIASED_POINT_SIZE_RANGE = 0x846D,
-        ALIASED_LINE_WIDTH_RANGE = 0x846E,
-        CULL_FACE_MODE = 0x0B45,
-        FRONT_FACE = 0x0B46,
-        DEPTH_RANGE = 0x0B70,
-        DEPTH_WRITEMASK = 0x0B72,
-        DEPTH_CLEAR_VALUE = 0x0B73,
-        DEPTH_FUNC = 0x0B74,
-        STENCIL_CLEAR_VALUE = 0x0B91,
-        STENCIL_FUNC = 0x0B92,
-        STENCIL_FAIL = 0x0B94,
-        STENCIL_PASS_DEPTH_FAIL = 0x0B95,
-        STENCIL_PASS_DEPTH_PASS = 0x0B96,
-        STENCIL_REF = 0x0B97,
-        STENCIL_VALUE_MASK = 0x0B93,
-        STENCIL_WRITEMASK = 0x0B98,
-        STENCIL_BACK_FUNC = 0x8800,
-        STENCIL_BACK_FAIL = 0x8801,
-        STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
-        STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
-        STENCIL_BACK_REF = 0x8CA3,
-        STENCIL_BACK_VALUE_MASK = 0x8CA4,
-        STENCIL_BACK_WRITEMASK = 0x8CA5,
-        VIEWPORT = 0x0BA2,
-        SCISSOR_BOX = 0x0C10,
-        COLOR_CLEAR_VALUE = 0x0C22,
-        COLOR_WRITEMASK = 0x0C23,
-        UNPACK_ALIGNMENT = 0x0CF5,
-        PACK_ALIGNMENT = 0x0D05,
-        MAX_TEXTURE_SIZE = 0x0D33,
-        MAX_VIEWPORT_DIMS = 0x0D3A,
-        SUBPIXEL_BITS = 0x0D50,
-        RED_BITS = 0x0D52,
-        GREEN_BITS = 0x0D53,
-        BLUE_BITS = 0x0D54,
-        ALPHA_BITS = 0x0D55,
-        DEPTH_BITS = 0x0D56,
-        STENCIL_BITS = 0x0D57,
-        POLYGON_OFFSET_UNITS = 0x2A00,
-        POLYGON_OFFSET_FACTOR = 0x8038,
-        TEXTURE_BINDING_2D = 0x8069,
-        SAMPLE_BUFFERS = 0x80A8,
-        SAMPLES = 0x80A9,
-        SAMPLE_COVERAGE_VALUE = 0x80AA,
-        SAMPLE_COVERAGE_INVERT = 0x80AB,
-        NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
-        COMPRESSED_TEXTURE_FORMATS = 0x86A3,
-        DONT_CARE = 0x1100,
-        FASTEST = 0x1101,
-        NICEST = 0x1102,
-        GENERATE_MIPMAP_HINT = 0x8192,
-        BYTE = 0x1400,
-        UNSIGNED_BYTE = 0x1401,
-        SHORT = 0x1402,
-        UNSIGNED_SHORT = 0x1403,
-        INT = 0x1404,
-        UNSIGNED_INT = 0x1405,
-        FLOAT = 0x1406,
-        HALF_FLOAT_OES = 0x8D61,
-        FIXED = 0x140C,
-        DEPTH_COMPONENT = 0x1902,
-        ALPHA = 0x1906,
-        RGB = 0x1907,
-        RGBA = 0x1908,
-        BGRA = 0x80E1,
-        LUMINANCE = 0x1909,
-        LUMINANCE_ALPHA = 0x190A,
-        UNSIGNED_SHORT_4_4_4_4 = 0x8033,
-        UNSIGNED_SHORT_5_5_5_1 = 0x8034,
-        UNSIGNED_SHORT_5_6_5 = 0x8363,
-        FRAGMENT_SHADER = 0x8B30,
-        VERTEX_SHADER = 0x8B31,
-        MAX_VERTEX_ATTRIBS = 0x8869,
-        MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
-        MAX_VARYING_VECTORS = 0x8DFC,
-        MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
-        MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
-        MAX_TEXTURE_IMAGE_UNITS = 0x8872,
-        MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
-        SHADER_TYPE = 0x8B4F,
-        DELETE_STATUS = 0x8B80,
-        LINK_STATUS = 0x8B82,
-        VALIDATE_STATUS = 0x8B83,
-        ATTACHED_SHADERS = 0x8B85,
-        ACTIVE_UNIFORMS = 0x8B86,
-        ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
-        ACTIVE_ATTRIBUTES = 0x8B89,
-        ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
-        SHADING_LANGUAGE_VERSION = 0x8B8C,
-        CURRENT_PROGRAM = 0x8B8D,
-        NEVER = 0x0200,
-        LESS = 0x0201,
-        EQUAL = 0x0202,
-        LEQUAL = 0x0203,
-        GREATER = 0x0204,
-        NOTEQUAL = 0x0205,
-        GEQUAL = 0x0206,
-        ALWAYS = 0x0207,
-        KEEP = 0x1E00,
-        REPLACE = 0x1E01,
-        INCR = 0x1E02,
-        DECR = 0x1E03,
-        INVERT = 0x150A,
-        INCR_WRAP = 0x8507,
-        DECR_WRAP = 0x8508,
-        VENDOR = 0x1F00,
-        RENDERER = 0x1F01,
-        VERSION = 0x1F02,
-        EXTENSIONS = 0x1F03,
-        NEAREST = 0x2600,
-        LINEAR = 0x2601,
-        NEAREST_MIPMAP_NEAREST = 0x2700,
-        LINEAR_MIPMAP_NEAREST = 0x2701,
-        NEAREST_MIPMAP_LINEAR = 0x2702,
-        LINEAR_MIPMAP_LINEAR = 0x2703,
-        TEXTURE_MAG_FILTER = 0x2800,
-        TEXTURE_MIN_FILTER = 0x2801,
-        TEXTURE_WRAP_S = 0x2802,
-        TEXTURE_WRAP_T = 0x2803,
-        TEXTURE = 0x1702,
-        TEXTURE_CUBE_MAP = 0x8513,
-        TEXTURE_BINDING_CUBE_MAP = 0x8514,
-        TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
-        TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
-        TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
-        TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
-        TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
-        TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
-        MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
-        TEXTURE0 = 0x84C0,
-        TEXTURE1 = 0x84C1,
-        TEXTURE2 = 0x84C2,
-        TEXTURE3 = 0x84C3,
-        TEXTURE4 = 0x84C4,
-        TEXTURE5 = 0x84C5,
-        TEXTURE6 = 0x84C6,
-        TEXTURE7 = 0x84C7,
-        TEXTURE8 = 0x84C8,
-        TEXTURE9 = 0x84C9,
-        TEXTURE10 = 0x84CA,
-        TEXTURE11 = 0x84CB,
-        TEXTURE12 = 0x84CC,
-        TEXTURE13 = 0x84CD,
-        TEXTURE14 = 0x84CE,
-        TEXTURE15 = 0x84CF,
-        TEXTURE16 = 0x84D0,
-        TEXTURE17 = 0x84D1,
-        TEXTURE18 = 0x84D2,
-        TEXTURE19 = 0x84D3,
-        TEXTURE20 = 0x84D4,
-        TEXTURE21 = 0x84D5,
-        TEXTURE22 = 0x84D6,
-        TEXTURE23 = 0x84D7,
-        TEXTURE24 = 0x84D8,
-        TEXTURE25 = 0x84D9,
-        TEXTURE26 = 0x84DA,
-        TEXTURE27 = 0x84DB,
-        TEXTURE28 = 0x84DC,
-        TEXTURE29 = 0x84DD,
-        TEXTURE30 = 0x84DE,
-        TEXTURE31 = 0x84DF,
-        ACTIVE_TEXTURE = 0x84E0,
-        REPEAT = 0x2901,
-        CLAMP_TO_EDGE = 0x812F,
-        MIRRORED_REPEAT = 0x8370,
-        FLOAT_VEC2 = 0x8B50,
-        FLOAT_VEC3 = 0x8B51,
-        FLOAT_VEC4 = 0x8B52,
-        INT_VEC2 = 0x8B53,
-        INT_VEC3 = 0x8B54,
-        INT_VEC4 = 0x8B55,
-        BOOL = 0x8B56,
-        BOOL_VEC2 = 0x8B57,
-        BOOL_VEC3 = 0x8B58,
-        BOOL_VEC4 = 0x8B59,
-        FLOAT_MAT2 = 0x8B5A,
-        FLOAT_MAT3 = 0x8B5B,
-        FLOAT_MAT4 = 0x8B5C,
-        SAMPLER_2D = 0x8B5E,
-        SAMPLER_CUBE = 0x8B60,
-        VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
-        VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
-        VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
-        VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
-        VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
-        VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
-        VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
-        IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
-        IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B,
-        COMPILE_STATUS = 0x8B81,
-        INFO_LOG_LENGTH = 0x8B84,
-        SHADER_SOURCE_LENGTH = 0x8B88,
-        SHADER_COMPILER = 0x8DFA,
-        SHADER_BINARY_FORMATS = 0x8DF8,
-        NUM_SHADER_BINARY_FORMATS = 0x8DF9,
-        LOW_FLOAT = 0x8DF0,
-        MEDIUM_FLOAT = 0x8DF1,
-        HIGH_FLOAT = 0x8DF2,
-        LOW_INT = 0x8DF3,
-        MEDIUM_INT = 0x8DF4,
-        HIGH_INT = 0x8DF5,
-        FRAMEBUFFER = 0x8D40,
-        RENDERBUFFER = 0x8D41,
-        RGBA4 = 0x8056,
-        RGB5_A1 = 0x8057,
-        RGB565 = 0x8D62,
-        DEPTH_COMPONENT16 = 0x81A5,
-        STENCIL_INDEX = 0x1901,
-        STENCIL_INDEX8 = 0x8D48,
-        RENDERBUFFER_WIDTH = 0x8D42,
-        RENDERBUFFER_HEIGHT = 0x8D43,
-        RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
-        RENDERBUFFER_RED_SIZE = 0x8D50,
-        RENDERBUFFER_GREEN_SIZE = 0x8D51,
-        RENDERBUFFER_BLUE_SIZE = 0x8D52,
-        RENDERBUFFER_ALPHA_SIZE = 0x8D53,
-        RENDERBUFFER_DEPTH_SIZE = 0x8D54,
-        RENDERBUFFER_STENCIL_SIZE = 0x8D55,
-        FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
-        FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
-        FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
-        FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
-        COLOR_ATTACHMENT0 = 0x8CE0,
-        DEPTH_ATTACHMENT = 0x8D00,
-        STENCIL_ATTACHMENT = 0x8D20,
-        NONE = 0,
-        FRAMEBUFFER_COMPLETE = 0x8CD5,
-        FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
-        FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
-        FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
-        FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
-        FRAMEBUFFER_BINDING = 0x8CA6,
-        RENDERBUFFER_BINDING = 0x8CA7,
-        MAX_RENDERBUFFER_SIZE = 0x84E8,
-        INVALID_FRAMEBUFFER_OPERATION = 0x0506,
-
-        // WebGL-specific enums
-        UNPACK_FLIP_Y_WEBGL = 0x9240,
-        UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
-        CONTEXT_LOST_WEBGL = 0x9242,
-        UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
-        BROWSER_DEFAULT_WEBGL = 0x9244,
-        VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE,
-        
-        // WebGL2 constants
-        READ_BUFFER = 0x0C02,
-        UNPACK_ROW_LENGTH = 0x0CF2,
-        UNPACK_SKIP_ROWS = 0x0CF3,
-        UNPACK_SKIP_PIXELS = 0x0CF4,
-        PACK_ROW_LENGTH = 0x0D02,
-        PACK_SKIP_ROWS = 0x0D03,
-        PACK_SKIP_PIXELS = 0x0D04,
-        COLOR = 0x1800,
-        DEPTH = 0x1801,
-        STENCIL = 0x1802,
-        RED = 0x1903,
-        RGB8 = 0x8051,
-        RGBA8 = 0x8058,
-        RGB10_A2 = 0x8059,
-        TEXTURE_BINDING_3D = 0x806A,
-        UNPACK_SKIP_IMAGES = 0x806D,
-        UNPACK_IMAGE_HEIGHT = 0x806E,
-        TEXTURE_3D = 0x806F,
-        TEXTURE_WRAP_R = 0x8072,
-        MAX_3D_TEXTURE_SIZE = 0x8073,
-        UNSIGNED_INT_2_10_10_10_REV = 0x8368,
-        MAX_ELEMENTS_VERTICES = 0x80E8,
-        MAX_ELEMENTS_INDICES = 0x80E9,
-        TEXTURE_MIN_LOD = 0x813A,
-        TEXTURE_MAX_LOD = 0x813B,
-        TEXTURE_BASE_LEVEL = 0x813C,
-        TEXTURE_MAX_LEVEL = 0x813D,
-        MIN = 0x8007,
-        MAX = 0x8008,
-        DEPTH_COMPONENT24 = 0x81A6,
-        MAX_TEXTURE_LOD_BIAS = 0x84FD,
-        TEXTURE_COMPARE_MODE = 0x884C,
-        TEXTURE_COMPARE_FUNC = 0x884D,
-        CURRENT_QUERY = 0x8865,
-        QUERY_RESULT = 0x8866,
-        QUERY_RESULT_AVAILABLE = 0x8867,
-        STREAM_READ = 0x88E1,
-        STREAM_COPY = 0x88E2,
-        STATIC_READ = 0x88E5,
-        STATIC_COPY = 0x88E6,
-        DYNAMIC_READ = 0x88E9,
-        DYNAMIC_COPY = 0x88EA,
-        MAX_DRAW_BUFFERS = 0x8824,
-        DRAW_BUFFER0 = 0x8825,
-        DRAW_BUFFER1 = 0x8826,
-        DRAW_BUFFER2 = 0x8827,
-        DRAW_BUFFER3 = 0x8828,
-        DRAW_BUFFER4 = 0x8829,
-        DRAW_BUFFER5 = 0x882A,
-        DRAW_BUFFER6 = 0x882B,
-        DRAW_BUFFER7 = 0x882C,
-        DRAW_BUFFER8 = 0x882D,
-        DRAW_BUFFER9 = 0x882E,
-        DRAW_BUFFER10 = 0x882F,
-        DRAW_BUFFER11 = 0x8830,
-        DRAW_BUFFER12 = 0x8831,
-        DRAW_BUFFER13 = 0x8832,
-        DRAW_BUFFER14 = 0x8833,
-        DRAW_BUFFER15 = 0x8834,
-        MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49,
-        MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A,
-        SAMPLER_3D = 0x8B5F,
-        SAMPLER_2D_SHADOW = 0x8B62,
-        FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B,
-        PIXEL_PACK_BUFFER = 0x88EB,
-        PIXEL_UNPACK_BUFFER = 0x88EC,
-        PIXEL_PACK_BUFFER_BINDING = 0x88ED,
-        PIXEL_UNPACK_BUFFER_BINDING = 0x88EF,
-        FLOAT_MAT2x3 = 0x8B65,
-        FLOAT_MAT2x4 = 0x8B66,
-        FLOAT_MAT3x2 = 0x8B67,
-        FLOAT_MAT3x4 = 0x8B68,
-        FLOAT_MAT4x2 = 0x8B69,
-        FLOAT_MAT4x3 = 0x8B6A,
-        SRGB = 0x8C40,
-        SRGB8 = 0x8C41,
-        SRGB_ALPHA = 0x8C42,
-        SRGB8_ALPHA8 = 0x8C43,
-        COMPARE_REF_TO_TEXTURE = 0x884E,
-        RGBA32F = 0x8814,
-        RGB32F = 0x8815,
-        RGBA16F = 0x881A,
-        RGB16F = 0x881B,
-        VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD,
-        MAX_ARRAY_TEXTURE_LAYERS = 0x88FF,
-        MIN_PROGRAM_TEXEL_OFFSET = 0x8904,
-        MAX_PROGRAM_TEXEL_OFFSET = 0x8905,
-        MAX_VARYING_COMPONENTS = 0x8B4B,
-        TEXTURE_2D_ARRAY = 0x8C1A,
-        TEXTURE_BINDING_2D_ARRAY = 0x8C1D,
-        R11F_G11F_B10F = 0x8C3A,
-        UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B,
-        RGB9_E5 = 0x8C3D,
-        UNSIGNED_INT_5_9_9_9_REV = 0x8C3E,
-        TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F,
-        MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80,
-        TRANSFORM_FEEDBACK_VARYINGS = 0x8C83,
-        TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84,
-        TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85,
-        TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88,
-        RASTERIZER_DISCARD = 0x8C89,
-        MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A,
-        MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B,
-        INTERLEAVED_ATTRIBS = 0x8C8C,
-        SEPARATE_ATTRIBS = 0x8C8D,
-        TRANSFORM_FEEDBACK_BUFFER = 0x8C8E,
-        TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F,
-        RGBA32UI = 0x8D70,
-        RGB32UI = 0x8D71,
-        RGBA16UI = 0x8D76,
-        RGB16UI = 0x8D77,
-        RGBA8UI = 0x8D7C,
-        RGB8UI = 0x8D7D,
-        RGBA32I = 0x8D82,
-        RGB32I = 0x8D83,
-        RGBA16I = 0x8D88,
-        RGB16I = 0x8D89,
-        RGBA8I = 0x8D8E,
-        RGB8I = 0x8D8F,
-        RED_INTEGER = 0x8D94,
-        RGB_INTEGER = 0x8D98,
-        RGBA_INTEGER = 0x8D99,
-        SAMPLER_2D_ARRAY = 0x8DC1,
-        SAMPLER_2D_ARRAY_SHADOW = 0x8DC4,
-        SAMPLER_CUBE_SHADOW = 0x8DC5,
-        UNSIGNED_INT_VEC2 = 0x8DC6,
-        UNSIGNED_INT_VEC3 = 0x8DC7,
-        UNSIGNED_INT_VEC4 = 0x8DC8,
-        INT_SAMPLER_2D = 0x8DCA,
-        INT_SAMPLER_3D = 0x8DCB,
-        INT_SAMPLER_CUBE = 0x8DCC,
-        INT_SAMPLER_2D_ARRAY = 0x8DCF,
-        UNSIGNED_INT_SAMPLER_2D = 0x8DD2,
-        UNSIGNED_INT_SAMPLER_3D = 0x8DD3,
-        UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4,
-        UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7,
-        DEPTH_COMPONENT32F = 0x8CAC,
-        DEPTH32F_STENCIL8 = 0x8CAD,
-        FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD,
-        FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210,
-        FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211,
-        FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212,
-        FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213,
-        FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214,
-        FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215,
-        FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216,
-        FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217,
-        FRAMEBUFFER_DEFAULT = 0x8218,
-        DEPTH_STENCIL_ATTACHMENT = 0x821A,
-        DEPTH_STENCIL = 0x84F9,
-        UNSIGNED_INT_24_8 = 0x84FA,
-        DEPTH24_STENCIL8 = 0x88F0,
-        UNSIGNED_NORMALIZED = 0x8C17,
-        DRAW_FRAMEBUFFER_BINDING = 0x8CA6, /* Same as FRAMEBUFFER_BINDING */
-        READ_FRAMEBUFFER = 0x8CA8,
-        DRAW_FRAMEBUFFER = 0x8CA9,
-        READ_FRAMEBUFFER_BINDING = 0x8CAA,
-        RENDERBUFFER_SAMPLES = 0x8CAB,
-        FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4,
-        MAX_COLOR_ATTACHMENTS = 0x8CDF,
-        COLOR_ATTACHMENT1 = 0x8CE1,
-        COLOR_ATTACHMENT2 = 0x8CE2,
-        COLOR_ATTACHMENT3 = 0x8CE3,
-        COLOR_ATTACHMENT4 = 0x8CE4,
-        COLOR_ATTACHMENT5 = 0x8CE5,
-        COLOR_ATTACHMENT6 = 0x8CE6,
-        COLOR_ATTACHMENT7 = 0x8CE7,
-        COLOR_ATTACHMENT8 = 0x8CE8,
-        COLOR_ATTACHMENT9 = 0x8CE9,
-        COLOR_ATTACHMENT10 = 0x8CEA,
-        COLOR_ATTACHMENT11 = 0x8CEB,
-        COLOR_ATTACHMENT12 = 0x8CEC,
-        COLOR_ATTACHMENT13 = 0x8CED,
-        COLOR_ATTACHMENT14 = 0x8CEE,
-        COLOR_ATTACHMENT15 = 0x8CEF,
-        FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
-        MAX_SAMPLES = 0x8D57,
-        HALF_FLOAT = 0x140B,
-        RG = 0x8227,
-        RG_INTEGER = 0x8228,
-        R8 = 0x8229,
-        RG8 = 0x822B,
-        R16F = 0x822D,
-        R32F = 0x822E,
-        RG16F = 0x822F,
-        RG32F = 0x8230,
-        R8I = 0x8231,
-        R8UI = 0x8232,
-        R16I = 0x8233,
-        R16UI = 0x8234,
-        R32I = 0x8235,
-        R32UI = 0x8236,
-        RG8I = 0x8237,
-        RG8UI = 0x8238,
-        RG16I = 0x8239,
-        RG16UI = 0x823A,
-        RG32I = 0x823B,
-        RG32UI = 0x823C,
-        VERTEX_ARRAY_BINDING = 0x85B5,
-        R8_SNORM = 0x8F94,
-        RG8_SNORM = 0x8F95,
-        RGB8_SNORM = 0x8F96,
-        RGBA8_SNORM = 0x8F97,
-        SIGNED_NORMALIZED = 0x8F9C,
-        COPY_READ_BUFFER = 0x8F36,
-        COPY_WRITE_BUFFER = 0x8F37,
-        COPY_READ_BUFFER_BINDING = 0x8F36, /* Same as COPY_READ_BUFFER */
-        COPY_WRITE_BUFFER_BINDING = 0x8F37, /* Same as COPY_WRITE_BUFFER */
-        UNIFORM_BUFFER = 0x8A11,
-        UNIFORM_BUFFER_BINDING = 0x8A28,
-        UNIFORM_BUFFER_START = 0x8A29,
-        UNIFORM_BUFFER_SIZE = 0x8A2A,
-        MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B,
-        MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D,
-        MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E,
-        MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F,
-        MAX_UNIFORM_BLOCK_SIZE = 0x8A30,
-        MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31,
-        MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33,
-        UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34,
-        ACTIVE_UNIFORM_BLOCKS = 0x8A36,
-        UNIFORM_TYPE = 0x8A37,
-        UNIFORM_SIZE = 0x8A38,
-        UNIFORM_BLOCK_INDEX = 0x8A3A,
-        UNIFORM_OFFSET = 0x8A3B,
-        UNIFORM_ARRAY_STRIDE = 0x8A3C,
-        UNIFORM_MATRIX_STRIDE = 0x8A3D,
-        UNIFORM_IS_ROW_MAJOR = 0x8A3E,
-        UNIFORM_BLOCK_BINDING = 0x8A3F,
-        UNIFORM_BLOCK_DATA_SIZE = 0x8A40,
-        UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42,
-        UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43,
-        UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44,
-        UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46,
-        INVALID_INDEX = 0xFFFFFFFF,
-        MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122,
-        MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125,
-        MAX_SERVER_WAIT_TIMEOUT = 0x9111,
-        OBJECT_TYPE = 0x9112,
-        SYNC_CONDITION = 0x9113,
-        SYNC_STATUS = 0x9114,
-        SYNC_FLAGS = 0x9115,
-        SYNC_FENCE = 0x9116,
-        SYNC_GPU_COMMANDS_COMPLETE = 0x9117,
-        UNSIGNALED = 0x9118,
-        SIGNALED = 0x9119,
-        ALREADY_SIGNALED = 0x911A,
-        TIMEOUT_EXPIRED = 0x911B,
-        CONDITION_SATISFIED = 0x911C,
-#if PLATFORM(WIN)
-        WAIT_FAILED_WIN = 0x911D,
-#else
-        WAIT_FAILED = 0x911D,
-#endif
-        SYNC_FLUSH_COMMANDS_BIT = 0x00000001,
-        VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE,
-        ANY_SAMPLES_PASSED = 0x8C2F,
-        ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
-        SAMPLER_BINDING = 0x8919,
-        RGB10_A2UI = 0x906F,
-        TEXTURE_SWIZZLE_R = 0x8E42,
-        TEXTURE_SWIZZLE_G = 0x8E43,
-        TEXTURE_SWIZZLE_B = 0x8E44,
-        TEXTURE_SWIZZLE_A = 0x8E45,
-        GREEN = 0x1904,
-        BLUE = 0x1905,
-        INT_2_10_10_10_REV = 0x8D9F,
-        TRANSFORM_FEEDBACK = 0x8E22,
-        TRANSFORM_FEEDBACK_PAUSED = 0x8E23,
-        TRANSFORM_FEEDBACK_ACTIVE = 0x8E24,
-        TRANSFORM_FEEDBACK_BINDING = 0x8E25,
-        COMPRESSED_R11_EAC = 0x9270,
-        COMPRESSED_SIGNED_R11_EAC = 0x9271,
-        COMPRESSED_RG11_EAC = 0x9272,
-        COMPRESSED_SIGNED_RG11_EAC = 0x9273,
-        COMPRESSED_RGB8_ETC2 = 0x9274,
-        COMPRESSED_SRGB8_ETC2 = 0x9275,
-        COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
-        COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
-        COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
-        COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
-        TEXTURE_IMMUTABLE_FORMAT = 0x912F,
-        MAX_ELEMENT_INDEX = 0x8D6B,
-        NUM_SAMPLE_COUNTS = 0x9380,
-        TEXTURE_IMMUTABLE_LEVELS = 0x82DF,
-        PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69,
-        PRIMITIVE_RESTART = 0x8F9D,
-
-        // OpenGL ES 3 constants.
-        MAP_READ_BIT = 0x0001,
-
-        // Necessary desktop OpenGL constants.
-        TEXTURE_RECTANGLE_ARB = 0x84F5
-    };
-
-    enum RenderStyle {
-        RenderOffscreen,
-        RenderDirectlyToHostWindow,
-    };
-
-    class ContextLostCallback {
-    public:
-        virtual void onContextLost() = 0;
-        virtual ~ContextLostCallback() = default;
-    };
-
-    class ErrorMessageCallback {
-    public:
-        virtual void onErrorMessage(const String& message, GC3Dint id) = 0;
-        virtual ~ErrorMessageCallback() = default;
-    };
-
-    void setContextLostCallback(std::unique_ptr<ContextLostCallback>);
-    void setErrorMessageCallback(std::unique_ptr<ErrorMessageCallback>);
-
-    static RefPtr<GraphicsContext3D> create(GraphicsContext3DAttributes, HostWindow*, RenderStyle = RenderOffscreen);
-    ~GraphicsContext3D();
+    static RefPtr<GraphicsContext3D> create(GraphicsContext3DAttributes, HostWindow*, Destination = Destination::Offscreen);
+    virtual ~GraphicsContext3D();
 
 #if PLATFORM(COCOA)
     static Ref<GraphicsContext3D> createShared(GraphicsContext3D& sharedContext);
 #endif
 
 #if PLATFORM(COCOA)
-    PlatformGraphicsContext3D platformGraphicsContext3D() const { return m_contextObj; }
-    Platform3DObject platformTexture() const { return m_texture; }
-    CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
+    PlatformGraphicsContext3D platformGraphicsContext3D() const override { return m_contextObj; }
+    Platform3DObject platformTexture() const override { return m_texture; }
+    CALayer* platformLayer() const override { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
 #if USE(ANGLE)
     PlatformGraphicsContext3DDisplay platformDisplay() const { return m_displayObj; }
     PlatformGraphicsContext3DConfig platformConfig() const { return m_configObj; }
 #endif // USE(ANGLE)
 #else
-    PlatformGraphicsContext3D platformGraphicsContext3D();
-    Platform3DObject platformTexture() const;
-    PlatformLayer* platformLayer() const;
+    PlatformGraphicsContext3D platformGraphicsContext3D() const override;
+    Platform3DObject platformTexture() const override;
+    PlatformLayer* platformLayer() const override;
 #endif
 
     bool makeContextCurrent();
@@ -864,314 +192,187 @@ public:
                             const void* pixels,
                             Vector<uint8_t>& data);
 
-
-    // Attempt to enumerate all possible native image formats to
-    // reduce the amount of temporary allocations during texture
-    // uploading. This enum must be public because it is accessed
-    // by non-member functions.
-    enum DataFormat {
-        DataFormatRGBA8 = 0,
-        DataFormatRGBA16Little,
-        DataFormatRGBA16Big,
-        DataFormatRGBA16F,
-        DataFormatRGBA32F,
-        DataFormatRGB8,
-        DataFormatRGB16Little,
-        DataFormatRGB16Big,
-        DataFormatRGB16F,
-        DataFormatRGB32F,
-        DataFormatBGR8,
-        DataFormatBGRA8,
-        DataFormatBGRA16Little,
-        DataFormatBGRA16Big,
-        DataFormatARGB8,
-        DataFormatARGB16Little,
-        DataFormatARGB16Big,
-        DataFormatABGR8,
-        DataFormatRGBA5551,
-        DataFormatRGBA4444,
-        DataFormatRGB565,
-        DataFormatR8,
-        DataFormatR16Little,
-        DataFormatR16Big,
-        DataFormatR16F,
-        DataFormatR32F,
-        DataFormatRA8,
-        DataFormatRA16Little,
-        DataFormatRA16Big,
-        DataFormatRA16F,
-        DataFormatRA32F,
-        DataFormatAR8,
-        DataFormatAR16Little,
-        DataFormatAR16Big,
-        DataFormatA8,
-        DataFormatA16Little,
-        DataFormatA16Big,
-        DataFormatA16F,
-        DataFormatA32F,
-        DataFormatNumFormats
-    };
-
-    ALWAYS_INLINE static bool hasAlpha(DataFormat format)
-    {
-        switch (format) {
-        case GraphicsContext3D::DataFormatA8:
-        case GraphicsContext3D::DataFormatA16F:
-        case GraphicsContext3D::DataFormatA32F:
-        case GraphicsContext3D::DataFormatRA8:
-        case GraphicsContext3D::DataFormatAR8:
-        case GraphicsContext3D::DataFormatRA16F:
-        case GraphicsContext3D::DataFormatRA32F:
-        case GraphicsContext3D::DataFormatRGBA8:
-        case GraphicsContext3D::DataFormatBGRA8:
-        case GraphicsContext3D::DataFormatARGB8:
-        case GraphicsContext3D::DataFormatABGR8:
-        case GraphicsContext3D::DataFormatRGBA16F:
-        case GraphicsContext3D::DataFormatRGBA32F:
-        case GraphicsContext3D::DataFormatRGBA4444:
-        case GraphicsContext3D::DataFormatRGBA5551:
-            return true;
-        default:
-            return false;
-        }
-    }
-
-    ALWAYS_INLINE static bool hasColor(DataFormat format)
-    {
-        switch (format) {
-        case GraphicsContext3D::DataFormatRGBA8:
-        case GraphicsContext3D::DataFormatRGBA16F:
-        case GraphicsContext3D::DataFormatRGBA32F:
-        case GraphicsContext3D::DataFormatRGB8:
-        case GraphicsContext3D::DataFormatRGB16F:
-        case GraphicsContext3D::DataFormatRGB32F:
-        case GraphicsContext3D::DataFormatBGR8:
-        case GraphicsContext3D::DataFormatBGRA8:
-        case GraphicsContext3D::DataFormatARGB8:
-        case GraphicsContext3D::DataFormatABGR8:
-        case GraphicsContext3D::DataFormatRGBA5551:
-        case GraphicsContext3D::DataFormatRGBA4444:
-        case GraphicsContext3D::DataFormatRGB565:
-        case GraphicsContext3D::DataFormatR8:
-        case GraphicsContext3D::DataFormatR16F:
-        case GraphicsContext3D::DataFormatR32F:
-        case GraphicsContext3D::DataFormatRA8:
-        case GraphicsContext3D::DataFormatRA16F:
-        case GraphicsContext3D::DataFormatRA32F:
-        case GraphicsContext3D::DataFormatAR8:
-            return true;
-        default:
-            return false;
-        }
-    }
-
-    // Check if the format is one of the formats from the ImageData or DOM elements.
-    // The formats from ImageData is always RGBA8.
-    // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
-    static ALWAYS_INLINE bool srcFormatComesFromDOMElementOrImageData(DataFormat SrcFormat)
-    {
-#if USE(CG)
-#if CPU(BIG_ENDIAN)
-    return SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8
-        || SrcFormat == DataFormatRA8 || SrcFormat == DataFormatAR8 || SrcFormat == DataFormatR8 || SrcFormat == DataFormatA8;
-#else
-    // That LITTLE_ENDIAN case has more possible formats than BIG_ENDIAN case is because some decoded image data is actually big endian
-    // even on little endian architectures.
-    return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatABGR8 || SrcFormat == DataFormatBGR8
-        || SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8
-        || SrcFormat == DataFormatR8 || SrcFormat == DataFormatA8
-        || SrcFormat == DataFormatRA8 || SrcFormat == DataFormatAR8;
-#endif
-#else
-    return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatRGBA8;
-#endif
-    }
-
     //----------------------------------------------------------------------
     // Entry points for WebGL.
     //
 
-    void activeTexture(GC3Denum texture);
-    void attachShader(Platform3DObject program, Platform3DObject shader);
-    void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name);
-    void bindBuffer(GC3Denum target, Platform3DObject);
-    void bindFramebuffer(GC3Denum target, Platform3DObject);
-    void bindRenderbuffer(GC3Denum target, Platform3DObject);
-    void bindTexture(GC3Denum target, Platform3DObject);
-    void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
-    void blendEquation(GC3Denum mode);
-    void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha);
-    void blendFunc(GC3Denum sfactor, GC3Denum dfactor);
-    void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha);
-
-    void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage);
-    void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage);
-    void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data);
-
-    void* mapBufferRange(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr length, GC3Dbitfield access);
-    GC3Dboolean unmapBuffer(GC3Denum target);
-    void copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dintptr readOffset, GC3Dintptr writeOffset, GC3Dsizeiptr);
-
-    void getInternalformativ(GC3Denum target, GC3Denum internalformat, GC3Denum pname, GC3Dsizei bufSize, GC3Dint* params);
-    void renderbufferStorageMultisample(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
-
-    void texStorage2D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
-    void texStorage3D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dsizei depth);
-
-    void getActiveUniforms(Platform3DObject program, const Vector<GC3Duint>& uniformIndices, GC3Denum pname, Vector<GC3Dint>& params);
-
-    GC3Denum checkFramebufferStatus(GC3Denum target);
-    void clear(GC3Dbitfield mask);
-    void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha);
-    void clearDepth(GC3Dclampf depth);
-    void clearStencil(GC3Dint s);
-    void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha);
-    void compileShader(Platform3DObject);
-
-    void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data);
-    void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data);
-    void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border);
-    void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
-    void cullFace(GC3Denum mode);
-    void depthFunc(GC3Denum func);
-    void depthMask(GC3Dboolean flag);
-    void depthRange(GC3Dclampf zNear, GC3Dclampf zFar);
-    void detachShader(Platform3DObject, Platform3DObject);
-    void disable(GC3Denum cap);
-    void disableVertexAttribArray(GC3Duint index);
-    void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count);
-    void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset);
-
-    void enable(GC3Denum cap);
-    void enableVertexAttribArray(GC3Duint index);
-    void finish();
-    void flush();
-    void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject);
-    void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level);
-    void frontFace(GC3Denum mode);
-    void generateMipmap(GC3Denum target);
-
-    bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&);
+    void activeTexture(GC3Denum texture) override;
+    void attachShader(Platform3DObject program, Platform3DObject shader) override;
+    void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name) override;
+    void bindBuffer(GC3Denum target, Platform3DObject) override;
+    void bindFramebuffer(GC3Denum target, Platform3DObject) override;
+    void bindRenderbuffer(GC3Denum target, Platform3DObject) override;
+    void bindTexture(GC3Denum target, Platform3DObject) override;
+    void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) override;
+    void blendEquation(GC3Denum mode) override;
+    void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) override;
+    void blendFunc(GC3Denum sfactor, GC3Denum dfactor) override;
+    void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) override;
+
+    void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) override;
+    void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) override;
+    void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) override;
+
+    void* mapBufferRange(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr length, GC3Dbitfield access) override;
+    GC3Dboolean unmapBuffer(GC3Denum target) override;
+    void copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dintptr readOffset, GC3Dintptr writeOffset, GC3Dsizeiptr) override;
+
+    void getInternalformativ(GC3Denum target, GC3Denum internalformat, GC3Denum pname, GC3Dsizei bufSize, GC3Dint* params) override;
+    void renderbufferStorageMultisample(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
+
+    void texStorage2D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
+    void texStorage3D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dsizei depth) override;
+
+    void getActiveUniforms(Platform3DObject program, const Vector<GC3Duint>& uniformIndices, GC3Denum pname, Vector<GC3Dint>& params) override;
+
+    GC3Denum checkFramebufferStatus(GC3Denum target) override;
+    void clear(GC3Dbitfield mask) override;
+    void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) override;
+    void clearDepth(GC3Dclampf depth) override;
+    void clearStencil(GC3Dint s) override;
+    void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) override;
+    void compileShader(Platform3DObject) override;
+
+    void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) override;
+    void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) override;
+    void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) override;
+    void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) override;
+    void cullFace(GC3Denum mode) override;
+    void depthFunc(GC3Denum func) override;
+    void depthMask(GC3Dboolean flag) override;
+    void depthRange(GC3Dclampf zNear, GC3Dclampf zFar) override;
+    void detachShader(Platform3DObject, Platform3DObject) override;
+    void disable(GC3Denum cap) override;
+    void disableVertexAttribArray(GC3Duint index) override;
+    void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) override;
+    void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) override;
+
+    void enable(GC3Denum cap) override;
+    void enableVertexAttribArray(GC3Duint index) override;
+    void finish() override;
+    void flush() override;
+    void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject) override;
+    void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level) override;
+    void frontFace(GC3Denum mode) override;
+    void generateMipmap(GC3Denum target) override;
+
+    bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&) override;
     bool getActiveAttribImpl(Platform3DObject program, GC3Duint index, ActiveInfo&);
-    bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&);
+    bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&) override;
     bool getActiveUniformImpl(Platform3DObject program, GC3Duint index, ActiveInfo&);
-    void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders);
-    GC3Dint getAttribLocation(Platform3DObject, const String& name);
-    void getBooleanv(GC3Denum pname, GC3Dboolean* value);
-    void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
-    GraphicsContext3DAttributes getContextAttributes();
-    GC3Denum getError();
-    void getFloatv(GC3Denum pname, GC3Dfloat* value);
-    void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value);
-    void getIntegerv(GC3Denum pname, GC3Dint* value);
-    void getInteger64v(GC3Denum pname, GC3Dint64* value);
-    void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value);
+    void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) override;
+    GC3Dint getAttribLocation(Platform3DObject, const String& name) override;
+    void getBooleanv(GC3Denum pname, GC3Dboolean* value) override;
+    void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) override;
+    GC3Denum getError() override;
+    void getFloatv(GC3Denum pname, GC3Dfloat* value) override;
+    void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) override;
+    void getIntegerv(GC3Denum pname, GC3Dint* value) override;
+    void getInteger64v(GC3Denum pname, GC3Dint64* value) override;
+    void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) override;
 #if !USE(ANGLE)
     void getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value);
 #endif // !USE(ANGLE)
-    String getProgramInfoLog(Platform3DObject);
+    String getProgramInfoLog(Platform3DObject) override;
     String getUnmangledInfoLog(Platform3DObject[2], GC3Dsizei, const String&);
-    void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
-    void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
-    String getShaderInfoLog(Platform3DObject);
-    void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision);
-#if !USE(ANGLE)
-    String getShaderSource(Platform3DObject);
-#endif // !USE(ANGLE)
-    String getString(GC3Denum name);
-    void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value);
-    void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
-    void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value);
-    void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value);
-    GC3Dint getUniformLocation(Platform3DObject, const String& name);
-    void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value);
-    void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value);
-    GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname);
-
-    void hint(GC3Denum target, GC3Denum mode);
-    GC3Dboolean isBuffer(Platform3DObject);
-    GC3Dboolean isEnabled(GC3Denum cap);
-    GC3Dboolean isFramebuffer(Platform3DObject);
-    GC3Dboolean isProgram(Platform3DObject);
-    GC3Dboolean isRenderbuffer(Platform3DObject);
-    GC3Dboolean isShader(Platform3DObject);
-    GC3Dboolean isTexture(Platform3DObject);
-    void lineWidth(GC3Dfloat);
-    void linkProgram(Platform3DObject);
-    void pixelStorei(GC3Denum pname, GC3Dint param);
-    void polygonOffset(GC3Dfloat factor, GC3Dfloat units);
-
-    void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data);
+    void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) override;
+    void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value) override;
+    String getShaderInfoLog(Platform3DObject) override;
+    void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision) override;
+    String getShaderSource(Platform3DObject) override;
+    String getString(GC3Denum name) override;
+    void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) override;
+    void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) override;
+    void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) override;
+    void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) override;
+    GC3Dint getUniformLocation(Platform3DObject, const String& name) override;
+    void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) override;
+    void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) override;
+    GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname) override;
+
+    void hint(GC3Denum target, GC3Denum mode) override;
+    GC3Dboolean isBuffer(Platform3DObject) override;
+    GC3Dboolean isEnabled(GC3Denum cap) override;
+    GC3Dboolean isFramebuffer(Platform3DObject) override;
+    GC3Dboolean isProgram(Platform3DObject) override;
+    GC3Dboolean isRenderbuffer(Platform3DObject) override;
+    GC3Dboolean isShader(Platform3DObject) override;
+    GC3Dboolean isTexture(Platform3DObject) override;
+    void lineWidth(GC3Dfloat) override;
+    void linkProgram(Platform3DObject) override;
+    void pixelStorei(GC3Denum pname, GC3Dint param) override;
+    void polygonOffset(GC3Dfloat factor, GC3Dfloat units) override;
+
+    void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) override;
 
     void releaseShaderCompiler();
 
-    void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
-    void sampleCoverage(GC3Dclampf value, GC3Dboolean invert);
-    void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
-    void shaderSource(Platform3DObject, const String& string);
-    void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask);
-    void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask);
-    void stencilMask(GC3Duint mask);
-    void stencilMaskSeparate(GC3Denum face, GC3Duint mask);
-    void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
-    void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass);
-
-    bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels);
-    void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param);
-    void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param);
-    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels);
-
-    void uniform1f(GC3Dint location, GC3Dfloat x);
-    void uniform1fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v);
-    void uniform1i(GC3Dint location, GC3Dint x);
-    void uniform1iv(GC3Dint location, GC3Dsizei, const GC3Dint* v);
-    void uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y);
-    void uniform2fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v);
-    void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y);
-    void uniform2iv(GC3Dint location, GC3Dsizei, const GC3Dint* v);
-    void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
-    void uniform3fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v);
-    void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z);
-    void uniform3iv(GC3Dint location, GC3Dsizei, const GC3Dint* v);
-    void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
-    void uniform4fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v);
-    void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w);
-    void uniform4iv(GC3Dint location, GC3Dsizei, const GC3Dint* v);
-    void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value);
-    void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value);
-    void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value);
-
-    void useProgram(Platform3DObject);
-    void validateProgram(Platform3DObject);
+    void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) override;
+    void sampleCoverage(GC3Dclampf value, GC3Dboolean invert) override;
+    void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) override;
+    void shaderSource(Platform3DObject, const String& string) override;
+    void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) override;
+    void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) override;
+    void stencilMask(GC3Duint mask) override;
+    void stencilMaskSeparate(GC3Denum face, GC3Duint mask) override;
+    void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) override;
+    void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) override;
+
+    bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) override;
+    void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param) override;
+    void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param) override;
+    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) override;
+
+    void uniform1f(GC3Dint location, GC3Dfloat x) override;
+    void uniform1fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) override;
+    void uniform1i(GC3Dint location, GC3Dint x) override;
+    void uniform1iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) override;
+    void uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y) override;
+    void uniform2fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) override;
+    void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y) override;
+    void uniform2iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) override;
+    void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) override;
+    void uniform3fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) override;
+    void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z) override;
+    void uniform3iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) override;
+    void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) override;
+    void uniform4fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) override;
+    void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w) override;
+    void uniform4iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) override;
+    void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) override;
+    void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) override;
+    void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) override;
+
+    void useProgram(Platform3DObject) override;
+    void validateProgram(Platform3DObject) override;
 #if !USE(ANGLE)
     bool checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
     bool precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
 #endif
 
-    void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
-    void vertexAttrib1fv(GC3Duint index, const GC3Dfloat* values);
-    void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y);
-    void vertexAttrib2fv(GC3Duint index, const GC3Dfloat* values);
-    void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z);
-    void vertexAttrib3fv(GC3Duint index, const GC3Dfloat* values);
-    void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w);
-    void vertexAttrib4fv(GC3Duint index, const GC3Dfloat* values);
-    void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized,
-                             GC3Dsizei stride, GC3Dintptr offset);
+    void vertexAttrib1f(GC3Duint index, GC3Dfloat x) override;
+    void vertexAttrib1fv(GC3Duint index, const GC3Dfloat* values) override;
+    void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y) override;
+    void vertexAttrib2fv(GC3Duint index, const GC3Dfloat* values) override;
+    void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) override;
+    void vertexAttrib3fv(GC3Duint index, const GC3Dfloat* values) override;
+    void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) override;
+    void vertexAttrib4fv(GC3Duint index, const GC3Dfloat* values) override;
+    void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) override;
 
-    void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height);
+    void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) override;
 
     void reshape(int width, int height);
 
-    void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount);
-    void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount);
-    void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
+    void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) override;
+    void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) override;
+    void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) override;
 
     // VertexArrayOject calls
-    Platform3DObject createVertexArray();
-    void deleteVertexArray(Platform3DObject);
-    GC3Dboolean isVertexArray(Platform3DObject);
-    void bindVertexArray(Platform3DObject);
+    Platform3DObject createVertexArray() override;
+    void deleteVertexArray(Platform3DObject) override;
+    GC3Dboolean isVertexArray(Platform3DObject) override;
+    void bindVertexArray(Platform3DObject) override;
 
     void paintToCanvas(const unsigned char* imagePixels, const IntSize& imageSize, const IntSize& canvasSize, GraphicsContext&);
 
@@ -1189,7 +390,7 @@ public:
     bool paintCompositedResultsToCanvas(ImageBuffer*);
 
 #if USE(OPENGL) && ENABLE(WEBGL2)
-    void primitiveRestartIndex(GC3Duint);
+    void primitiveRestartIndex(GC3Duint) override;
 #endif
 
 #if PLATFORM(COCOA)
@@ -1213,19 +414,19 @@ public:
     GraphicsContext3DPowerPreference powerPreferenceUsedForCreation() const { return m_powerPreferenceUsedForCreation; }
 
     // Support for buffer creation and deletion
-    Platform3DObject createBuffer();
-    Platform3DObject createFramebuffer();
-    Platform3DObject createProgram();
-    Platform3DObject createRenderbuffer();
-    Platform3DObject createShader(GC3Denum);
-    Platform3DObject createTexture();
-
-    void deleteBuffer(Platform3DObject);
-    void deleteFramebuffer(Platform3DObject);
-    void deleteProgram(Platform3DObject);
-    void deleteRenderbuffer(Platform3DObject);
-    void deleteShader(Platform3DObject);
-    void deleteTexture(Platform3DObject);
+    Platform3DObject createBuffer() override;
+    Platform3DObject createFramebuffer() override;
+    Platform3DObject createProgram() override;
+    Platform3DObject createRenderbuffer() override;
+    Platform3DObject createShader(GC3Denum) override;
+    Platform3DObject createTexture() override;
+
+    void deleteBuffer(Platform3DObject) override;
+    void deleteFramebuffer(Platform3DObject) override;
+    void deleteProgram(Platform3DObject) override;
+    void deleteRenderbuffer(Platform3DObject) override;
+    void deleteShader(Platform3DObject) override;
+    void deleteTexture(Platform3DObject) override;
 
     // Synthesizes an OpenGL error which will be returned from a
     // later call to getError. This is used to emulate OpenGL ES
@@ -1245,42 +446,10 @@ public:
     // all methods it contains may necessarily be supported on the
     // current hardware. Must call Extensions3D::supports() to
     // determine this.
-    Extensions3D& getExtensions();
+    Extensions3D& getExtensions() override;
 
     IntSize getInternalFramebufferSize() const;
 
-    static unsigned getClearBitsByAttachmentType(GC3Denum);
-    static unsigned getClearBitsByFormat(GC3Denum);
-
-    enum ChannelBits {
-        ChannelRed = 1,
-        ChannelGreen = 2,
-        ChannelBlue = 4,
-        ChannelAlpha = 8,
-        ChannelDepth = 16,
-        ChannelStencil = 32,
-        ChannelRGB = ChannelRed | ChannelGreen | ChannelBlue,
-        ChannelRGBA = ChannelRGB | ChannelAlpha,
-    };
-
-    static unsigned getChannelBitsByFormat(GC3Denum);
-
-    // Possible alpha operations that may need to occur during
-    // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must
-    // be removed.
-    enum AlphaOp {
-        AlphaDoNothing = 0,
-        AlphaDoPremultiply = 1,
-        AlphaDoUnmultiply = 2
-    };
-
-    enum ImageHtmlDomSource {
-        HtmlDomImage = 0,
-        HtmlDomCanvas = 1,
-        HtmlDomVideo = 2,
-        HtmlDomNone = 3
-    };
-
     // Packs the contents of the given Image which is passed in |pixels| into the passed Vector
     // according to the given format and type, and obeying the flipY and AlphaOp flags.
     // Returns true upon success.
@@ -1288,7 +457,7 @@ public:
 
     class ImageExtractor {
     public:
-        ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
+        ImageExtractor(Image*, DOMSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
 
         // Each platform must provide an implementation of this method to deallocate or release resources
         // associated with the image if needed.
@@ -1301,7 +470,7 @@ public:
         DataFormat imageSourceFormat() { return m_imageSourceFormat; }
         AlphaOp imageAlphaOp() { return m_alphaOp; }
         unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignment; }
-        ImageHtmlDomSource imageHtmlDomSource() { return m_imageHtmlDomSource; }
+        DOMSource imageHtmlDomSource() { return m_imageHtmlDomSource; }
     private:
         // Each platform must provide an implementation of this method.
         // Extracts the image and keeps track of its status, such as width, height, Source Alignment, format and AlphaOp etc,
@@ -1317,7 +486,7 @@ public:
         UniqueArray<uint8_t> m_formalizedRGBA8Data;
 #endif
         Image* m_image;
-        ImageHtmlDomSource m_imageHtmlDomSource;
+        DOMSource m_imageHtmlDomSource;
         bool m_extractSucceeded;
         const void* m_imagePixelData;
         unsigned m_imageWidth;
@@ -1340,7 +509,7 @@ public:
 #endif
 
 private:
-    GraphicsContext3D(GraphicsContext3DAttributes, HostWindow*, RenderStyle = RenderOffscreen, GraphicsContext3D* sharedContext = nullptr);
+    GraphicsContext3D(GraphicsContext3DAttributes, HostWindow*, Destination = Destination::Offscreen, GraphicsContext3D* sharedContext = nullptr);
 
     // Helper for packImageData/extractImageData/extractTextureData which implement packing of pixel
     // data into the specified OpenGL destination format and type.
@@ -1474,9 +643,7 @@ private:
     std::unique_ptr<Extensions3DOpenGL> m_extensions;
 #endif
 
-    GraphicsContext3DAttributes m_attrs;
     GraphicsContext3DPowerPreference m_powerPreferenceUsedForCreation { GraphicsContext3DPowerPreference::Default };
-    RenderStyle m_renderStyle;
     Vector<Vector<float>> m_vertexArray;
 
 #if !USE(ANGLE)
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3DBase.cpp b/Source/WebCore/platform/graphics/GraphicsContext3DBase.cpp
new file mode 100644 (file)
index 0000000..6ceaa61
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "GraphicsContext3DBase.h"
+
+#if ENABLE(WEBGL)
+
+#include "Extensions3D.h"
+
+namespace WebCore {
+
+GraphicsContext3DBase::GraphicsContext3DBase(GraphicsContext3DAttributes attrs, Destination destination, GraphicsContext3DBase*)
+    : m_attrs(attrs)
+    , m_destination(destination)
+{
+}
+
+unsigned GraphicsContext3DBase::getClearBitsByAttachmentType(GC3Denum attachment)
+{
+    switch (attachment) {
+    case GraphicsContext3DBase::COLOR_ATTACHMENT0:
+    case Extensions3D::COLOR_ATTACHMENT1_EXT:
+    case Extensions3D::COLOR_ATTACHMENT2_EXT:
+    case Extensions3D::COLOR_ATTACHMENT3_EXT:
+    case Extensions3D::COLOR_ATTACHMENT4_EXT:
+    case Extensions3D::COLOR_ATTACHMENT5_EXT:
+    case Extensions3D::COLOR_ATTACHMENT6_EXT:
+    case Extensions3D::COLOR_ATTACHMENT7_EXT:
+    case Extensions3D::COLOR_ATTACHMENT8_EXT:
+    case Extensions3D::COLOR_ATTACHMENT9_EXT:
+    case Extensions3D::COLOR_ATTACHMENT10_EXT:
+    case Extensions3D::COLOR_ATTACHMENT11_EXT:
+    case Extensions3D::COLOR_ATTACHMENT12_EXT:
+    case Extensions3D::COLOR_ATTACHMENT13_EXT:
+    case Extensions3D::COLOR_ATTACHMENT14_EXT:
+    case Extensions3D::COLOR_ATTACHMENT15_EXT:
+        return GraphicsContext3DBase::COLOR_BUFFER_BIT;
+    case GraphicsContext3DBase::DEPTH_ATTACHMENT:
+        return GraphicsContext3DBase::DEPTH_BUFFER_BIT;
+    case GraphicsContext3DBase::STENCIL_ATTACHMENT:
+        return GraphicsContext3DBase::STENCIL_BUFFER_BIT;
+    case GraphicsContext3DBase::DEPTH_STENCIL_ATTACHMENT:
+        return GraphicsContext3DBase::DEPTH_BUFFER_BIT | GraphicsContext3DBase::STENCIL_BUFFER_BIT;
+    default:
+        return 0;
+    }
+}
+
+unsigned GraphicsContext3DBase::getClearBitsByFormat(GC3Denum format)
+{
+    switch (format) {
+    case GraphicsContext3DBase::RGB:
+    case GraphicsContext3DBase::RGBA:
+    case GraphicsContext3DBase::LUMINANCE_ALPHA:
+    case GraphicsContext3DBase::LUMINANCE:
+    case GraphicsContext3DBase::ALPHA:
+    case GraphicsContext3DBase::R8:
+    case GraphicsContext3DBase::R8_SNORM:
+    case GraphicsContext3DBase::R16F:
+    case GraphicsContext3DBase::R32F:
+    case GraphicsContext3DBase::R8UI:
+    case GraphicsContext3DBase::R8I:
+    case GraphicsContext3DBase::R16UI:
+    case GraphicsContext3DBase::R16I:
+    case GraphicsContext3DBase::R32UI:
+    case GraphicsContext3DBase::R32I:
+    case GraphicsContext3DBase::RG8:
+    case GraphicsContext3DBase::RG8_SNORM:
+    case GraphicsContext3DBase::RG16F:
+    case GraphicsContext3DBase::RG32F:
+    case GraphicsContext3DBase::RG8UI:
+    case GraphicsContext3DBase::RG8I:
+    case GraphicsContext3DBase::RG16UI:
+    case GraphicsContext3DBase::RG16I:
+    case GraphicsContext3DBase::RG32UI:
+    case GraphicsContext3DBase::RG32I:
+    case GraphicsContext3DBase::RGB8:
+    case GraphicsContext3DBase::SRGB8:
+    case GraphicsContext3DBase::RGB565:
+    case GraphicsContext3DBase::RGB8_SNORM:
+    case GraphicsContext3DBase::R11F_G11F_B10F:
+    case GraphicsContext3DBase::RGB9_E5:
+    case GraphicsContext3DBase::RGB16F:
+    case GraphicsContext3DBase::RGB32F:
+    case GraphicsContext3DBase::RGB8UI:
+    case GraphicsContext3DBase::RGB8I:
+    case GraphicsContext3DBase::RGB16UI:
+    case GraphicsContext3DBase::RGB16I:
+    case GraphicsContext3DBase::RGB32UI:
+    case GraphicsContext3DBase::RGB32I:
+    case GraphicsContext3DBase::RGBA8:
+    case GraphicsContext3DBase::SRGB8_ALPHA8:
+    case GraphicsContext3DBase::RGBA8_SNORM:
+    case GraphicsContext3DBase::RGB5_A1:
+    case GraphicsContext3DBase::RGBA4:
+    case GraphicsContext3DBase::RGB10_A2:
+    case GraphicsContext3DBase::RGBA16F:
+    case GraphicsContext3DBase::RGBA32F:
+    case GraphicsContext3DBase::RGBA8UI:
+    case GraphicsContext3DBase::RGBA8I:
+    case GraphicsContext3DBase::RGB10_A2UI:
+    case GraphicsContext3DBase::RGBA16UI:
+    case GraphicsContext3DBase::RGBA16I:
+    case GraphicsContext3DBase::RGBA32I:
+    case GraphicsContext3DBase::RGBA32UI:
+    case Extensions3D::SRGB_EXT:
+    case Extensions3D::SRGB_ALPHA_EXT:
+        return GraphicsContext3DBase::COLOR_BUFFER_BIT;
+    case GraphicsContext3DBase::DEPTH_COMPONENT16:
+    case GraphicsContext3DBase::DEPTH_COMPONENT24:
+    case GraphicsContext3DBase::DEPTH_COMPONENT32F:
+    case GraphicsContext3DBase::DEPTH_COMPONENT:
+        return GraphicsContext3DBase::DEPTH_BUFFER_BIT;
+    case GraphicsContext3DBase::STENCIL_INDEX8:
+        return GraphicsContext3DBase::STENCIL_BUFFER_BIT;
+    case GraphicsContext3DBase::DEPTH_STENCIL:
+    case GraphicsContext3DBase::DEPTH24_STENCIL8:
+    case GraphicsContext3DBase::DEPTH32F_STENCIL8:
+        return GraphicsContext3DBase::DEPTH_BUFFER_BIT | GraphicsContext3DBase::STENCIL_BUFFER_BIT;
+    default:
+        return 0;
+    }
+}
+
+uint8_t GraphicsContext3DBase::getChannelBitsByFormat(GC3Denum format)
+{
+    switch (format) {
+    case GraphicsContext3DBase::ALPHA:
+        return static_cast<uint8_t>(ChannelBits::Alpha);
+    case GraphicsContext3DBase::LUMINANCE:
+        return static_cast<uint8_t>(ChannelBits::RGB);
+    case GraphicsContext3DBase::LUMINANCE_ALPHA:
+        return static_cast<uint8_t>(ChannelBits::RGBA);
+    case GraphicsContext3DBase::RGB:
+    case GraphicsContext3DBase::RGB565:
+    case Extensions3D::SRGB_EXT:
+        return static_cast<uint8_t>(ChannelBits::RGB);
+    case GraphicsContext3DBase::RGBA:
+    case GraphicsContext3DBase::RGBA4:
+    case GraphicsContext3DBase::RGB5_A1:
+    case Extensions3D::SRGB_ALPHA_EXT:
+        return static_cast<uint8_t>(ChannelBits::RGBA);
+    case GraphicsContext3DBase::DEPTH_COMPONENT16:
+    case GraphicsContext3DBase::DEPTH_COMPONENT:
+        return static_cast<uint8_t>(ChannelBits::Depth);
+    case GraphicsContext3DBase::STENCIL_INDEX8:
+        return static_cast<uint8_t>(ChannelBits::Stencil);
+    case GraphicsContext3DBase::DEPTH_STENCIL:
+        return static_cast<uint8_t>(ChannelBits::DepthStencil);
+    default:
+        return 0;
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3DBase.h b/Source/WebCore/platform/graphics/GraphicsContext3DBase.h
new file mode 100644 (file)
index 0000000..6b8c9ad
--- /dev/null
@@ -0,0 +1,1069 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGL)
+
+#include "GraphicsContext3DAttributes.h"
+#include "GraphicsTypes3D.h"
+#include "Image.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "PlatformLayer.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+typedef void* PlatformGraphicsContext3D;
+typedef void* PlatformGraphicsContext3DDisplay;
+typedef void* PlatformGraphicsContext3DSurface;
+typedef void* PlatformGraphicsContext3DConfig;
+
+namespace WebCore {
+class Extensions3D;
+class HostWindow;
+class ImageBuffer;
+class ImageData;
+
+class GraphicsContext3DBase : public RefCounted<GraphicsContext3DBase> {
+public:
+    enum {
+        // WebGL 1 constants.
+        DEPTH_BUFFER_BIT = 0x00000100,
+        STENCIL_BUFFER_BIT = 0x00000400,
+        COLOR_BUFFER_BIT = 0x00004000,
+        POINTS = 0x0000,
+        LINES = 0x0001,
+        LINE_LOOP = 0x0002,
+        LINE_STRIP = 0x0003,
+        TRIANGLES = 0x0004,
+        TRIANGLE_STRIP = 0x0005,
+        TRIANGLE_FAN = 0x0006,
+        ZERO = 0,
+        ONE = 1,
+        SRC_COLOR = 0x0300,
+        ONE_MINUS_SRC_COLOR = 0x0301,
+        SRC_ALPHA = 0x0302,
+        ONE_MINUS_SRC_ALPHA = 0x0303,
+        DST_ALPHA = 0x0304,
+        ONE_MINUS_DST_ALPHA = 0x0305,
+        DST_COLOR = 0x0306,
+        ONE_MINUS_DST_COLOR = 0x0307,
+        SRC_ALPHA_SATURATE = 0x0308,
+        FUNC_ADD = 0x8006,
+        BLEND_EQUATION = 0x8009,
+        BLEND_EQUATION_RGB = 0x8009,
+        BLEND_EQUATION_ALPHA = 0x883D,
+        FUNC_SUBTRACT = 0x800A,
+        FUNC_REVERSE_SUBTRACT = 0x800B,
+        BLEND_DST_RGB = 0x80C8,
+        BLEND_SRC_RGB = 0x80C9,
+        BLEND_DST_ALPHA = 0x80CA,
+        BLEND_SRC_ALPHA = 0x80CB,
+        CONSTANT_COLOR = 0x8001,
+        ONE_MINUS_CONSTANT_COLOR = 0x8002,
+        CONSTANT_ALPHA = 0x8003,
+        ONE_MINUS_CONSTANT_ALPHA = 0x8004,
+        BLEND_COLOR = 0x8005,
+        ARRAY_BUFFER = 0x8892,
+        ELEMENT_ARRAY_BUFFER = 0x8893,
+        ARRAY_BUFFER_BINDING = 0x8894,
+        ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
+        STREAM_DRAW = 0x88E0,
+        STATIC_DRAW = 0x88E4,
+        DYNAMIC_DRAW = 0x88E8,
+        BUFFER_SIZE = 0x8764,
+        BUFFER_USAGE = 0x8765,
+        CURRENT_VERTEX_ATTRIB = 0x8626,
+        FRONT = 0x0404,
+        BACK = 0x0405,
+        FRONT_AND_BACK = 0x0408,
+        TEXTURE_2D = 0x0DE1,
+        CULL_FACE = 0x0B44,
+        BLEND = 0x0BE2,
+        DITHER = 0x0BD0,
+        STENCIL_TEST = 0x0B90,
+        DEPTH_TEST = 0x0B71,
+        SCISSOR_TEST = 0x0C11,
+        POLYGON_OFFSET_FILL = 0x8037,
+        SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
+        SAMPLE_COVERAGE = 0x80A0,
+        NO_ERROR = 0,
+        INVALID_ENUM = 0x0500,
+        INVALID_VALUE = 0x0501,
+        INVALID_OPERATION = 0x0502,
+        OUT_OF_MEMORY = 0x0505,
+        CW = 0x0900,
+        CCW = 0x0901,
+        LINE_WIDTH = 0x0B21,
+        ALIASED_POINT_SIZE_RANGE = 0x846D,
+        ALIASED_LINE_WIDTH_RANGE = 0x846E,
+        CULL_FACE_MODE = 0x0B45,
+        FRONT_FACE = 0x0B46,
+        DEPTH_RANGE = 0x0B70,
+        DEPTH_WRITEMASK = 0x0B72,
+        DEPTH_CLEAR_VALUE = 0x0B73,
+        DEPTH_FUNC = 0x0B74,
+        STENCIL_CLEAR_VALUE = 0x0B91,
+        STENCIL_FUNC = 0x0B92,
+        STENCIL_FAIL = 0x0B94,
+        STENCIL_PASS_DEPTH_FAIL = 0x0B95,
+        STENCIL_PASS_DEPTH_PASS = 0x0B96,
+        STENCIL_REF = 0x0B97,
+        STENCIL_VALUE_MASK = 0x0B93,
+        STENCIL_WRITEMASK = 0x0B98,
+        STENCIL_BACK_FUNC = 0x8800,
+        STENCIL_BACK_FAIL = 0x8801,
+        STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
+        STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
+        STENCIL_BACK_REF = 0x8CA3,
+        STENCIL_BACK_VALUE_MASK = 0x8CA4,
+        STENCIL_BACK_WRITEMASK = 0x8CA5,
+        VIEWPORT = 0x0BA2,
+        SCISSOR_BOX = 0x0C10,
+        COLOR_CLEAR_VALUE = 0x0C22,
+        COLOR_WRITEMASK = 0x0C23,
+        UNPACK_ALIGNMENT = 0x0CF5,
+        PACK_ALIGNMENT = 0x0D05,
+        MAX_TEXTURE_SIZE = 0x0D33,
+        MAX_VIEWPORT_DIMS = 0x0D3A,
+        SUBPIXEL_BITS = 0x0D50,
+        RED_BITS = 0x0D52,
+        GREEN_BITS = 0x0D53,
+        BLUE_BITS = 0x0D54,
+        ALPHA_BITS = 0x0D55,
+        DEPTH_BITS = 0x0D56,
+        STENCIL_BITS = 0x0D57,
+        POLYGON_OFFSET_UNITS = 0x2A00,
+        POLYGON_OFFSET_FACTOR = 0x8038,
+        TEXTURE_BINDING_2D = 0x8069,
+        SAMPLE_BUFFERS = 0x80A8,
+        SAMPLES = 0x80A9,
+        SAMPLE_COVERAGE_VALUE = 0x80AA,
+        SAMPLE_COVERAGE_INVERT = 0x80AB,
+        NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
+        COMPRESSED_TEXTURE_FORMATS = 0x86A3,
+        DONT_CARE = 0x1100,
+        FASTEST = 0x1101,
+        NICEST = 0x1102,
+        GENERATE_MIPMAP_HINT = 0x8192,
+        BYTE = 0x1400,
+        UNSIGNED_BYTE = 0x1401,
+        SHORT = 0x1402,
+        UNSIGNED_SHORT = 0x1403,
+        INT = 0x1404,
+        UNSIGNED_INT = 0x1405,
+        FLOAT = 0x1406,
+        HALF_FLOAT_OES = 0x8D61,
+        FIXED = 0x140C,
+        DEPTH_COMPONENT = 0x1902,
+        ALPHA = 0x1906,
+        RGB = 0x1907,
+        RGBA = 0x1908,
+        BGRA = 0x80E1,
+        LUMINANCE = 0x1909,
+        LUMINANCE_ALPHA = 0x190A,
+        UNSIGNED_SHORT_4_4_4_4 = 0x8033,
+        UNSIGNED_SHORT_5_5_5_1 = 0x8034,
+        UNSIGNED_SHORT_5_6_5 = 0x8363,
+        FRAGMENT_SHADER = 0x8B30,
+        VERTEX_SHADER = 0x8B31,
+        MAX_VERTEX_ATTRIBS = 0x8869,
+        MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
+        MAX_VARYING_VECTORS = 0x8DFC,
+        MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
+        MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
+        MAX_TEXTURE_IMAGE_UNITS = 0x8872,
+        MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
+        SHADER_TYPE = 0x8B4F,
+        DELETE_STATUS = 0x8B80,
+        LINK_STATUS = 0x8B82,
+        VALIDATE_STATUS = 0x8B83,
+        ATTACHED_SHADERS = 0x8B85,
+        ACTIVE_UNIFORMS = 0x8B86,
+        ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
+        ACTIVE_ATTRIBUTES = 0x8B89,
+        ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
+        SHADING_LANGUAGE_VERSION = 0x8B8C,
+        CURRENT_PROGRAM = 0x8B8D,
+        NEVER = 0x0200,
+        LESS = 0x0201,
+        EQUAL = 0x0202,
+        LEQUAL = 0x0203,
+        GREATER = 0x0204,
+        NOTEQUAL = 0x0205,
+        GEQUAL = 0x0206,
+        ALWAYS = 0x0207,
+        KEEP = 0x1E00,
+        REPLACE = 0x1E01,
+        INCR = 0x1E02,
+        DECR = 0x1E03,
+        INVERT = 0x150A,
+        INCR_WRAP = 0x8507,
+        DECR_WRAP = 0x8508,
+        VENDOR = 0x1F00,
+        RENDERER = 0x1F01,
+        VERSION = 0x1F02,
+        EXTENSIONS = 0x1F03,
+        NEAREST = 0x2600,
+        LINEAR = 0x2601,
+        NEAREST_MIPMAP_NEAREST = 0x2700,
+        LINEAR_MIPMAP_NEAREST = 0x2701,
+        NEAREST_MIPMAP_LINEAR = 0x2702,
+        LINEAR_MIPMAP_LINEAR = 0x2703,
+        TEXTURE_MAG_FILTER = 0x2800,
+        TEXTURE_MIN_FILTER = 0x2801,
+        TEXTURE_WRAP_S = 0x2802,
+        TEXTURE_WRAP_T = 0x2803,
+        TEXTURE = 0x1702,
+        TEXTURE_CUBE_MAP = 0x8513,
+        TEXTURE_BINDING_CUBE_MAP = 0x8514,
+        TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
+        TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
+        TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
+        TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
+        TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
+        TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
+        MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
+        TEXTURE0 = 0x84C0,
+        TEXTURE1 = 0x84C1,
+        TEXTURE2 = 0x84C2,
+        TEXTURE3 = 0x84C3,
+        TEXTURE4 = 0x84C4,
+        TEXTURE5 = 0x84C5,
+        TEXTURE6 = 0x84C6,
+        TEXTURE7 = 0x84C7,
+        TEXTURE8 = 0x84C8,
+        TEXTURE9 = 0x84C9,
+        TEXTURE10 = 0x84CA,
+        TEXTURE11 = 0x84CB,
+        TEXTURE12 = 0x84CC,
+        TEXTURE13 = 0x84CD,
+        TEXTURE14 = 0x84CE,
+        TEXTURE15 = 0x84CF,
+        TEXTURE16 = 0x84D0,
+        TEXTURE17 = 0x84D1,
+        TEXTURE18 = 0x84D2,
+        TEXTURE19 = 0x84D3,
+        TEXTURE20 = 0x84D4,
+        TEXTURE21 = 0x84D5,
+        TEXTURE22 = 0x84D6,
+        TEXTURE23 = 0x84D7,
+        TEXTURE24 = 0x84D8,
+        TEXTURE25 = 0x84D9,
+        TEXTURE26 = 0x84DA,
+        TEXTURE27 = 0x84DB,
+        TEXTURE28 = 0x84DC,
+        TEXTURE29 = 0x84DD,
+        TEXTURE30 = 0x84DE,
+        TEXTURE31 = 0x84DF,
+        ACTIVE_TEXTURE = 0x84E0,
+        REPEAT = 0x2901,
+        CLAMP_TO_EDGE = 0x812F,
+        MIRRORED_REPEAT = 0x8370,
+        FLOAT_VEC2 = 0x8B50,
+        FLOAT_VEC3 = 0x8B51,
+        FLOAT_VEC4 = 0x8B52,
+        INT_VEC2 = 0x8B53,
+        INT_VEC3 = 0x8B54,
+        INT_VEC4 = 0x8B55,
+        BOOL = 0x8B56,
+        BOOL_VEC2 = 0x8B57,
+        BOOL_VEC3 = 0x8B58,
+        BOOL_VEC4 = 0x8B59,
+        FLOAT_MAT2 = 0x8B5A,
+        FLOAT_MAT3 = 0x8B5B,
+        FLOAT_MAT4 = 0x8B5C,
+        SAMPLER_2D = 0x8B5E,
+        SAMPLER_CUBE = 0x8B60,
+        VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
+        VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
+        VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
+        VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
+        VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
+        VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
+        VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
+        IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A,
+        IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B,
+        COMPILE_STATUS = 0x8B81,
+        INFO_LOG_LENGTH = 0x8B84,
+        SHADER_SOURCE_LENGTH = 0x8B88,
+        SHADER_COMPILER = 0x8DFA,
+        SHADER_BINARY_FORMATS = 0x8DF8,
+        NUM_SHADER_BINARY_FORMATS = 0x8DF9,
+        LOW_FLOAT = 0x8DF0,
+        MEDIUM_FLOAT = 0x8DF1,
+        HIGH_FLOAT = 0x8DF2,
+        LOW_INT = 0x8DF3,
+        MEDIUM_INT = 0x8DF4,
+        HIGH_INT = 0x8DF5,
+        FRAMEBUFFER = 0x8D40,
+        RENDERBUFFER = 0x8D41,
+        RGBA4 = 0x8056,
+        RGB5_A1 = 0x8057,
+        RGB565 = 0x8D62,
+        DEPTH_COMPONENT16 = 0x81A5,
+        STENCIL_INDEX = 0x1901,
+        STENCIL_INDEX8 = 0x8D48,
+        RENDERBUFFER_WIDTH = 0x8D42,
+        RENDERBUFFER_HEIGHT = 0x8D43,
+        RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
+        RENDERBUFFER_RED_SIZE = 0x8D50,
+        RENDERBUFFER_GREEN_SIZE = 0x8D51,
+        RENDERBUFFER_BLUE_SIZE = 0x8D52,
+        RENDERBUFFER_ALPHA_SIZE = 0x8D53,
+        RENDERBUFFER_DEPTH_SIZE = 0x8D54,
+        RENDERBUFFER_STENCIL_SIZE = 0x8D55,
+        FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
+        FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
+        FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
+        FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
+        COLOR_ATTACHMENT0 = 0x8CE0,
+        DEPTH_ATTACHMENT = 0x8D00,
+        STENCIL_ATTACHMENT = 0x8D20,
+        NONE = 0,
+        FRAMEBUFFER_COMPLETE = 0x8CD5,
+        FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
+        FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
+        FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
+        FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
+        FRAMEBUFFER_BINDING = 0x8CA6,
+        RENDERBUFFER_BINDING = 0x8CA7,
+        MAX_RENDERBUFFER_SIZE = 0x84E8,
+        INVALID_FRAMEBUFFER_OPERATION = 0x0506,
+
+        // WebGL-specific enums
+        UNPACK_FLIP_Y_WEBGL = 0x9240,
+        UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
+        CONTEXT_LOST_WEBGL = 0x9242,
+        UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
+        BROWSER_DEFAULT_WEBGL = 0x9244,
+        VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE,
+        
+        // WebGL2 constants
+        READ_BUFFER = 0x0C02,
+        UNPACK_ROW_LENGTH = 0x0CF2,
+        UNPACK_SKIP_ROWS = 0x0CF3,
+        UNPACK_SKIP_PIXELS = 0x0CF4,
+        PACK_ROW_LENGTH = 0x0D02,
+        PACK_SKIP_ROWS = 0x0D03,
+        PACK_SKIP_PIXELS = 0x0D04,
+        COLOR = 0x1800,
+        DEPTH = 0x1801,
+        STENCIL = 0x1802,
+        RED = 0x1903,
+        RGB8 = 0x8051,
+        RGBA8 = 0x8058,
+        RGB10_A2 = 0x8059,
+        TEXTURE_BINDING_3D = 0x806A,
+        UNPACK_SKIP_IMAGES = 0x806D,
+        UNPACK_IMAGE_HEIGHT = 0x806E,
+        TEXTURE_3D = 0x806F,
+        TEXTURE_WRAP_R = 0x8072,
+        MAX_3D_TEXTURE_SIZE = 0x8073,
+        UNSIGNED_INT_2_10_10_10_REV = 0x8368,
+        MAX_ELEMENTS_VERTICES = 0x80E8,
+        MAX_ELEMENTS_INDICES = 0x80E9,
+        TEXTURE_MIN_LOD = 0x813A,
+        TEXTURE_MAX_LOD = 0x813B,
+        TEXTURE_BASE_LEVEL = 0x813C,
+        TEXTURE_MAX_LEVEL = 0x813D,
+        MIN = 0x8007,
+        MAX = 0x8008,
+        DEPTH_COMPONENT24 = 0x81A6,
+        MAX_TEXTURE_LOD_BIAS = 0x84FD,
+        TEXTURE_COMPARE_MODE = 0x884C,
+        TEXTURE_COMPARE_FUNC = 0x884D,
+        CURRENT_QUERY = 0x8865,
+        QUERY_RESULT = 0x8866,
+        QUERY_RESULT_AVAILABLE = 0x8867,
+        STREAM_READ = 0x88E1,
+        STREAM_COPY = 0x88E2,
+        STATIC_READ = 0x88E5,
+        STATIC_COPY = 0x88E6,
+        DYNAMIC_READ = 0x88E9,
+        DYNAMIC_COPY = 0x88EA,
+        MAX_DRAW_BUFFERS = 0x8824,
+        DRAW_BUFFER0 = 0x8825,
+        DRAW_BUFFER1 = 0x8826,
+        DRAW_BUFFER2 = 0x8827,
+        DRAW_BUFFER3 = 0x8828,
+        DRAW_BUFFER4 = 0x8829,
+        DRAW_BUFFER5 = 0x882A,
+        DRAW_BUFFER6 = 0x882B,
+        DRAW_BUFFER7 = 0x882C,
+        DRAW_BUFFER8 = 0x882D,
+        DRAW_BUFFER9 = 0x882E,
+        DRAW_BUFFER10 = 0x882F,
+        DRAW_BUFFER11 = 0x8830,
+        DRAW_BUFFER12 = 0x8831,
+        DRAW_BUFFER13 = 0x8832,
+        DRAW_BUFFER14 = 0x8833,
+        DRAW_BUFFER15 = 0x8834,
+        MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49,
+        MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A,
+        SAMPLER_3D = 0x8B5F,
+        SAMPLER_2D_SHADOW = 0x8B62,
+        FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B,
+        PIXEL_PACK_BUFFER = 0x88EB,
+        PIXEL_UNPACK_BUFFER = 0x88EC,
+        PIXEL_PACK_BUFFER_BINDING = 0x88ED,
+        PIXEL_UNPACK_BUFFER_BINDING = 0x88EF,
+        FLOAT_MAT2x3 = 0x8B65,
+        FLOAT_MAT2x4 = 0x8B66,
+        FLOAT_MAT3x2 = 0x8B67,
+        FLOAT_MAT3x4 = 0x8B68,
+        FLOAT_MAT4x2 = 0x8B69,
+        FLOAT_MAT4x3 = 0x8B6A,
+        SRGB = 0x8C40,
+        SRGB8 = 0x8C41,
+        SRGB_ALPHA = 0x8C42,
+        SRGB8_ALPHA8 = 0x8C43,
+        COMPARE_REF_TO_TEXTURE = 0x884E,
+        RGBA32F = 0x8814,
+        RGB32F = 0x8815,
+        RGBA16F = 0x881A,
+        RGB16F = 0x881B,
+        VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD,
+        MAX_ARRAY_TEXTURE_LAYERS = 0x88FF,
+        MIN_PROGRAM_TEXEL_OFFSET = 0x8904,
+        MAX_PROGRAM_TEXEL_OFFSET = 0x8905,
+        MAX_VARYING_COMPONENTS = 0x8B4B,
+        TEXTURE_2D_ARRAY = 0x8C1A,
+        TEXTURE_BINDING_2D_ARRAY = 0x8C1D,
+        R11F_G11F_B10F = 0x8C3A,
+        UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B,
+        RGB9_E5 = 0x8C3D,
+        UNSIGNED_INT_5_9_9_9_REV = 0x8C3E,
+        TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F,
+        MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80,
+        TRANSFORM_FEEDBACK_VARYINGS = 0x8C83,
+        TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84,
+        TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85,
+        TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88,
+        RASTERIZER_DISCARD = 0x8C89,
+        MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A,
+        MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B,
+        INTERLEAVED_ATTRIBS = 0x8C8C,
+        SEPARATE_ATTRIBS = 0x8C8D,
+        TRANSFORM_FEEDBACK_BUFFER = 0x8C8E,
+        TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F,
+        RGBA32UI = 0x8D70,
+        RGB32UI = 0x8D71,
+        RGBA16UI = 0x8D76,
+        RGB16UI = 0x8D77,
+        RGBA8UI = 0x8D7C,
+        RGB8UI = 0x8D7D,
+        RGBA32I = 0x8D82,
+        RGB32I = 0x8D83,
+        RGBA16I = 0x8D88,
+        RGB16I = 0x8D89,
+        RGBA8I = 0x8D8E,
+        RGB8I = 0x8D8F,
+        RED_INTEGER = 0x8D94,
+        RGB_INTEGER = 0x8D98,
+        RGBA_INTEGER = 0x8D99,
+        SAMPLER_2D_ARRAY = 0x8DC1,
+        SAMPLER_2D_ARRAY_SHADOW = 0x8DC4,
+        SAMPLER_CUBE_SHADOW = 0x8DC5,
+        UNSIGNED_INT_VEC2 = 0x8DC6,
+        UNSIGNED_INT_VEC3 = 0x8DC7,
+        UNSIGNED_INT_VEC4 = 0x8DC8,
+        INT_SAMPLER_2D = 0x8DCA,
+        INT_SAMPLER_3D = 0x8DCB,
+        INT_SAMPLER_CUBE = 0x8DCC,
+        INT_SAMPLER_2D_ARRAY = 0x8DCF,
+        UNSIGNED_INT_SAMPLER_2D = 0x8DD2,
+        UNSIGNED_INT_SAMPLER_3D = 0x8DD3,
+        UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4,
+        UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7,
+        DEPTH_COMPONENT32F = 0x8CAC,
+        DEPTH32F_STENCIL8 = 0x8CAD,
+        FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD,
+        FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210,
+        FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211,
+        FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212,
+        FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213,
+        FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214,
+        FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215,
+        FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216,
+        FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217,
+        FRAMEBUFFER_DEFAULT = 0x8218,
+        DEPTH_STENCIL_ATTACHMENT = 0x821A,
+        DEPTH_STENCIL = 0x84F9,
+        UNSIGNED_INT_24_8 = 0x84FA,
+        DEPTH24_STENCIL8 = 0x88F0,
+        UNSIGNED_NORMALIZED = 0x8C17,
+        DRAW_FRAMEBUFFER_BINDING = 0x8CA6, /* Same as FRAMEBUFFER_BINDING */
+        READ_FRAMEBUFFER = 0x8CA8,
+        DRAW_FRAMEBUFFER = 0x8CA9,
+        READ_FRAMEBUFFER_BINDING = 0x8CAA,
+        RENDERBUFFER_SAMPLES = 0x8CAB,
+        FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4,
+        MAX_COLOR_ATTACHMENTS = 0x8CDF,
+        COLOR_ATTACHMENT1 = 0x8CE1,
+        COLOR_ATTACHMENT2 = 0x8CE2,
+        COLOR_ATTACHMENT3 = 0x8CE3,
+        COLOR_ATTACHMENT4 = 0x8CE4,
+        COLOR_ATTACHMENT5 = 0x8CE5,
+        COLOR_ATTACHMENT6 = 0x8CE6,
+        COLOR_ATTACHMENT7 = 0x8CE7,
+        COLOR_ATTACHMENT8 = 0x8CE8,
+        COLOR_ATTACHMENT9 = 0x8CE9,
+        COLOR_ATTACHMENT10 = 0x8CEA,
+        COLOR_ATTACHMENT11 = 0x8CEB,
+        COLOR_ATTACHMENT12 = 0x8CEC,
+        COLOR_ATTACHMENT13 = 0x8CED,
+        COLOR_ATTACHMENT14 = 0x8CEE,
+        COLOR_ATTACHMENT15 = 0x8CEF,
+        FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
+        MAX_SAMPLES = 0x8D57,
+        HALF_FLOAT = 0x140B,
+        RG = 0x8227,
+        RG_INTEGER = 0x8228,
+        R8 = 0x8229,
+        RG8 = 0x822B,
+        R16F = 0x822D,
+        R32F = 0x822E,
+        RG16F = 0x822F,
+        RG32F = 0x8230,
+        R8I = 0x8231,
+        R8UI = 0x8232,
+        R16I = 0x8233,
+        R16UI = 0x8234,
+        R32I = 0x8235,
+        R32UI = 0x8236,
+        RG8I = 0x8237,
+        RG8UI = 0x8238,
+        RG16I = 0x8239,
+        RG16UI = 0x823A,
+        RG32I = 0x823B,
+        RG32UI = 0x823C,
+        VERTEX_ARRAY_BINDING = 0x85B5,
+        R8_SNORM = 0x8F94,
+        RG8_SNORM = 0x8F95,
+        RGB8_SNORM = 0x8F96,
+        RGBA8_SNORM = 0x8F97,
+        SIGNED_NORMALIZED = 0x8F9C,
+        COPY_READ_BUFFER = 0x8F36,
+        COPY_WRITE_BUFFER = 0x8F37,
+        COPY_READ_BUFFER_BINDING = 0x8F36, /* Same as COPY_READ_BUFFER */
+        COPY_WRITE_BUFFER_BINDING = 0x8F37, /* Same as COPY_WRITE_BUFFER */
+        UNIFORM_BUFFER = 0x8A11,
+        UNIFORM_BUFFER_BINDING = 0x8A28,
+        UNIFORM_BUFFER_START = 0x8A29,
+        UNIFORM_BUFFER_SIZE = 0x8A2A,
+        MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B,
+        MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D,
+        MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E,
+        MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F,
+        MAX_UNIFORM_BLOCK_SIZE = 0x8A30,
+        MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31,
+        MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33,
+        UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34,
+        ACTIVE_UNIFORM_BLOCKS = 0x8A36,
+        UNIFORM_TYPE = 0x8A37,
+        UNIFORM_SIZE = 0x8A38,
+        UNIFORM_BLOCK_INDEX = 0x8A3A,
+        UNIFORM_OFFSET = 0x8A3B,
+        UNIFORM_ARRAY_STRIDE = 0x8A3C,
+        UNIFORM_MATRIX_STRIDE = 0x8A3D,
+        UNIFORM_IS_ROW_MAJOR = 0x8A3E,
+        UNIFORM_BLOCK_BINDING = 0x8A3F,
+        UNIFORM_BLOCK_DATA_SIZE = 0x8A40,
+        UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42,
+        UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43,
+        UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44,
+        UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46,
+        INVALID_INDEX = 0xFFFFFFFF,
+        MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122,
+        MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125,
+        MAX_SERVER_WAIT_TIMEOUT = 0x9111,
+        OBJECT_TYPE = 0x9112,
+        SYNC_CONDITION = 0x9113,
+        SYNC_STATUS = 0x9114,
+        SYNC_FLAGS = 0x9115,
+        SYNC_FENCE = 0x9116,
+        SYNC_GPU_COMMANDS_COMPLETE = 0x9117,
+        UNSIGNALED = 0x9118,
+        SIGNALED = 0x9119,
+        ALREADY_SIGNALED = 0x911A,
+        TIMEOUT_EXPIRED = 0x911B,
+        CONDITION_SATISFIED = 0x911C,
+#if PLATFORM(WIN)
+        WAIT_FAILED_WIN = 0x911D,
+#else
+        WAIT_FAILED = 0x911D,
+#endif
+        SYNC_FLUSH_COMMANDS_BIT = 0x00000001,
+        VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE,
+        ANY_SAMPLES_PASSED = 0x8C2F,
+        ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A,
+        SAMPLER_BINDING = 0x8919,
+        RGB10_A2UI = 0x906F,
+        TEXTURE_SWIZZLE_R = 0x8E42,
+        TEXTURE_SWIZZLE_G = 0x8E43,
+        TEXTURE_SWIZZLE_B = 0x8E44,
+        TEXTURE_SWIZZLE_A = 0x8E45,
+        GREEN = 0x1904,
+        BLUE = 0x1905,
+        INT_2_10_10_10_REV = 0x8D9F,
+        TRANSFORM_FEEDBACK = 0x8E22,
+        TRANSFORM_FEEDBACK_PAUSED = 0x8E23,
+        TRANSFORM_FEEDBACK_ACTIVE = 0x8E24,
+        TRANSFORM_FEEDBACK_BINDING = 0x8E25,
+        COMPRESSED_R11_EAC = 0x9270,
+        COMPRESSED_SIGNED_R11_EAC = 0x9271,
+        COMPRESSED_RG11_EAC = 0x9272,
+        COMPRESSED_SIGNED_RG11_EAC = 0x9273,
+        COMPRESSED_RGB8_ETC2 = 0x9274,
+        COMPRESSED_SRGB8_ETC2 = 0x9275,
+        COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
+        COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
+        COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
+        COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
+        TEXTURE_IMMUTABLE_FORMAT = 0x912F,
+        MAX_ELEMENT_INDEX = 0x8D6B,
+        NUM_SAMPLE_COUNTS = 0x9380,
+        TEXTURE_IMMUTABLE_LEVELS = 0x82DF,
+        PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69,
+        PRIMITIVE_RESTART = 0x8F9D,
+
+        // OpenGL ES 3 constants.
+        MAP_READ_BIT = 0x0001,
+
+        // Necessary desktop OpenGL constants.
+        TEXTURE_RECTANGLE_ARB = 0x84F5
+    };
+
+    enum class DataFormat : uint8_t {
+        RGBA8 = 0,
+        RGBA16Little,
+        RGBA16Big,
+        RGBA16F,
+        RGBA32F,
+        RGB8,
+        RGB16Little,
+        RGB16Big,
+        RGB16F,
+        RGB32F,
+        BGR8,
+        BGRA8,
+        BGRA16Little,
+        BGRA16Big,
+        ARGB8,
+        ARGB16Little,
+        ARGB16Big,
+        ABGR8,
+        RGBA5551,
+        RGBA4444,
+        RGB565,
+        R8,
+        R16Little,
+        R16Big,
+        R16F,
+        R32F,
+        RA8,
+        RA16Little,
+        RA16Big,
+        RA16F,
+        RA32F,
+        AR8,
+        AR16Little,
+        AR16Big,
+        A8,
+        A16Little,
+        A16Big,
+        A16F,
+        A32F,
+        NumFormats
+    };
+
+    enum class Destination : uint8_t {
+        Offscreen,
+        DirectlyToHostWindow,
+    };
+
+    enum class ChannelBits : uint8_t {
+        Red = 1,
+        Green = 2,
+        Blue = 4,
+        Alpha = 8,
+        Depth = 16,
+        Stencil = 32,
+        RGB = Red | Green | Blue,
+        RGBA = RGB | Alpha,
+        DepthStencil = Depth | Stencil,
+    };
+
+    // Possible alpha operations that may need to occur during
+    // pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must
+    // be removed.
+    enum AlphaOp : uint8_t {
+        DoNothing,
+        DoPremultiply,
+        DoUnmultiply,
+    };
+
+    enum class DOMSource : uint8_t {
+        Image,
+        Canvas,
+        Video,
+        None,
+    };
+
+    virtual PlatformGraphicsContext3D platformGraphicsContext3D() const = 0;
+    virtual Platform3DObject platformTexture() const = 0;
+    virtual PlatformLayer* platformLayer() const = 0;
+
+    ALWAYS_INLINE static bool hasAlpha(DataFormat format)
+    {
+        switch (format) {
+        case DataFormat::A8:
+        case DataFormat::A16F:
+        case DataFormat::A32F:
+        case DataFormat::RA8:
+        case DataFormat::AR8:
+        case DataFormat::RA16F:
+        case DataFormat::RA32F:
+        case DataFormat::RGBA8:
+        case DataFormat::BGRA8:
+        case DataFormat::ARGB8:
+        case DataFormat::ABGR8:
+        case DataFormat::RGBA16F:
+        case DataFormat::RGBA32F:
+        case DataFormat::RGBA4444:
+        case DataFormat::RGBA5551:
+            return true;
+        default:
+            return false;
+        }
+    }
+
+    ALWAYS_INLINE static bool hasColor(DataFormat format)
+    {
+        switch (format) {
+        case DataFormat::RGBA8:
+        case DataFormat::RGBA16F:
+        case DataFormat::RGBA32F:
+        case DataFormat::RGB8:
+        case DataFormat::RGB16F:
+        case DataFormat::RGB32F:
+        case DataFormat::BGR8:
+        case DataFormat::BGRA8:
+        case DataFormat::ARGB8:
+        case DataFormat::ABGR8:
+        case DataFormat::RGBA5551:
+        case DataFormat::RGBA4444:
+        case DataFormat::RGB565:
+        case DataFormat::R8:
+        case DataFormat::R16F:
+        case DataFormat::R32F:
+        case DataFormat::RA8:
+        case DataFormat::RA16F:
+        case DataFormat::RA32F:
+        case DataFormat::AR8:
+            return true;
+        default:
+            return false;
+        }
+    }
+
+    // Check if the format is one of the formats from the ImageData or DOM elements.
+    // The formats from ImageData is always RGBA8.
+    // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
+    static ALWAYS_INLINE bool srcFormatComesFromDOMElementOrImageData(DataFormat SrcFormat)
+    {
+#if USE(CG)
+#if CPU(BIG_ENDIAN)
+    return SrcFormat == DataFormat::RGBA8 || SrcFormat == DataFormat::ARGB8 || SrcFormat == DataFormat::RGB8
+        || SrcFormat == DataFormat::RA8 || SrcFormat == DataFormat::AR8 || SrcFormat == DataFormat::R8 || SrcFormat == DataFormat::A8;
+#else
+    // That LITTLE_ENDIAN case has more possible formats than BIG_ENDIAN case is because some decoded image data is actually big endian
+    // even on little endian architectures.
+    return SrcFormat == DataFormat::BGRA8 || SrcFormat == DataFormat::ABGR8 || SrcFormat == DataFormat::BGR8
+        || SrcFormat == DataFormat::RGBA8 || SrcFormat == DataFormat::ARGB8 || SrcFormat == DataFormat::RGB8
+        || SrcFormat == DataFormat::R8 || SrcFormat == DataFormat::A8
+        || SrcFormat == DataFormat::RA8 || SrcFormat == DataFormat::AR8;
+#endif
+#else
+    return SrcFormat == DataFormat::BGRA8 || SrcFormat == DataFormat::RGBA8;
+#endif
+    }
+
+    struct ActiveInfo {
+        String name;
+        GC3Denum type;
+        GC3Dint size;
+    };
+
+    GraphicsContext3DBase(GraphicsContext3DAttributes, Destination = Destination::Offscreen, GraphicsContext3DBase* sharedContext = nullptr);
+    virtual ~GraphicsContext3DBase() = default;
+
+    // ========== WebGL 1 entry points.
+
+    virtual void activeTexture(GC3Denum texture) = 0;
+    virtual void attachShader(Platform3DObject program, Platform3DObject shader) = 0;
+    virtual void bindAttribLocation(Platform3DObject, GC3Duint index, const String& name) = 0;
+    virtual void bindBuffer(GC3Denum target, Platform3DObject) = 0;
+    virtual void bindFramebuffer(GC3Denum target, Platform3DObject) = 0;
+    virtual void bindRenderbuffer(GC3Denum target, Platform3DObject) = 0;
+    virtual void bindTexture(GC3Denum target, Platform3DObject) = 0;
+    virtual void blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) = 0;
+    virtual void blendEquation(GC3Denum mode) = 0;
+    virtual void blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) = 0;
+    virtual void blendFunc(GC3Denum sfactor, GC3Denum dfactor) = 0;
+    virtual void blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) = 0;
+
+    virtual GC3Denum checkFramebufferStatus(GC3Denum target) = 0;
+    virtual void clear(GC3Dbitfield mask) = 0;
+    virtual void clearColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) = 0;
+    virtual void clearDepth(GC3Dclampf depth) = 0;
+    virtual void clearStencil(GC3Dint s) = 0;
+    virtual void colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) = 0;
+    virtual void compileShader(Platform3DObject) = 0;
+
+    virtual void copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border) = 0;
+    virtual void copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
+
+    virtual Platform3DObject createBuffer() = 0;
+    virtual Platform3DObject createFramebuffer() = 0;
+    virtual Platform3DObject createProgram() = 0;
+    virtual Platform3DObject createRenderbuffer() = 0;
+    virtual Platform3DObject createShader(GC3Denum) = 0;
+    virtual Platform3DObject createTexture() = 0;
+
+    virtual void cullFace(GC3Denum mode) = 0;
+
+    virtual void deleteBuffer(Platform3DObject) = 0;
+    virtual void deleteFramebuffer(Platform3DObject) = 0;
+    virtual void deleteProgram(Platform3DObject) = 0;
+    virtual void deleteRenderbuffer(Platform3DObject) = 0;
+    virtual void deleteShader(Platform3DObject) = 0;
+    virtual void deleteTexture(Platform3DObject) = 0;
+
+    virtual void depthFunc(GC3Denum func) = 0;
+    virtual void depthMask(GC3Dboolean flag) = 0;
+    virtual void depthRange(GC3Dclampf zNear, GC3Dclampf zFar) = 0;
+    virtual void detachShader(Platform3DObject, Platform3DObject) = 0;
+    virtual void disable(GC3Denum cap) = 0;
+    virtual void disableVertexAttribArray(GC3Duint index) = 0;
+    virtual void drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) = 0;
+    virtual void drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) = 0;
+
+    virtual void enable(GC3Denum cap) = 0;
+    virtual void enableVertexAttribArray(GC3Duint index) = 0;
+    virtual void finish() = 0;
+    virtual void flush() = 0;
+    virtual void framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject) = 0;
+    virtual void framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject, GC3Dint level) = 0;
+    virtual void frontFace(GC3Denum mode) = 0;
+
+    virtual void generateMipmap(GC3Denum target) = 0;
+
+    virtual bool getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo&) = 0;
+    virtual bool getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo&) = 0;
+    virtual void getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) = 0;
+
+    virtual GC3Dint getAttribLocation(Platform3DObject, const String& name) = 0;
+
+    virtual void getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
+
+    // getParameter
+    virtual String getString(GC3Denum name) = 0;
+    virtual void getFloatv(GC3Denum pname, GC3Dfloat* value) = 0;
+    virtual void getIntegerv(GC3Denum pname, GC3Dint* value) = 0;
+    virtual void getInteger64v(GC3Denum pname, GC3Dint64* value) = 0;
+    virtual void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) = 0;
+    virtual void getBooleanv(GC3Denum pname, GC3Dboolean* value) = 0;
+
+    virtual GC3Denum getError() = 0;
+
+    // getFramebufferAttachmentParameter
+    virtual void getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) = 0;
+
+    // getProgramParameter
+    virtual String getProgramInfoLog(Platform3DObject) = 0;
+
+    // getRenderbufferParameter
+    virtual void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
+
+    // getShaderParameter
+    virtual void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value) = 0;
+
+    virtual String getShaderInfoLog(Platform3DObject) = 0;
+    virtual void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision) = 0;
+
+    virtual String getShaderSource(Platform3DObject) = 0;
+
+    // getTexParameter
+    virtual void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) = 0;
+    virtual void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) = 0;
+
+    // getUniform
+    virtual void getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) = 0;
+    virtual void getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) = 0;
+
+    virtual GC3Dint getUniformLocation(Platform3DObject, const String& name) = 0;
+
+    // getVertexAttrib
+    virtual void getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) = 0;
+    virtual void getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) = 0;
+
+    virtual GC3Dsizeiptr getVertexAttribOffset(GC3Duint index, GC3Denum pname) = 0;
+
+    virtual void hint(GC3Denum target, GC3Denum mode) = 0;
+    virtual GC3Dboolean isBuffer(Platform3DObject) = 0;
+    virtual GC3Dboolean isEnabled(GC3Denum cap) = 0;
+    virtual GC3Dboolean isFramebuffer(Platform3DObject) = 0;
+    virtual GC3Dboolean isProgram(Platform3DObject) = 0;
+    virtual GC3Dboolean isRenderbuffer(Platform3DObject) = 0;
+    virtual GC3Dboolean isShader(Platform3DObject) = 0;
+    virtual GC3Dboolean isTexture(Platform3DObject) = 0;
+    virtual void lineWidth(GC3Dfloat) = 0;
+    virtual void linkProgram(Platform3DObject) = 0;
+    virtual void pixelStorei(GC3Denum pname, GC3Dint param) = 0;
+    virtual void polygonOffset(GC3Dfloat factor, GC3Dfloat units) = 0;
+
+    virtual void renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
+    virtual void sampleCoverage(GC3Dclampf value, GC3Dboolean invert) = 0;
+    virtual void scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
+
+    virtual void shaderSource(Platform3DObject, const String& string) = 0;
+
+    virtual void stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) = 0;
+    virtual void stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) = 0;
+    virtual void stencilMask(GC3Duint mask) = 0;
+    virtual void stencilMaskSeparate(GC3Denum face, GC3Duint mask) = 0;
+    virtual void stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) = 0;
+    virtual void stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) = 0;
+
+    virtual void texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat param) = 0;
+    virtual void texParameteri(GC3Denum target, GC3Denum pname, GC3Dint param) = 0;
+
+    virtual void uniform1f(GC3Dint location, GC3Dfloat x) = 0;
+    virtual void uniform1fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
+    virtual void uniform1i(GC3Dint location, GC3Dint x) = 0;
+    virtual void uniform1iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
+    virtual void uniform2f(GC3Dint location, GC3Dfloat x, GC3Dfloat y) = 0;
+    virtual void uniform2fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
+    virtual void uniform2i(GC3Dint location, GC3Dint x, GC3Dint y) = 0;
+    virtual void uniform2iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
+    virtual void uniform3f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) = 0;
+    virtual void uniform3fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
+    virtual void uniform3i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z) = 0;
+    virtual void uniform3iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
+    virtual void uniform4f(GC3Dint location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) = 0;
+    virtual void uniform4fv(GC3Dint location, GC3Dsizei, const GC3Dfloat* v) = 0;
+    virtual void uniform4i(GC3Dint location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w) = 0;
+    virtual void uniform4iv(GC3Dint location, GC3Dsizei, const GC3Dint* v) = 0;
+    virtual void uniformMatrix2fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
+    virtual void uniformMatrix3fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
+    virtual void uniformMatrix4fv(GC3Dint location, GC3Dsizei, GC3Dboolean transpose, const GC3Dfloat* value) = 0;
+
+    virtual void useProgram(Platform3DObject) = 0;
+    virtual void validateProgram(Platform3DObject) = 0;
+
+    virtual void vertexAttrib1f(GC3Duint index, GC3Dfloat x) = 0;
+    virtual void vertexAttrib1fv(GC3Duint index, const GC3Dfloat* values) = 0;
+    virtual void vertexAttrib2f(GC3Duint index, GC3Dfloat x, GC3Dfloat y) = 0;
+    virtual void vertexAttrib2fv(GC3Duint index, const GC3Dfloat* values) = 0;
+    virtual void vertexAttrib3f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z) = 0;
+    virtual void vertexAttrib3fv(GC3Duint index, const GC3Dfloat* values) = 0;
+    virtual void vertexAttrib4f(GC3Duint index, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w) = 0;
+    virtual void vertexAttrib4fv(GC3Duint index, const GC3Dfloat* values) = 0;
+
+    virtual void vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) = 0;
+
+    virtual void viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) = 0;
+
+    virtual void bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) = 0;
+    virtual void bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) = 0;
+    virtual void bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) = 0;
+
+    virtual void compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) = 0;
+    virtual void compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) = 0;
+
+    virtual void readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) = 0;
+
+    virtual bool texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) = 0;
+    virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) = 0;
+
+    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0;
+    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) = 0;
+    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0;
+
+    GraphicsContext3DAttributes contextAttributes() const { return m_attrs; }
+    void setContextAttributes(const GraphicsContext3DAttributes& attrs) { m_attrs = attrs; }
+
+    // VertexArrayOject calls
+    virtual Platform3DObject createVertexArray() = 0;
+    virtual void deleteVertexArray(Platform3DObject) = 0;
+    virtual GC3Dboolean isVertexArray(Platform3DObject) = 0;
+    virtual void bindVertexArray(Platform3DObject) = 0;
+
+#if USE(OPENGL) && ENABLE(WEBGL2)
+    virtual void primitiveRestartIndex(GC3Duint) = 0;
+#endif
+
+    // Support for extensions. Returns a non-null object, though not
+    // all methods it contains may necessarily be supported on the
+    // current hardware. Must call Extensions3D::supports() to
+    // determine this.
+    virtual Extensions3D& getExtensions() = 0;
+
+    // ========== WebGL 2 entry points.
+
+    virtual void* mapBufferRange(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr length, GC3Dbitfield access) = 0;
+    virtual GC3Dboolean unmapBuffer(GC3Denum target) = 0;
+    virtual void copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dintptr readOffset, GC3Dintptr writeOffset, GC3Dsizeiptr) = 0;
+
+    // getInternalFormatParameter
+    virtual void getInternalformativ(GC3Denum target, GC3Denum internalformat, GC3Denum pname, GC3Dsizei bufSize, GC3Dint* params) = 0;
+
+    virtual void renderbufferStorageMultisample(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
+
+    virtual void texStorage2D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) = 0;
+    virtual void texStorage3D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dsizei depth) = 0;
+
+    virtual void getActiveUniforms(Platform3DObject program, const Vector<GC3Duint>& uniformIndices, GC3Denum pname, Vector<GC3Dint>& params) = 0;
+
+    // ========== Non-WebGL based entry points.
+
+    static unsigned getClearBitsByAttachmentType(GC3Denum);
+    static unsigned getClearBitsByFormat(GC3Denum);
+
+    static uint8_t getChannelBitsByFormat(GC3Denum);
+
+    Destination destination() const { return m_destination; }
+
+private:
+    GraphicsContext3DAttributes m_attrs;
+    Destination m_destination;
+};
+
+} // namespace WebCore
+
+#endif
index 9130044..a3e6d25 100644 (file)
 
 namespace WebCore {
 
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle renderStyle)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::Destination destination)
 {
-    switch (renderStyle) {
-    case GraphicsContext3D::RenderOffscreen:
+    switch (destination) {
+    case GraphicsContext3D::Destination::Offscreen:
         m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
         break;
-    case GraphicsContext3D::RenderDirectlyToHostWindow:
+    case GraphicsContext3D::Destination::DirectlyToHostWindow:
         ASSERT_NOT_REACHED();
         break;
     }
index e33f8fb..f3254a8 100644 (file)
@@ -30,7 +30,7 @@ class BitmapTextureGL;
 class GraphicsContext3DPrivate {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
+    GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::Destination);
     ~GraphicsContext3DPrivate();
     bool makeContextCurrent();
     PlatformGraphicsContext3D platformContext();
index 1ab1a4f..5ec2714 100644 (file)
@@ -51,4 +51,8 @@ typedef unsigned long long GC3Duint64;
 
 typedef GC3Duint Platform3DObject;
 
+#if !PLATFORM(COCOA)
+typedef unsigned GLuint;
+#endif
+
 #endif
index 782fa3e..5afe8b0 100644 (file)
@@ -122,7 +122,7 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int
 #endif
 
 #if PLATFORM(MAC)
-    if (!m_attrs.alpha)
+    if (!contextAttributes().alpha)
         wipeAlphaChannelFromPixels(width, height, pixels);
 #endif
 }
@@ -134,17 +134,18 @@ void GraphicsContext3D::validateAttributes()
 
 bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 {
+    auto attrs = contextAttributes();
     const int width = size.width();
     const int height = size.height();
     GLuint colorFormat, internalDepthStencilFormat = 0;
-    if (m_attrs.alpha) {
+    if (attrs.alpha) {
         m_internalColorFormat = GL_RGBA8;
         colorFormat = GL_RGBA;
     } else {
         m_internalColorFormat = GL_RGB8;
         colorFormat = GL_RGB;
     }
-    if (m_attrs.stencil || m_attrs.depth) {
+    if (attrs.stencil || attrs.depth) {
         // We don't allow the logic where stencil is required and depth is not.
         // See GraphicsContext3D::validateAttributes.
 
@@ -157,7 +158,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     }
 
     // Resize multisample FBO.
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         GLint maxSampleCount;
         gl::GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount);
         // Using more than 4 samples is slow on some hardware and is unlikely to
@@ -167,7 +168,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
         gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer);
         getExtensions().renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, m_internalColorFormat, width, height);
         gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth) {
+        if (attrs.stencil || attrs.depth) {
             gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleDepthStencilBuffer);
             getExtensions().renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, internalDepthStencilFormat, width, height);
             // WebGL 1.0's rules state that combined depth/stencil renderbuffers
@@ -175,9 +176,9 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
             if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES)
                 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer);
             else {
-                if (m_attrs.stencil)
+                if (attrs.stencil)
                     gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer);
-                if (m_attrs.depth)
+                if (attrs.depth)
                     gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer);
             }
         }
@@ -215,7 +216,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
 
     bool mustRestoreFBO = true;
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
         if (m_state.boundFBO == m_multisampleFBO)
             mustRestoreFBO = false;
@@ -229,7 +230,9 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 
 void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height)
 {
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
+    auto attrs = contextAttributes();
+
+    if (!attrs.antialias && (attrs.stencil || attrs.depth)) {
         gl::BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
         gl::RenderbufferStorage(GL_RENDERBUFFER, internalDepthStencilFormat, width, height);
         // WebGL 1.0's rules state that combined depth/stencil renderbuffers
@@ -237,9 +240,9 @@ void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepth
         if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES)
             gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
         else {
-            if (m_attrs.stencil)
+            if (attrs.stencil)
                 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
-            if (m_attrs.depth)
+            if (attrs.depth)
                 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
         }
         gl::BindRenderbuffer(GL_RENDERBUFFER, 0);
@@ -378,17 +381,18 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
     // all previous rendering calls should be done before reading pixels.
     makeContextCurrent();
     gl::Flush();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    auto attrs = contextAttributes();
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
         gl::Flush();
     }
     gl::ReadPixels(x, y, width, height, format, type, data);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 
 #if PLATFORM(MAC)
-    if (!m_attrs.alpha && (format == GraphicsContext3D::RGBA || format == GraphicsContext3D::BGRA) && (m_state.boundFBO == m_fbo || (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)))
+    if (!attrs.alpha && (format == GraphicsContext3D::RGBA || format == GraphicsContext3D::BGRA) && (m_state.boundFBO == m_fbo || (attrs.antialias && m_state.boundFBO == m_multisampleFBO)))
         wipeAlphaChannelFromPixels(width, height, static_cast<unsigned char*>(data));
 #endif
 }
@@ -399,20 +403,23 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension)
 {
     Extensions3D& extensions = getExtensions();
-    if (m_attrs.stencil) {
+    auto attrs = contextAttributes();
+
+    if (attrs.stencil) {
         if (extensions.supports(packedDepthStencilExtension)) {
             extensions.ensureEnabled(packedDepthStencilExtension);
             // Force depth if stencil is true.
-            m_attrs.depth = true;
+            attrs.depth = true;
         } else
-            m_attrs.stencil = false;
-
+            attrs.stencil = false;
+        setContextAttributes(attrs);
     }
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         // FIXME: must adjust this when upgrading to WebGL 2.0 / OpenGL ES 3.0 support.
-        if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || !extensions.supports("GL_ANGLE_framebuffer_blit") || !extensions.supports("GL_OES_rgb8_rgba8"))
-            m_attrs.antialias = false;
-        else {
+        if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || !extensions.supports("GL_ANGLE_framebuffer_blit") || !extensions.supports("GL_OES_rgb8_rgba8")) {
+            attrs.antialias = false;
+            setContextAttributes(attrs);
+        } else {
             extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
             extensions.ensureEnabled("GL_ANGLE_framebuffer_blit");
             extensions.ensureEnabled("GL_OES_rgb8_rgba8");
@@ -437,7 +444,7 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer)
 
     readRenderingResults(pixels.get(), totalBytes);
 
-    if (!m_attrs.premultipliedAlpha) {
+    if (!contextAttributes().premultipliedAlpha) {
         for (int i = 0; i < totalBytes; i += 4) {
             // Premultiply alpha.
             pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255);
@@ -464,7 +471,7 @@ RefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData()
 {
     // Reading premultiplied alpha would involve unpremultiplying, which is
     // lossy.
-    if (m_attrs.premultipliedAlpha)
+    if (contextAttributes().premultipliedAlpha)
         return nullptr;
 
     auto imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight));
@@ -490,7 +497,7 @@ void GraphicsContext3D::prepareTexture()
 
     makeContextCurrent();
 
-    if (m_attrs.antialias)
+    if (contextAttributes().antialias)
         resolveMultisamplingIfNecessary();
 
 #if USE(COORDINATED_GRAPHICS)
@@ -517,7 +524,7 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi
     makeContextCurrent();
 
     bool mustRestoreFBO = false;
-    if (m_attrs.antialias) {
+    if (contextAttributes().antialias) {
         resolveMultisamplingIfNecessary();
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
         mustRestoreFBO = true;
@@ -569,6 +576,7 @@ void GraphicsContext3D::reshape(int width, int height)
     TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE);
 
     bool mustRestoreFBO = reshapeFBOs(IntSize(width, height));
+    auto attrs = contextAttributes();
 
     // Initialize renderbuffers to 0.
     GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
@@ -580,14 +588,14 @@ void GraphicsContext3D::reshape(int width, int height)
     gl::ClearColor(0, 0, 0, 0);
     gl::GetBooleanv(GL_COLOR_WRITEMASK, colorMask);
     gl::ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    if (m_attrs.depth) {
+    if (attrs.depth) {
         gl::GetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
         GraphicsContext3D::clearDepth(1);
         gl::GetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
         gl::DepthMask(GL_TRUE);
         clearMask |= GL_DEPTH_BUFFER_BIT;
     }
-    if (m_attrs.stencil) {
+    if (attrs.stencil) {
         gl::GetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
         gl::ClearStencil(0);
         gl::GetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
@@ -601,11 +609,11 @@ void GraphicsContext3D::reshape(int width, int height)
 
     gl::ClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
     gl::ColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
-    if (m_attrs.depth) {
+    if (attrs.depth) {
         GraphicsContext3D::clearDepth(clearDepth);
         gl::DepthMask(depthMask);
     }
-    if (m_attrs.stencil) {
+    if (attrs.stencil) {
         gl::ClearStencil(clearStencil);
         gl::StencilMaskSeparate(GL_FRONT, stencilMask);
         gl::StencilMaskSeparate(GL_BACK, stencilMaskBack);
@@ -657,7 +665,7 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer
     if (buffer)
         fbo = buffer;
     else
-        fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
+        fbo = (contextAttributes().antialias ? m_multisampleFBO : m_fbo);
     if (fbo != m_state.boundFBO) {
         gl::BindFramebuffer(target, fbo);
         m_state.boundFBO = fbo;
@@ -832,24 +840,28 @@ void GraphicsContext3D::compileShaderDirect(Platform3DObject shader)
 void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
 {
     makeContextCurrent();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    auto attrs = contextAttributes();
+
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     }
     gl::CopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 }
 
 void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
 {
     makeContextCurrent();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    auto attrs = contextAttributes();
+
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     }
     gl::CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 }
 
@@ -1037,11 +1049,6 @@ int GraphicsContext3D::getAttribLocationDirect(Platform3DObject program, const S
     return getAttribLocation(program, name);
 }
 
-GraphicsContext3DAttributes GraphicsContext3D::getContextAttributes()
-{
-    return m_attrs;
-}
-
 bool GraphicsContext3D::moveErrorsToSyntheticErrorList()
 {
     makeContextCurrent();
@@ -1585,6 +1592,11 @@ String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
     return getUnmangledInfoLog(shaders, 1, String(info.data(), size));
 }
 
+String GraphicsContext3D::getShaderSource(Platform3DObject)
+{
+    return emptyString();
+}
+
 void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value)
 {
     makeContextCurrent();
index 360640f..488957e 100644 (file)
@@ -49,7 +49,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
     AlphaOption alphaOption = premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied;
     GammaAndColorProfileOption gammaAndColorProfileOption = ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied;
     auto source = ImageSource::create(nullptr, alphaOption, gammaAndColorProfileOption);
-    m_alphaOp = AlphaDoNothing;
+    m_alphaOp = AlphaOp::DoNothing;
 
     if (m_image->data()) {
         source->setData(m_image->data(), true);
@@ -62,8 +62,8 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
         // which is true at present and may be changed in the future and needs adjustment accordingly.
         // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port, 
         // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
-        if (!premultiplyAlpha && m_imageHtmlDomSource != HtmlDomVideo)
-            m_alphaOp = AlphaDoUnmultiply;
+        if (!premultiplyAlpha && m_imageHtmlDomSource != DOMSource::Video)
+            m_alphaOp = AlphaOp::DoUnmultiply;
 
         // if m_imageSurface is not an image, extract a copy of the surface
         if (m_imageSurface && cairo_surface_get_type(m_imageSurface.get()) != CAIRO_SURFACE_TYPE_IMAGE) {
@@ -99,7 +99,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
     }
 
     m_imagePixelData = cairo_image_surface_get_data(m_imageSurface.get());
-    m_imageSourceFormat = DataFormatBGRA8;
+    m_imageSourceFormat = DataFormat::BGRA8;
     m_imageSourceUnpackAlignment = srcUnpackAlignment;
     return true;
 }
index 418bf35..bc938b4 100644 (file)
@@ -77,21 +77,21 @@ static GraphicsContext3D::DataFormat getSourceDataFormat(unsigned componentsPerP
         { SourceFormatBaseRGB,        SourceFormatBaseNumFormats, SourceFormatBaseNumFormats }, // 3 componentsPerPixel
         { SourceFormatBaseNumFormats, SourceFormatBaseARGB,       SourceFormatBaseRGBA        } // 4 componentsPerPixel
     };
-    const static GraphicsContext3D::DataFormat formatTable[SourceFormatBaseNumFormats][4] = { // SourceDataFormatBase x bitsPerComponent x endian
+    const static GraphicsContext3D::DataFormat formatTable[SourceFormatBaseNumFormats][4] = { // SourceDataFormat::Base x bitsPerComponent x endian
         // 8bits, little endian                 8bits, big endian                     16bits, little endian                        16bits, big endian
-        { GraphicsContext3D::DataFormatR8,    GraphicsContext3D::DataFormatR8,    GraphicsContext3D::DataFormatR16Little,    GraphicsContext3D::DataFormatR16Big },
-        { GraphicsContext3D::DataFormatA8,    GraphicsContext3D::DataFormatA8,    GraphicsContext3D::DataFormatA16Little,    GraphicsContext3D::DataFormatA16Big },
-        { GraphicsContext3D::DataFormatAR8,   GraphicsContext3D::DataFormatRA8,   GraphicsContext3D::DataFormatRA16Little,   GraphicsContext3D::DataFormatRA16Big },
-        { GraphicsContext3D::DataFormatRA8,   GraphicsContext3D::DataFormatAR8,   GraphicsContext3D::DataFormatAR16Little,   GraphicsContext3D::DataFormatAR16Big },
-        { GraphicsContext3D::DataFormatBGR8,  GraphicsContext3D::DataFormatRGB8,  GraphicsContext3D::DataFormatRGB16Little,  GraphicsContext3D::DataFormatRGB16Big },
-        { GraphicsContext3D::DataFormatABGR8, GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::DataFormatRGBA16Little, GraphicsContext3D::DataFormatRGBA16Big },
-        { GraphicsContext3D::DataFormatBGRA8, GraphicsContext3D::DataFormatARGB8, GraphicsContext3D::DataFormatARGB16Little, GraphicsContext3D::DataFormatARGB16Big }
+        { GraphicsContext3D::DataFormat::R8,    GraphicsContext3D::DataFormat::R8,    GraphicsContext3D::DataFormat::R16Little,    GraphicsContext3D::DataFormat::R16Big },
+        { GraphicsContext3D::DataFormat::A8,    GraphicsContext3D::DataFormat::A8,    GraphicsContext3D::DataFormat::A16Little,    GraphicsContext3D::DataFormat::A16Big },
+        { GraphicsContext3D::DataFormat::AR8,   GraphicsContext3D::DataFormat::RA8,   GraphicsContext3D::DataFormat::RA16Little,   GraphicsContext3D::DataFormat::RA16Big },
+        { GraphicsContext3D::DataFormat::RA8,   GraphicsContext3D::DataFormat::AR8,   GraphicsContext3D::DataFormat::AR16Little,   GraphicsContext3D::DataFormat::AR16Big },
+        { GraphicsContext3D::DataFormat::BGR8,  GraphicsContext3D::DataFormat::RGB8,  GraphicsContext3D::DataFormat::RGB16Little,  GraphicsContext3D::DataFormat::RGB16Big },
+        { GraphicsContext3D::DataFormat::ABGR8, GraphicsContext3D::DataFormat::RGBA8, GraphicsContext3D::DataFormat::RGBA16Little, GraphicsContext3D::DataFormat::RGBA16Big },
+        { GraphicsContext3D::DataFormat::BGRA8, GraphicsContext3D::DataFormat::ARGB8, GraphicsContext3D::DataFormat::ARGB16Little, GraphicsContext3D::DataFormat::ARGB16Big }
     };
 
     ASSERT(componentsPerPixel <= 4 && componentsPerPixel > 0);
     SourceDataFormatBase formatBase = formatTableBase[componentsPerPixel - 1][alphaFormat];
     if (formatBase == SourceFormatBaseNumFormats)
-        return GraphicsContext3D::DataFormatNumFormats;
+        return GraphicsContext3D::DataFormat::NumFormats;
     return formatTable[formatBase][(is16BitFormat ? 2 : 0) + (bigEndian ? 1 : 0)];
 }
 
@@ -106,13 +106,13 @@ uint8_t convertColor16BigTo8(uint16_t value)
     return static_cast<uint8_t>(value & 0x00FF);
 }
 
-template<int format, typename SourceType, typename DstType>
+template<GraphicsContext3D::DataFormat format, typename SourceType, typename DstType>
 ALWAYS_INLINE void convert16BitFormatToRGBA8(const SourceType*, DstType*, unsigned)
 {
     ASSERT_NOT_REACHED();
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGBA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RGBA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfRGBA16LittleToRGBA8(source, destination, pixelsPerRow);
@@ -127,7 +127,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGBA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RGBA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[0]);
@@ -139,7 +139,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfRGB16LittleToRGBA8(source, destination, pixelsPerRow);
@@ -154,7 +154,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[0]);
@@ -166,7 +166,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatARGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::ARGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
 #if HAVE(ARM_NEON_INTRINSICS)
     SIMD::unpackOneRowOfARGB16LittleToRGBA8(source, destination, pixelsPerRow);
@@ -181,7 +181,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatARGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::ARGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[1]);
@@ -193,7 +193,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatR16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::R16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16LittleTo8(source[0]);
@@ -205,7 +205,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatR16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::R16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[0]);
@@ -217,7 +217,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16LittleTo8(source[0]);
@@ -229,7 +229,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::RA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[0]);
@@ -241,7 +241,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatAR16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::AR16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16LittleTo8(source[1]);
@@ -253,7 +253,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatAR16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::AR16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = convertColor16BigTo8(source[1]);
@@ -265,7 +265,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::A16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = 0x0;
@@ -277,7 +277,7 @@ template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataF
     }
 }
 
-template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormat::A16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
 {
     for (unsigned i = 0; i < pixelsPerRow; ++i) {
         destination[0] = 0x0;
@@ -296,20 +296,20 @@ void convert16BitFormatToRGBA8(GraphicsContext3D::DataFormat srcFormat, const ui
         return convert16BitFormatToRGBA8<SrcFormat>(source, destination, pixelsPerRow);
 
     switch (srcFormat) {
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatR16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatR16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatA16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatA16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRA16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRA16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatAR16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatAR16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGB16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGB16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGBA16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGBA16Big)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatARGB16Little)
-        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatARGB16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::R16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::R16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::A16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::A16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RA16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RA16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::AR16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::AR16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RGB16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RGB16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RGBA16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::RGBA16Big)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::ARGB16Little)
+        CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormat::ARGB16Big)
     default:
         ASSERT_NOT_REACHED();
     }
@@ -417,18 +417,18 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
         }
     }
 
-    m_alphaOp = AlphaDoNothing;
+    m_alphaOp = AlphaOp::DoNothing;
     AlphaFormat alphaFormat = AlphaFormatNone;
     switch (CGImageGetAlphaInfo(m_cgImage.get())) {
     case kCGImageAlphaPremultipliedFirst:
         if (!premultiplyAlpha)
-            m_alphaOp = AlphaDoUnmultiply;
+            m_alphaOp = AlphaOp::DoUnmultiply;
         alphaFormat = AlphaFormatFirst;
         break;
     case kCGImageAlphaFirst:
         // This path is only accessible for MacOS earlier than 10.6.4.
         if (premultiplyAlpha)
-            m_alphaOp = AlphaDoPremultiply;
+            m_alphaOp = AlphaOp::DoPremultiply;
         alphaFormat = AlphaFormatFirst;
         break;
     case kCGImageAlphaNoneSkipFirst:
@@ -437,12 +437,12 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
         break;
     case kCGImageAlphaPremultipliedLast:
         if (!premultiplyAlpha)
-            m_alphaOp = AlphaDoUnmultiply;
+            m_alphaOp = AlphaOp::DoUnmultiply;
         alphaFormat = AlphaFormatLast;
         break;
     case kCGImageAlphaLast:
         if (premultiplyAlpha)
-            m_alphaOp = AlphaDoPremultiply;
+            m_alphaOp = AlphaOp::DoPremultiply;
         alphaFormat = AlphaFormatLast;
         break;
     case kCGImageAlphaNoneSkipLast:
@@ -456,7 +456,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
     }
 
     m_imageSourceFormat = getSourceDataFormat(componentsPerPixel, alphaFormat, bitsPerComponent == 16, bigEndianSource);
-    if (m_imageSourceFormat == DataFormatNumFormats)
+    if (m_imageSourceFormat == DataFormat::NumFormats)
         return false;
 
     m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(m_cgImage.get())));
@@ -490,7 +490,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
             destination += dstStrideInElements;
         }
         m_imagePixelData = reinterpret_cast<const void*>(m_formalizedRGBA8Data.get());
-        m_imageSourceFormat = DataFormatRGBA8;
+        m_imageSourceFormat = DataFormat::RGBA8;
         m_imageSourceUnpackAlignment = 1;
     }
     return true;
index 4aa52cb..2f912c2 100644 (file)
@@ -102,10 +102,10 @@ public:
     ~GraphicsContext3DPrivate() { }
 };
 
-RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::Destination destination)
 {
     // This implementation doesn't currently support rendering directly to the HostWindow.
-    if (renderStyle == RenderDirectlyToHostWindow)
+    if (destination == Destination::DirectlyToHostWindow)
         return nullptr;
 
     // Make space for the incoming context if we're full.
@@ -113,7 +113,7 @@ RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes
     if (GraphicsContext3DManager::sharedManager().hasTooManyContexts())
         return nullptr;
 
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, destination));
 
     if (!context->m_contextObj)
         return nullptr;
@@ -126,7 +126,7 @@ RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes
 Ref<GraphicsContext3D> GraphicsContext3D::createShared(GraphicsContext3D& sharedContext)
 {
     auto hostWindow = GraphicsContext3DManager::sharedManager().hostWindowForContext(&sharedContext);
-    auto context = adoptRef(*new GraphicsContext3D(sharedContext.getContextAttributes(), hostWindow, sharedContext.m_renderStyle, &sharedContext));
+    auto context = adoptRef(*new GraphicsContext3D(sharedContext.contextAttributes(), hostWindow, sharedContext.destination(), &sharedContext));
 
     GraphicsContext3DManager::sharedManager().addContext(context.ptr(), hostWindow);
 
@@ -183,10 +183,15 @@ static void setGPUByRegistryID(CGLContextObj contextObj, CGLPixelFormatObj pixel
 
 #endif // PLATFORM(MAC) && (USE(OPENGL) || USE(ANGLE))
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext)
-    : m_attrs(attrs)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::Destination destination, GraphicsContext3D* sharedContext)
+    : GraphicsContext3DBase(attrs, destination, sharedContext)
     , m_private(makeUnique<GraphicsContext3DPrivate>(this))
 {
+    ASSERT(ANGLEWebKitBridge::angleAvailable());
+    if (!ANGLEWebKitBridge::angleAvailable())
+        return;
+
+    m_isForWebGL2 = attrs.isWebGL2;
 
 #if HAVE(APPLE_GRAPHICS_CONTROL)
     m_powerPreferenceUsedForCreation = (hasLowAndHighPowerGPUs() && attrs.powerPreference == GraphicsContext3DPowerPreference::HighPerformance) ? GraphicsContext3DPowerPreference::HighPerformance : GraphicsContext3DPowerPreference::Default;
@@ -195,35 +200,35 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 #endif
 
 #if !USE(ANGLE)
-    ASSERT(ANGLEWebKitBridge::angleAvailable());
-    if (!ANGLEWebKitBridge::angleAvailable())
-        return;
-
 #if USE(OPENGL_ES)
-    if (m_attrs.isWebGL2)
+    if (m_isForWebGL2)
         m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC);
     else
         m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT);
 #else
-    if (m_attrs.isWebGL2)
+    if (m_isForWebGL2)
         m_compiler = ANGLEWebKitBridge(SH_GLSL_410_CORE_OUTPUT, SH_WEBGL2_SPEC);
 #endif // USE(OPENGL_ES)
 #endif // !USE(ANGLE)
 
 #if USE(OPENGL_ES)
     UNUSED_PARAM(hostWindow);
-    EAGLRenderingAPI api = m_attrs.isWebGL2 ? kEAGLRenderingAPIOpenGLES3 : kEAGLRenderingAPIOpenGLES2;
+    EAGLRenderingAPI api = m_isForWebGL2 ? kEAGLRenderingAPIOpenGLES3 : kEAGLRenderingAPIOpenGLES2;
+    EAGLContext *contextObj;
     if (!sharedContext)
-        m_contextObj = [[EAGLContext alloc] initWithAPI:api];
+        contextObj = [[EAGLContext alloc] initWithAPI:api];
     else
-        m_contextObj = [[EAGLContext alloc] initWithAPI:api sharegroup:sharedContext->m_contextObj.sharegroup];
+        contextObj = [[EAGLContext alloc] initWithAPI:api sharegroup:static_cast<EAGLContext *>(sharedContext->m_contextObj).sharegroup];
+
+    m_contextObj = static_cast<void *>(contextObj);
+
     makeContextCurrent();
 
-    if (m_attrs.isWebGL2)
+    if (m_isForWebGL2)
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX);
 #elif USE(OPENGL)
 
-    bool useMultisampling = m_attrs.antialias;
+    bool useMultisampling = attrs.antialias;
 
     Vector<CGLPixelFormatAttribute> attribs;
     CGLPixelFormatObj pixelFormatObj = 0;
@@ -250,7 +255,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         attribs.append(static_cast<CGLPixelFormatAttribute>(4));
     }
 
-    if (m_attrs.isWebGL2) {
+    if (m_isForWebGL2) {
         // FIXME: Instead of backing a WebGL2 GraphicsContext3D with a OpenGL 4 context, we should instead back it with ANGLE.
         // Use an OpenGL 4 context for now until the ANGLE backend is ready.
         attribs.append(kCGLPFAOpenGLProfile);
@@ -264,30 +269,35 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     if (!numPixelFormats)
         return;
 
-    CGLError err = CGLCreateContext(pixelFormatObj, sharedContext ? sharedContext->m_contextObj : nullptr, &m_contextObj);
+    CGLContextObj cglContext = nullptr;
+    CGLContextObj sharedCGLContext = sharedContext ? static_cast<CGLContextObj>(sharedContext->m_contextObj) : nullptr;
+
+    CGLError err = CGLCreateContext(pixelFormatObj, sharedCGLContext, &cglContext);
     GLint abortOnBlacklist = 0;
-    CGLSetParameter(m_contextObj, kCGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
-    
+    CGLSetParameter(cglContext, kCGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
+
 #if PLATFORM(MAC) // FIXME: This probably should be USE(OPENGL) - see <rdar://53062794>.
 
     auto gpuID = (hostWindow && hostWindow->displayID()) ? gpuIDForDisplay(hostWindow->displayID()) : primaryGPUID();
-    setGPUByRegistryID(m_contextObj, pixelFormatObj, gpuID);
+    setGPUByRegistryID(cglContext, pixelFormatObj, gpuID);
 
 #else
     UNUSED_PARAM(hostWindow);
 #endif
 
     CGLDestroyPixelFormat(pixelFormatObj);
-    
+
+    m_contextObj = cglContext;
+
     if (err != kCGLNoError || !m_contextObj) {
         // We were unable to create the context.
         m_contextObj = 0;
         return;
     }
 
-    m_isForWebGL2 = m_attrs.isWebGL2;
+    m_contextObj = cglContext;
 
-    CGLSetCurrentContext(m_contextObj);
+    CGLSetCurrentContext(cglContext);
 
     // WebGL 2 expects ES 3-only PRIMITIVE_RESTART_FIXED_INDEX to be enabled; we must emulate this on non-ES 3 systems.
     if (m_isForWebGL2)
@@ -295,10 +305,6 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 
 #elif USE(ANGLE)
 
-    ASSERT(ANGLEWebKitBridge::angleAvailable());
-    if (!ANGLEWebKitBridge::angleAvailable())
-        return;
-
     m_displayObj = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
     if (m_displayObj == EGL_NO_DISPLAY)
         return;
@@ -333,29 +339,29 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         return;
     }
 
-    std::vector<EGLint> contextAttributes;
-    if (m_attrs.isWebGL2) {
-        contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
-        contextAttributes.push_back(3);
+    Vector<EGLint> eglContextAttributes;
+    if (m_isForWebGL2) {
+        eglContextAttributes.append(EGL_CONTEXT_CLIENT_VERSION);
+        eglContextAttributes.append(3);
     } else {
-        contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
-        contextAttributes.push_back(2);
+        eglContextAttributes.append(EGL_CONTEXT_CLIENT_VERSION);
+        eglContextAttributes.append(2);
         // ANGLE will upgrade the context to ES3 automatically unless this is specified.
-        contextAttributes.push_back(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE);
-        contextAttributes.push_back(EGL_FALSE);
+        eglContextAttributes.append(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE);
+        eglContextAttributes.append(EGL_FALSE);
     }
-    contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
-    contextAttributes.push_back(EGL_TRUE);
+    eglContextAttributes.append(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
+    eglContextAttributes.append(EGL_TRUE);
 
     if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
-        contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
+        eglContextAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
         // EGL_LOW_POWER_ANGLE is the default. Change to
         // EGL_HIGH_POWER_ANGLE if desired.
-        contextAttributes.push_back(EGL_LOW_POWER_ANGLE);
+        eglContextAttributes.append(EGL_LOW_POWER_ANGLE);
     }
-    contextAttributes.push_back(EGL_NONE);
+    eglContextAttributes.append(EGL_NONE);
 
-    m_contextObj = EGL_CreateContext(m_displayObj, m_configObj, sharedContext ? static_cast<EGLContext>(sharedContext->m_contextObj) : EGL_NO_CONTEXT, contextAttributes.data());
+    m_contextObj = EGL_CreateContext(m_displayObj, m_configObj, sharedContext ? static_cast<EGLContext>(sharedContext->m_contextObj) : EGL_NO_CONTEXT, eglContextAttributes.data());
     if (m_contextObj == EGL_NO_CONTEXT) {
         LOG(WebGL, "EGLContext Initialization failed.");
         return;
@@ -364,7 +370,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 
     EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
 
-    if (m_attrs.isWebGL2)
+    if (m_isForWebGL2)
         gl::Enable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX);
 
 #if PLATFORM(MAC)
@@ -399,6 +405,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 #endif // #elif USE(ANGLE)
 
     validateAttributes();
+    attrs = contextAttributes(); // They may have changed during validation.
 
     // Create the WebGLLayer
     BEGIN_BLOCK_OBJC_EXCEPTIONS
@@ -455,16 +462,16 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
 
     m_state.boundFBO = m_fbo;
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+    if (!attrs.antialias && (attrs.stencil || attrs.depth))
         ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
 
     // If necessary, create another framebuffer for the multisample results.
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         ::glGenFramebuffersEXT(1, &m_multisampleFBO);
         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
         m_state.boundFBO = m_multisampleFBO;
         ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth)
+        if (attrs.stencil || attrs.depth)
             ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     }
 #elif USE(ANGLE)
@@ -472,16 +479,16 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
     m_state.boundFBO = m_fbo;
 
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+    if (!attrs.antialias && (attrs.stencil || attrs.depth))
         gl::GenRenderbuffers(1, &m_depthStencilBuffer);
 
     // If necessary, create another framebuffer for the multisample results.
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         gl::GenFramebuffers(1, &m_multisampleFBO);
         gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
         m_state.boundFBO = m_multisampleFBO;
         gl::GenRenderbuffers(1, &m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth)
+        if (attrs.stencil || attrs.depth)
             gl::GenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
     }
 
@@ -531,12 +538,15 @@ GraphicsContext3D::~GraphicsContext3D()
     GraphicsContext3DManager::sharedManager().removeContext(this);
 
     if (m_contextObj) {
+        GraphicsContext3DAttributes attrs = contextAttributes();
+
 #if USE(OPENGL_ES)
         makeContextCurrent();
-        [m_contextObj renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil];
+        [static_cast<EAGLContext *>(m_contextObj) renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil];
         ::glDeleteRenderbuffers(1, &m_texture);
 #elif USE(OPENGL)
-        CGLSetCurrentContext(m_contextObj);
+        CGLContextObj cglContext = static_cast<CGLContextObj>(m_contextObj);
+        CGLSetCurrentContext(cglContext);
         ::glDeleteTextures(1, &m_texture);
 #elif USE(ANGLE)
         EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
@@ -544,24 +554,24 @@ GraphicsContext3D::~GraphicsContext3D()
 #endif
 
 #if USE(OPENGL) || USE(OPENGL_ES)
-        if (m_attrs.antialias) {
+        if (attrs.antialias) {
             ::glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer);
-            if (m_attrs.stencil || m_attrs.depth)
+            if (attrs.stencil || attrs.depth)
                 ::glDeleteRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
             ::glDeleteFramebuffersEXT(1, &m_multisampleFBO);
         } else {
-            if (m_attrs.stencil || m_attrs.depth)
+            if (attrs.stencil || attrs.depth)
                 ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer);
         }
         ::glDeleteFramebuffersEXT(1, &m_fbo);
 #elif USE(ANGLE)
-        if (m_attrs.antialias) {
+        if (attrs.antialias) {
             gl::DeleteRenderbuffers(1, &m_multisampleColorBuffer);
-            if (m_attrs.stencil || m_attrs.depth)
+            if (attrs.stencil || attrs.depth)
                 gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
             gl::DeleteFramebuffers(1, &m_multisampleFBO);
         } else {
-            if (m_attrs.stencil || m_attrs.depth)
+            if (attrs.stencil || attrs.depth)
                 gl::DeleteRenderbuffers(1, &m_depthStencilBuffer);
         }
         gl::DeleteFramebuffers(1, &m_fbo);
@@ -569,10 +579,10 @@ GraphicsContext3D::~GraphicsContext3D()
 
 #if USE(OPENGL_ES)
         [EAGLContext setCurrentContext:0];
-        [static_cast<EAGLContext*>(m_contextObj) release];
+        [static_cast<EAGLContext *>(m_contextObj) release];
 #elif USE(OPENGL)
         CGLSetCurrentContext(0);
-        CGLDestroyContext(m_contextObj);
+        CGLDestroyContext(cglContext);
 #elif USE(ANGLE)
         EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
         EGL_DestroyContext(m_displayObj, m_contextObj);
@@ -591,9 +601,9 @@ void GraphicsContext3D::setRenderbufferStorageFromDrawable(GC3Dsizei width, GC3D
     CGRect previousBounds = [m_webGLLayer.get() bounds];
 
     [m_webGLLayer setBounds:CGRectMake(0, 0, width, height)];
-    [m_webGLLayer setOpaque:!m_attrs.alpha];
+    [m_webGLLayer setOpaque:!contextAttributes().alpha];
 
-    [m_contextObj renderbufferStorage:GL_RENDERBUFFER fromDrawable:static_cast<id<EAGLDrawable>>(m_webGLLayer.get())];
+    [static_cast<EAGLContext *>(m_contextObj) renderbufferStorage:GL_RENDERBUFFER fromDrawable:static_cast<id<EAGLDrawable>>(m_webGLLayer.get())];
 
     [m_webGLLayer setBounds:previousBounds];
 }
@@ -610,7 +620,7 @@ bool GraphicsContext3D::makeContextCurrent()
 #elif USE(OPENGL)
     CGLContextObj currentContext = CGLGetCurrentContext();
     if (currentContext != m_contextObj)
-        return CGLSetCurrentContext(m_contextObj) == kCGLNoError;
+        return CGLSetCurrentContext(static_cast<CGLContextObj>(m_contextObj)) == kCGLNoError;
 #elif USE(ANGLE)
     if (EGL_GetCurrentContext() != m_contextObj)
         return EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
@@ -642,7 +652,8 @@ void GraphicsContext3D::checkGPUStatus()
 
     GLint restartStatus = 0;
 #if USE(OPENGL)
-    CGLGetParameter(platformGraphicsContext3D(), kCGLCPGPURestartStatus, &restartStatus);
+    CGLContextObj cglContext = static_cast<CGLContextObj>(platformGraphicsContext3D());
+    CGLGetParameter(cglContext, kCGLCPGPURestartStatus, &restartStatus);
     if (restartStatus == kCGLCPGPURestartStatusBlacklisted) {
         LOG(WebGL, "The GPU has blacklisted us (%p). Terminating.", this);
         exit(EX_OSERR);
@@ -670,7 +681,7 @@ void GraphicsContext3D::checkGPUStatus()
 void GraphicsContext3D::presentRenderbuffer()
 {
     makeContextCurrent();
-    if (m_attrs.antialias)
+    if (contextAttributes().antialias)
         resolveMultisamplingIfNecessary();
 
     ::glFlush();
@@ -683,9 +694,10 @@ void GraphicsContext3D::presentRenderbuffer()
 bool GraphicsContext3D::texImageIOSurface2D(GC3Denum target, GC3Denum internalFormat, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, IOSurfaceRef surface, GC3Duint plane)
 {
 #if USE(OPENGL)
-    return kCGLNoError == CGLTexImageIOSurface2D(platformGraphicsContext3D(), target, internalFormat, width, height, format, type, surface, plane);
+    CGLContextObj cglContext = static_cast<CGLContextObj>(platformGraphicsContext3D());
+    return kCGLNoError == CGLTexImageIOSurface2D(cglContext, target, internalFormat, width, height, format, type, surface, plane);
 #elif USE(OPENGL_ES) && !PLATFORM(IOS_FAMILY_SIMULATOR)
-    return [platformGraphicsContext3D() texImageIOSurface:surface target:target internalFormat:internalFormat width:width height:height format:format type:type plane:plane];
+    return [static_cast<EAGLContext *>(platformGraphicsContext3D()) texImageIOSurface:surface target:target internalFormat:internalFormat width:width height:height format:format type:type plane:plane];
 #else
     UNUSED_PARAM(target);
     UNUSED_PARAM(internalFormat);
@@ -703,7 +715,7 @@ bool GraphicsContext3D::texImageIOSurface2D(GC3Denum target, GC3Denum internalFo
 void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size)
 {
     LOG(WebGL, "GraphicsContext3D::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this);
-    [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:m_attrs.alpha];
+    [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:contextAttributes().alpha];
 }
 
 void GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer()
@@ -720,7 +732,7 @@ void GraphicsContext3D::updateCGLContext()
     LOG(WebGL, "Detected a mux switch or display reconfiguration. Call CGLUpdateContext. (%p)", this);
 
     makeContextCurrent();
-    CGLUpdateContext(m_contextObj);
+    CGLUpdateContext(static_cast<CGLContextObj>(m_contextObj));
     m_hasSwitchedToHighPerformanceGPU = true;
 }
 
@@ -763,7 +775,7 @@ void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size)
 {
 #if HAVE(IOSURFACE)
     LOG(WebGL, "GraphicsContext3D::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this);
-    [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:m_attrs.alpha];
+    [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:contextAttributes().alpha];
 #else
     UNUSED_PARAM(size);
 #endif
@@ -783,14 +795,6 @@ bool GraphicsContext3D::isGLES2Compliant() const
     return m_isForWebGL2;
 }
 
-void GraphicsContext3D::setContextLostCallback(std::unique_ptr<ContextLostCallback>)
-{
-}
-
-void GraphicsContext3D::setErrorMessageCallback(std::unique_ptr<ErrorMessageCallback>)
-{
-}
-
 void GraphicsContext3D::simulateContextChanged()
 {
     GraphicsContext3DManager::sharedManager().updateAllContexts();
@@ -838,8 +842,10 @@ void GraphicsContext3D::screenDidChange(PlatformDisplayID displayID)
     }
 #else
 #if USE(OPENGL)
-    if (!m_hasSwitchedToHighPerformanceGPU)
-        setGPUByRegistryID(m_contextObj, CGLGetPixelFormat(m_contextObj), gpuIDForDisplay(displayID));
+    if (!m_hasSwitchedToHighPerformanceGPU) {
+        CGLContextObj cglContext = static_cast<CGLContextObj>(m_contextObj);
+        setGPUByRegistryID(cglContext, CGLGetPixelFormat(cglContext), gpuIDForDisplay(displayID));
+    }
 #endif
 #endif // USE(ANGLE)
 }
index d8e8500..55494ed 100644 (file)
@@ -70,13 +70,14 @@ const GLenum ioSurfaceTextureType = GL_TEXTURE_2D;
 {
     _context = context;
     self = [super init];
-    _devicePixelRatio = context->getContextAttributes().devicePixelRatio;
+    auto attributes = context->contextAttributes();
+    _devicePixelRatio = attributes.devicePixelRatio;
 #if USE(OPENGL) || USE(ANGLE)
-    self.contentsOpaque = !context->getContextAttributes().alpha;
+    self.contentsOpaque = !attributes.alpha;
     self.transform = CATransform3DIdentity;
     self.contentsScale = _devicePixelRatio;
 #else
-    self.opaque = !context->getContextAttributes().alpha;
+    self.opaque = !attributes.alpha;
 #endif
     return self;
 }
@@ -112,7 +113,8 @@ static void freeData(void *, const void *data, size_t /* size */)
         return nullptr;
 
 #if USE(OPENGL)
-    CGLSetCurrentContext(_context->platformGraphicsContext3D());
+    CGLContextObj cglContext = static_cast<CGLContextObj>(_context->platformGraphicsContext3D());
+    CGLSetCurrentContext(cglContext);
 
     RetainPtr<CGColorSpaceRef> imageColorSpace = colorSpace;
     if (!imageColorSpace)
@@ -251,7 +253,8 @@ static void freeData(void *, const void *data, size_t /* size */)
     GC3Denum internalFormat = _usingAlpha ? GL_RGBA : GL_RGB;
 
     // Link the IOSurface to the texture.
-    CGLError error = CGLTexImageIOSurface2D(_context->platformGraphicsContext3D(), GL_TEXTURE_RECTANGLE_ARB, internalFormat, _bufferSize.width(), _bufferSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, ioSurface, 0);
+    CGLContextObj cglContext = static_cast<CGLContextObj>(_context->platformGraphicsContext3D());
+    CGLError error = CGLTexImageIOSurface2D(cglContext, GL_TEXTURE_RECTANGLE_ARB, internalFormat, _bufferSize.width(), _bufferSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, ioSurface, 0);
     ASSERT_UNUSED(error, error == kCGLNoError);
 #elif USE(ANGLE)
     GC3Denum texture = _context->platformTexture();
index 019d239..f52fe3d 100644 (file)
@@ -38,9 +38,11 @@ std::unique_ptr<TextureCacheCV> TextureCacheCV::create(GraphicsContext3D& contex
 {
     TextureCacheType cache = nullptr;
 #if USE(OPENGL_ES)
-    CVReturn error = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), nullptr, &cache);
+    CVEAGLContext eaglContext = static_cast<CVEAGLContext>(context.platformGraphicsContext3D());
+    CVReturn error = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr, eaglContext, nullptr, &cache);
 #elif USE(OPENGL)
-    CVReturn error = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), CGLGetPixelFormat(context.platformGraphicsContext3D()), nullptr, &cache);
+    CGLContextObj cglContext = static_cast<CGLContextObj>(context.platformGraphicsContext3D());
+    CVReturn error = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nullptr, cglContext, CGLGetPixelFormat(cglContext), nullptr, &cache);
 #elif USE(ANGLE)
     // FIXME: figure out how to do this integrating via ANGLE.
     UNUSED_PARAM(context);
index 47cf5d1..aa3dea0 100644 (file)
@@ -174,19 +174,19 @@ bool GC3DANGLELayer::ANGLEContext::makeContextCurrent()
     return true;
 }
 
-PlatformGraphicsContext3D GC3DANGLELayer::ANGLEContext::platformContext()
+PlatformGraphicsContext3D GC3DANGLELayer::ANGLEContext::platformContext() const
 {
     return m_context;
 }
 
-GC3DANGLELayer::GC3DANGLELayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle)
+GC3DANGLELayer::GC3DANGLELayer(GraphicsContext3D& context, GraphicsContext3D::Destination destination)
     : GC3DLayer(context)
 {
-    switch (renderStyle) {
-    case GraphicsContext3D::RenderOffscreen:
+    switch (destination) {
+    case GraphicsContext3D::Destination::Offscreen:
         m_angleContext = ANGLEContext::createContext();
         break;
-    case GraphicsContext3D::RenderDirectlyToHostWindow:
+    case GraphicsContext3D::Destination::DirectlyToHostWindow:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -203,7 +203,7 @@ bool GC3DANGLELayer::makeContextCurrent()
 
 }
 
-PlatformGraphicsContext3D GC3DANGLELayer::platformContext()
+PlatformGraphicsContext3D GC3DANGLELayer::platformContext() const
 {
     ASSERT(m_angleContext);
     return m_angleContext->platformContext();
index bc2f6ef..ec47ead 100644 (file)
@@ -62,7 +62,7 @@ public:
 
         bool makeContextCurrent();
 #if ENABLE(GRAPHICS_CONTEXT_3D)
-        PlatformGraphicsContext3D platformContext();
+        PlatformGraphicsContext3D platformContext() const;
 #endif
 
     private:
@@ -73,11 +73,11 @@ public:
         EGLSurface m_surface { nullptr };
     };
 
-    GC3DANGLELayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle);
+    GC3DANGLELayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::Destination);
     virtual ~GC3DANGLELayer();
 
     bool makeContextCurrent() override;
-    PlatformGraphicsContext3D platformContext() override;
+    PlatformGraphicsContext3D platformContext() const override;
 
 private:
     std::unique_ptr<ANGLEContext> m_angleContext;
index bda6588..16a1453 100644 (file)
@@ -53,15 +53,15 @@ GC3DLayer::GC3DLayer(GraphicsContext3D& context)
 {
 }
 
-GC3DLayer::GC3DLayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle)
+GC3DLayer::GC3DLayer(GraphicsContext3D& context, GraphicsContext3D::Destination destination)
     : m_context(context)
     , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)))
 {
-    switch (renderStyle) {
-    case GraphicsContext3D::RenderOffscreen:
+    switch (destination) {
+    case GraphicsContext3D::Destination::Offscreen:
         m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing());
         break;
-    case GraphicsContext3D::RenderDirectlyToHostWindow:
+    case GraphicsContext3D::Destination::DirectlyToHostWindow:
         ASSERT_NOT_REACHED();
         break;
     }
@@ -78,7 +78,7 @@ bool GC3DLayer::makeContextCurrent()
     return m_glContext->makeContextCurrent();
 }
 
-PlatformGraphicsContext3D GC3DLayer::platformContext()
+PlatformGraphicsContext3D GC3DLayer::platformContext() const
 {
     ASSERT(m_glContext);
     return m_glContext->platformContext();
@@ -92,7 +92,7 @@ void GC3DLayer::swapBuffersIfNeeded()
 
     m_context.prepareTexture();
     IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight);
-    TextureMapperGL::Flags flags = m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0;
+    TextureMapperGL::Flags flags = m_context.contextAttributes().alpha ? TextureMapperGL::ShouldBlend : 0;
 #if USE(ANGLE)
     std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(textureSize, Unaccelerated);
     if (!imageBuffer)
index 326d6e5..e857217 100644 (file)
@@ -44,13 +44,13 @@ class GC3DLayer : public ContentLayerTextureMapperImpl::Client {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     explicit GC3DLayer(WebCore::GraphicsContext3D&);
-    GC3DLayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle);
+    GC3DLayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::Destination);
 
     virtual ~GC3DLayer();
 
     ContentLayer& contentLayer() const { return m_contentLayer; }
     virtual bool makeContextCurrent();
-    virtual PlatformGraphicsContext3D platformContext();
+    virtual PlatformGraphicsContext3D platformContext() const;
 
     void swapBuffersIfNeeded() override;
 
index b2b4b03..14941f6 100644 (file)
@@ -190,12 +190,8 @@ int Extensions3DOpenGLES::getGraphicsResetStatusARB()
     if (m_glGetGraphicsResetStatusEXT) {
         m_context->makeContextCurrent();
         int reasonForReset = m_glGetGraphicsResetStatusEXT();
-        if (reasonForReset != GL_NO_ERROR) {
-            ASSERT(m_contextLostCallback);
-            if (m_contextLostCallback)
-                m_contextLostCallback->onContextLost();
+        if (reasonForReset != GL_NO_ERROR)
             m_contextResetStatus = reasonForReset;
-        }
         return reasonForReset;
     }
 
index f56222f..4772fc6 100644 (file)
@@ -122,8 +122,6 @@ protected:
     PFNGLVERTEXATTRIBDIVISORANGLEPROC m_glVertexAttribDivisorANGLE;
     PFNGLDRAWARRAYSINSTANCEDANGLEPROC m_glDrawArraysInstancedANGLE;
     PFNGLDRAWELEMENTSINSTANCEDANGLEPROC m_glDrawElementsInstancedANGLE;
-
-    std::unique_ptr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
 };
 
 } // namespace WebCore
index b96363b..cd47e24 100644 (file)
@@ -82,8 +82,10 @@ static void wipeAlphaChannelFromPixels(int width, int height, unsigned char* pix
 
 void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
 {
+    auto attrs = contextAttributes();
+
     // NVIDIA drivers have a bug where calling readPixels in BGRA can return the wrong values for the alpha channel when the alpha is off for the context.
-    if (!m_attrs.alpha && getExtensions().isNVIDIA()) {
+    if (!attrs.alpha && getExtensions().isNVIDIA()) {
         ::glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 #if USE(ACCELERATE)
         vImage_Buffer src;
@@ -110,7 +112,7 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int
         ::glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
 
 #if PLATFORM(MAC)
-    if (!m_attrs.alpha)
+    if (!attrs.alpha)
         wipeAlphaChannelFromPixels(width, height, pixels);
 #endif
 }
@@ -122,17 +124,18 @@ void GraphicsContext3D::validateAttributes()
 
 bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 {
+    auto attrs = contextAttributes();
     const int width = size.width();
     const int height = size.height();
     GLuint colorFormat, internalDepthStencilFormat = 0;
-    if (m_attrs.alpha) {
+    if (attrs.alpha) {
         m_internalColorFormat = GL_RGBA8;
         colorFormat = GL_RGBA;
     } else {
         m_internalColorFormat = GL_RGB8;
         colorFormat = GL_RGB;
     }
-    if (m_attrs.stencil || m_attrs.depth) {
+    if (attrs.stencil || attrs.depth) {
         // We don't allow the logic where stencil is required and depth is not.
         // See GraphicsContext3D::validateAttributes.
 
@@ -149,7 +152,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     }
 
     // Resize multisample FBO.
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         GLint maxSampleCount;
         ::glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
         // Using more than 4 samples is slow on some hardware and is unlikely to
@@ -163,12 +166,12 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
         ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, m_internalColorFormat, width, height);
 #endif
         ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth) {
+        if (attrs.stencil || attrs.depth) {
             ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
             ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, width, height);
-            if (m_attrs.stencil)
+            if (attrs.stencil)
                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
-            if (m_attrs.depth)
+            if (attrs.depth)
                 ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_multisampleDepthStencilBuffer);
         }
         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
@@ -211,7 +214,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
 
     bool mustRestoreFBO = true;
-    if (m_attrs.antialias) {
+    if (attrs.antialias) {
         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
         if (m_state.boundFBO == m_multisampleFBO)
             mustRestoreFBO = false;
@@ -225,12 +228,14 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 
 void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height)
 {
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) {
+    auto attrs = contextAttributes();
+
+    if (!attrs.antialias && (attrs.stencil || attrs.depth)) {
         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
         ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, width, height);
-        if (m_attrs.stencil)
+        if (attrs.stencil)
             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
-        if (m_attrs.depth)
+        if (attrs.depth)
             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
     }
@@ -475,28 +480,34 @@ void GraphicsContext3D::clearDepth(GC3Dclampf depth)
 Extensions3D& GraphicsContext3D::getExtensions()
 {
     if (!m_extensions)
+#if PLATFORM(COCOA) && USE(OPENGL_ES)
+        m_extensions = makeUnique<Extensions3DOpenGL>(this, false);
+#else
         m_extensions = makeUnique<Extensions3DOpenGL>(this, isGLES2Compliant());
+#endif
     return *m_extensions;
 }
 #endif
 
 void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data)
 {
+    auto attrs = contextAttributes();
+
     // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e.,
     // all previous rendering calls should be done before reading pixels.
     makeContextCurrent();
     ::glFlush();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
         ::glFlush();
     }
     ::glReadPixels(x, y, width, height, format, type, data);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 
 #if PLATFORM(MAC)
-    if (!m_attrs.alpha && (format == GraphicsContext3D::RGBA || format == GraphicsContext3D::BGRA) && (m_state.boundFBO == m_fbo || (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)))
+    if (!attrs.alpha && (format == GraphicsContext3D::RGBA || format == GraphicsContext3D::BGRA) && (m_state.boundFBO == m_fbo || (attrs.antialias && m_state.boundFBO == m_multisampleFBO)))
         wipeAlphaChannelFromPixels(width, height, static_cast<unsigned char*>(data));
 #endif
 }
index 42bc8e1..b6dde01 100644 (file)
@@ -141,19 +141,23 @@ static uint64_t nameHashForShader(const char* name, size_t length)
 
 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension)
 {
+    auto attrs = contextAttributes();
+
     Extensions3D& extensions = getExtensions();
-    if (m_attrs.stencil) {
+    if (attrs.stencil) {
         if (extensions.supports(packedDepthStencilExtension)) {
             extensions.ensureEnabled(packedDepthStencilExtension);
             // Force depth if stencil is true.
-            m_attrs.depth = true;
+            attrs.depth = true;
         } else
-            m_attrs.stencil = false;
+            attrs.stencil = false;
+        setContextAttributes(attrs);
     }
-    if (m_attrs.antialias) {
-        if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant())
-            m_attrs.antialias = false;
-        else
+    if (attrs.antialias && !m_isForWebGL2) {
+        if (!extensions.supports("GL_ANGLE_framebuffer_multisample")) {
+            attrs.antialias = false;
+            setContextAttributes(attrs);
+        } else
             extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
     }
 }
@@ -175,7 +179,7 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer)
 
     readRenderingResults(pixels.get(), totalBytes);
 
-    if (!m_attrs.premultipliedAlpha) {
+    if (!contextAttributes().premultipliedAlpha) {
         for (int i = 0; i < totalBytes; i += 4) {
             // Premultiply alpha.
             pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255);
@@ -201,7 +205,7 @@ RefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData()
 {
     // Reading premultiplied alpha would involve unpremultiplying, which is
     // lossy.
-    if (m_attrs.premultipliedAlpha)
+    if (contextAttributes().premultipliedAlpha)
         return nullptr;
 
     auto imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight));
@@ -232,7 +236,7 @@ void GraphicsContext3D::prepareTexture()
     TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
 #endif
 
-    if (m_attrs.antialias)
+    if (contextAttributes().antialias)
         resolveMultisamplingIfNecessary();
 
 #if USE(COORDINATED_GRAPHICS)
@@ -265,7 +269,7 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi
     makeContextCurrent();
 
     bool mustRestoreFBO = false;
-    if (m_attrs.antialias) {
+    if (contextAttributes().antialias) {
         resolveMultisamplingIfNecessary();
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
         mustRestoreFBO = true;
@@ -328,14 +332,17 @@ void GraphicsContext3D::reshape(int width, int height)
     ::glClearColor(0, 0, 0, 0);
     ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
     ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    if (m_attrs.depth) {
+
+    auto attrs = contextAttributes();
+
+    if (attrs.depth) {
         ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
         GraphicsContext3D::clearDepth(1);
         ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
         ::glDepthMask(GL_TRUE);
         clearMask |= GL_DEPTH_BUFFER_BIT;
     }
-    if (m_attrs.stencil) {
+    if (attrs.stencil) {
         ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
         ::glClearStencil(0);
         ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
@@ -349,11 +356,11 @@ void GraphicsContext3D::reshape(int width, int height)
 
     ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
     ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
-    if (m_attrs.depth) {
+    if (attrs.depth) {
         GraphicsContext3D::clearDepth(clearDepth);
         ::glDepthMask(depthMask);
     }
-    if (m_attrs.stencil) {
+    if (attrs.stencil) {
         ::glClearStencil(clearStencil);
         ::glStencilMaskSeparate(GL_FRONT, stencilMask);
         ::glStencilMaskSeparate(GL_BACK, stencilMaskBack);
@@ -481,7 +488,7 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer
     if (buffer)
         fbo = buffer;
     else
-        fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
+        fbo = (contextAttributes().antialias ? m_multisampleFBO : m_fbo);
     if (fbo != m_state.boundFBO) {
         ::glBindFramebufferEXT(target, fbo);
         m_state.boundFBO = fbo;
@@ -744,24 +751,28 @@ void GraphicsContext3D::compileShaderDirect(Platform3DObject shader)
 void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
 {
     makeContextCurrent();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    auto attrs = contextAttributes();
+
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     }
     ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 }
 
 void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
 {
     makeContextCurrent();
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
+    auto attrs = contextAttributes();
+
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
         resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     }
     ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-    if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
+    if (attrs.antialias && m_state.boundFBO == m_multisampleFBO)
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 }
 
@@ -1128,11 +1139,6 @@ int GraphicsContext3D::getAttribLocationDirect(Platform3DObject program, const S
     return ::glGetAttribLocation(program, name.utf8().data());
 }
 
-GraphicsContext3DAttributes GraphicsContext3D::getContextAttributes()
-{
-    return m_attrs;
-}
-
 bool GraphicsContext3D::moveErrorsToSyntheticErrorList()
 {
     makeContextCurrent();
@@ -1807,7 +1813,6 @@ String GraphicsContext3D::getShaderSource(Platform3DObject shader)
     return result->value.source;
 }
 
-