WebKit Bugzilla
Attachment 372309 Details for
Bug 197755
: Add preliminary ANGLE backend to WebCore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197755-20190617181028.patch (text/plain), 161.27 KB, created by
Kenneth Russell
on 2019-06-17 18:10:29 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kenneth Russell
Created:
2019-06-17 18:10:29 PDT
Size:
161.27 KB
patch
obsolete
>Subversion Revision: 246525 >diff --git a/Source/ThirdParty/ANGLE/ChangeLog b/Source/ThirdParty/ANGLE/ChangeLog >index d38a5f0e9647595e27ddfaf3ede45fd9a6831d65..fd7ef9a12fcb49bd170e9033a5ed463cc49482f1 100644 >--- a/Source/ThirdParty/ANGLE/ChangeLog >+++ b/Source/ThirdParty/ANGLE/ChangeLog >@@ -1,3 +1,18 @@ >+2019-06-17 Kenneth Russell <kbr@chromium.org> >+ >+ Add preliminary ANGLE backend to WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=197755 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a build step which processes ANGLE's copied public headers so they >+ can all be referred to under the <ANGLE/xyz.h> prefix. This avoids >+ touching ANGLE's headers and allows WebCore to include them with no >+ additional include path modifications. >+ >+ * ANGLE.xcodeproj/project.pbxproj: >+ * adjust-angle-include-paths.sh: Added. >+ > 2019-06-17 Ryan Haddad <ryanhaddad@apple.com> > > Unreviewed, rolling out r246501. >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 26049362030fffd6844826caf0a515196859132b..dacf8407d90c84e27f765a3a53d9f20087e12fed 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,16 @@ >+2019-06-17 Kenneth Russell <kbr@chromium.org> >+ >+ Add preliminary ANGLE backend to WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=197755 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a USE_ANGLE definition to wtf/Platform.h (currently disabled) >+ which, when enabled, uses ANGLE instead of the OpenGL or OpenGL ES >+ backend. >+ >+ * wtf/Platform.h: >+ > 2019-06-17 Jiewen Tan <jiewen_tan@apple.com> > > Move SOAuthorization from WebKitAdditions to WebKit >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4f25d9e5578dcc3aef179192e096a7f48c4d659e..5dd61af57b19dda275551b0c15ad520ea599623b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,279 @@ >+2019-06-17 Kenneth Russell <kbr@chromium.org> >+ >+ Add preliminary ANGLE backend to WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=197755 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add new files supplying an ANGLE version of GraphicsContext3D and >+ Extensions3D, conditionalized under USE_ANGLE. Update Xcode project to >+ build these files. This option compiles and links successfully. >+ >+ FIXMEs remain in several common files which will be addressed in >+ subsequent patches. >+ >+ This work will be tested with the preexisting WebGL conformance >+ suite. >+ >+ * SourcesCocoa.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/graphics/ANGLEWebKitBridge.h: >+ * platform/graphics/GraphicsContext3D.h: >+ * platform/graphics/GraphicsContext3DManager.cpp: >+ (WebCore::GraphicsContext3DManager::updateAllContexts): >+ (WebCore::GraphicsContext3DManager::updateHighPerformanceState): >+ (WebCore::GraphicsContext3DManager::disableHighPerformanceGPUTimerFired): >+ * platform/graphics/angle/Extensions3DANGLE.cpp: Copied from Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp. >+ (WebCore::Extensions3DANGLE::Extensions3DANGLE): >+ (WebCore::Extensions3DANGLE::supports): >+ (WebCore::Extensions3DANGLE::ensureEnabled): >+ (WebCore::Extensions3DANGLE::isEnabled): >+ (WebCore::Extensions3DANGLE::getGraphicsResetStatusARB): >+ (WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE): >+ (WebCore::Extensions3DANGLE::initializeAvailableExtensions): >+ (WebCore::Extensions3DANGLE::readnPixelsEXT): >+ (WebCore::Extensions3DANGLE::getnUniformfvEXT): >+ (WebCore::Extensions3DANGLE::getnUniformivEXT): >+ (WebCore::Extensions3DANGLE::blitFramebuffer): >+ (WebCore::Extensions3DANGLE::renderbufferStorageMultisample): >+ (WebCore::Extensions3DANGLE::createVertexArrayOES): >+ (WebCore::Extensions3DANGLE::deleteVertexArrayOES): >+ (WebCore::Extensions3DANGLE::isVertexArrayOES): >+ (WebCore::Extensions3DANGLE::bindVertexArrayOES): >+ (WebCore::Extensions3DANGLE::insertEventMarkerEXT): >+ (WebCore::Extensions3DANGLE::pushGroupMarkerEXT): >+ (WebCore::Extensions3DANGLE::popGroupMarkerEXT): >+ (WebCore::Extensions3DANGLE::supportsExtension): >+ (WebCore::Extensions3DANGLE::drawBuffersEXT): >+ (WebCore::Extensions3DANGLE::drawArraysInstanced): >+ (WebCore::Extensions3DANGLE::drawElementsInstanced): >+ (WebCore::Extensions3DANGLE::vertexAttribDivisor): >+ (WebCore::Extensions3DANGLE::getExtensions): >+ * platform/graphics/angle/Extensions3DANGLE.h: Added. >+ * platform/graphics/angle/GraphicsContext3DANGLE.cpp: Copied from Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp. >+ (WebCore::GraphicsContext3D::releaseShaderCompiler): >+ (WebCore::wipeAlphaChannelFromPixels): >+ (WebCore::GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary): >+ (WebCore::GraphicsContext3D::validateAttributes): >+ (WebCore::GraphicsContext3D::reshapeFBOs): >+ (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded): >+ (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): >+ (WebCore::GraphicsContext3D::renderbufferStorage): >+ (WebCore::GraphicsContext3D::getIntegerv): >+ (WebCore::GraphicsContext3D::getShaderPrecisionFormat): >+ (WebCore::GraphicsContext3D::texImage2D): >+ (WebCore::GraphicsContext3D::depthRange): >+ (WebCore::GraphicsContext3D::clearDepth): >+ (WebCore::GraphicsContext3D::getExtensions): >+ (WebCore::GraphicsContext3D::readPixels): >+ (WebCore::setCurrentNameHashMapForShader): >+ (WebCore::nameHashForShader): >+ (WebCore::GraphicsContext3D::validateDepthStencil): >+ (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas): >+ (WebCore::GraphicsContext3D::paintCompositedResultsToCanvas): >+ (WebCore::GraphicsContext3D::paintRenderingResultsToImageData): >+ (WebCore::GraphicsContext3D::prepareTexture): >+ (WebCore::GraphicsContext3D::readRenderingResults): >+ (WebCore::GraphicsContext3D::reshape): >+ (WebCore::GraphicsContext3D::checkVaryingsPacking const): >+ (WebCore::GraphicsContext3D::precisionsMatch const): >+ (WebCore::GraphicsContext3D::getInternalFramebufferSize const): >+ (WebCore::GraphicsContext3D::activeTexture): >+ (WebCore::GraphicsContext3D::attachShader): >+ (WebCore::GraphicsContext3D::bindAttribLocation): >+ (WebCore::GraphicsContext3D::bindBuffer): >+ (WebCore::GraphicsContext3D::bindFramebuffer): >+ (WebCore::GraphicsContext3D::bindRenderbuffer): >+ (WebCore::GraphicsContext3D::bindTexture): >+ (WebCore::GraphicsContext3D::blendColor): >+ (WebCore::GraphicsContext3D::blendEquation): >+ (WebCore::GraphicsContext3D::blendEquationSeparate): >+ (WebCore::GraphicsContext3D::blendFunc): >+ (WebCore::GraphicsContext3D::blendFuncSeparate): >+ (WebCore::GraphicsContext3D::bufferData): >+ (WebCore::GraphicsContext3D::bufferSubData): >+ (WebCore::GraphicsContext3D::mapBufferRange): >+ (WebCore::GraphicsContext3D::unmapBuffer): >+ (WebCore::GraphicsContext3D::copyBufferSubData): >+ (WebCore::GraphicsContext3D::getInternalformativ): >+ (WebCore::GraphicsContext3D::renderbufferStorageMultisample): >+ (WebCore::GraphicsContext3D::texStorage2D): >+ (WebCore::GraphicsContext3D::texStorage3D): >+ (WebCore::GraphicsContext3D::getActiveUniforms): >+ (WebCore::GraphicsContext3D::checkFramebufferStatus): >+ (WebCore::GraphicsContext3D::clearColor): >+ (WebCore::GraphicsContext3D::clear): >+ (WebCore::GraphicsContext3D::clearStencil): >+ (WebCore::GraphicsContext3D::colorMask): >+ (WebCore::GraphicsContext3D::compileShader): >+ (WebCore::GraphicsContext3D::compileShaderDirect): >+ (WebCore::GraphicsContext3D::copyTexImage2D): >+ (WebCore::GraphicsContext3D::copyTexSubImage2D): >+ (WebCore::GraphicsContext3D::cullFace): >+ (WebCore::GraphicsContext3D::depthFunc): >+ (WebCore::GraphicsContext3D::depthMask): >+ (WebCore::GraphicsContext3D::detachShader): >+ (WebCore::GraphicsContext3D::disable): >+ (WebCore::GraphicsContext3D::disableVertexAttribArray): >+ (WebCore::GraphicsContext3D::drawArrays): >+ (WebCore::GraphicsContext3D::drawElements): >+ (WebCore::GraphicsContext3D::enable): >+ (WebCore::GraphicsContext3D::enableVertexAttribArray): >+ (WebCore::GraphicsContext3D::finish): >+ (WebCore::GraphicsContext3D::flush): >+ (WebCore::GraphicsContext3D::framebufferRenderbuffer): >+ (WebCore::GraphicsContext3D::framebufferTexture2D): >+ (WebCore::GraphicsContext3D::frontFace): >+ (WebCore::GraphicsContext3D::generateMipmap): >+ (WebCore::GraphicsContext3D::getActiveAttribImpl): >+ (WebCore::GraphicsContext3D::getActiveAttrib): >+ (WebCore::GraphicsContext3D::getActiveUniformImpl): >+ (WebCore::GraphicsContext3D::getActiveUniform): >+ (WebCore::GraphicsContext3D::getAttachedShaders): >+ (WebCore::generateHashedName): >+ (WebCore::GraphicsContext3D::mappedSymbolInShaderSourceMap): >+ (WebCore::GraphicsContext3D::mappedSymbolName): >+ (WebCore::GraphicsContext3D::originalSymbolInShaderSourceMap): >+ (WebCore::GraphicsContext3D::originalSymbolName): >+ (WebCore::GraphicsContext3D::getAttribLocation): >+ (WebCore::GraphicsContext3D::getAttribLocationDirect): >+ (WebCore::GraphicsContext3D::getContextAttributes): >+ (WebCore::GraphicsContext3D::moveErrorsToSyntheticErrorList): >+ (WebCore::GraphicsContext3D::getError): >+ (WebCore::GraphicsContext3D::getString): >+ (WebCore::GraphicsContext3D::hint): >+ (WebCore::GraphicsContext3D::isBuffer): >+ (WebCore::GraphicsContext3D::isEnabled): >+ (WebCore::GraphicsContext3D::isFramebuffer): >+ (WebCore::GraphicsContext3D::isProgram): >+ (WebCore::GraphicsContext3D::isRenderbuffer): >+ (WebCore::GraphicsContext3D::isShader): >+ (WebCore::GraphicsContext3D::isTexture): >+ (WebCore::GraphicsContext3D::lineWidth): >+ (WebCore::GraphicsContext3D::linkProgram): >+ (WebCore::GraphicsContext3D::pixelStorei): >+ (WebCore::GraphicsContext3D::polygonOffset): >+ (WebCore::GraphicsContext3D::sampleCoverage): >+ (WebCore::GraphicsContext3D::scissor): >+ (WebCore::GraphicsContext3D::shaderSource): >+ (WebCore::GraphicsContext3D::stencilFunc): >+ (WebCore::GraphicsContext3D::stencilFuncSeparate): >+ (WebCore::GraphicsContext3D::stencilMask): >+ (WebCore::GraphicsContext3D::stencilMaskSeparate): >+ (WebCore::GraphicsContext3D::stencilOp): >+ (WebCore::GraphicsContext3D::stencilOpSeparate): >+ (WebCore::GraphicsContext3D::texParameterf): >+ (WebCore::GraphicsContext3D::texParameteri): >+ (WebCore::GraphicsContext3D::uniform1f): >+ (WebCore::GraphicsContext3D::uniform1fv): >+ (WebCore::GraphicsContext3D::uniform2f): >+ (WebCore::GraphicsContext3D::uniform2fv): >+ (WebCore::GraphicsContext3D::uniform3f): >+ (WebCore::GraphicsContext3D::uniform3fv): >+ (WebCore::GraphicsContext3D::uniform4f): >+ (WebCore::GraphicsContext3D::uniform4fv): >+ (WebCore::GraphicsContext3D::uniform1i): >+ (WebCore::GraphicsContext3D::uniform1iv): >+ (WebCore::GraphicsContext3D::uniform2i): >+ (WebCore::GraphicsContext3D::uniform2iv): >+ (WebCore::GraphicsContext3D::uniform3i): >+ (WebCore::GraphicsContext3D::uniform3iv): >+ (WebCore::GraphicsContext3D::uniform4i): >+ (WebCore::GraphicsContext3D::uniform4iv): >+ (WebCore::GraphicsContext3D::uniformMatrix2fv): >+ (WebCore::GraphicsContext3D::uniformMatrix3fv): >+ (WebCore::GraphicsContext3D::uniformMatrix4fv): >+ (WebCore::GraphicsContext3D::useProgram): >+ (WebCore::GraphicsContext3D::validateProgram): >+ (WebCore::GraphicsContext3D::vertexAttrib1f): >+ (WebCore::GraphicsContext3D::vertexAttrib1fv): >+ (WebCore::GraphicsContext3D::vertexAttrib2f): >+ (WebCore::GraphicsContext3D::vertexAttrib2fv): >+ (WebCore::GraphicsContext3D::vertexAttrib3f): >+ (WebCore::GraphicsContext3D::vertexAttrib3fv): >+ (WebCore::GraphicsContext3D::vertexAttrib4f): >+ (WebCore::GraphicsContext3D::vertexAttrib4fv): >+ (WebCore::GraphicsContext3D::vertexAttribPointer): >+ (WebCore::GraphicsContext3D::viewport): >+ (WebCore::GraphicsContext3D::createVertexArray): >+ (WebCore::GraphicsContext3D::deleteVertexArray): >+ (WebCore::GraphicsContext3D::isVertexArray): >+ (WebCore::GraphicsContext3D::bindVertexArray): >+ (WebCore::GraphicsContext3D::getBooleanv): >+ (WebCore::GraphicsContext3D::getBufferParameteriv): >+ (WebCore::GraphicsContext3D::getFloatv): >+ (WebCore::GraphicsContext3D::getInteger64v): >+ (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv): >+ (WebCore::GraphicsContext3D::getProgramiv): >+ (WebCore::GraphicsContext3D::getNonBuiltInActiveSymbolCount): >+ (WebCore::GraphicsContext3D::getUnmangledInfoLog): >+ (WebCore::GraphicsContext3D::getProgramInfoLog): >+ (WebCore::GraphicsContext3D::getRenderbufferParameteriv): >+ (WebCore::GraphicsContext3D::getShaderiv): >+ (WebCore::GraphicsContext3D::getShaderInfoLog): >+ (WebCore::GraphicsContext3D::getShaderSource): >+ (WebCore::GraphicsContext3D::getTexParameterfv): >+ (WebCore::GraphicsContext3D::getTexParameteriv): >+ (WebCore::GraphicsContext3D::getUniformfv): >+ (WebCore::GraphicsContext3D::getUniformiv): >+ (WebCore::GraphicsContext3D::getUniformLocation): >+ (WebCore::GraphicsContext3D::getVertexAttribfv): >+ (WebCore::GraphicsContext3D::getVertexAttribiv): >+ (WebCore::GraphicsContext3D::getVertexAttribOffset): >+ (WebCore::GraphicsContext3D::texSubImage2D): >+ (WebCore::GraphicsContext3D::compressedTexImage2D): >+ (WebCore::GraphicsContext3D::compressedTexSubImage2D): >+ (WebCore::GraphicsContext3D::createBuffer): >+ (WebCore::GraphicsContext3D::createFramebuffer): >+ (WebCore::GraphicsContext3D::createProgram): >+ (WebCore::GraphicsContext3D::createRenderbuffer): >+ (WebCore::GraphicsContext3D::createShader): >+ (WebCore::GraphicsContext3D::createTexture): >+ (WebCore::GraphicsContext3D::deleteBuffer): >+ (WebCore::GraphicsContext3D::deleteFramebuffer): >+ (WebCore::GraphicsContext3D::deleteProgram): >+ (WebCore::GraphicsContext3D::deleteRenderbuffer): >+ (WebCore::GraphicsContext3D::deleteShader): >+ (WebCore::GraphicsContext3D::deleteTexture): >+ (WebCore::GraphicsContext3D::synthesizeGLError): >+ (WebCore::GraphicsContext3D::markContextChanged): >+ (WebCore::GraphicsContext3D::markLayerComposited): >+ (WebCore::GraphicsContext3D::layerComposited const): >+ (WebCore::GraphicsContext3D::forceContextLost): >+ (WebCore::GraphicsContext3D::recycleContext): >+ (WebCore::GraphicsContext3D::dispatchContextChangedNotification): >+ (WebCore::GraphicsContext3D::texImage2DDirect): >+ (WebCore::GraphicsContext3D::drawArraysInstanced): >+ (WebCore::GraphicsContext3D::drawElementsInstanced): >+ (WebCore::GraphicsContext3D::vertexAttribDivisor): >+ * platform/graphics/angle/TemporaryANGLESetting.cpp: Added. >+ (WebCore::TemporaryANGLESetting::TemporaryANGLESetting): >+ (WebCore::TemporaryANGLESetting::~TemporaryANGLESetting): >+ * platform/graphics/angle/TemporaryANGLESetting.h: Added. >+ * platform/graphics/cocoa/GraphicsContext3DCocoa.mm: >+ (WebCore::GraphicsContext3D::GraphicsContext3D): >+ (WebCore::GraphicsContext3D::~GraphicsContext3D): >+ (WebCore::GraphicsContext3D::makeContextCurrent): >+ (WebCore::GraphicsContext3D::checkGPUStatus): >+ (WebCore::GraphicsContext3D::screenDidChange): >+ * platform/graphics/cocoa/WebGLLayer.h: >+ * platform/graphics/cocoa/WebGLLayer.mm: >+ (-[WebGLLayer display]): >+ * platform/graphics/cv/TextureCacheCV.mm: >+ (WebCore::TextureCacheCV::create): >+ (WebCore::TextureCacheCV::textureFromImage): >+ * platform/graphics/cv/VideoTextureCopierCV.cpp: >+ (WebCore::enumToStringMap): >+ (WebCore::VideoTextureCopierCV::initializeContextObjects): >+ (WebCore::VideoTextureCopierCV::initializeUVContextObjects): >+ (WebCore::VideoTextureCopierCV::copyImageToPlatformTexture): >+ (WebCore::VideoTextureCopierCV::copyVideoTextureToPlatformTexture): >+ * platform/graphics/opengl/Extensions3DOpenGL.cpp: >+ * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp: >+ * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: >+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: >+ * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: >+ > 2019-06-17 Alex Christensen <achristensen@webkit.org> > > Fix iOS crash when starting loads with no active DocumentLoader >diff --git a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj >index cf94badec0c60c8d759b5114c6a439b345a29879..7cefc59e5ae9fea60fa337db14dc16d36d73c62a 100644 >--- a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj >+++ b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj >@@ -2557,6 +2557,7 @@ > FB39D0CF1200F0E300088E69 /* Frameworks */, > 312BDB0B15FECAB00097EBC7 /* CopyFiles */, > 312BDB0D15FECACE0097EBC7 /* CopyFiles */, >+ 6E28B8742294DD8000717E69 /* ShellScript */, > ); > buildRules = ( > ); >@@ -2595,6 +2596,26 @@ > }; > /* End PBXProject section */ > >+/* Begin PBXShellScriptBuildPhase section */ >+ 6E28B8742294DD8000717E69 /* ShellScript */ = { >+ isa = PBXShellScriptBuildPhase; >+ buildActionMask = 2147483647; >+ files = ( >+ ); >+ inputFileListPaths = ( >+ ); >+ inputPaths = ( >+ ); >+ outputFileListPaths = ( >+ ); >+ outputPaths = ( >+ ); >+ runOnlyForDeploymentPostprocessing = 0; >+ shellPath = /bin/sh; >+ shellScript = "/bin/sh $SRCROOT/adjust-angle-include-paths.sh\n"; >+ }; >+/* End PBXShellScriptBuildPhase section */ >+ > /* Begin PBXSourcesBuildPhase section */ > FB39D0CE1200F0E300088E69 /* Sources */ = { > isa = PBXSourcesBuildPhase; >diff --git a/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh b/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh >new file mode 100755 >index 0000000000000000000000000000000000000000..26cb204f1103706871dff61ea9b2480f7a2c086c >--- /dev/null >+++ b/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh >@@ -0,0 +1,42 @@ >+#!/bin/sh >+ >+# WebKit builds ANGLE as a static library, and exports some of the >+# internal header files as "public headers" in the Xcode project for >+# consumption by other build targets - e.g. WebCore. >+# >+# The build phase which copies these headers also flattens the >+# directory structure (so that "ANGLE" is the top-level directory >+# containing all of them - e.g., "#include <ANGLE/gl2.h>"). >+# >+# It isn't practical to override the include paths so drastically for >+# the other build targets (like WebCore) that we could make the >+# original include paths, like <GLES2/gl2.h> work. Changing them so >+# their namespace is "ANGLE", which implicitly occurs during the "copy >+# headers" phase, is a reasonable solution. >+# >+# This script processes the header files after they're copied during >+# the Copy Header Files build phase, and adjusts their #includes so >+# that they refer to each other. This avoids modifying the ANGLE >+# sources, and allows WebCore to more easily call ANGLE APIs directly. >+ >+if [ -n "$ANGLE_INSTALL_PATH_PREFIX" ] ; then >+ # Assume this is an Apple-internal build. >+ output_dir=$PUBLIC_HEADERS_FOLDER_PATH >+elif [ -n "$BUILT_PRODUCTS_DIR" ] ; then >+ # Assume this is an Apple-external build. >+ output_dir=$BUILT_PRODUCTS_DIR/$PUBLIC_HEADERS_FOLDER_PATH >+else >+ echo Requires either ANGLE_INSTALL_PATH_PREFIX or BUILT_PRODUCTS_DIR environment variable to be set >+ exit 1 >+fi >+ >+for i in $output_dir/*.h ; do >+ sed -i -e ' >+s/^#include <EGL\/\(.*\)>/#include <ANGLE\/\1>/ >+s/^#include <GLES2\/\(.*\)>/#include <ANGLE\/\1>/ >+s/^#include <GLES3\/\(.*\)>/#include <ANGLE\/\1>/ >+s/^#include <KHR\/\(.*\)>/#include <ANGLE\/\1>/ >+s/^#include <export.h>/#include <ANGLE\/export.h>/ >+s/^#include "\(eglext_angle\|gl2ext_angle\|ShaderVars\).h"/#include <ANGLE\/\1.h>/ >+' $i >+done >diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h >index 1eb79970a77400286c454b93ed97d7a9fbfa3282..8a56c6cf0531683d90fc2395e32ee8d9558243e2 100644 >--- a/Source/WTF/wtf/Platform.h >+++ b/Source/WTF/wtf/Platform.h >@@ -1101,15 +1101,20 @@ > #endif > > #if ENABLE(WEBGL) >+/* USE_ANGLE=1 uses ANGLE for the WebGL backend. >+ It replaces USE_OPENGL, USE_OPENGL_ES and USE_EGL. */ > #if PLATFORM(MAC) > #define USE_OPENGL 1 > #define USE_OPENGL_ES 0 >+#define USE_ANGLE 0 > #elif PLATFORM(IOSMAC) && __has_include(<OpenGL/OpenGL.h>) > #define USE_OPENGL 1 > #define USE_OPENGL_ES 0 >+#define USE_ANGLE 0 > #else > #define USE_OPENGL 0 > #define USE_OPENGL_ES 1 >+#define USE_ANGLE 0 > #endif > #if PLATFORM(COCOA) > #ifndef GL_SILENCE_DEPRECATION >@@ -1132,6 +1137,12 @@ > #define USE_EGL 1 > #endif > >+#if ENABLE(WEBGL) >+#if (USE_ANGLE && (USE_OPENGL || USE_OPENGL_ES || (defined(USE_EGL) && USE_EGL))) >+#error USE_ANGLE is incompatible with USE_OPENGL, USE_OPENGL_ES and USE_EGL >+#endif >+#endif >+ > #if USE(TEXTURE_MAPPER) && ENABLE(GRAPHICS_CONTEXT_3D) && !defined(USE_TEXTURE_MAPPER_GL) > #define USE_TEXTURE_MAPPER_GL 1 > #endif >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index 18bfd301d965632b7b1029e08ba361b11e649368..e80a53da721767b3e0183d6f8e070274499dd6b6 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -220,6 +220,12 @@ platform/gamepad/mac/HIDGamepadProvider.cpp > > platform/graphics/MediaPlaybackTargetPicker.cpp > >+// These sources can't be unified with others in case they are merged >+// with files that use the system OpenGL. >+platform/graphics/angle/Extensions3DANGLE.cpp @no-unify >+platform/graphics/angle/GraphicsContext3DANGLE.cpp @no-unify >+platform/graphics/angle/TemporaryANGLESetting.cpp @no-unify >+ > platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm @no-unify > platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm @no-unify > platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm @no-unify >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index aacba4c14b071add6cd196b1ea7925fe76e5fe72..36cf664154b8c9528c6b74166c26814f876ce180 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2007,6 +2007,11 @@ > 6E4E91AF10F7FB3100A2779C /* WebGLContextAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 6E67D2A71280E8A4008758F7 /* Extensions3DOpenGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E67D2A51280E8A4008758F7 /* Extensions3DOpenGL.h */; }; > 6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E67D2A81280E8BD008758F7 /* Extensions3D.h */; }; >+ 6E72F54C229DCD0C00B3E151 /* Extensions3DANGLE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E27F243229C9F8400F1F632 /* Extensions3DANGLE.cpp */; }; >+ 6E72F54E229DCD1000B3E151 /* GraphicsContext3DANGLE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E27F2422298CE4B00F1F632 /* GraphicsContext3DANGLE.cpp */; }; >+ 6E72F54F229DCD1300B3E151 /* TemporaryANGLESetting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E290861229DB950000986E2 /* TemporaryANGLESetting.cpp */; }; >+ 6E72F550229DCD1700B3E151 /* Extensions3DANGLE.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E27F244229C9F8D00F1F632 /* Extensions3DANGLE.h */; }; >+ 6E72F551229DCD1A00B3E151 /* TemporaryANGLESetting.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E290863229DB970000986E2 /* TemporaryANGLESetting.h */; }; > 6E84E9E117668BF100815B68 /* RasterShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E84E9DF17668BAD00815B68 /* RasterShape.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 6EBF0E4812A8926100DB1709 /* OESTextureFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */; }; > 6EBF0E4912A8926100DB1709 /* OESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */; }; >@@ -9100,6 +9105,11 @@ > 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatRoundedRect.h; sourceTree = "<group>"; }; > 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; }; > 6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; }; >+ 6E27F2422298CE4B00F1F632 /* GraphicsContext3DANGLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DANGLE.cpp; sourceTree = "<group>"; }; >+ 6E27F243229C9F8400F1F632 /* Extensions3DANGLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Extensions3DANGLE.cpp; sourceTree = "<group>"; }; >+ 6E27F244229C9F8D00F1F632 /* Extensions3DANGLE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Extensions3DANGLE.h; sourceTree = "<group>"; }; >+ 6E290861229DB950000986E2 /* TemporaryANGLESetting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporaryANGLESetting.cpp; sourceTree = "<group>"; }; >+ 6E290863229DB970000986E2 /* TemporaryANGLESetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporaryANGLESetting.h; sourceTree = "<group>"; }; > 6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTextureS3TC.cpp; sourceTree = "<group>"; }; > 6E3FAD3614733F4000E42307 /* JSWebGLDepthTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLDepthTexture.cpp; sourceTree = "<group>"; }; > 6E3FAD3614733F4010E42307 /* JSWebGLDebugRendererInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLDebugRendererInfo.cpp; sourceTree = "<group>"; }; >@@ -20404,6 +20414,18 @@ > tabWidth = 4; > usesTabs = 0; > }; >+ 6E27F2412298CE2E00F1F632 /* angle */ = { >+ isa = PBXGroup; >+ children = ( >+ 6E27F243229C9F8400F1F632 /* Extensions3DANGLE.cpp */, >+ 6E27F244229C9F8D00F1F632 /* Extensions3DANGLE.h */, >+ 6E27F2422298CE4B00F1F632 /* GraphicsContext3DANGLE.cpp */, >+ 6E290861229DB950000986E2 /* TemporaryANGLESetting.cpp */, >+ 6E290863229DB970000986E2 /* TemporaryANGLESetting.h */, >+ ); >+ path = angle; >+ sourceTree = "<group>"; >+ }; > 6FCFC055212DACC2007695D2 /* floats */ = { > isa = PBXGroup; > children = ( >@@ -24355,6 +24377,7 @@ > B2A015910AF6CD53006BCE0E /* graphics */ = { > isa = PBXGroup; > children = ( >+ 6E27F2412298CE2E00F1F632 /* angle */, > 076F0D0812B8192700C26AA4 /* avfoundation */, > 499B3EC0128CCC1800E726C2 /* ca */, > B27535290B053814002CE64F /* cg */, >@@ -29038,6 +29061,7 @@ > 837FB3451F9EA06D00D0FC31 /* ExtendableMessageEvent.h in Headers */, > 31DCDF441DA1C45400EA5B93 /* ExtendedColor.h in Headers */, > 6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */, >+ 6E72F550229DCD1700B3E151 /* Extensions3DANGLE.h in Headers */, > 6E67D2A71280E8A4008758F7 /* Extensions3DOpenGL.h in Headers */, > 44DAB5B215A623580097C1E4 /* Extensions3DOpenGLCommon.h in Headers */, > E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */, >@@ -31817,6 +31841,7 @@ > F55B3DD61251F12D003EF269 /* TelephoneInputType.h in Headers */, > 7CC564B818BABEA6001B9652 /* TelephoneNumberDetector.h in Headers */, > C65046A9167BFB5500CC2A4D /* TemplateContentDocumentFragment.h in Headers */, >+ 6E72F551229DCD1A00B3E151 /* TemporaryANGLESetting.h in Headers */, > 26E944DD1AC4B4EA007B85B5 /* Term.h in Headers */, > 6550B6A6099DF0270090D781 /* Text.h in Headers */, > 93309E17099E64920056E581 /* TextAffinity.h in Headers */, >@@ -32716,6 +32741,7 @@ > E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */, > 515BE18F1D54F5FB00DD7C68 /* EmptyGamepadProvider.cpp in Sources */, > 724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */, >+ 6E72F54C229DCD0C00B3E151 /* Extensions3DANGLE.cpp in Sources */, > 72F1ADA21A3904DC00014E18 /* EXTFragDepth.cpp in Sources */, > 5C4304B0191AC908000E2BC0 /* EXTShaderTextureLOD.cpp in Sources */, > 727AFED41A2EA6AE000442E8 /* EXTsRGB.cpp in Sources */, >@@ -32729,6 +32755,7 @@ > 837964CF1F8DB69D00218EA0 /* GeolocationPositionIOS.mm in Sources */, > D084033C221CBF6900007205 /* GPUBuffer.cpp in Sources */, > 6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */, >+ 6E72F54E229DCD1000B3E151 /* GraphicsContext3DANGLE.cpp in Sources */, > 7C3E510B18DF8F3500C112F7 /* HTMLConverter.mm in Sources */, > A8D06B3A0A265DCD005E7203 /* HTMLNames.cpp in Sources */, > 1AC900C31943C0FC008625B5 /* HTTPHeaderNames.cpp in Sources */, >@@ -32813,6 +32840,7 @@ > 538F10A81F9022A4005102CE /* SoftLinkLibxslt.cpp in Sources */, > CDC8B5AA18047FF10016E685 /* SourceBufferPrivateAVFObjC.mm in Sources */, > A833C7CA0A2CF06B00D57664 /* SVGNames.cpp in Sources */, >+ 6E72F54F229DCD1300B3E151 /* TemporaryANGLESetting.cpp in Sources */, > 9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */, > 9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */, > 071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */, >diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h >index 4f38bf3ede351e5ef164ebc28f96b2bec5c0bc33..60af01b87f34e2947a4622384aff64656dec1ff6 100644 >--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h >+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h >@@ -38,8 +38,12 @@ > > #if USE(OPENGL_ES) > #import <OpenGLES/ES2/glext.h> >-#else >+#elif USE(OPENGL) > #include <OpenGL/gl.h> >+#elif USE(ANGLE) >+#include <ANGLE/gl2.h> >+#else >+#error Unsupported configuration > #endif > > #elif PLATFORM(WIN) >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h >index 11b0e9936c583e5b956d1bc004da2fe03d5929cc..49eba7a2fd9c429583f73dc7a2a6fd42f88a3848 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h >@@ -64,10 +64,14 @@ typedef void* PlatformGraphicsContext3D; > #endif // __OBJC__ > #endif // USE(OPENGL_ES) > >-#if !USE(OPENGL_ES) >+#if USE(OPENGL) > typedef struct _CGLContextObject *CGLContextObj; > typedef CGLContextObj PlatformGraphicsContext3D; >-#endif >+#endif // USE(OPENGL) >+ >+#if USE(ANGLE) >+typedef void* PlatformGraphicsContext3D; >+#endif // USE(ANGLE) > > OBJC_CLASS CALayer; > OBJC_CLASS WebGLLayer; >@@ -94,8 +98,10 @@ namespace WebCore { > class Extensions3D; > #if !PLATFORM(COCOA) && USE(OPENGL_ES) > class Extensions3DOpenGLES; >-#else >+#elif USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES)) > class Extensions3DOpenGL; >+#elif USE(ANGLE) >+class Extensions3DANGLE; > #endif > class HostWindow; > class Image; >@@ -1431,12 +1437,16 @@ private: > > #if !PLATFORM(COCOA) && USE(OPENGL_ES) > friend class Extensions3DOpenGLES; >+ friend class Extensions3DOpenGLCommon; > std::unique_ptr<Extensions3DOpenGLES> m_extensions; >-#else >+#elif USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES)) > friend class Extensions3DOpenGL; >+ friend class Extensions3DOpenGLCommon; > std::unique_ptr<Extensions3DOpenGL> m_extensions; >+#elif USE(ANGLE) >+ friend class Extensions3DANGLE; >+ std::unique_ptr<Extensions3DANGLE> m_extensions; > #endif >- friend class Extensions3DOpenGLCommon; > > GraphicsContext3DAttributes m_attrs; > GraphicsContext3DPowerPreference m_powerPreferenceUsedForCreation { GraphicsContext3DPowerPreference::Default }; >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp b/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp >index 286b4ed19a2f98a79775bad938c9616bd94e1cca..0880008e4d8b6f258aa1c252b85fb76e9386c9b6 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp >+++ b/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp >@@ -35,7 +35,7 @@ > #include <sys/sysctl.h> > #endif > >-#if PLATFORM(MAC) >+#if PLATFORM(MAC) && USE(OPENGL) > #include "SwitchingGPUClient.h" > #include <OpenGL/OpenGL.h> > #endif >@@ -134,7 +134,8 @@ void GraphicsContext3DManager::displayWasReconfigured(CGDirectDisplayID, CGDispl > > void GraphicsContext3DManager::updateAllContexts() > { >-#if PLATFORM(MAC) >+ // FIXME: determine whether to do anything when using ANGLE. >+#if PLATFORM(MAC) && USE(OPENGL) > for (const auto& context : m_contexts) { > context->updateCGLContext(); > context->dispatchContextChangedNotification(); >@@ -217,7 +218,7 @@ void GraphicsContext3DManager::removeContextRequiringHighPerformance(GraphicsCon > > void GraphicsContext3DManager::updateHighPerformanceState() > { >-#if PLATFORM(MAC) >+#if PLATFORM(MAC) && USE(OPENGL) > if (!hasLowAndHighPowerGPUs()) > return; > >@@ -257,7 +258,7 @@ void GraphicsContext3DManager::disableHighPerformanceGPUTimerFired() > return; > > m_requestingHighPerformance = false; >-#if PLATFORM(MAC) >+#if PLATFORM(MAC) && USE(OPENGL) > SwitchingGPUClient::singleton().releaseHighPerformanceGPU(); > #endif > } >diff --git a/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp b/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5ef901175c0387742ef9a6ce710001908b4de60c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp >@@ -0,0 +1,314 @@ >+/* >+ * Copyright (C) 2019 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >+#include "Extensions3DANGLE.h" >+ >+#include "GraphicsContext3D.h" >+ >+#include <ANGLE/entry_points_gles_2_0_autogen.h> >+#include <ANGLE/entry_points_gles_3_0_autogen.h> >+ >+// Note: this file can't be compiled in the same unified source file >+// as others which include the system's OpenGL headers. >+ >+namespace WebCore { >+ >+Extensions3DANGLE::Extensions3DANGLE(GraphicsContext3D* context, bool useIndexedGetString) >+ : m_initializedAvailableExtensions(false) >+ , m_context(context) >+ , m_isNVIDIA(false) >+ , m_isAMD(false) >+ , m_isIntel(false) >+ , m_isImagination(false) >+ , m_requiresBuiltInFunctionEmulation(false) >+ , m_requiresRestrictedMaximumTextureSize(false) >+ , m_useIndexedGetString(useIndexedGetString) >+{ >+ // FIXME: ideally, remove this initialization altogether. ANGLE >+ // subsumes the responsibility for graphics driver workarounds. >+ m_vendor = String(reinterpret_cast<const char*>(::glGetString(GL_VENDOR))); >+ m_renderer = String(reinterpret_cast<const char*>(::glGetString(GL_RENDERER))); >+ >+ Vector<String> vendorComponents = m_vendor.convertToASCIILowercase().split(' '); >+ if (vendorComponents.contains("nvidia")) >+ m_isNVIDIA = true; >+ if (vendorComponents.contains("ati") || vendorComponents.contains("amd")) >+ m_isAMD = true; >+ if (vendorComponents.contains("intel")) >+ m_isIntel = true; >+ if (vendorComponents.contains("imagination")) >+ m_isImagination = true; >+} >+ >+Extensions3DANGLE::~Extensions3DANGLE() = default; >+ >+bool Extensions3DANGLE::supports(const String& name) >+{ >+ if (!m_initializedAvailableExtensions) >+ initializeAvailableExtensions(); >+ >+ // We explicitly do not support this extension until >+ // we fix the following bug: >+ // https://bugs.webkit.org/show_bug.cgi?id=149734 >+ // FIXME: given that ANGLE is in use, rewrite this in terms of >+ // ANGLE queries and enable this extension. >+ if (name == "GL_ANGLE_translated_shader_source") >+ return false; >+ >+ return supportsExtension(name); >+} >+ >+void Extensions3DANGLE::ensureEnabled(const String& name) >+{ >+ if (name == "GL_OES_standard_derivatives") { >+ // Enable support in ANGLE (if not enabled already). >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ ShBuiltInResources ANGLEResources = compiler.getResources(); >+ if (!ANGLEResources.OES_standard_derivatives) { >+ ANGLEResources.OES_standard_derivatives = 1; >+ compiler.setResources(ANGLEResources); >+ } >+ } else if (name == "GL_EXT_draw_buffers") { >+ // Enable support in ANGLE (if not enabled already). >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ ShBuiltInResources ANGLEResources = compiler.getResources(); >+ if (!ANGLEResources.EXT_draw_buffers) { >+ ANGLEResources.EXT_draw_buffers = 1; >+ m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &ANGLEResources.MaxDrawBuffers); >+ compiler.setResources(ANGLEResources); >+ } >+ } else if (name == "GL_EXT_shader_texture_lod") { >+ // Enable support in ANGLE (if not enabled already). >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ ShBuiltInResources ANGLEResources = compiler.getResources(); >+ if (!ANGLEResources.EXT_shader_texture_lod) { >+ ANGLEResources.EXT_shader_texture_lod = 1; >+ compiler.setResources(ANGLEResources); >+ } >+ } else if (name == "GL_EXT_frag_depth") { >+ // Enable support in ANGLE (if not enabled already). >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ ShBuiltInResources ANGLEResources = compiler.getResources(); >+ if (!ANGLEResources.EXT_frag_depth) { >+ ANGLEResources.EXT_frag_depth = 1; >+ compiler.setResources(ANGLEResources); >+ } >+ } >+} >+ >+bool Extensions3DANGLE::isEnabled(const String& name) >+{ >+ if (name == "GL_OES_standard_derivatives") { >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ return compiler.getResources().OES_standard_derivatives; >+ } >+ return supports(name); >+} >+ >+int Extensions3DANGLE::getGraphicsResetStatusARB() >+{ >+ return GraphicsContext3D::NO_ERROR; >+} >+ >+String Extensions3DANGLE::getTranslatedShaderSourceANGLE(Platform3DObject shader) >+{ >+ // FIXME: port to use ANGLE's implementation directly. >+ ASSERT(shader); >+ int GLshaderType; >+ ANGLEShaderType shaderType; >+ >+ ANGLEWebKitBridge& compiler = m_context->m_compiler; >+ >+ m_context->getShaderiv(shader, GraphicsContext3D::SHADER_TYPE, &GLshaderType); >+ >+ if (GLshaderType == GraphicsContext3D::VERTEX_SHADER) >+ shaderType = SHADER_TYPE_VERTEX; >+ else if (GLshaderType == GraphicsContext3D::FRAGMENT_SHADER) >+ shaderType = SHADER_TYPE_FRAGMENT; >+ else >+ return emptyString(); // Invalid shader type. >+ >+ HashMap<Platform3DObject, GraphicsContext3D::ShaderSourceEntry>::iterator result = m_context->m_shaderSourceMap.find(shader); >+ >+ if (result == m_context->m_shaderSourceMap.end()) >+ return emptyString(); >+ >+ GraphicsContext3D::ShaderSourceEntry& entry = result->value; >+ >+ String translatedShaderSource; >+ String shaderInfoLog; >+ uint64_t extraCompileOptions = SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_UNFOLD_SHORT_CIRCUIT | SH_INIT_OUTPUT_VARIABLES | SH_ENFORCE_PACKING_RESTRICTIONS | SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH | SH_INITIALIZE_UNINITIALIZED_LOCALS; >+ >+ if (m_requiresBuiltInFunctionEmulation) >+ extraCompileOptions |= SH_EMULATE_ABS_INT_FUNCTION; >+ >+ Vector<std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>> symbols; >+ bool isValid = compiler.compileShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, symbols, extraCompileOptions); >+ >+ entry.log = shaderInfoLog; >+ entry.isValid = isValid; >+ >+ for (const std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>& pair : symbols) { >+ const std::string& name = pair.second.name; >+ entry.symbolMap(pair.first).set(String(name.c_str(), name.length()), pair.second); >+ } >+ >+ if (!isValid) >+ return emptyString(); >+ >+ return translatedShaderSource; >+} >+ >+void Extensions3DANGLE::initializeAvailableExtensions() >+{ >+ if (m_useIndexedGetString) { >+ GLint numExtensions = 0; >+ gl::GetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); >+ for (GLint i = 0; i < numExtensions; ++i) >+ m_availableExtensions.add(glGetStringi(GL_EXTENSIONS, i)); >+ } else { >+ String extensionsString = getExtensions(); >+ for (auto& extension : extensionsString.split(' ')) >+ m_availableExtensions.add(extension); >+ } >+ m_initializedAvailableExtensions = true; >+} >+ >+void Extensions3DANGLE::readnPixelsEXT(int, int, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, GC3Dsizei, void *) >+{ >+ m_context->synthesizeGLError(GL_INVALID_OPERATION); >+} >+ >+void Extensions3DANGLE::getnUniformfvEXT(GC3Duint, int, GC3Dsizei, float *) >+{ >+ m_context->synthesizeGLError(GL_INVALID_OPERATION); >+} >+ >+void Extensions3DANGLE::getnUniformivEXT(GC3Duint, int, GC3Dsizei, int *) >+{ >+ m_context->synthesizeGLError(GL_INVALID_OPERATION); >+} >+ >+void Extensions3DANGLE::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) >+{ >+ // FIXME: consider adding support for APPLE_framebuffer_multisample. >+ gl::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); >+} >+ >+void Extensions3DANGLE::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) >+{ >+ gl::RenderbufferStorageMultisample(target, samples, internalformat, width, height); >+} >+ >+Platform3DObject Extensions3DANGLE::createVertexArrayOES() >+{ >+ m_context->makeContextCurrent(); >+ GLuint array = 0; >+ gl::GenVertexArrays(1, &array); >+ return array; >+} >+ >+void Extensions3DANGLE::deleteVertexArrayOES(Platform3DObject array) >+{ >+ if (!array) >+ return; >+ >+ m_context->makeContextCurrent(); >+ gl::DeleteVertexArrays(1, &array); >+} >+ >+GC3Dboolean Extensions3DANGLE::isVertexArrayOES(Platform3DObject array) >+{ >+ if (!array) >+ return GL_FALSE; >+ >+ m_context->makeContextCurrent(); >+ return gl::IsVertexArray(array); >+} >+ >+void Extensions3DANGLE::bindVertexArrayOES(Platform3DObject array) >+{ >+ m_context->makeContextCurrent(); >+ gl::BindVertexArray(array); >+} >+ >+void Extensions3DANGLE::insertEventMarkerEXT(const String&) >+{ >+ // FIXME: implement this function and add GL_EXT_debug_marker in supports(). >+ return; >+} >+ >+void Extensions3DANGLE::pushGroupMarkerEXT(const String&) >+{ >+ // FIXME: implement this function and add GL_EXT_debug_marker in supports(). >+ return; >+} >+ >+void Extensions3DANGLE::popGroupMarkerEXT(void) >+{ >+ // FIXME: implement this function and add GL_EXT_debug_marker in supports(). >+ return; >+} >+ >+bool Extensions3DANGLE::supportsExtension(const String& name) >+{ >+ return m_availableExtensions.contains(name); >+} >+ >+void Extensions3DANGLE::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) >+{ >+ gl::DrawBuffers(n, bufs); >+} >+ >+void Extensions3DANGLE::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) >+{ >+ m_context->makeContextCurrent(); >+ gl::DrawArraysInstanced(mode, first, count, primcount); >+} >+ >+void Extensions3DANGLE::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) >+{ >+ m_context->makeContextCurrent(); >+ gl::DrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount); >+} >+ >+void Extensions3DANGLE::vertexAttribDivisor(GC3Duint index, GC3Duint divisor) >+{ >+ m_context->makeContextCurrent(); >+ gl::VertexAttribDivisor(index, divisor); >+} >+ >+String Extensions3DANGLE::getExtensions() >+{ >+ ASSERT(!m_useIndexedGetString); >+ return String(reinterpret_cast<const char*>(gl::GetString(GL_EXTENSIONS))); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >diff --git a/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.h b/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.h >new file mode 100644 >index 0000000000000000000000000000000000000000..dc29af6dd8b08dd9e30d1b1115b124928e48b6ae >--- /dev/null >+++ b/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.h >@@ -0,0 +1,104 @@ >+/* >+ * Copyright (C) 2019 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "Extensions3D.h" >+ >+#include "GraphicsContext3D.h" >+#include <wtf/text/StringHash.h> >+ >+namespace WebCore { >+ >+class Extensions3DANGLE : public Extensions3D { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ // This class only needs to be instantiated by GraphicsContext3D implementations. >+ Extensions3DANGLE(GraphicsContext3D*, bool useIndexedGetString); >+ virtual ~Extensions3DANGLE(); >+ >+ // Extensions3D methods. >+ bool supports(const String&) override; >+ void ensureEnabled(const String&) override; >+ bool isEnabled(const String&) override; >+ int getGraphicsResetStatusARB() override; >+ >+ Platform3DObject createVertexArrayOES() override; >+ void deleteVertexArrayOES(Platform3DObject) override; >+ GC3Dboolean isVertexArrayOES(Platform3DObject) override; >+ void bindVertexArrayOES(Platform3DObject) override; >+ void insertEventMarkerEXT(const String&) override; >+ void pushGroupMarkerEXT(const String&) override; >+ void popGroupMarkerEXT(void) override; >+ void drawBuffersEXT(GC3Dsizei, const GC3Denum*) override; >+ >+ String getTranslatedShaderSourceANGLE(Platform3DObject) override; >+ >+ void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) override; >+ void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) override; >+ >+ void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) override; >+ void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) override; >+ void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) override; >+ >+ // EXT Robustness - uses getGraphicsResetStatusARB() >+ void readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data) override; >+ void getnUniformfvEXT(GC3Duint program, int location, GC3Dsizei bufSize, float *params) override; >+ void getnUniformivEXT(GC3Duint program, int location, GC3Dsizei bufSize, int *params) override; >+ >+ bool isNVIDIA() override { return m_isNVIDIA; } >+ bool isAMD() override { return m_isAMD; } >+ bool isIntel() override { return m_isIntel; } >+ bool isImagination() override { return m_isImagination; } >+ String vendor() override { return m_vendor; } >+ >+ bool requiresBuiltInFunctionEmulation() override { return m_requiresBuiltInFunctionEmulation; } >+ bool requiresRestrictedMaximumTextureSize() override { return m_requiresRestrictedMaximumTextureSize; } >+ >+private: >+ bool supportsExtension(const WTF::String&); >+ String getExtensions(); >+ >+ virtual void initializeAvailableExtensions(); >+ bool m_initializedAvailableExtensions; >+ HashSet<String> m_availableExtensions; >+ >+ // Weak pointer back to GraphicsContext3D. >+ GraphicsContext3D* m_context; >+ >+ bool m_isNVIDIA; >+ bool m_isAMD; >+ bool m_isIntel; >+ bool m_isImagination; >+ bool m_requiresBuiltInFunctionEmulation; >+ bool m_requiresRestrictedMaximumTextureSize; >+ >+ bool m_useIndexedGetString { false }; >+ >+ String m_vendor; >+ String m_renderer; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp b/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..94e5af3a483879d0c01f54f691c917a2e0b24f03 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp >@@ -0,0 +1,2305 @@ >+/* >+ * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE 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" >+ >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >+#include "GraphicsContext3D.h" >+ >+#if PLATFORM(IOS_FAMILY) >+#include "GraphicsContext3DIOS.h" >+#endif >+#include "Extensions3DANGLE.h" >+#include "ImageBuffer.h" >+#include "ImageData.h" >+#include "IntRect.h" >+#include "IntSize.h" >+#include "Logging.h" >+#include "NotImplemented.h" >+#include "TemporaryANGLESetting.h" >+#include <JavaScriptCore/RegularExpression.h> >+#include <algorithm> >+#include <cstring> >+#include <wtf/HexNumber.h> >+#include <wtf/ThreadSpecific.h> >+#include <wtf/text/CString.h> >+#include <wtf/text/StringBuilder.h> >+ >+#if USE(ACCELERATE) >+#include <Accelerate/Accelerate.h> >+#endif >+ >+#include <ANGLE/entry_points_gles_2_0_autogen.h> >+#include <ANGLE/entry_points_gles_3_0_autogen.h> >+ >+// Note: this file can't be compiled in the same unified source file >+// as others which include the system's OpenGL headers. >+ >+// This one definition short-circuits the need for gl2ext.h, which >+// would need more work to be included from WebCore. >+#define GL_MAX_SAMPLES_EXT 0x8D57 >+ >+namespace WebCore { >+ >+void GraphicsContext3D::releaseShaderCompiler() >+{ >+ makeContextCurrent(); >+ notImplemented(); >+} >+ >+#if PLATFORM(MAC) >+static void wipeAlphaChannelFromPixels(int width, int height, unsigned char* pixels) >+{ >+ // We can assume this doesn't overflow because the calling functions >+ // use checked arithmetic. >+ int totalBytes = width * height * 4; >+ for (int i = 0; i < totalBytes; i += 4) >+ pixels[i + 3] = 255; >+} >+#endif >+ >+void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels) >+{ >+ // 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. >+ gl::ReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); >+#if USE(ACCELERATE) >+ vImage_Buffer src; >+ src.height = height; >+ src.width = width; >+ src.rowBytes = width * 4; >+ src.data = pixels; >+ >+ vImage_Buffer dest; >+ dest.height = height; >+ dest.width = width; >+ dest.rowBytes = width * 4; >+ dest.data = pixels; >+ >+ // Swap pixel channels from RGBA to BGRA. >+ const uint8_t map[4] = { 2, 1, 0, 3 }; >+ vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags); >+#else >+ int totalBytes = width * height * 4; >+ for (int i = 0; i < totalBytes; i += 4) >+ std::swap(pixels[i], pixels[i + 2]); >+#endif >+ >+#if PLATFORM(MAC) >+ if (!m_attrs.alpha) >+ wipeAlphaChannelFromPixels(width, height, pixels); >+#endif >+} >+ >+void GraphicsContext3D::validateAttributes() >+{ >+ validateDepthStencil("GL_EXT_packed_depth_stencil"); >+} >+ >+bool GraphicsContext3D::reshapeFBOs(const IntSize& size) >+{ >+ const int width = size.width(); >+ const int height = size.height(); >+ GLuint colorFormat, internalDepthStencilFormat = 0; >+ if (m_attrs.alpha) { >+ m_internalColorFormat = GL_RGBA8; >+ colorFormat = GL_RGBA; >+ } else { >+ m_internalColorFormat = GL_RGB8; >+ colorFormat = GL_RGB; >+ } >+ if (m_attrs.stencil || m_attrs.depth) { >+ // We don't allow the logic where stencil is required and depth is not. >+ // See GraphicsContext3D::validateAttributes. >+ >+ Extensions3D& extensions = getExtensions(); >+ // Use a 24 bit depth buffer where we know we have it. >+ if (extensions.supports("GL_OES_packed_depth_stencil")) >+ internalDepthStencilFormat = GL_DEPTH24_STENCIL8; >+ else >+ internalDepthStencilFormat = GL_DEPTH_COMPONENT16; >+ } >+ >+ // Resize multisample FBO. >+ if (m_attrs.antialias) { >+ GLint maxSampleCount; >+ gl::GetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount); >+ // Using more than 4 samples is slow on some hardware and is unlikely to >+ // produce a significantly better result. >+ GLint sampleCount = std::min(4, maxSampleCount); >+ gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); >+ gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); >+ gl::RenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA8, width, height); >+ gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); >+ if (m_attrs.stencil || m_attrs.depth) { >+ gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); >+ gl::RenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, internalDepthStencilFormat, width, height); >+ if (m_attrs.stencil) >+ gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); >+ if (m_attrs.depth) >+ gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); >+ } >+ gl::BindRenderbuffer(GL_RENDERBUFFER, 0); >+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { >+ // FIXME: cleanup. >+ notImplemented(); >+ } >+ } >+ >+ // resize regular FBO >+ gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo); >+ ASSERT(m_texture); >+#if PLATFORM(COCOA) >+ >+#if PLATFORM(MAC) >+ // FIXME: implement back buffer path using ANGLE and pbuffers. >+ // allocateIOSurfaceBackingStore(IntSize(width, height)); >+ // updateFramebufferTextureBackingStoreFromLayer(); >+ // gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, m_texture, 0); >+#elif PLATFORM(IOS_FAMILY) >+ // FIXME (kbr): implement iOS path, ideally using glFramebufferTexture2DMultisample. >+ // gl::BindRenderbuffer(GL_RENDERBUFFER, m_texture); >+ // gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_texture); >+ // setRenderbufferStorageFromDrawable(m_currentWidth, m_currentHeight); >+#else >+#error Unknown platform >+#endif >+#else >+ gl::BindTexture(GL_TEXTURE_2D, m_texture); >+ gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); >+ gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0); >+ >+#if USE(COORDINATED_GRAPHICS) >+ if (m_compositorTexture) { >+ gl::BindTexture(GL_TEXTURE_2D, m_compositorTexture); >+ gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); >+ gl::BindTexture(GL_TEXTURE_2D, 0); >+ gl::BindTexture(GL_TEXTURE_2D, m_intermediateTexture); >+ gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); >+ gl::BindTexture(GL_TEXTURE_2D, 0); >+ } >+#endif >+#endif // PLATFORM(COCOA) >+ >+ attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height); >+ >+ bool mustRestoreFBO = true; >+ if (m_attrs.antialias) { >+ gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); >+ if (m_state.boundFBO == m_multisampleFBO) >+ mustRestoreFBO = false; >+ } else { >+ if (m_state.boundFBO == m_fbo) >+ mustRestoreFBO = false; >+ } >+ >+ return mustRestoreFBO; >+} >+ >+void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height) >+{ >+ if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) { >+ gl::BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); >+ gl::RenderbufferStorage(GL_RENDERBUFFER, internalDepthStencilFormat, width, height); >+ if (m_attrs.stencil) >+ gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); >+ if (m_attrs.depth) >+ gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); >+ gl::BindRenderbuffer(GL_RENDERBUFFER, 0); >+ } >+ >+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { >+ // FIXME: cleanup >+ notImplemented(); >+ } >+} >+ >+void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect) >+{ >+ TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE); >+ TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE); >+ TemporaryANGLESetting scopedDepth(GL_DEPTH_TEST, GL_FALSE); >+ TemporaryANGLESetting scopedStencil(GL_STENCIL_TEST, GL_FALSE); >+ >+ // FIXME: figure out more efficient solution for iOS. >+ IntRect resolveRect = rect; >+ if (rect.isEmpty()) >+ resolveRect = IntRect(0, 0, m_currentWidth, m_currentHeight); >+ >+ gl::BlitFramebuffer(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_LINEAR); >+} >+ >+void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ gl::RenderbufferStorage(target, internalformat, width, height); >+} >+ >+void GraphicsContext3D::getIntegerv(GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ switch (pname) { >+ case MAX_TEXTURE_SIZE: >+ gl::GetIntegerv(MAX_TEXTURE_SIZE, value); >+ if (getExtensions().requiresRestrictedMaximumTextureSize()) >+ *value = std::min(4096, *value); >+ break; >+ case MAX_CUBE_MAP_TEXTURE_SIZE: >+ gl::GetIntegerv(MAX_CUBE_MAP_TEXTURE_SIZE, value); >+ if (getExtensions().requiresRestrictedMaximumTextureSize()) >+ *value = std::min(1024, *value); >+ break; >+#if PLATFORM(MAC) >+ // Some older hardware advertises a larger maximum than they >+ // can actually handle. Rather than detecting such devices, simply >+ // clamp the maximum to 8192, which is big enough for a 5K display. >+ case MAX_RENDERBUFFER_SIZE: >+ gl::GetIntegerv(MAX_RENDERBUFFER_SIZE, value); >+ *value = std::min(8192, *value); >+ break; >+ case MAX_VIEWPORT_DIMS: >+ gl::GetIntegerv(MAX_VIEWPORT_DIMS, value); >+ value[0] = std::min(8192, value[0]); >+ value[1] = std::min(8192, value[1]); >+ break; >+#endif >+ default: >+ gl::GetIntegerv(pname, value); >+ } >+} >+ >+void GraphicsContext3D::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision) >+{ >+ UNUSED_PARAM(shaderType); >+ ASSERT(range); >+ ASSERT(precision); >+ >+ makeContextCurrent(); >+ >+ switch (precisionType) { >+ case GraphicsContext3D::LOW_INT: >+ case GraphicsContext3D::MEDIUM_INT: >+ case GraphicsContext3D::HIGH_INT: >+ // These values are for a 32-bit twos-complement integer format. >+ range[0] = 31; >+ range[1] = 30; >+ precision[0] = 0; >+ break; >+ case GraphicsContext3D::LOW_FLOAT: >+ case GraphicsContext3D::MEDIUM_FLOAT: >+ case GraphicsContext3D::HIGH_FLOAT: >+ // These values are for an IEEE single-precision floating-point format. >+ range[0] = 127; >+ range[1] = 127; >+ precision[0] = 23; >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ break; >+ } >+} >+ >+bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ if (width && height && !pixels) { >+ synthesizeGLError(INVALID_VALUE); >+ return false; >+ } >+ >+ texImage2DDirect(target, level, internalformat, width, height, border, format, type, pixels); >+ return true; >+} >+ >+void GraphicsContext3D::depthRange(GC3Dclampf zNear, GC3Dclampf zFar) >+{ >+ makeContextCurrent(); >+ gl::DepthRangef(static_cast<float>(zNear), static_cast<float>(zFar)); >+} >+ >+void GraphicsContext3D::clearDepth(GC3Dclampf depth) >+{ >+ makeContextCurrent(); >+ gl::ClearDepthf(static_cast<float>(depth)); >+} >+ >+Extensions3D& GraphicsContext3D::getExtensions() >+{ >+ if (!m_extensions) >+ m_extensions = std::make_unique<Extensions3DANGLE>(this, isGLES2Compliant()); >+ return *m_extensions; >+} >+ >+void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) >+{ >+ // FIXME: remove the two glFlush calls when the driver bug is fixed, i.e., >+ // all previous rendering calls should be done before reading pixels. >+ makeContextCurrent(); >+ gl::Flush(); >+ if (m_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) >+ 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))) >+ wipeAlphaChannelFromPixels(width, height, static_cast<unsigned char*>(data)); >+#endif >+} >+ >+ >+// The contents of GraphicsContext3DOpenGLCommon follow, ported to use ANGLE. >+ >+static ThreadSpecific<ShaderNameHash*>& getCurrentNameHashMapForShader() >+{ >+ static std::once_flag onceFlag; >+ static ThreadSpecific<ShaderNameHash*>* sharedNameHash; >+ std::call_once(onceFlag, [] { >+ sharedNameHash = new ThreadSpecific<ShaderNameHash*>; >+ }); >+ >+ return *sharedNameHash; >+} >+ >+static void setCurrentNameHashMapForShader(ShaderNameHash* shaderNameHash) >+{ >+ *getCurrentNameHashMapForShader() = shaderNameHash; >+} >+ >+// Hash function used by the ANGLE translator/compiler to do >+// symbol name mangling. Since this is a static method, before >+// calling compileShader we set currentNameHashMapForShader >+// to point to the map kept by the current instance of GraphicsContext3D. >+ >+static uint64_t nameHashForShader(const char* name, size_t length) >+{ >+ if (!length) >+ return 0; >+ >+ CString nameAsCString = CString(name); >+ >+ // Look up name in our local map. >+ ShaderNameHash*& currentNameHashMapForShader = *getCurrentNameHashMapForShader(); >+ ShaderNameHash::iterator findResult = currentNameHashMapForShader->find(nameAsCString); >+ if (findResult != currentNameHashMapForShader->end()) >+ return findResult->value; >+ >+ unsigned hashValue = nameAsCString.hash(); >+ >+ // Convert the 32-bit hash from CString::hash into a 64-bit result >+ // by shifting then adding the size of our table. Overflow would >+ // only be a problem if we're already hashing to the same value (and >+ // we're hoping that over the lifetime of the context we >+ // don't have that many symbols). >+ >+ uint64_t result = hashValue; >+ result = (result << 32) + (currentNameHashMapForShader->size() + 1); >+ >+ currentNameHashMapForShader->set(nameAsCString, result); >+ return result; >+} >+ >+void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) >+{ >+ Extensions3D& extensions = getExtensions(); >+ if (m_attrs.stencil) { >+ if (extensions.supports(packedDepthStencilExtension)) { >+ extensions.ensureEnabled(packedDepthStencilExtension); >+ // Force depth if stencil is true. >+ m_attrs.depth = true; >+ } else >+ m_attrs.stencil = false; >+ } >+ if (m_attrs.antialias) { >+ if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant()) >+ m_attrs.antialias = false; >+ else >+ extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample"); >+ } >+} >+ >+void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) >+{ >+ Checked<int, RecordOverflow> rowBytes = Checked<int, RecordOverflow>(m_currentWidth) * 4; >+ if (rowBytes.hasOverflowed()) >+ return; >+ >+ Checked<int, RecordOverflow> totalBytesChecked = rowBytes * m_currentHeight; >+ if (totalBytesChecked.hasOverflowed()) >+ return; >+ int totalBytes = totalBytesChecked.unsafeGet(); >+ >+ auto pixels = makeUniqueArray<unsigned char>(totalBytes); >+ if (!pixels) >+ return; >+ >+ readRenderingResults(pixels.get(), totalBytes); >+ >+ if (!m_attrs.premultipliedAlpha) { >+ for (int i = 0; i < totalBytes; i += 4) { >+ // Premultiply alpha. >+ pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); >+ pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); >+ pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); >+ } >+ } >+ >+ paintToCanvas(pixels.get(), IntSize(m_currentWidth, m_currentHeight), imageBuffer->internalSize(), imageBuffer->context()); >+ >+#if PLATFORM(COCOA) && USE(OPENGL_ES) >+ // FIXME: work on iOS integration. >+ presentRenderbuffer(); >+#endif >+} >+ >+bool GraphicsContext3D::paintCompositedResultsToCanvas(ImageBuffer*) >+{ >+ // Not needed at the moment, so return that nothing was done. >+ return false; >+} >+ >+RefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData() >+{ >+ // Reading premultiplied alpha would involve unpremultiplying, which is >+ // lossy. >+ if (m_attrs.premultipliedAlpha) >+ return nullptr; >+ >+ auto imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight)); >+ unsigned char* pixels = imageData->data()->data(); >+ Checked<int, RecordOverflow> totalBytesChecked = 4 * Checked<int, RecordOverflow>(m_currentWidth) * Checked<int, RecordOverflow>(m_currentHeight); >+ if (totalBytesChecked.hasOverflowed()) >+ return imageData; >+ int totalBytes = totalBytesChecked.unsafeGet(); >+ >+ readRenderingResults(pixels, totalBytes); >+ >+ // Convert to RGBA. >+ for (int i = 0; i < totalBytes; i += 4) >+ std::swap(pixels[i], pixels[i + 2]); >+ >+ return imageData; >+} >+ >+void GraphicsContext3D::prepareTexture() >+{ >+ if (m_layerComposited) >+ return; >+ >+ makeContextCurrent(); >+ >+#if !USE(COORDINATED_GRAPHICS) >+ TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE); >+ TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE); >+#endif >+ >+ if (m_attrs.antialias) >+ resolveMultisamplingIfNecessary(); >+ >+#if USE(COORDINATED_GRAPHICS) >+ std::swap(m_texture, m_compositorTexture); >+ std::swap(m_texture, m_intermediateTexture); >+ gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo); >+ gl::FramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0); >+ glFlush(); >+ >+ if (m_state.boundFBO != m_fbo) >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); >+ else >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ return; >+#endif >+ >+ gl::ActiveTexture(GL_TEXTURE0); >+ gl::BindTexture(GL_TEXTURE_2D, m_state.boundTarget(GL_TEXTURE0) == GL_TEXTURE_2D ? m_state.boundTexture(GL_TEXTURE0) : 0); >+ gl::ActiveTexture(m_state.activeTextureUnit); >+ if (m_state.boundFBO != m_fbo) >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); >+ gl::Flush(); >+} >+ >+void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSize) >+{ >+ if (pixelsSize < m_currentWidth * m_currentHeight * 4) >+ return; >+ >+ makeContextCurrent(); >+ >+ bool mustRestoreFBO = false; >+ if (m_attrs.antialias) { >+ resolveMultisamplingIfNecessary(); >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ mustRestoreFBO = true; >+ } else { >+ if (m_state.boundFBO != m_fbo) { >+ mustRestoreFBO = true; >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); >+ } >+ } >+ >+ GLint packAlignment = 4; >+ bool mustRestorePackAlignment = false; >+ gl::GetIntegerv(GL_PACK_ALIGNMENT, &packAlignment); >+ if (packAlignment > 4) { >+ gl::PixelStorei(GL_PACK_ALIGNMENT, 4); >+ mustRestorePackAlignment = true; >+ } >+ >+ readPixelsAndConvertToBGRAIfNecessary(0, 0, m_currentWidth, m_currentHeight, pixels); >+ >+ if (mustRestorePackAlignment) >+ gl::PixelStorei(GL_PACK_ALIGNMENT, packAlignment); >+ >+ if (mustRestoreFBO) >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); >+} >+ >+void GraphicsContext3D::reshape(int width, int height) >+{ >+ if (!platformGraphicsContext3D()) >+ return; >+ >+ if (width == m_currentWidth && height == m_currentHeight) >+ return; >+ >+ ASSERT(width >= 0 && height >= 0); >+ if (width < 0 || height < 0) >+ return; >+ >+ markContextChanged(); >+ >+ m_currentWidth = width; >+ m_currentHeight = height; >+ >+ makeContextCurrent(); >+ validateAttributes(); >+ >+ TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE); >+ TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE); >+ >+ bool mustRestoreFBO = reshapeFBOs(IntSize(width, height)); >+ >+ // Initialize renderbuffers to 0. >+ GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0; >+ GLint clearStencil = 0; >+ GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE; >+ GLuint stencilMask = 0xffffffff, stencilMaskBack = 0xffffffff; >+ GLbitfield clearMask = GL_COLOR_BUFFER_BIT; >+ gl::GetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); >+ 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) { >+ 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) { >+ gl::GetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil); >+ gl::ClearStencil(0); >+ gl::GetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask)); >+ gl::GetIntegerv(GL_STENCIL_BACK_WRITEMASK, reinterpret_cast<GLint*>(&stencilMaskBack)); >+ gl::StencilMaskSeparate(GL_FRONT, 0xffffffff); >+ gl::StencilMaskSeparate(GL_BACK, 0xffffffff); >+ clearMask |= GL_STENCIL_BUFFER_BIT; >+ } >+ >+ gl::Clear(clearMask); >+ >+ gl::ClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); >+ gl::ColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); >+ if (m_attrs.depth) { >+ GraphicsContext3D::clearDepth(clearDepth); >+ gl::DepthMask(depthMask); >+ } >+ if (m_attrs.stencil) { >+ gl::ClearStencil(clearStencil); >+ gl::StencilMaskSeparate(GL_FRONT, stencilMask); >+ gl::StencilMaskSeparate(GL_BACK, stencilMaskBack); >+ } >+ >+ if (mustRestoreFBO) >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); >+ >+ gl::Flush(); >+} >+ >+bool GraphicsContext3D::checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const >+{ >+ ASSERT(m_shaderSourceMap.contains(vertexShader)); >+ ASSERT(m_shaderSourceMap.contains(fragmentShader)); >+ const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value; >+ const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value; >+ >+ HashMap<String, sh::ShaderVariable> combinedVaryings; >+ for (const auto& vertexSymbol : vertexEntry.varyingMap) { >+ const String& symbolName = vertexSymbol.key; >+ // The varying map includes variables for each index of an array variable. >+ // We only want a single variable to represent the array. >+ if (symbolName.endsWith("]")) >+ continue; >+ >+ // Don't count built in varyings. >+ if (symbolName == "gl_FragCoord" || symbolName == "gl_FrontFacing" || symbolName == "gl_PointCoord") >+ continue; >+ >+ const auto& fragmentSymbol = fragmentEntry.varyingMap.find(symbolName); >+ if (fragmentSymbol != fragmentEntry.varyingMap.end()) >+ combinedVaryings.add(symbolName, fragmentSymbol->value); >+ } >+ >+ size_t numVaryings = combinedVaryings.size(); >+ if (!numVaryings) >+ return true; >+ >+ std::vector<sh::ShaderVariable> variables; >+ variables.reserve(combinedVaryings.size()); >+ for (const auto& varyingSymbol : combinedVaryings.values()) >+ variables.push_back(varyingSymbol); >+ >+ GC3Dint maxVaryingVectors = 0; >+ gl::GetIntegerv(MAX_VARYING_VECTORS, &maxVaryingVectors); >+ return sh::CheckVariablesWithinPackingLimits(maxVaryingVectors, variables); >+} >+ >+bool GraphicsContext3D::precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const >+{ >+ ASSERT(m_shaderSourceMap.contains(vertexShader)); >+ ASSERT(m_shaderSourceMap.contains(fragmentShader)); >+ const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value; >+ const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value; >+ >+ HashMap<String, sh::GLenum> vertexSymbolPrecisionMap; >+ >+ for (const auto& entry : vertexEntry.uniformMap) { >+ const std::string& mappedName = entry.value.mappedName; >+ vertexSymbolPrecisionMap.add(String(mappedName.c_str(), mappedName.length()), entry.value.precision); >+ } >+ >+ for (const auto& entry : fragmentEntry.uniformMap) { >+ const std::string& mappedName = entry.value.mappedName; >+ const auto& vertexSymbol = vertexSymbolPrecisionMap.find(String(mappedName.c_str(), mappedName.length())); >+ if (vertexSymbol != vertexSymbolPrecisionMap.end() && vertexSymbol->value != entry.value.precision) >+ return false; >+ } >+ >+ return true; >+} >+ >+IntSize GraphicsContext3D::getInternalFramebufferSize() const >+{ >+ return IntSize(m_currentWidth, m_currentHeight); >+} >+ >+void GraphicsContext3D::activeTexture(GC3Denum texture) >+{ >+ makeContextCurrent(); >+ m_state.activeTextureUnit = texture; >+ gl::ActiveTexture(texture); >+} >+ >+void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject shader) >+{ >+ ASSERT(program); >+ ASSERT(shader); >+ makeContextCurrent(); >+ m_shaderProgramSymbolCountMap.remove(program); >+ gl::AttachShader(program, shader); >+} >+ >+void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) >+{ >+ ASSERT(program); >+ makeContextCurrent(); >+ >+ String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name); >+ LOG(WebGL, "::bindAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); >+ gl::BindAttribLocation(program, index, mappedName.utf8().data()); >+} >+ >+void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ gl::BindBuffer(target, buffer); >+} >+ >+void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ GLuint fbo; >+ if (buffer) >+ fbo = buffer; >+ else >+ fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo); >+ if (fbo != m_state.boundFBO) { >+ gl::BindFramebuffer(target, fbo); >+ m_state.boundFBO = fbo; >+ } >+} >+ >+void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject renderbuffer) >+{ >+ makeContextCurrent(); >+ gl::BindRenderbuffer(target, renderbuffer); >+} >+ >+ >+void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture) >+{ >+ makeContextCurrent(); >+ m_state.setBoundTexture(m_state.activeTextureUnit, texture, target); >+ gl::BindTexture(target, texture); >+} >+ >+void GraphicsContext3D::blendColor(GC3Dclampf red, GC3Dclampf green, GC3Dclampf blue, GC3Dclampf alpha) >+{ >+ makeContextCurrent(); >+ gl::BlendColor(red, green, blue, alpha); >+} >+ >+void GraphicsContext3D::blendEquation(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ gl::BlendEquation(mode); >+} >+ >+void GraphicsContext3D::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha) >+{ >+ makeContextCurrent(); >+ gl::BlendEquationSeparate(modeRGB, modeAlpha); >+} >+ >+ >+void GraphicsContext3D::blendFunc(GC3Denum sfactor, GC3Denum dfactor) >+{ >+ makeContextCurrent(); >+ gl::BlendFunc(sfactor, dfactor); >+} >+ >+void GraphicsContext3D::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha) >+{ >+ makeContextCurrent(); >+ gl::BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); >+} >+ >+void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, GC3Denum usage) >+{ >+ makeContextCurrent(); >+ gl::BufferData(target, size, 0, usage); >+} >+ >+void GraphicsContext3D::bufferData(GC3Denum target, GC3Dsizeiptr size, const void* data, GC3Denum usage) >+{ >+ makeContextCurrent(); >+ gl::BufferData(target, size, data, usage); >+} >+ >+void GraphicsContext3D::bufferSubData(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr size, const void* data) >+{ >+ makeContextCurrent(); >+ gl::BufferSubData(target, offset, size, data); >+} >+ >+void* GraphicsContext3D::mapBufferRange(GC3Denum target, GC3Dintptr offset, GC3Dsizeiptr length, GC3Dbitfield access) >+{ >+ makeContextCurrent(); >+ return gl::MapBufferRange(target, offset, length, access); >+} >+ >+GC3Dboolean GraphicsContext3D::unmapBuffer(GC3Denum target) >+{ >+ makeContextCurrent(); >+ return gl::UnmapBuffer(target); >+} >+ >+void GraphicsContext3D::copyBufferSubData(GC3Denum readTarget, GC3Denum writeTarget, GC3Dintptr readOffset, GC3Dintptr writeOffset, GC3Dsizeiptr size) >+{ >+ makeContextCurrent(); >+ gl::CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size); >+} >+ >+void GraphicsContext3D::getInternalformativ(GC3Denum target, GC3Denum internalformat, GC3Denum pname, GC3Dsizei bufSize, GC3Dint* params) >+{ >+ makeContextCurrent(); >+ gl::GetInternalformativ(target, internalformat, pname, bufSize, params); >+} >+ >+void GraphicsContext3D::renderbufferStorageMultisample(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ gl::RenderbufferStorageMultisample(target, samples, internalformat, width, height); >+} >+ >+void GraphicsContext3D::texStorage2D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ gl::TexStorage2D(target, levels, internalformat, width, height); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::texStorage3D(GC3Denum target, GC3Dsizei levels, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dsizei depth) >+{ >+ makeContextCurrent(); >+ gl::TexStorage3D(target, levels, internalformat, width, height, depth); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::getActiveUniforms(Platform3DObject program, const Vector<GC3Duint>& uniformIndices, GC3Denum pname, Vector<GC3Dint>& params) >+{ >+ ASSERT(program); >+ makeContextCurrent(); >+ >+ gl::GetActiveUniformsiv(program, uniformIndices.size(), uniformIndices.data(), pname, params.data()); >+} >+ >+GC3Denum GraphicsContext3D::checkFramebufferStatus(GC3Denum target) >+{ >+ makeContextCurrent(); >+ return gl::CheckFramebufferStatus(target); >+} >+ >+void GraphicsContext3D::clearColor(GC3Dclampf r, GC3Dclampf g, GC3Dclampf b, GC3Dclampf a) >+{ >+ makeContextCurrent(); >+ gl::ClearColor(r, g, b, a); >+} >+ >+void GraphicsContext3D::clear(GC3Dbitfield mask) >+{ >+ makeContextCurrent(); >+ gl::Clear(mask); >+ checkGPUStatus(); >+} >+ >+void GraphicsContext3D::clearStencil(GC3Dint s) >+{ >+ makeContextCurrent(); >+ gl::ClearStencil(s); >+} >+ >+void GraphicsContext3D::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha) >+{ >+ makeContextCurrent(); >+ gl::ColorMask(red, green, blue, alpha); >+} >+ >+void GraphicsContext3D::compileShader(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ makeContextCurrent(); >+ >+ // Turn on name mapping. Due to the way ANGLE name hashing works, we >+ // point a global hashmap to the map owned by this context. >+ ShBuiltInResources ANGLEResources = m_compiler.getResources(); >+ ShHashFunction64 previousHashFunction = ANGLEResources.HashFunction; >+ ANGLEResources.HashFunction = nameHashForShader; >+ >+ if (!nameHashMapForShaders) >+ nameHashMapForShaders = std::make_unique<ShaderNameHash>(); >+ setCurrentNameHashMapForShader(nameHashMapForShaders.get()); >+ m_compiler.setResources(ANGLEResources); >+ >+ String translatedShaderSource = m_extensions->getTranslatedShaderSourceANGLE(shader); >+ >+ ANGLEResources.HashFunction = previousHashFunction; >+ m_compiler.setResources(ANGLEResources); >+ setCurrentNameHashMapForShader(nullptr); >+ >+ if (!translatedShaderSource.length()) >+ return; >+ >+ const CString& translatedShaderCString = translatedShaderSource.utf8(); >+ const char* translatedShaderPtr = translatedShaderCString.data(); >+ int translatedShaderLength = translatedShaderCString.length(); >+ >+ LOG(WebGL, "--- begin original shader source ---\n%s\n--- end original shader source ---\n", getShaderSource(shader).utf8().data()); >+ LOG(WebGL, "--- begin translated shader source ---\n%s\n--- end translated shader source ---", translatedShaderPtr); >+ >+ gl::ShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); >+ >+ ::glCompileShader(shader); >+ >+ int compileStatus; >+ >+ gl::GetShaderiv(shader, COMPILE_STATUS, &compileStatus); >+ >+ ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader); >+ GraphicsContext3D::ShaderSourceEntry& entry = result->value; >+ >+ // Populate the shader log >+ GLint length = 0; >+ gl::GetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); >+ >+ if (length) { >+ GLsizei size = 0; >+ Vector<GLchar> info(length); >+ gl::GetShaderInfoLog(shader, length, &size, info.data()); >+ >+ Platform3DObject shaders[2] = { shader, 0 }; >+ entry.log = getUnmangledInfoLog(shaders, 1, String(info.data(), size)); >+ } >+ >+ if (compileStatus != GL_TRUE) { >+ entry.isValid = false; >+ LOG(WebGL, "Error: shader translator produced a shader that OpenGL would not compile."); >+ } >+} >+ >+void GraphicsContext3D::compileShaderDirect(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ makeContextCurrent(); >+ >+ HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); >+ >+ if (result == m_shaderSourceMap.end()) >+ return; >+ >+ ShaderSourceEntry& entry = result->value; >+ >+ const CString& shaderSourceCString = entry.source.utf8(); >+ const char* shaderSourcePtr = shaderSourceCString.data(); >+ int shaderSourceLength = shaderSourceCString.length(); >+ >+ LOG(WebGL, "--- begin direct shader source ---\n%s\n--- end direct shader source ---\n", shaderSourcePtr); >+ >+ gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength); >+ >+ gl::CompileShader(shader); >+ >+ int compileStatus; >+ >+ gl::GetShaderiv(shader, COMPILE_STATUS, &compileStatus); >+ >+ if (compileStatus == GL_TRUE) { >+ entry.isValid = true; >+ LOG(WebGL, "Direct compilation of shader succeeded."); >+ } else { >+ entry.isValid = false; >+ LOG(WebGL, "Error: direct compilation of shader failed."); >+ } >+} >+ >+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) { >+ 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) >+ 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) { >+ 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) >+ gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); >+} >+ >+void GraphicsContext3D::cullFace(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ gl::CullFace(mode); >+} >+ >+void GraphicsContext3D::depthFunc(GC3Denum func) >+{ >+ makeContextCurrent(); >+ gl::DepthFunc(func); >+} >+ >+void GraphicsContext3D::depthMask(GC3Dboolean flag) >+{ >+ makeContextCurrent(); >+ gl::DepthMask(flag); >+} >+ >+void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject shader) >+{ >+ ASSERT(program); >+ ASSERT(shader); >+ makeContextCurrent(); >+ m_shaderProgramSymbolCountMap.remove(program); >+ gl::DetachShader(program, shader); >+} >+ >+void GraphicsContext3D::disable(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ gl::Disable(cap); >+} >+ >+void GraphicsContext3D::disableVertexAttribArray(GC3Duint index) >+{ >+ makeContextCurrent(); >+ gl::DisableVertexAttribArray(index); >+} >+ >+void GraphicsContext3D::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count) >+{ >+ makeContextCurrent(); >+ gl::DrawArrays(mode, first, count); >+ checkGPUStatus(); >+} >+ >+void GraphicsContext3D::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset) >+{ >+ makeContextCurrent(); >+ gl::DrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >+ checkGPUStatus(); >+} >+ >+void GraphicsContext3D::enable(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ gl::Enable(cap); >+} >+ >+void GraphicsContext3D::enableVertexAttribArray(GC3Duint index) >+{ >+ makeContextCurrent(); >+ gl::EnableVertexAttribArray(index); >+} >+ >+void GraphicsContext3D::finish() >+{ >+ makeContextCurrent(); >+ gl::Finish(); >+} >+ >+void GraphicsContext3D::flush() >+{ >+ makeContextCurrent(); >+ gl::Flush(); >+} >+ >+void GraphicsContext3D::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ gl::FramebufferRenderbuffer(target, attachment, renderbuffertarget, buffer); >+} >+ >+void GraphicsContext3D::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, Platform3DObject texture, GC3Dint level) >+{ >+ makeContextCurrent(); >+ gl::FramebufferTexture2D(target, attachment, textarget, texture, level); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::frontFace(GC3Denum mode) >+{ >+ makeContextCurrent(); >+ gl::FrontFace(mode); >+} >+ >+void GraphicsContext3D::generateMipmap(GC3Denum target) >+{ >+ makeContextCurrent(); >+ gl::GenerateMipmap(target); >+} >+ >+bool GraphicsContext3D::getActiveAttribImpl(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ if (!program) { >+ synthesizeGLError(INVALID_VALUE); >+ return false; >+ } >+ makeContextCurrent(); >+ GLint maxAttributeSize = 0; >+ gl::GetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); >+ Vector<GLchar> name(maxAttributeSize); // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination. >+ GLsizei nameLength = 0; >+ GLint size = 0; >+ GLenum type = 0; >+ gl::GetActiveAttrib(program, index, maxAttributeSize, &nameLength, &size, &type, name.data()); >+ if (!nameLength) >+ return false; >+ >+ String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, String(name.data(), nameLength)); >+ >+#ifndef NDEBUG >+ String uniformName(name.data(), nameLength); >+ LOG(WebGL, "Program %d is mapping active attribute %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data()); >+#endif >+ >+ info.name = originalName; >+ info.type = type; >+ info.size = size; >+ return true; >+} >+ >+bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ GC3Dint symbolCount; >+ auto result = m_shaderProgramSymbolCountMap.find(program); >+ if (result == m_shaderProgramSymbolCountMap.end()) { >+ getNonBuiltInActiveSymbolCount(program, GraphicsContext3D::ACTIVE_ATTRIBUTES, &symbolCount); >+ result = m_shaderProgramSymbolCountMap.find(program); >+ } >+ >+ ActiveShaderSymbolCounts& symbolCounts = result->value; >+ GC3Duint rawIndex = (index < symbolCounts.filteredToActualAttributeIndexMap.size()) ? symbolCounts.filteredToActualAttributeIndexMap[index] : -1; >+ >+ return getActiveAttribImpl(program, rawIndex, info); >+} >+ >+bool GraphicsContext3D::getActiveUniformImpl(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ if (!program) { >+ synthesizeGLError(INVALID_VALUE); >+ return false; >+ } >+ >+ makeContextCurrent(); >+ GLint maxUniformSize = 0; >+ gl::GetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); >+ >+ Vector<GLchar> name(maxUniformSize); // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination. >+ GLsizei nameLength = 0; >+ GLint size = 0; >+ GLenum type = 0; >+ gl::GetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.data()); >+ if (!nameLength) >+ return false; >+ >+ String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, String(name.data(), nameLength)); >+ >+#ifndef NDEBUG >+ String uniformName(name.data(), nameLength); >+ LOG(WebGL, "Program %d is mapping active uniform %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data()); >+#endif >+ >+ info.name = originalName; >+ info.type = type; >+ info.size = size; >+ return true; >+} >+ >+bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) >+{ >+ GC3Dint symbolCount; >+ auto result = m_shaderProgramSymbolCountMap.find(program); >+ if (result == m_shaderProgramSymbolCountMap.end()) { >+ getNonBuiltInActiveSymbolCount(program, GraphicsContext3D::ACTIVE_UNIFORMS, &symbolCount); >+ result = m_shaderProgramSymbolCountMap.find(program); >+ } >+ >+ ActiveShaderSymbolCounts& symbolCounts = result->value; >+ GC3Duint rawIndex = (index < symbolCounts.filteredToActualUniformIndexMap.size()) ? symbolCounts.filteredToActualUniformIndexMap[index] : -1; >+ >+ return getActiveUniformImpl(program, rawIndex, info); >+} >+ >+void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders) >+{ >+ if (!program) { >+ synthesizeGLError(INVALID_VALUE); >+ return; >+ } >+ makeContextCurrent(); >+ gl::GetAttachedShaders(program, maxCount, count, shaders); >+} >+ >+static String generateHashedName(const String& name) >+{ >+ if (name.isEmpty()) >+ return name; >+ uint64_t number = nameHashForShader(name.utf8().data(), name.length()); >+ StringBuilder builder; >+ builder.appendLiteral("webgl_"); >+ appendUnsignedAsHex(number, builder, Lowercase); >+ return builder.toString(); >+} >+ >+Optional<String> GraphicsContext3D::mappedSymbolInShaderSourceMap(Platform3DObject shader, ANGLEShaderSymbolType symbolType, const String& name) >+{ >+ auto result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return WTF::nullopt; >+ >+ const auto& symbolMap = result->value.symbolMap(symbolType); >+ auto symbolEntry = symbolMap.find(name); >+ if (symbolEntry == symbolMap.end()) >+ return WTF::nullopt; >+ >+ auto& mappedName = symbolEntry->value.mappedName; >+ return String(mappedName.c_str(), mappedName.length()); >+} >+ >+String GraphicsContext3D::mappedSymbolName(Platform3DObject program, ANGLEShaderSymbolType symbolType, const String& name) >+{ >+ GC3Dsizei count = 0; >+ Platform3DObject shaders[2] = { }; >+ getAttachedShaders(program, 2, &count, shaders); >+ >+ for (GC3Dsizei i = 0; i < count; ++i) { >+ auto mappedName = mappedSymbolInShaderSourceMap(shaders[i], symbolType, name); >+ if (mappedName) >+ return mappedName.value(); >+ } >+ >+ // We might have detached or deleted the shaders after linking. >+ auto result = m_linkedShaderMap.find(program); >+ if (result != m_linkedShaderMap.end()) { >+ auto linkedShaders = result->value; >+ auto mappedName = mappedSymbolInShaderSourceMap(linkedShaders.first, symbolType, name); >+ if (mappedName) >+ return mappedName.value(); >+ mappedName = mappedSymbolInShaderSourceMap(linkedShaders.second, symbolType, name); >+ if (mappedName) >+ return mappedName.value(); >+ } >+ >+ if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) { >+ // Attributes are a special case: they may be requested before any shaders have been compiled, >+ // and aren't even required to be used in any shader program. >+ if (!nameHashMapForShaders) >+ nameHashMapForShaders = std::make_unique<ShaderNameHash>(); >+ setCurrentNameHashMapForShader(nameHashMapForShaders.get()); >+ >+ auto generatedName = generateHashedName(name); >+ >+ setCurrentNameHashMapForShader(nullptr); >+ >+ m_possiblyUnusedAttributeMap.set(generatedName, name); >+ >+ return generatedName; >+ } >+ >+ return name; >+} >+ >+Optional<String> GraphicsContext3D::originalSymbolInShaderSourceMap(Platform3DObject shader, ANGLEShaderSymbolType symbolType, const String& name) >+{ >+ auto result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return WTF::nullopt; >+ >+ const auto& symbolMap = result->value.symbolMap(symbolType); >+ for (const auto& symbolEntry : symbolMap) { >+ if (name == symbolEntry.value.mappedName.c_str()) >+ return symbolEntry.key; >+ } >+ return WTF::nullopt; >+} >+ >+String GraphicsContext3D::originalSymbolName(Platform3DObject program, ANGLEShaderSymbolType symbolType, const String& name) >+{ >+ GC3Dsizei count; >+ Platform3DObject shaders[2]; >+ getAttachedShaders(program, 2, &count, shaders); >+ >+ for (GC3Dsizei i = 0; i < count; ++i) { >+ auto originalName = originalSymbolInShaderSourceMap(shaders[i], symbolType, name); >+ if (originalName) >+ return originalName.value(); >+ } >+ >+ // We might have detached or deleted the shaders after linking. >+ auto result = m_linkedShaderMap.find(program); >+ if (result != m_linkedShaderMap.end()) { >+ auto linkedShaders = result->value; >+ auto originalName = originalSymbolInShaderSourceMap(linkedShaders.first, symbolType, name); >+ if (originalName) >+ return originalName.value(); >+ originalName = originalSymbolInShaderSourceMap(linkedShaders.second, symbolType, name); >+ if (originalName) >+ return originalName.value(); >+ } >+ >+ if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) { >+ // Attributes are a special case: they may be requested before any shaders have been compiled, >+ // and aren't even required to be used in any shader program. >+ >+ const auto& cached = m_possiblyUnusedAttributeMap.find(name); >+ if (cached != m_possiblyUnusedAttributeMap.end()) >+ return cached->value; >+ } >+ >+ return name; >+} >+ >+String GraphicsContext3D::mappedSymbolName(Platform3DObject shaders[2], size_t count, const String& name) >+{ >+ for (size_t symbolType = 0; symbolType <= static_cast<size_t>(SHADER_SYMBOL_TYPE_VARYING); ++symbolType) { >+ for (size_t i = 0; i < count; ++i) { >+ ShaderSourceMap::iterator result = m_shaderSourceMap.find(shaders[i]); >+ if (result == m_shaderSourceMap.end()) >+ continue; >+ >+ const ShaderSymbolMap& symbolMap = result->value.symbolMap(static_cast<enum ANGLEShaderSymbolType>(symbolType)); >+ for (const auto& symbolEntry : symbolMap) { >+ if (name == symbolEntry.value.mappedName.c_str()) >+ return symbolEntry.key; >+ } >+ } >+ } >+ return name; >+} >+ >+int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name) >+{ >+ if (!program) >+ return -1; >+ >+ makeContextCurrent(); >+ >+ String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name); >+ LOG(WebGL, "gl::GetAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); >+ return gl::GetAttribLocation(program, mappedName.utf8().data()); >+} >+ >+int GraphicsContext3D::getAttribLocationDirect(Platform3DObject program, const String& name) >+{ >+ if (!program) >+ return -1; >+ >+ makeContextCurrent(); >+ >+ return gl::GetAttribLocation(program, name.utf8().data()); >+} >+ >+GraphicsContext3DAttributes GraphicsContext3D::getContextAttributes() >+{ >+ return m_attrs; >+} >+ >+bool GraphicsContext3D::moveErrorsToSyntheticErrorList() >+{ >+ makeContextCurrent(); >+ bool movedAnError = false; >+ >+ // Set an arbitrary limit of 100 here to avoid creating a hang if >+ // a problem driver has a bug that causes it to never clear the error. >+ // Otherwise, we would just loop until we got NO_ERROR. >+ for (unsigned i = 0; i < 100; ++i) { >+ GC3Denum error = glGetError(); >+ if (error == NO_ERROR) >+ break; >+ m_syntheticErrors.add(error); >+ movedAnError = true; >+ } >+ >+ return movedAnError; >+} >+ >+GC3Denum GraphicsContext3D::getError() >+{ >+ if (!m_syntheticErrors.isEmpty()) { >+ // Need to move the current errors to the synthetic error list in case >+ // that error is already there, since the expected behavior of both >+ // glGetError and getError is to only report each error code once. >+ moveErrorsToSyntheticErrorList(); >+ return m_syntheticErrors.takeFirst(); >+ } >+ >+ makeContextCurrent(); >+ return gl::GetError(); >+} >+ >+String GraphicsContext3D::getString(GC3Denum name) >+{ >+ makeContextCurrent(); >+ return String(reinterpret_cast<const char*>(gl::GetString(name))); >+} >+ >+void GraphicsContext3D::hint(GC3Denum target, GC3Denum mode) >+{ >+ makeContextCurrent(); >+ gl::Hint(target, mode); >+} >+ >+GC3Dboolean GraphicsContext3D::isBuffer(Platform3DObject buffer) >+{ >+ if (!buffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsBuffer(buffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isEnabled(GC3Denum cap) >+{ >+ makeContextCurrent(); >+ return gl::IsEnabled(cap); >+} >+ >+GC3Dboolean GraphicsContext3D::isFramebuffer(Platform3DObject framebuffer) >+{ >+ if (!framebuffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsFramebuffer(framebuffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isProgram(Platform3DObject program) >+{ >+ if (!program) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsProgram(program); >+} >+ >+GC3Dboolean GraphicsContext3D::isRenderbuffer(Platform3DObject renderbuffer) >+{ >+ if (!renderbuffer) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsRenderbuffer(renderbuffer); >+} >+ >+GC3Dboolean GraphicsContext3D::isShader(Platform3DObject shader) >+{ >+ if (!shader) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsShader(shader); >+} >+ >+GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture) >+{ >+ if (!texture) >+ return GL_FALSE; >+ >+ makeContextCurrent(); >+ return gl::IsTexture(texture); >+} >+ >+void GraphicsContext3D::lineWidth(GC3Dfloat width) >+{ >+ makeContextCurrent(); >+ gl::LineWidth(width); >+} >+ >+void GraphicsContext3D::linkProgram(Platform3DObject program) >+{ >+ ASSERT(program); >+ makeContextCurrent(); >+ >+ GC3Dsizei count = 0; >+ Platform3DObject shaders[2] = { }; >+ getAttachedShaders(program, 2, &count, shaders); >+ >+ if (count == 2) >+ m_linkedShaderMap.set(program, std::make_pair(shaders[0], shaders[1])); >+ >+ gl::LinkProgram(program); >+} >+ >+void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param) >+{ >+ makeContextCurrent(); >+ gl::PixelStorei(pname, param); >+} >+ >+void GraphicsContext3D::polygonOffset(GC3Dfloat factor, GC3Dfloat units) >+{ >+ makeContextCurrent(); >+ gl::PolygonOffset(factor, units); >+} >+ >+void GraphicsContext3D::sampleCoverage(GC3Dclampf value, GC3Dboolean invert) >+{ >+ makeContextCurrent(); >+ gl::SampleCoverage(value, invert); >+} >+ >+void GraphicsContext3D::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ gl::Scissor(x, y, width, height); >+} >+ >+void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& string) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ ShaderSourceEntry entry; >+ >+ entry.source = string; >+ >+ m_shaderSourceMap.set(shader, entry); >+} >+ >+void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ gl::StencilFunc(func, ref, mask); >+} >+ >+void GraphicsContext3D::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ gl::StencilFuncSeparate(face, func, ref, mask); >+} >+ >+void GraphicsContext3D::stencilMask(GC3Duint mask) >+{ >+ makeContextCurrent(); >+ gl::StencilMask(mask); >+} >+ >+void GraphicsContext3D::stencilMaskSeparate(GC3Denum face, GC3Duint mask) >+{ >+ makeContextCurrent(); >+ gl::StencilMaskSeparate(face, mask); >+} >+ >+void GraphicsContext3D::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >+{ >+ makeContextCurrent(); >+ gl::StencilOp(fail, zfail, zpass); >+} >+ >+void GraphicsContext3D::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass) >+{ >+ makeContextCurrent(); >+ gl::StencilOpSeparate(face, fail, zfail, zpass); >+} >+ >+void GraphicsContext3D::texParameterf(GC3Denum target, GC3Denum pname, GC3Dfloat value) >+{ >+ makeContextCurrent(); >+ gl::TexParameterf(target, pname, value); >+} >+ >+void GraphicsContext3D::texParameteri(GC3Denum target, GC3Denum pname, GC3Dint value) >+{ >+ makeContextCurrent(); >+ gl::TexParameteri(target, pname, value); >+} >+ >+void GraphicsContext3D::uniform1f(GC3Dint location, GC3Dfloat v0) >+{ >+ makeContextCurrent(); >+ gl::Uniform1f(location, v0); >+} >+ >+void GraphicsContext3D::uniform1fv(GC3Dint location, GC3Dsizei size, const GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ gl::Uniform1fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform2f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1) >+{ >+ makeContextCurrent(); >+ gl::Uniform2f(location, v0, v1); >+} >+ >+void GraphicsContext3D::uniform2fv(GC3Dint location, GC3Dsizei size, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 2. >+ makeContextCurrent(); >+ gl::Uniform2fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform3f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >+{ >+ makeContextCurrent(); >+ gl::Uniform3f(location, v0, v1, v2); >+} >+ >+void GraphicsContext3D::uniform3fv(GC3Dint location, GC3Dsizei size, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 3. >+ makeContextCurrent(); >+ gl::Uniform3fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform4f(GC3Dint location, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >+{ >+ makeContextCurrent(); >+ gl::Uniform4f(location, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::uniform4fv(GC3Dint location, GC3Dsizei size, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 4. >+ makeContextCurrent(); >+ gl::Uniform4fv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform1i(GC3Dint location, GC3Dint v0) >+{ >+ makeContextCurrent(); >+ gl::Uniform1i(location, v0); >+} >+ >+void GraphicsContext3D::uniform1iv(GC3Dint location, GC3Dsizei size, const GC3Dint* array) >+{ >+ makeContextCurrent(); >+ gl::Uniform1iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform2i(GC3Dint location, GC3Dint v0, GC3Dint v1) >+{ >+ makeContextCurrent(); >+ gl::Uniform2i(location, v0, v1); >+} >+ >+void GraphicsContext3D::uniform2iv(GC3Dint location, GC3Dsizei size, const GC3Dint* array) >+{ >+ // FIXME: length needs to be a multiple of 2. >+ makeContextCurrent(); >+ gl::Uniform2iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform3i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2) >+{ >+ makeContextCurrent(); >+ gl::Uniform3i(location, v0, v1, v2); >+} >+ >+void GraphicsContext3D::uniform3iv(GC3Dint location, GC3Dsizei size, const GC3Dint* array) >+{ >+ // FIXME: length needs to be a multiple of 3. >+ makeContextCurrent(); >+ gl::Uniform3iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniform4i(GC3Dint location, GC3Dint v0, GC3Dint v1, GC3Dint v2, GC3Dint v3) >+{ >+ makeContextCurrent(); >+ gl::Uniform4i(location, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::uniform4iv(GC3Dint location, GC3Dsizei size, const GC3Dint* array) >+{ >+ // FIXME: length needs to be a multiple of 4. >+ makeContextCurrent(); >+ gl::Uniform4iv(location, size, array); >+} >+ >+void GraphicsContext3D::uniformMatrix2fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 4. >+ makeContextCurrent(); >+ gl::UniformMatrix2fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::uniformMatrix3fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 9. >+ makeContextCurrent(); >+ gl::UniformMatrix3fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::uniformMatrix4fv(GC3Dint location, GC3Dsizei size, GC3Dboolean transpose, const GC3Dfloat* array) >+{ >+ // FIXME: length needs to be a multiple of 16. >+ makeContextCurrent(); >+ gl::UniformMatrix4fv(location, size, transpose, array); >+} >+ >+void GraphicsContext3D::useProgram(Platform3DObject program) >+{ >+ makeContextCurrent(); >+ gl::UseProgram(program); >+} >+ >+void GraphicsContext3D::validateProgram(Platform3DObject program) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ gl::ValidateProgram(program); >+} >+ >+void GraphicsContext3D::vertexAttrib1f(GC3Duint index, GC3Dfloat v0) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib1f(index, v0); >+} >+ >+void GraphicsContext3D::vertexAttrib1fv(GC3Duint index, const GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib1fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib2f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib2f(index, v0, v1); >+} >+ >+void GraphicsContext3D::vertexAttrib2fv(GC3Duint index, const GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib2fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib3f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib3f(index, v0, v1, v2); >+} >+ >+void GraphicsContext3D::vertexAttrib3fv(GC3Duint index, const GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib3fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttrib4f(GC3Duint index, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib4f(index, v0, v1, v2, v3); >+} >+ >+void GraphicsContext3D::vertexAttrib4fv(GC3Duint index, const GC3Dfloat* array) >+{ >+ makeContextCurrent(); >+ gl::VertexAttrib4fv(index, array); >+} >+ >+void GraphicsContext3D::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, GC3Dintptr offset) >+{ >+ makeContextCurrent(); >+ gl::VertexAttribPointer(index, size, type, normalized, stride, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset))); >+} >+ >+void GraphicsContext3D::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height) >+{ >+ makeContextCurrent(); >+ gl::Viewport(x, y, width, height); >+} >+ >+Platform3DObject GraphicsContext3D::createVertexArray() >+{ >+ makeContextCurrent(); >+ GLuint array = 0; >+ gl::GenVertexArrays(1, &array); >+ return array; >+} >+ >+void GraphicsContext3D::deleteVertexArray(Platform3DObject array) >+{ >+ if (!array) >+ return; >+ makeContextCurrent(); >+ gl::DeleteVertexArrays(1, &array); >+} >+ >+GC3Dboolean GraphicsContext3D::isVertexArray(Platform3DObject array) >+{ >+ if (!array) >+ return GL_FALSE; >+ makeContextCurrent(); >+ return gl::IsVertexArray(array); >+} >+ >+void GraphicsContext3D::bindVertexArray(Platform3DObject array) >+{ >+ makeContextCurrent(); >+ gl::BindVertexArray(array); >+} >+ >+void GraphicsContext3D::getBooleanv(GC3Denum pname, GC3Dboolean* value) >+{ >+ makeContextCurrent(); >+ gl::GetBooleanv(pname, value); >+} >+ >+void GraphicsContext3D::getBufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetBufferParameteriv(target, pname, value); >+} >+ >+void GraphicsContext3D::getFloatv(GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ gl::GetFloatv(pname, value); >+} >+ >+void GraphicsContext3D::getInteger64v(GC3Denum pname, GC3Dint64* value) >+{ >+ UNUSED_PARAM(pname); >+ makeContextCurrent(); >+ *value = 0; >+ // FIXME 141178: Before enabling this we must first switch over to using gl3.h and creating and initialing the WebGL2 context using OpenGL ES 3.0. >+ // gl::GetInteger64v(pname, value); >+} >+ >+void GraphicsContext3D::getFramebufferAttachmentParameteriv(GC3Denum target, GC3Denum attachment, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ if (attachment == DEPTH_STENCIL_ATTACHMENT) >+ attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works. >+ gl::GetFramebufferAttachmentParameteriv(target, attachment, pname, value); >+} >+ >+void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetProgramiv(program, pname, value); >+} >+ >+void GraphicsContext3D::getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value) >+{ >+ ASSERT(ACTIVE_ATTRIBUTES == pname || ACTIVE_UNIFORMS == pname); >+ if (!value) >+ return; >+ >+ makeContextCurrent(); >+ const auto& result = m_shaderProgramSymbolCountMap.find(program); >+ if (result != m_shaderProgramSymbolCountMap.end()) { >+ *value = result->value.countForType(pname); >+ return; >+ } >+ >+ m_shaderProgramSymbolCountMap.set(program, ActiveShaderSymbolCounts()); >+ ActiveShaderSymbolCounts& symbolCounts = m_shaderProgramSymbolCountMap.find(program)->value; >+ >+ // Retrieve the active attributes, build a filtered count, and a mapping of >+ // our internal attributes indexes to the real unfiltered indexes inside OpenGL. >+ GC3Dint attributeCount = 0; >+ gl::GetProgramiv(program, ACTIVE_ATTRIBUTES, &attributeCount); >+ for (GC3Dint i = 0; i < attributeCount; ++i) { >+ ActiveInfo info; >+ getActiveAttribImpl(program, i, info); >+ if (info.name.startsWith("gl_")) >+ continue; >+ >+ symbolCounts.filteredToActualAttributeIndexMap.append(i); >+ } >+ >+ // Do the same for uniforms. >+ GC3Dint uniformCount = 0; >+ gl::GetProgramiv(program, ACTIVE_UNIFORMS, &uniformCount); >+ for (GC3Dint i = 0; i < uniformCount; ++i) { >+ ActiveInfo info; >+ getActiveUniformImpl(program, i, info); >+ if (info.name.startsWith("gl_")) >+ continue; >+ >+ symbolCounts.filteredToActualUniformIndexMap.append(i); >+ } >+ >+ *value = symbolCounts.countForType(pname); >+} >+ >+String GraphicsContext3D::getUnmangledInfoLog(Platform3DObject shaders[2], GC3Dsizei count, const String& log) >+{ >+ LOG(WebGL, "Original ShaderInfoLog:\n%s", log.utf8().data()); >+ >+ JSC::Yarr::RegularExpression regExp("webgl_[0123456789abcdefABCDEF]+"); >+ >+ StringBuilder processedLog; >+ >+ // ANGLE inserts a "#extension" line into the shader source that >+ // causes a warning in some compilers. There is no point showing >+ // this warning to the user since they didn't write the code that >+ // is causing it. >+ static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s }; >+ int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0; >+ int matchedLength = 0; >+ >+ do { >+ int start = regExp.match(log, startFrom, &matchedLength); >+ if (start == -1) >+ break; >+ >+ processedLog.append(log.substring(startFrom, start - startFrom)); >+ startFrom = start + matchedLength; >+ >+ const String& mangledSymbol = log.substring(start, matchedLength); >+ const String& mappedSymbol = mappedSymbolName(shaders, count, mangledSymbol); >+ LOG(WebGL, "Demangling: %s to %s", mangledSymbol.utf8().data(), mappedSymbol.utf8().data()); >+ processedLog.append(mappedSymbol); >+ } while (startFrom < static_cast<int>(log.length())); >+ >+ processedLog.append(log.substring(startFrom, log.length() - startFrom)); >+ >+ LOG(WebGL, "Unmangled ShaderInfoLog:\n%s", processedLog.toString().utf8().data()); >+ return processedLog.toString(); >+} >+ >+String GraphicsContext3D::getProgramInfoLog(Platform3DObject program) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ GLint length = 0; >+ gl::GetProgramiv(program, GL_INFO_LOG_LENGTH, &length); >+ if (!length) >+ return String(); >+ >+ GLsizei size = 0; >+ Vector<GLchar> info(length); >+ gl::GetProgramInfoLog(program, length, &size, info.data()); >+ >+ GC3Dsizei count; >+ Platform3DObject shaders[2]; >+ getAttachedShaders(program, 2, &count, shaders); >+ >+ return getUnmangledInfoLog(shaders, count, String(info.data(), size)); >+} >+ >+void GraphicsContext3D::getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetRenderbufferParameteriv(target, pname, value); >+} >+ >+void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3Dint* value) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ const auto& result = m_shaderSourceMap.find(shader); >+ >+ switch (pname) { >+ case DELETE_STATUS: >+ case SHADER_TYPE: >+ gl::GetShaderiv(shader, pname, value); >+ break; >+ case COMPILE_STATUS: >+ if (result == m_shaderSourceMap.end()) { >+ *value = static_cast<int>(false); >+ return; >+ } >+ *value = static_cast<int>(result->value.isValid); >+ break; >+ case INFO_LOG_LENGTH: >+ if (result == m_shaderSourceMap.end()) { >+ *value = 0; >+ return; >+ } >+ *value = getShaderInfoLog(shader).length(); >+ break; >+ case SHADER_SOURCE_LENGTH: >+ *value = getShaderSource(shader).length(); >+ break; >+ default: >+ synthesizeGLError(INVALID_ENUM); >+ } >+} >+ >+String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ const auto& result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return String(); >+ >+ const ShaderSourceEntry& entry = result->value; >+ if (!entry.isValid) >+ return entry.log; >+ >+ GLint length = 0; >+ gl::GetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); >+ if (!length) >+ return String(); >+ >+ GLsizei size = 0; >+ Vector<GLchar> info(length); >+ gl::GetShaderInfoLog(shader, length, &size, info.data()); >+ >+ Platform3DObject shaders[2] = { shader, 0 }; >+ return getUnmangledInfoLog(shaders, 1, String(info.data(), size)); >+} >+ >+String GraphicsContext3D::getShaderSource(Platform3DObject shader) >+{ >+ ASSERT(shader); >+ >+ makeContextCurrent(); >+ >+ const auto& result = m_shaderSourceMap.find(shader); >+ if (result == m_shaderSourceMap.end()) >+ return String(); >+ >+ return result->value.source; >+} >+ >+ >+void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ gl::GetTexParameterfv(target, pname, value); >+} >+ >+void GraphicsContext3D::getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetTexParameteriv(target, pname, value); >+} >+ >+void GraphicsContext3D::getUniformfv(Platform3DObject program, GC3Dint location, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ gl::GetUniformfv(program, location, value); >+} >+ >+void GraphicsContext3D::getUniformiv(Platform3DObject program, GC3Dint location, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetUniformiv(program, location, value); >+} >+ >+GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name) >+{ >+ ASSERT(program); >+ >+ makeContextCurrent(); >+ >+ String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, name); >+ LOG(WebGL, "::getUniformLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); >+ return gl::GetUniformLocation(program, mappedName.utf8().data()); >+} >+ >+void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value) >+{ >+ makeContextCurrent(); >+ gl::GetVertexAttribfv(index, pname, value); >+} >+ >+void GraphicsContext3D::getVertexAttribiv(GC3Duint index, GC3Denum pname, GC3Dint* value) >+{ >+ makeContextCurrent(); >+ gl::GetVertexAttribiv(index, pname, value); >+} >+ >+GC3Dsizeiptr GraphicsContext3D::getVertexAttribOffset(GC3Duint index, GC3Denum pname) >+{ >+ makeContextCurrent(); >+ >+ GLvoid* pointer = 0; >+ gl::GetVertexAttribPointerv(index, pname, &pointer); >+ return static_cast<GC3Dsizeiptr>(reinterpret_cast<intptr_t>(pointer)); >+} >+ >+void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoff, GC3Dint yoff, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ makeContextCurrent(); >+ >+ // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size. >+ gl::TexSubImage2D(target, level, xoff, yoff, width, height, format, type, pixels); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Dsizei imageSize, const void* data) >+{ >+ makeContextCurrent(); >+ gl::CompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Dsizei imageSize, const void* data) >+{ >+ makeContextCurrent(); >+ gl::CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+Platform3DObject GraphicsContext3D::createBuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenBuffers(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createFramebuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenFramebuffers(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createProgram() >+{ >+ makeContextCurrent(); >+ return glCreateProgram(); >+} >+ >+Platform3DObject GraphicsContext3D::createRenderbuffer() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenRenderbuffers(1, &o); >+ return o; >+} >+ >+Platform3DObject GraphicsContext3D::createShader(GC3Denum type) >+{ >+ makeContextCurrent(); >+ return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); >+} >+ >+Platform3DObject GraphicsContext3D::createTexture() >+{ >+ makeContextCurrent(); >+ GLuint o = 0; >+ glGenTextures(1, &o); >+ m_state.textureSeedCount.add(o); >+ return o; >+} >+ >+void GraphicsContext3D::deleteBuffer(Platform3DObject buffer) >+{ >+ makeContextCurrent(); >+ glDeleteBuffers(1, &buffer); >+} >+ >+void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer) >+{ >+ makeContextCurrent(); >+ if (framebuffer == m_state.boundFBO) { >+ // Make sure the framebuffer is not going to be used for drawing >+ // operations after it gets deleted. >+ bindFramebuffer(FRAMEBUFFER, 0); >+ } >+ glDeleteFramebuffers(1, &framebuffer); >+} >+ >+void GraphicsContext3D::deleteProgram(Platform3DObject program) >+{ >+ makeContextCurrent(); >+ m_shaderProgramSymbolCountMap.remove(program); >+ glDeleteProgram(program); >+} >+ >+void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer) >+{ >+ makeContextCurrent(); >+ glDeleteRenderbuffers(1, &renderbuffer); >+} >+ >+void GraphicsContext3D::deleteShader(Platform3DObject shader) >+{ >+ makeContextCurrent(); >+ glDeleteShader(shader); >+} >+ >+void GraphicsContext3D::deleteTexture(Platform3DObject texture) >+{ >+ makeContextCurrent(); >+ m_state.boundTextureMap.removeIf([texture] (auto& keyValue) { >+ return keyValue.value.first == texture; >+ }); >+ glDeleteTextures(1, &texture); >+ m_state.textureSeedCount.removeAll(texture); >+} >+ >+void GraphicsContext3D::synthesizeGLError(GC3Denum error) >+{ >+ // Need to move the current errors to the synthetic error list to >+ // preserve the order of errors, so a caller to getError will get >+ // any errors from glError before the error we are synthesizing. >+ moveErrorsToSyntheticErrorList(); >+ m_syntheticErrors.add(error); >+} >+ >+void GraphicsContext3D::markContextChanged() >+{ >+ m_layerComposited = false; >+} >+ >+void GraphicsContext3D::markLayerComposited() >+{ >+ m_layerComposited = true; >+ >+ for (auto* client : copyToVector(m_clients)) >+ client->didComposite(); >+} >+ >+bool GraphicsContext3D::layerComposited() const >+{ >+ return m_layerComposited; >+} >+ >+void GraphicsContext3D::forceContextLost() >+{ >+ for (auto* client : copyToVector(m_clients)) >+ client->forceContextLost(); >+} >+ >+void GraphicsContext3D::recycleContext() >+{ >+ for (auto* client : copyToVector(m_clients)) >+ client->recycleContext(); >+} >+ >+void GraphicsContext3D::dispatchContextChangedNotification() >+{ >+ for (auto* client : copyToVector(m_clients)) >+ client->dispatchContextChangedNotification(); >+} >+ >+void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels) >+{ >+ makeContextCurrent(); >+ gl::TexImage2D(target, level, internalformat, width, height, border, format, type, pixels); >+ m_state.textureSeedCount.add(m_state.currentBoundTexture()); >+} >+ >+void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) >+{ >+ getExtensions().drawArraysInstanced(mode, first, count, primcount); >+ checkGPUStatus(); >+} >+ >+void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) >+{ >+ getExtensions().drawElementsInstanced(mode, count, type, offset, primcount); >+ checkGPUStatus(); >+} >+ >+void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor) >+{ >+ getExtensions().vertexAttribDivisor(index, divisor); >+} >+ >+} >+ >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >diff --git a/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.cpp b/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..bb958da02a0d64f9d432d3bbbc1f9fada4e8bf2b >--- /dev/null >+++ b/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.cpp >@@ -0,0 +1,63 @@ >+/* >+ * Copyright (C) 2013 Apple Inc. All rights reserved. >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >+#include "TemporaryANGLESetting.h" >+ >+#include <ANGLE/entry_points_gles_2_0_autogen.h> >+ >+namespace WebCore { >+ >+TemporaryANGLESetting::TemporaryANGLESetting(GLenum capability, GLenum scopedState) >+ : m_capability(capability) >+ , m_scopedState(scopedState) >+{ >+ m_originalState = gl::IsEnabled(m_capability); >+ if (m_originalState == m_scopedState) >+ return; >+ >+ if (GL_TRUE == m_scopedState) >+ gl::Enable(m_capability); >+ else >+ gl::Disable(m_capability); >+} >+ >+TemporaryANGLESetting::~TemporaryANGLESetting() >+{ >+ if (m_originalState == m_scopedState) >+ return; >+ >+ if (GL_TRUE == m_originalState) >+ gl::Enable(m_capability); >+ else >+ gl::Disable(m_capability); >+} >+ >+} >+ >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && USE(ANGLE) >diff --git a/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.h b/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8f6cfe1eee90cccb5ed171862e9cfb1448c818ce >--- /dev/null >+++ b/Source/WebCore/platform/graphics/angle/TemporaryANGLESetting.h >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2013 Apple Inc. All rights reserved. >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "GraphicsTypes3D.h" >+ >+#include <wtf/Noncopyable.h> >+ >+namespace WebCore { >+ >+// TemporaryANGLESetting<> is useful for temporarily disabling (or enabling) a particular OpenGL >+// feature with a particular scope. A TemporaryANGLESetting<> object returns the flag to its original >+// value upon destruction, making it an alternative to checking, clearing, and resetting each flag >+// at all of a block's exit points. >+// >+// Based on WTF::SetForScope<> >+ >+class TemporaryANGLESetting { >+ WTF_MAKE_NONCOPYABLE(TemporaryANGLESetting); >+public: >+ TemporaryANGLESetting(GC3Denum capability, GC3Denum scopedState); >+ ~TemporaryANGLESetting(); >+ >+private: >+ const GC3Denum m_capability; >+ const GC3Denum m_scopedState; >+ GC3Denum m_originalState; >+}; >+ >+} >+ >+using WebCore::TemporaryANGLESetting; >diff --git a/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm b/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >index 77c5d6ca67c628ab49671de14b96faa77e299cda..2defba242747635016d4cb1006aaf32a6a4df702 100644 >--- a/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm >@@ -28,12 +28,11 @@ > #if ENABLE(GRAPHICS_CONTEXT_3D) > #import "GraphicsContext3D.h" > >-#if PLATFORM(IOS_FAMILY) >+#if PLATFORM(IOS_FAMILY) && !USE(ANGLE) > #import "GraphicsContext3DIOS.h" > #endif > > #import "CanvasRenderingContext.h" >-#import "Extensions3DOpenGL.h" > #import "GraphicsContext.h" > #import "GraphicsContext3DManager.h" > #import "HTMLCanvasElement.h" >@@ -56,10 +55,18 @@ > #import <OpenGLES/ES2/glext.h> > #import <QuartzCore/QuartzCore.h> > #import <pal/spi/ios/OpenGLESSPI.h> >-#else >+#elif USE(OPENGL) > #import <IOKit/IOKitLib.h> > #import <OpenGL/CGLRenderers.h> > #import <OpenGL/gl.h> >+#elif USE(ANGLE) >+#include <ANGLE/entry_points_gles_2_0_autogen.h> >+#endif >+ >+#if USE(OPENGL_ES) || USE(OPENGL) >+#include "Extensions3DOpenGL.h" >+#elif USE(ANGLE) >+#include "Extensions3DANGLE.h" > #endif > > #if PLATFORM(MAC) >@@ -161,7 +168,7 @@ Ref<GraphicsContext3D> GraphicsContext3D::createShared(GraphicsContext3D& shared > return context; > } > >-#if PLATFORM(MAC) >+#if PLATFORM(MAC) && USE(OPENGL) > > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 > static void setGPUByRegistryID(PlatformGraphicsContext3D contextObj, CGLPixelFormatObj pixelFormatObj, IORegistryGPUID preferredGPUID) >@@ -240,12 +247,18 @@ static void setGPUByDisplayMask(PlatformGraphicsContext3D contextObj, CGLPixelFo > } > #endif > >-#endif // !PLATFORM(MAC) >+#endif // PLATFORM(MAC) && USE(OPENGL) > > GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext) > : m_attrs(attrs) > , m_private(std::make_unique<GraphicsContext3DPrivate>(this)) > { >+#if USE(ANGLE) >+ if (m_attrs.isWebGL2) >+ m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC); >+ else >+ m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT); >+#else > #if PLATFORM(IOS_FAMILY) > if (m_attrs.isWebGL2) > m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC); >@@ -254,7 +267,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > #else > if (m_attrs.isWebGL2) > m_compiler = ANGLEWebKitBridge(SH_GLSL_410_CORE_OUTPUT, SH_WEBGL2_SPEC); >-#endif >+#endif // PLATFORM(IOS_FAMILY) >+#endif // USE(ANGLE) > > #if USE(OPENGL_ES) > UNUSED_PARAM(hostWindow); >@@ -267,7 +281,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > > if (m_attrs.isWebGL2) > ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX); >-#else >+#elif USE(OPENGL) > Vector<CGLPixelFormatAttribute> attribs; > CGLPixelFormatObj pixelFormatObj = 0; > GLint numPixelFormats = 0; >@@ -353,7 +367,13 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > if (m_isForWebGL2) > ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART); > >-#endif // !USE(OPENGL_ES) >+#elif USE(ANGLE) >+ >+ // FIXME: implement context setup via ANGLE. >+ UNUSED_PARAM(hostWindow); >+ UNUSED_PARAM(sharedContext); >+ >+#endif > > validateAttributes(); > >@@ -373,7 +393,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > // Create the texture that will be used for the framebuffer. > #if USE(OPENGL_ES) > ::glGenRenderbuffers(1, &m_texture); >-#else >+#elif USE(OPENGL) > ::glGenTextures(1, &m_texture); > // We bind to GL_TEXTURE_RECTANGLE_EXT rather than TEXTURE_2D because > // that's what is required for a texture backed by IOSurface. >@@ -383,8 +403,13 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > ::glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); > ::glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); > ::glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0); >+#elif USE(ANGLE) >+ // FIXME: implement back buffer setup via ANGLE. >+#else >+#error Unsupported configuration > #endif > >+#if USE(OPENGL) || USE(OPENGL_ES) > // Create the framebuffer object. > ::glGenFramebuffersEXT(1, &m_fbo); > ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); >@@ -402,7 +427,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > if (m_attrs.stencil || m_attrs.depth) > ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer); > } >- >+#endif // USE(ANGLE) || USE(OPENGL_ES) >+ > // ANGLE initialization. > > ShBuiltInResources ANGLEResources; >@@ -431,7 +457,9 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind > ::glEnable(GL_POINT_SPRITE); > #endif > >+#if USE(OPENGL) || USE(OPENGL_ES) > ::glClearColor(0, 0, 0, 0); >+#endif > > LOG(WebGL, "Created a GraphicsContext3D (%p).", this); > } >@@ -445,10 +473,14 @@ GraphicsContext3D::~GraphicsContext3D() > makeContextCurrent(); > [m_contextObj renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil]; > ::glDeleteRenderbuffers(1, &m_texture); >-#else >+#elif USE(OPENGL) > CGLSetCurrentContext(m_contextObj); > ::glDeleteTextures(1, &m_texture); >+#elif USE(ANGLE) >+ // FIXME: make context current via ANGLE. > #endif >+ >+#if USE(OPENGL) || USE(OPENGL_ES) > if (m_attrs.antialias) { > ::glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer); > if (m_attrs.stencil || m_attrs.depth) >@@ -459,12 +491,16 @@ GraphicsContext3D::~GraphicsContext3D() > ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer); > } > ::glDeleteFramebuffersEXT(1, &m_fbo); >+#endif >+ > #if USE(OPENGL_ES) > [EAGLContext setCurrentContext:0]; > [static_cast<EAGLContext*>(m_contextObj) release]; >-#else >+#elif USE(OPENGL) > CGLSetCurrentContext(0); > CGLDestroyContext(m_contextObj); >+#elif USE(ANGLE) >+ // FIXME: implement context teardown via ANGLE. > #endif > [m_webGLLayer setContext:nullptr]; > } >@@ -496,10 +532,12 @@ bool GraphicsContext3D::makeContextCurrent() > #if USE(OPENGL_ES) > if ([EAGLContext currentContext] != m_contextObj) > return [EAGLContext setCurrentContext:static_cast<EAGLContext*>(m_contextObj)]; >-#else >+#elif USE(OPENGL) > CGLContextObj currentContext = CGLGetCurrentContext(); > if (currentContext != m_contextObj) > return CGLSetCurrentContext(m_contextObj) == kCGLNoError; >+#elif USE(ANGLE) >+ // FIXME: implement making context current via ANGLE. > #endif > return true; > } >@@ -512,8 +550,10 @@ void GraphicsContext3D::checkGPUStatus() > forceContextLost(); > #if USE(OPENGL) > CGLSetCurrentContext(0); >-#else >+#elif USE(OPENGL_ES) > [EAGLContext setCurrentContext:0]; >+#elif USE(ANGLE) >+ // FIXME: implement forced context loss via ANGLE. > #endif > return; > } >@@ -536,7 +576,7 @@ void GraphicsContext3D::checkGPUStatus() > forceContextLost(); > CGLSetCurrentContext(0); > } >-#else >+#elif USE(OPENGL_ES) > EAGLContext* currentContext = static_cast<EAGLContext*>(PlatformGraphicsContext3D()); > [currentContext getParameter:kEAGLCPGPURestartStatus to:&restartStatus]; > if (restartStatus == kEAGLCPGPURestartStatusCaused || restartStatus == kEAGLCPGPURestartStatusBlacklisted) { >@@ -544,6 +584,9 @@ void GraphicsContext3D::checkGPUStatus() > forceContextLost(); > [EAGLContext setCurrentContext:0]; > } >+#elif USE(ANGLE) >+ // FIXME: check via KHR_robustness. >+ restartStatus = 0; > #endif > } > >@@ -660,12 +703,19 @@ void GraphicsContext3D::screenDidChange(PlatformDisplayID displayID) > { > if (!m_contextObj) > return; >+#if USE(ANGLE) >+ UNUSED_PARAM(displayID); >+#else > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 >+ // FIXME: figure out whether to integrate more code into ANGLE to have this effect. >+#if USE(OPENGL) > if (!m_hasSwitchedToHighPerformanceGPU) > setGPUByRegistryID(m_contextObj, CGLGetPixelFormat(m_contextObj), gpuIDForDisplay(displayID)); >+#endif > #else > setGPUByDisplayMask(m_contextObj, CGLGetPixelFormat(m_contextObj), displayMaskForDisplay(displayID)); >-#endif >+#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 >+#endif // USE(ANGLE) > } > #endif // !PLATFORM(MAC) > >diff --git a/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h b/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h >index 609222a97b2f4eef1d01cc92bf126e8f327a6b97..234e8e17df729ff5cc781ef67545cededff43213 100644 >--- a/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h >+++ b/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h >@@ -38,8 +38,14 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN > > #if USE(OPENGL) > @interface WebGLLayer : CALayer >-#else >+#elif USE(OPENGL_ES) >+@interface WebGLLayer : CAEAGLLayer >+#elif USE(ANGLE) && PLATFORM(MAC) >+@interface WebGLLayer : CALayer >+#elif USE(ANGLE) && PLATFORM(IOS_FAMILY) > @interface WebGLLayer : CAEAGLLayer >+#else >+#error Unsupported platform > #endif > { > WebCore::GraphicsContext3D* _context; >diff --git a/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm b/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm >index 8cc9fc427ca1a1568f4322ae2c8c2d7a9a7671c9..f4d2d00a177d7656cd9298fb911a934c08bacf49 100644 >--- a/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm >+++ b/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm >@@ -136,8 +136,10 @@ static void freeData(void *, const void *data, size_t /* size */) > [self reloadValueForKeyPath:@"contents"]; > [self bindFramebufferToNextAvailableSurface]; > } >-#else >+#elif USE(OPENGL_ES) > _context->presentRenderbuffer(); >+#elif USE(ANGLE) >+ // FIXME: display rendering results via ANGLE. > #endif > > _context->markLayerComposited(); >diff --git a/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm b/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >index cf95929820a00f9746d97c59748ed9f9a9a264a2..577ec2846392a7215d998aa310d3d8d633f5f1ec 100644 >--- a/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >+++ b/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >@@ -39,8 +39,12 @@ std::unique_ptr<TextureCacheCV> TextureCacheCV::create(GraphicsContext3D& contex > TextureCacheType cache = nullptr; > #if USE(OPENGL_ES) > CVReturn error = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), nullptr, &cache); >-#else >+#elif USE(OPENGL) > CVReturn error = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nullptr, context.platformGraphicsContext3D(), CGLGetPixelFormat(context.platformGraphicsContext3D()), nullptr, &cache); >+#elif USE(ANGLE) >+ // FIXME: figure out how to do this integrating via ANGLE. >+ UNUSED_PARAM(context); >+ CVReturn error = kCVReturnSuccess + 1; > #endif > if (error != kCVReturnSuccess) > return nullptr; >@@ -63,7 +67,7 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB > size_t height = CVPixelBufferGetHeight(image); > if (kCVReturnSuccess != CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_cache.get(), image, nullptr, outputTarget, internalFormat, width, height, format, type, level, &bareVideoTexture)) > return nullptr; >-#else >+#elif USE(OPENGL) > UNUSED_PARAM(outputTarget); > UNUSED_PARAM(level); > UNUSED_PARAM(internalFormat); >@@ -71,6 +75,15 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB > UNUSED_PARAM(type); > if (kCVReturnSuccess != CVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_cache.get(), image, nullptr, &bareVideoTexture)) > return nullptr; >+#elif USE(ANGLE) >+ // FIXME: figure out how to do this integrating via ANGLE. >+ UNUSED_PARAM(image); >+ UNUSED_PARAM(outputTarget); >+ UNUSED_PARAM(level); >+ UNUSED_PARAM(internalFormat); >+ UNUSED_PARAM(format); >+ UNUSED_PARAM(type); >+ return nullptr; > #endif > RetainPtr<TextureType> videoTexture = adoptCF(bareVideoTexture); > >diff --git a/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp b/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp >index ab59c08b983525fd545e0d972ff0dd6624765375..d6976544920502a7cdfddbb9c7b35698e192af51 100644 >--- a/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp >+++ b/Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp >@@ -403,62 +403,62 @@ static StringMap& enumToStringMap() > static NeverDestroyed<StringMap> map; > if (map.get().empty()) { > StringMap stringMap; >- map.get().emplace(STRINGIFY_PAIR(GL_RGB)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGBA)); >- map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE_ALPHA)); >- map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE)); >- map.get().emplace(STRINGIFY_PAIR(GL_ALPHA)); >- map.get().emplace(STRINGIFY_PAIR(GL_R8)); >- map.get().emplace(STRINGIFY_PAIR(GL_R16F)); >- map.get().emplace(STRINGIFY_PAIR(GL_R32F)); >- map.get().emplace(STRINGIFY_PAIR(GL_R8UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_R8I)); >- map.get().emplace(STRINGIFY_PAIR(GL_R16UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_R16I)); >- map.get().emplace(STRINGIFY_PAIR(GL_R32UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_R32I)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG8)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG16F)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG32F)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG8UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG8I)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG16UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG16I)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG32UI)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG32I)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGB8)); >- map.get().emplace(STRINGIFY_PAIR(GL_SRGB8)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGBA8)); >- map.get().emplace(STRINGIFY_PAIR(GL_SRGB8_ALPHA8)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGBA4)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGB10_A2)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT16)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT24)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_COMPONENT32F)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH24_STENCIL8)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH32F_STENCIL8)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGB)); >- map.get().emplace(STRINGIFY_PAIR(GL_RGBA)); >- map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE_ALPHA)); >- map.get().emplace(STRINGIFY_PAIR(GL_LUMINANCE)); >- map.get().emplace(STRINGIFY_PAIR(GL_ALPHA)); >- map.get().emplace(STRINGIFY_PAIR(GL_RED)); >- map.get().emplace(STRINGIFY_PAIR(GL_RG_INTEGER)); >- map.get().emplace(STRINGIFY_PAIR(GL_DEPTH_STENCIL)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_BYTE)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_5_6_5)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_4_4_4_4)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT_5_5_5_1)); >- map.get().emplace(STRINGIFY_PAIR(GL_BYTE)); >- map.get().emplace(STRINGIFY_PAIR(GL_HALF_FLOAT)); >- map.get().emplace(STRINGIFY_PAIR(GL_FLOAT)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_SHORT)); >- map.get().emplace(STRINGIFY_PAIR(GL_SHORT)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT)); >- map.get().emplace(STRINGIFY_PAIR(GL_INT)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_2_10_10_10_REV)); >- map.get().emplace(STRINGIFY_PAIR(GL_UNSIGNED_INT_24_8)); >- map.get().emplace(STRINGIFY_PAIR(GL_FLOAT_32_UNSIGNED_INT_24_8_REV)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGB)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGBA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::LUMINANCE_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::LUMINANCE)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R16F)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R32F)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R8I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R16I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::R32I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG16F)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG32F)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG8UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG8I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG16UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG16I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG32UI)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG32I)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGB8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::SRGB8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGBA8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::SRGB8_ALPHA8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGBA4)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGB10_A2)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH_COMPONENT16)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH_COMPONENT24)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH_COMPONENT32F)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH24_STENCIL8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH32F_STENCIL8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGB)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RGBA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::LUMINANCE_ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::LUMINANCE)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::ALPHA)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RED)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::RG_INTEGER)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::DEPTH_STENCIL)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_BYTE)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_SHORT_5_6_5)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::BYTE)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::HALF_FLOAT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::FLOAT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_SHORT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::SHORT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_INT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::INT)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_INT_2_10_10_10_REV)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::UNSIGNED_INT_24_8)); >+ map.get().emplace(STRINGIFY_PAIR(GraphicsContext3D::FLOAT_32_UNSIGNED_INT_24_8_REV)); > > #if USE(OPENGL_ES) > map.get().emplace(STRINGIFY_PAIR(GL_RED_INTEGER)); >@@ -530,8 +530,13 @@ bool VideoTextureCopierCV::initializeContextObjects() > #if USE(OPENGL_ES) > fragmentShaderSource.appendLiteral("precision mediump float;\n"); > fragmentShaderSource.appendLiteral("uniform sampler2D u_texture;\n"); >-#else >+#elif USE(OPENGL) > fragmentShaderSource.appendLiteral("uniform sampler2DRect u_texture;\n"); >+#elif USE(ANGLE) >+ // FIXME: determine how to access rectangular textures via ANGLE. >+ ASSERT_NOT_REACHED(); >+#else >+#error Unsupported configuration > #endif > fragmentShaderSource.appendLiteral("varying vec2 v_texturePosition;\n"); > fragmentShaderSource.appendLiteral("uniform int u_premultiply;\n"); >@@ -541,8 +546,13 @@ bool VideoTextureCopierCV::initializeContextObjects() > fragmentShaderSource.appendLiteral(" vec2 texPos = vec2(v_texturePosition.x * u_textureDimensions.x, v_texturePosition.y * u_textureDimensions.y);\n"); > #if USE(OPENGL_ES) > fragmentShaderSource.appendLiteral(" vec4 color = texture2D(u_texture, texPos);\n"); >-#else >+#elif USE(OPENGL) > fragmentShaderSource.appendLiteral(" vec4 color = texture2DRect(u_texture, texPos);\n"); >+#elif USE(ANGLE) >+ // FIXME: determine how to access rectangular textures via ANGLE. >+ ASSERT_NOT_REACHED(); >+#else >+#error Unsupported configuration > #endif > fragmentShaderSource.appendLiteral(" if (u_swapColorChannels == 1) {\n"); > fragmentShaderSource.appendLiteral(" color.rgba = color.bgra;\n"); >@@ -623,9 +633,13 @@ bool VideoTextureCopierCV::initializeUVContextObjects() > #if USE(OPENGL_ES) > " v_yTextureCoordinate = normalizedPosition;\n" > " v_uvTextureCoordinate = normalizedPosition;\n" >-#else >+#elif USE(OPENGL) > " v_yTextureCoordinate = normalizedPosition * u_yTextureSize;\n" > " v_uvTextureCoordinate = normalizedPosition * u_uvTextureSize;\n" >+#elif USE(ANGLE) >+ // FIXME: determine how to access rectangular textures via ANGLE. >+#else >+#error Unsupported configuration > #endif > "}\n"_s > }; >@@ -647,9 +661,13 @@ bool VideoTextureCopierCV::initializeUVContextObjects() > "precision mediump float;\n" > "#define SAMPLERTYPE sampler2D\n" > "#define TEXTUREFUNC texture2D\n" >-#else >+#elif USE(OPENGL) > "#define SAMPLERTYPE sampler2DRect\n" > "#define TEXTUREFUNC texture2DRect\n" >+#elif USE(ANGLE) >+ // FIXME: determine how to access rectangular textures via ANGLE. >+#else >+#error Unsupported configuration > #endif > "uniform SAMPLERTYPE u_yTexture;\n" > "uniform SAMPLERTYPE u_uvTexture;\n" >@@ -790,8 +808,13 @@ bool VideoTextureCopierCV::copyImageToPlatformTexture(CVPixelBufferRef image, si > > #if USE(OPENGL_ES) > GC3Denum videoTextureTarget = GraphicsContext3D::TEXTURE_2D; >-#else >+#elif USE(OPENGL) > GC3Denum videoTextureTarget = GL_TEXTURE_RECTANGLE_ARB; >+#elif USE(ANGLE) >+ // FIXME: determine how to access rectangular textures via ANGLE. >+ GC3Denum videoTextureTarget = GraphicsContext3D::TEXTURE_2D; >+#else >+#error Unsupported configuration > #endif > auto uvTexture = m_context->createTexture(); > m_context->activeTexture(GraphicsContext3D::TEXTURE1); >@@ -800,7 +823,7 @@ bool VideoTextureCopierCV::copyImageToPlatformTexture(CVPixelBufferRef image, si > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >- if (!m_context->texImageIOSurface2D(videoTextureTarget, GL_RG, uvPlaneWidth, uvPlaneHeight, GL_RG, GL_UNSIGNED_BYTE, surface, 1)) { >+ if (!m_context->texImageIOSurface2D(videoTextureTarget, GraphicsContext3D::RG, uvPlaneWidth, uvPlaneHeight, GraphicsContext3D::RG, GraphicsContext3D::UNSIGNED_BYTE, surface, 1)) { > m_context->deleteTexture(uvTexture); > return false; > } >@@ -812,7 +835,7 @@ bool VideoTextureCopierCV::copyImageToPlatformTexture(CVPixelBufferRef image, si > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); > m_context->texParameteri(videoTextureTarget, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); >- if (!m_context->texImageIOSurface2D(videoTextureTarget, GL_LUMINANCE, yPlaneWidth, yPlaneHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, surface, 0)) { >+ if (!m_context->texImageIOSurface2D(videoTextureTarget, GraphicsContext3D::LUMINANCE, yPlaneWidth, yPlaneHeight, GraphicsContext3D::LUMINANCE, GraphicsContext3D::UNSIGNED_BYTE, surface, 0)) { > m_context->deleteTexture(yTexture); > m_context->deleteTexture(uvTexture); > return false; >@@ -867,10 +890,16 @@ bool VideoTextureCopierCV::copyVideoTextureToPlatformTexture(TextureType inputVi > Platform3DObject videoTextureName = CVOpenGLESTextureGetName(inputVideoTexture); > GC3Denum videoTextureTarget = CVOpenGLESTextureGetTarget(inputVideoTexture); > CVOpenGLESTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft); >-#else >+#elif USE(OPENGL) >+ Platform3DObject videoTextureName = CVOpenGLTextureGetName(inputVideoTexture); >+ GC3Denum videoTextureTarget = CVOpenGLTextureGetTarget(inputVideoTexture); >+ CVOpenGLTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft); >+#elif USE(ANGLE) > Platform3DObject videoTextureName = CVOpenGLTextureGetName(inputVideoTexture); > GC3Denum videoTextureTarget = CVOpenGLTextureGetTarget(inputVideoTexture); > CVOpenGLTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft); >+ // FIXME: determine how to access rectangular textures via ANGLE. >+ ASSERT_NOT_REACHED(); > #endif > > if (lowerLeft[1] < upperRight[1]) >diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp >index f40fe6ae637dec2d4b9a15b63321807e594aff72..13119ffa75e1c307d0834a7fd7fc9dded52643df 100644 >--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp >@@ -25,7 +25,7 @@ > > #include "config.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES))) > > #include "Extensions3DOpenGL.h" > >@@ -308,4 +308,4 @@ bool Extensions3DOpenGL::isVertexArrayObjectSupported() > > } // namespace WebCore > >-#endif // ENABLE(GRAPHICS_CONTEXT_3D) >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES))) >diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp >index bf91e72457ade7077c4e081ec37d46c46406c920..b13ef58f7454b5ffe25f90366c1c44ef1d2975b6 100644 >--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp >@@ -26,7 +26,7 @@ > > #include "config.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES)) > #include "Extensions3DOpenGLCommon.h" > > #include "ANGLEWebKitBridge.h" >@@ -256,4 +256,4 @@ void Extensions3DOpenGLCommon::getnUniformivEXT(GC3Duint, int, GC3Dsizei, int *) > > } // namespace WebCore > >-#endif // ENABLE(GRAPHICS_CONTEXT_3D) >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES)) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >index 1dcf53b2f0cd008e82fc1631395a82400d6eb86a..e6848fceca41e9736f2a3817a9fd03cebae3ac11 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp >@@ -26,7 +26,7 @@ > > #include "config.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES))) > > #include "GraphicsContext3D.h" > >@@ -503,4 +503,4 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi > > } > >-#endif // ENABLE(GRAPHICS_CONTEXT_3D) >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || (PLATFORM(COCOA) && USE(OPENGL_ES))) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >index 7366dfca6ea26092fd79fd3b6536062b1d6c1daa..b24df035e288e1eb2f8af9f7ab91d779d0aca49e 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >@@ -28,7 +28,7 @@ > > #include "config.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES)) > > #include "GraphicsContext3D.h" > #if PLATFORM(IOS_FAMILY) >@@ -2079,4 +2079,4 @@ void GraphicsContext3D::primitiveRestartIndex(GC3Duint index) > > } > >-#endif // ENABLE(GRAPHICS_CONTEXT_3D) >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES)) >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >index 0da2599b5ac371939598a76a08dab5c07750f093..ad5460b3b2c2c091b5070291a77ee596cb5b0125 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp >@@ -28,7 +28,7 @@ > > #include "config.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) && !PLATFORM(IOS_FAMILY) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(OPENGL_ES) && !PLATFORM(IOS_FAMILY) > > #include "GraphicsContext3D.h" > >@@ -400,4 +400,4 @@ PlatformLayer* GraphicsContext3D::platformLayer() const > > } > >-#endif // ENABLE(GRAPHICS_CONTEXT_3D) && !PLATFORM(IOS_FAMILY) >+#endif // ENABLE(GRAPHICS_CONTEXT_3D) && USE(OPENGL_ES) && !PLATFORM(IOS_FAMILY)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197755
:
369534
|
369780
|
369786
|
369787
|
369793
|
371212
|
371576
|
371764
|
371784
|
371798
|
372093
|
372129
|
372309
|
372349