[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)
commitfcaab631a89222128e7e162a5792f1fcaa8f3227
tree0307e0924ca6254ae274e9da8410788adf16ebb1
parent8a3929efa9ca34fc4824a2b1623a701c7111593d
[WebGL] Add a pure virtual base class for GraphicsContext3D
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