Hook up WebGL's back buffer in ANGLE backend on macOS
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 18:43:02 +0000 (18:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jul 2019 18:43:02 +0000 (18:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198982

Patch by Kenneth Russell <kbr@chromium.org> on 2019-07-10
Reviewed by Alex Christensen.

Source/ThirdParty/ANGLE:

Add source files needed to implement and call ANGLE extensions, and
export headers necessary for those extensions. Update the script which
adjusts include paths to handle the new headers.

Cherry-pick fix for ANGLE bug crbug.com/angleproject/3669 to support
antialias:true for ANGLE-backed WebGL contexts.

* ANGLE.xcodeproj/project.pbxproj:
* adjust-angle-include-paths.sh:
* src/libANGLE/FramebufferAttachment.cpp:
(gl::FramebufferAttachment::getTextureImageIndex const): Deleted.
* src/libANGLE/FramebufferAttachment.h:
(gl::FramebufferAttachment::getTextureImageIndex const):
* src/libANGLE/validationES2.cpp:
(gl::ValidateBlitFramebufferANGLE):

Source/WebCore:

Fix a few places which were accidentally calling desktop OpenGL rather
than ANGLE. Fix some calls which were using ANGLE's OpenGL ES 3.0
entry points rather than the OpenGL ES 2.0 extension APIs, causing
them to generate errors in WebGL 1.0's backend. Change
Extensions3DANGLE to use ANGLE's requestable extension mechanism.

Fix framebuffer setup when using ANGLE for WebGL 1.0 contexts, for
both antialias:true and false.

Remove ANGLEWebKitBridge in ANGLE backend. It interfered with the
correct operation of ANGLE's internal shader compiler, and was
unnecessary given the use of ANGLE. Remove all manual shader name
hashing and mapping in ANGLE backend.

Tested with parts of the WebGL conformance suite and the San
Angeles demo, which now runs properly with WebKit's ANGLE backend
for WebGL.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::getProgramParameter):
(WebCore::WebGLRenderingContextBase::getUniformLocation):
(WebCore::WebGLRenderingContextBase::linkProgramWithoutInvalidatingAttribLocations):
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/angle/Extensions3DANGLE.cpp:
(WebCore::Extensions3DANGLE::Extensions3DANGLE):
(WebCore::Extensions3DANGLE::supports):
(WebCore::Extensions3DANGLE::ensureEnabled):
(WebCore::Extensions3DANGLE::isEnabled):
(WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE):
(WebCore::Extensions3DANGLE::initializeAvailableExtensions):
(WebCore::Extensions3DANGLE::blitFramebuffer):
(WebCore::Extensions3DANGLE::renderbufferStorageMultisample):
(WebCore::Extensions3DANGLE::createVertexArrayOES):
(WebCore::Extensions3DANGLE::deleteVertexArrayOES):
(WebCore::Extensions3DANGLE::isVertexArrayOES):
(WebCore::Extensions3DANGLE::bindVertexArrayOES):
(WebCore::Extensions3DANGLE::supportsExtension):
(WebCore::Extensions3DANGLE::drawBuffersEXT):
(WebCore::Extensions3DANGLE::drawArraysInstanced):
(WebCore::Extensions3DANGLE::drawElementsInstanced):
(WebCore::Extensions3DANGLE::vertexAttribDivisor):
* platform/graphics/angle/Extensions3DANGLE.h:
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::validateAttributes):
(WebCore::GraphicsContext3D::reshapeFBOs):
(WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
(WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary):
(WebCore::GraphicsContext3D::validateDepthStencil):
(WebCore::GraphicsContext3D::prepareTexture):
(WebCore::GraphicsContext3D::attachShader):
(WebCore::GraphicsContext3D::bindAttribLocation):
(WebCore::GraphicsContext3D::compileShader):
(WebCore::GraphicsContext3D::compileShaderDirect):
(WebCore::GraphicsContext3D::detachShader):
(WebCore::GraphicsContext3D::getActiveAttribImpl):
(WebCore::GraphicsContext3D::getActiveAttrib):
(WebCore::GraphicsContext3D::getActiveUniformImpl):
(WebCore::GraphicsContext3D::getActiveUniform):
(WebCore::GraphicsContext3D::getAttribLocation):
(WebCore::GraphicsContext3D::getAttribLocationDirect):
(WebCore::GraphicsContext3D::moveErrorsToSyntheticErrorList):
(WebCore::GraphicsContext3D::linkProgram):
(WebCore::GraphicsContext3D::shaderSource):
(WebCore::GraphicsContext3D::getUnmangledInfoLog):
(WebCore::GraphicsContext3D::getShaderiv):
(WebCore::GraphicsContext3D::getShaderInfoLog):
(WebCore::GraphicsContext3D::getUniformLocation):
(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):
(): Deleted.
(WebCore::setCurrentNameHashMapForShader): Deleted.
(WebCore::nameHashForShader): Deleted.
(WebCore::GraphicsContext3D::checkVaryingsPacking const): Deleted.
(WebCore::GraphicsContext3D::precisionsMatch const): Deleted.
(WebCore::generateHashedName): Deleted.
(WebCore::GraphicsContext3D::mappedSymbolInShaderSourceMap): Deleted.
(WebCore::GraphicsContext3D::mappedSymbolName): Deleted.
(WebCore::GraphicsContext3D::originalSymbolInShaderSourceMap): Deleted.
(WebCore::GraphicsContext3D::originalSymbolName): Deleted.
(WebCore::GraphicsContext3D::getNonBuiltInActiveSymbolCount): Deleted.
(WebCore::GraphicsContext3D::getShaderSource): Deleted.
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::checkGPUStatus):
(WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
(WebCore::GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer):
* platform/graphics/cocoa/WebGLLayer.h:
* platform/graphics/cocoa/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]):
(-[WebGLLayer copyImageSnapshotWithColorSpace:]):
(-[WebGLLayer display]):
(-[WebGLLayer setEGLDisplay:andConfig:]):
(-[WebGLLayer dealloc]):
(-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
(-[WebGLLayer bindFramebufferToNextAvailableSurface]):

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

15 files changed:
Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh
Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.cpp
Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.h
Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp
Source/WebCore/platform/graphics/angle/Extensions3DANGLE.h
Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp
Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
Source/WebCore/platform/graphics/cocoa/WebGLLayer.h
Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm

index 7cefc59..e23eb06 100644 (file)
                5CB305011DE4164800D2C405 /* TransformFeedbackImpl_mock.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB304D71DE4164800D2C405 /* TransformFeedbackImpl_mock.h */; };
                5CB305021DE4164800D2C405 /* TransformFeedbackImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB304D81DE4164800D2C405 /* TransformFeedbackImpl.h */; };
                5CB305031DE4164800D2C405 /* VertexArrayImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB304D91DE4164800D2C405 /* VertexArrayImpl.h */; };
-               5CB5E1A71DFB8AF600F90FC9 /* libEGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB300B51DE39E6300D2C405 /* libEGL.cpp */; };
                5CC7D457191024E4000B8C1F /* ValidateOutputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */; };
                5CC7D458191024E4000B8C1F /* ValidateOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D451191024E4000B8C1F /* ValidateOutputs.h */; };
                5CC7D46B19102620000B8C1F /* angleutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D45A19102620000B8C1F /* angleutils.h */; };
                5CCD81B01DBFEA5C006066B8 /* ConstantUnion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD81991DBFEA5C006066B8 /* ConstantUnion.cpp */; };
                5CCD81B51DBFEA5C006066B8 /* QualifierTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD819E1DBFEA5C006066B8 /* QualifierTypes.cpp */; };
                5CCD81B61DBFEA5C006066B8 /* QualifierTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCD819F1DBFEA5C006066B8 /* QualifierTypes.h */; };
+               6E344AB122BC35C3001DDB2C /* entry_points_enum_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */; };
+               6E344AB222BC35C3001DDB2C /* entry_points_gles_ext_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6E344AB322BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */; };
+               6E344AB622BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */; };
+               6E344AB722BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */; };
+               6ED70A0C22CD630E008688CE /* gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0922CD630E008688CE /* gl.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6ED70A0D22CD630E008688CE /* glext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0A22CD630E008688CE /* glext.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6ED70A0E22CD630E008688CE /* glplatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0B22CD630E008688CE /* glplatform.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6ED70A1022CD6822008688CE /* glext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0F22CD6822008688CE /* glext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6EE2FD2D22BAE99C001D369E /* eglext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE2FD2C22BAE99C001D369E /* eglext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; };
+               6EE2FD2F22BAE9CD001D369E /* gl2ext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; };
                72309A56183C27DE00370B93 /* Tokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A55183C27DB00370B93 /* Tokenizer.cpp */; settings = {COMPILER_FLAGS = "-Wno-unreachable-code"; }; };
                72309A58183C27F300370B93 /* ExpressionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A57183C27F100370B93 /* ExpressionParser.cpp */; settings = {COMPILER_FLAGS = "-Wno-unreachable-code"; }; };
                A08C3CDC16D6CB61003F0B83 /* ArrayBoundsClamper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A08C3CDA16D6CB61003F0B83 /* ArrayBoundsClamper.cpp */; };
                5C55D732228274DE00B5BA2C /* Declarator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Declarator.h; sourceTree = "<group>"; };
                5C9FFF4C19102A000025B8FA /* FlagStd140Structs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlagStd140Structs.cpp; sourceTree = "<group>"; };
                5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlagStd140Structs.h; sourceTree = "<group>"; };
-               5CB300B51DE39E6300D2C405 /* libEGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libEGL.cpp; sourceTree = "<group>"; };
                5CB300B81DE39E6300D2C405 /* resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resource.h; sourceTree = "<group>"; };
                5CB300BB1DE39E7500D2C405 /* entry_points_egl_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_egl_ext.cpp; sourceTree = "<group>"; };
                5CB300BC1DE39E7500D2C405 /* entry_points_egl_ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_egl_ext.h; sourceTree = "<group>"; };
                5D7C59C51208C68B001C873E /* ANGLE.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ANGLE.xcconfig; sourceTree = "<group>"; };
                5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
                5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
+               6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_enum_autogen.h; sourceTree = "<group>"; };
+               6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_gles_ext_autogen.h; sourceTree = "<group>"; };
+               6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_gles_ext_autogen.cpp; sourceTree = "<group>"; };
+               6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_gles_1_0_autogen.cpp; sourceTree = "<group>"; };
+               6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_gles_1_0_autogen.h; sourceTree = "<group>"; };
+               6ED70A0922CD630E008688CE /* gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl.h; path = include/GLES/gl.h; sourceTree = "<group>"; };
+               6ED70A0A22CD630E008688CE /* glext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glext.h; path = include/GLES/glext.h; sourceTree = "<group>"; };
+               6ED70A0B22CD630E008688CE /* glplatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glplatform.h; path = include/GLES/glplatform.h; sourceTree = "<group>"; };
+               6ED70A0F22CD6822008688CE /* glext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glext_angle.h; path = include/GLES/glext_angle.h; sourceTree = "<group>"; };
+               6EE2FD2C22BAE99C001D369E /* eglext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = eglext_angle.h; path = include/EGL/eglext_angle.h; sourceTree = "<group>"; };
+               6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl2ext_angle.h; path = include/GLES2/gl2ext_angle.h; sourceTree = "<group>"; };
                72309A55183C27DB00370B93 /* Tokenizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Tokenizer.cpp; sourceTree = "<group>"; };
                72309A57183C27F100370B93 /* ExpressionParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ExpressionParser.cpp; sourceTree = "<group>"; };
                A08C3CDA16D6CB61003F0B83 /* ArrayBoundsClamper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArrayBoundsClamper.cpp; path = compiler/ArrayBoundsClamper.cpp; sourceTree = "<group>"; };
                        children = (
                                5C1BAAA61DFB6124002906BB /* egl.h */,
                                5C1BAAA71DFB6124002906BB /* eglext.h */,
+                               6EE2FD2C22BAE99C001D369E /* eglext_angle.h */,
                                5C1BAAA81DFB6124002906BB /* eglplatform.h */,
                        );
                        name = EGL;
                        children = (
                                5C1BAA9E1DFB610E002906BB /* gl2.h */,
                                5C1BAA9F1DFB610E002906BB /* gl2ext.h */,
+                               6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */,
                                5C1BAAA01DFB610E002906BB /* gl2platform.h */,
                        );
                        name = GLES2;
                5CB300B41DE39E5400D2C405 /* libEGL */ = {
                        isa = PBXGroup;
                        children = (
-                               5CB300B51DE39E6300D2C405 /* libEGL.cpp */,
                                5CB300B81DE39E6300D2C405 /* resource.h */,
                        );
                        path = libEGL;
                                5CB300BE1DE39E7500D2C405 /* entry_points_egl.h */,
                                5CB300BB1DE39E7500D2C405 /* entry_points_egl_ext.cpp */,
                                5CB300BC1DE39E7500D2C405 /* entry_points_egl_ext.h */,
+                               6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */,
+                               6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */,
+                               6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */,
                                315EBE021FCE456200AC7A89 /* entry_points_gles_2_0_autogen.cpp */,
                                315EBDFE1FCE456100AC7A89 /* entry_points_gles_2_0_autogen.h */,
                                315EBE001FCE456100AC7A89 /* entry_points_gles_3_0_autogen.cpp */,
                                315EBDFD1FCE456100AC7A89 /* entry_points_gles_3_0_autogen.h */,
                                315EBE011FCE456100AC7A89 /* entry_points_gles_3_1_autogen.cpp */,
                                315EBDFF1FCE456100AC7A89 /* entry_points_gles_3_1_autogen.h */,
+                               6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */,
+                               6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */,
                                5CB300C71DE39E7500D2C405 /* global_state.cpp */,
                                5CB300C81DE39E7500D2C405 /* global_state.h */,
                                315EBDFC1FCE456100AC7A89 /* proc_table.h */,
                        path = Configurations;
                        sourceTree = "<group>";
                };
+               6ED70A0822CD62E8008688CE /* GLES */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6ED70A0922CD630E008688CE /* gl.h */,
+                               6ED70A0A22CD630E008688CE /* glext.h */,
+                               6ED70A0F22CD6822008688CE /* glext_angle.h */,
+                               6ED70A0B22CD630E008688CE /* glplatform.h */,
+                       );
+                       name = GLES;
+                       sourceTree = "<group>";
+               };
                A08C3CD816D6CB35003F0B83 /* third_party */ = {
                        isa = PBXGroup;
                        children = (
                        isa = PBXGroup;
                        children = (
                                5C1BAA931DFB60E2002906BB /* EGL */,
+                               6ED70A0822CD62E8008688CE /* GLES */,
                                5C1BAA941DFB60EA002906BB /* GLES2 */,
                                5C1BAA951DFB60EF002906BB /* GLES3 */,
                                FB39D2BD1200F3E600088E69 /* GLSLANG */,
                                315EBDC91FCE44E400AC7A89 /* driver_utils.h in Headers */,
                                5C1BAAAA1DFB6124002906BB /* egl.h in Headers */,
                                5C1BAAAB1DFB6124002906BB /* eglext.h in Headers */,
+                               6EE2FD2D22BAE99C001D369E /* eglext_angle.h in Headers */,
                                5CB304E31DE4164800D2C405 /* EGLImplFactory.h in Headers */,
                                5C1BAAAC1DFB6124002906BB /* eglplatform.h in Headers */,
                                5CCD59672284F7960018F2D8 /* EGLSync.h in Headers */,
                                5C55D6A322826B9F00B5BA2C /* EmulatePrecision.h in Headers */,
                                5CB304981DE4157B00D2C405 /* entry_points_egl.h in Headers */,
                                5CB304961DE4157B00D2C405 /* entry_points_egl_ext.h in Headers */,
+                               6E344AB122BC35C3001DDB2C /* entry_points_enum_autogen.h in Headers */,
+                               6E344AB722BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h in Headers */,
                                315EBE061FCE456200AC7A89 /* entry_points_gles_2_0_autogen.h in Headers */,
                                315EBE051FCE456200AC7A89 /* entry_points_gles_3_0_autogen.h in Headers */,
                                315EBE071FCE456200AC7A89 /* entry_points_gles_3_1_autogen.h in Headers */,
+                               6E344AB222BC35C3001DDB2C /* entry_points_gles_ext_autogen.h in Headers */,
                                5C1DBDEB1B0438D300235552 /* Error.h in Headers */,
                                315EBDE91FCE452D00AC7A89 /* ErrorStrings.h in Headers */,
                                5CC7D47119102621000B8C1F /* event_tracer.h in Headers */,
                                5CB301291DE39F1A00D2C405 /* functionsgl_enums.h in Headers */,
                                5CB3012A1DE39F1A00D2C405 /* functionsgl_typedefs.h in Headers */,
                                5CCD59942284FC400018F2D8 /* generatemip.h in Headers */,
+                               6ED70A0C22CD630E008688CE /* gl.h in Headers */,
                                5C1BAAA21DFB610E002906BB /* gl2.h in Headers */,
                                5C1BAAA31DFB610E002906BB /* gl2ext.h in Headers */,
+                               6EE2FD2F22BAE9CD001D369E /* gl2ext_angle.h in Headers */,
                                5C1BAAA41DFB610E002906BB /* gl2platform.h in Headers */,
                                5C1BAA9A1DFB60FF002906BB /* gl3.h in Headers */,
                                5C1BAA9C1DFB60FF002906BB /* gl31.h in Headers */,
                                5C1BAA9B1DFB60FF002906BB /* gl3platform.h in Headers */,
                                5CCD59602284F7960018F2D8 /* GLES1Renderer.h in Headers */,
                                5CCD59622284F7960018F2D8 /* GLES1State.h in Headers */,
+                               6ED70A0D22CD630E008688CE /* glext.h in Headers */,
+                               6ED70A1022CD6822008688CE /* glext_angle.h in Headers */,
                                5CB304EC1DE4164800D2C405 /* GLImplFactory.h in Headers */,
                                5CB304A21DE4157B00D2C405 /* global_state.h in Headers */,
+                               6ED70A0E22CD630E008688CE /* glplatform.h in Headers */,
                                31012E2D18B97B9B0039062F /* glslang.h in Headers */,
                                31012E3218B97B9B0039062F /* glslang_tab.h in Headers */,
                                5C1DBDF91B0438D300235552 /* HandleAllocator.h in Headers */,
                                5C55D6B222826BC800B5BA2C /* EmulatePrecision.cpp in Sources */,
                                5C1BAAB51DFB6F54002906BB /* entry_points_egl.cpp in Sources */,
                                5C1BAAB61DFB6F58002906BB /* entry_points_egl_ext.cpp in Sources */,
+                               6E344AB622BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp in Sources */,
                                315EBE0A1FCE456200AC7A89 /* entry_points_gles_2_0_autogen.cpp in Sources */,
                                315EBE081FCE456200AC7A89 /* entry_points_gles_3_0_autogen.cpp in Sources */,
                                315EBE091FCE456200AC7A89 /* entry_points_gles_3_1_autogen.cpp in Sources */,
+                               6E344AB322BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp in Sources */,
                                5C1DBDEA1B0438D300235552 /* Error.cpp in Sources */,
                                315EBDEF1FCE452D00AC7A89 /* es3_copy_conversion_table_autogen.cpp in Sources */,
                                5CC7D47019102621000B8C1F /* event_tracer.cpp in Sources */,
                                5CCD59792284FA830018F2D8 /* IOSurfaceSurfaceCGL.mm in Sources */,
                                315EBD9C1FCE443600AC7A89 /* IsASTDepthBelowLimit.cpp in Sources */,
                                A264F8B616974DED006FAA5A /* Lexer.cpp in Sources */,
-                               5CB5E1A71DFB8AF600F90FC9 /* libEGL.cpp in Sources */,
                                5CB304EF1DE4164800D2C405 /* load_functions_table_autogen.cpp in Sources */,
                                5CCD59952284FC400018F2D8 /* loadimage.cpp in Sources */,
                                5CCD59922284FC400018F2D8 /* loadimage_etc.cpp in Sources */,
index 956edfd..6f7836e 100644 (file)
@@ -1,3 +1,26 @@
+2019-07-10  Kenneth Russell  <kbr@chromium.org>
+
+        Hook up WebGL's back buffer in ANGLE backend on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=198982
+
+        Reviewed by Alex Christensen.
+
+        Add source files needed to implement and call ANGLE extensions, and
+        export headers necessary for those extensions. Update the script which
+        adjusts include paths to handle the new headers.
+
+        Cherry-pick fix for ANGLE bug crbug.com/angleproject/3669 to support
+        antialias:true for ANGLE-backed WebGL contexts.
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        * adjust-angle-include-paths.sh:
+        * src/libANGLE/FramebufferAttachment.cpp:
+        (gl::FramebufferAttachment::getTextureImageIndex const): Deleted.
+        * src/libANGLE/FramebufferAttachment.h:
+        (gl::FramebufferAttachment::getTextureImageIndex const):
+        * src/libANGLE/validationES2.cpp:
+        (gl::ValidateBlitFramebufferANGLE):
+
 2019-06-27  Beth Dakin  <bdakin@apple.com>
 
         Upstream use of MACCATALYST
index f7593e8..b683fdd 100755 (executable)
@@ -31,6 +31,7 @@ for i in $output_dir/*.h ; do
     if [ ! -f $output_dir/angle.timestamp ] || [ $i -nt $output_dir/angle.timestamp ] ; then
         sed -e '
 s/^#include <EGL\/\(.*\)>/#include <ANGLE\/\1>/
+s/^#include <GLES\/\(.*\)>/#include <ANGLE\/\1>/
 s/^#include <GLES2\/\(.*\)>/#include <ANGLE\/\1>/
 s/^#include <GLES3\/\(.*\)>/#include <ANGLE\/\1>/
 s/^#include <KHR\/\(.*\)>/#include <ANGLE\/\1>/
index 8238541..cad883d 100644 (file)
@@ -178,12 +178,6 @@ GLuint FramebufferAttachment::id() const
     return mResource->getId();
 }
 
-const ImageIndex &FramebufferAttachment::getTextureImageIndex() const
-{
-    ASSERT(type() == GL_TEXTURE);
-    return mTarget.textureIndex();
-}
-
 TextureTarget FramebufferAttachment::cubeMapFace() const
 {
     ASSERT(mType == GL_TEXTURE);
index 10d8c99..20c4d54 100644 (file)
@@ -216,6 +216,12 @@ class FramebufferAttachmentObject : public angle::Subject
     virtual rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const = 0;
 };
 
+inline const ImageIndex &FramebufferAttachment::getTextureImageIndex() const
+{
+    ASSERT(type() == GL_TEXTURE);
+    return mTarget.textureIndex();
+}
+
 inline Extents FramebufferAttachment::getSize() const
 {
     ASSERT(mResource);
index 254db5b..3813e7e 100644 (file)
@@ -2572,7 +2572,8 @@ bool ValidateBlitFramebufferANGLE(Context *context,
         if (readColorAttachment && drawColorAttachment)
         {
             if (!(readColorAttachment->type() == GL_TEXTURE &&
-                  readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D) &&
+                  (readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D ||
+                   readColorAttachment->getTextureImageIndex().getType() == TextureType::Rectangle)) &&
                 readColorAttachment->type() != GL_RENDERBUFFER &&
                 readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT)
             {
@@ -2589,7 +2590,8 @@ bool ValidateBlitFramebufferANGLE(Context *context,
                 if (attachment)
                 {
                     if (!(attachment->type() == GL_TEXTURE &&
-                          attachment->getTextureImageIndex().getType() == TextureType::_2D) &&
+                          (attachment->getTextureImageIndex().getType() == TextureType::_2D ||
+                           attachment->getTextureImageIndex().getType() == TextureType::Rectangle)) &&
                         attachment->type() != GL_RENDERBUFFER &&
                         attachment->type() != GL_FRAMEBUFFER_DEFAULT)
                     {
index a6566b6..95e4e21 100644 (file)
@@ -1,3 +1,119 @@
+2019-07-10  Kenneth Russell  <kbr@chromium.org>
+
+        Hook up WebGL's back buffer in ANGLE backend on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=198982
+
+        Reviewed by Alex Christensen.
+
+        Fix a few places which were accidentally calling desktop OpenGL rather
+        than ANGLE. Fix some calls which were using ANGLE's OpenGL ES 3.0
+        entry points rather than the OpenGL ES 2.0 extension APIs, causing
+        them to generate errors in WebGL 1.0's backend. Change
+        Extensions3DANGLE to use ANGLE's requestable extension mechanism.
+
+        Fix framebuffer setup when using ANGLE for WebGL 1.0 contexts, for
+        both antialias:true and false.
+
+        Remove ANGLEWebKitBridge in ANGLE backend. It interfered with the
+        correct operation of ANGLE's internal shader compiler, and was
+        unnecessary given the use of ANGLE. Remove all manual shader name
+        hashing and mapping in ANGLE backend.
+
+        Tested with parts of the WebGL conformance suite and the San
+        Angeles demo, which now runs properly with WebKit's ANGLE backend
+        for WebGL.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::getProgramParameter):
+        (WebCore::WebGLRenderingContextBase::getUniformLocation):
+        (WebCore::WebGLRenderingContextBase::linkProgramWithoutInvalidatingAttribLocations):
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/angle/Extensions3DANGLE.cpp:
+        (WebCore::Extensions3DANGLE::Extensions3DANGLE):
+        (WebCore::Extensions3DANGLE::supports):
+        (WebCore::Extensions3DANGLE::ensureEnabled):
+        (WebCore::Extensions3DANGLE::isEnabled):
+        (WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE):
+        (WebCore::Extensions3DANGLE::initializeAvailableExtensions):
+        (WebCore::Extensions3DANGLE::blitFramebuffer):
+        (WebCore::Extensions3DANGLE::renderbufferStorageMultisample):
+        (WebCore::Extensions3DANGLE::createVertexArrayOES):
+        (WebCore::Extensions3DANGLE::deleteVertexArrayOES):
+        (WebCore::Extensions3DANGLE::isVertexArrayOES):
+        (WebCore::Extensions3DANGLE::bindVertexArrayOES):
+        (WebCore::Extensions3DANGLE::supportsExtension):
+        (WebCore::Extensions3DANGLE::drawBuffersEXT):
+        (WebCore::Extensions3DANGLE::drawArraysInstanced):
+        (WebCore::Extensions3DANGLE::drawElementsInstanced):
+        (WebCore::Extensions3DANGLE::vertexAttribDivisor):
+        * platform/graphics/angle/Extensions3DANGLE.h:
+        * platform/graphics/angle/GraphicsContext3DANGLE.cpp:
+        (WebCore::GraphicsContext3D::validateAttributes):
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded):
+        (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary):
+        (WebCore::GraphicsContext3D::validateDepthStencil):
+        (WebCore::GraphicsContext3D::prepareTexture):
+        (WebCore::GraphicsContext3D::attachShader):
+        (WebCore::GraphicsContext3D::bindAttribLocation):
+        (WebCore::GraphicsContext3D::compileShader):
+        (WebCore::GraphicsContext3D::compileShaderDirect):
+        (WebCore::GraphicsContext3D::detachShader):
+        (WebCore::GraphicsContext3D::getActiveAttribImpl):
+        (WebCore::GraphicsContext3D::getActiveAttrib):
+        (WebCore::GraphicsContext3D::getActiveUniformImpl):
+        (WebCore::GraphicsContext3D::getActiveUniform):
+        (WebCore::GraphicsContext3D::getAttribLocation):
+        (WebCore::GraphicsContext3D::getAttribLocationDirect):
+        (WebCore::GraphicsContext3D::moveErrorsToSyntheticErrorList):
+        (WebCore::GraphicsContext3D::linkProgram):
+        (WebCore::GraphicsContext3D::shaderSource):
+        (WebCore::GraphicsContext3D::getUnmangledInfoLog):
+        (WebCore::GraphicsContext3D::getShaderiv):
+        (WebCore::GraphicsContext3D::getShaderInfoLog):
+        (WebCore::GraphicsContext3D::getUniformLocation):
+        (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):
+        (): Deleted.
+        (WebCore::setCurrentNameHashMapForShader): Deleted.
+        (WebCore::nameHashForShader): Deleted.
+        (WebCore::GraphicsContext3D::checkVaryingsPacking const): Deleted.
+        (WebCore::GraphicsContext3D::precisionsMatch const): Deleted.
+        (WebCore::generateHashedName): Deleted.
+        (WebCore::GraphicsContext3D::mappedSymbolInShaderSourceMap): Deleted.
+        (WebCore::GraphicsContext3D::mappedSymbolName): Deleted.
+        (WebCore::GraphicsContext3D::originalSymbolInShaderSourceMap): Deleted.
+        (WebCore::GraphicsContext3D::originalSymbolName): Deleted.
+        (WebCore::GraphicsContext3D::getNonBuiltInActiveSymbolCount): Deleted.
+        (WebCore::GraphicsContext3D::getShaderSource): Deleted.
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::~GraphicsContext3D):
+        (WebCore::GraphicsContext3D::makeContextCurrent):
+        (WebCore::GraphicsContext3D::checkGPUStatus):
+        (WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
+        (WebCore::GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer):
+        * platform/graphics/cocoa/WebGLLayer.h:
+        * platform/graphics/cocoa/WebGLLayer.mm:
+        (-[WebGLLayer initWithGraphicsContext3D:]):
+        (-[WebGLLayer copyImageSnapshotWithColorSpace:]):
+        (-[WebGLLayer display]):
+        (-[WebGLLayer setEGLDisplay:andConfig:]):
+        (-[WebGLLayer dealloc]):
+        (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
+        (-[WebGLLayer bindFramebufferToNextAvailableSurface]):
+
 2019-07-10  Youenn Fablet  <youenn@apple.com>
 
         openDatabase property should not be enumerable on DOMWindow
index 21a3ad3..4737b49 100644 (file)
@@ -2675,7 +2675,11 @@ WebGLAny WebGLRenderingContextBase::getProgramParameter(WebGLProgram* program, G
         return value;
     case GraphicsContext3D::ACTIVE_ATTRIBUTES:
     case GraphicsContext3D::ACTIVE_UNIFORMS:
+#if USE(ANGLE)
+        m_context->getProgramiv(objectOrZero(program), pname, &value);
+#else
         m_context->getNonBuiltInActiveSymbolCount(objectOrZero(program), pname, &value);
+#endif // USE(ANGLE)
         return value;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getProgramParameter", "invalid parameter name");
@@ -2994,7 +2998,11 @@ RefPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUniformLocation(WebGL
         return nullptr;
 
     GC3Dint activeUniforms = 0;
+#if USE(ANGLE)
+    m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms);
+#else
     m_context->getNonBuiltInActiveSymbolCount(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms);
+#endif
     for (GC3Dint i = 0; i < activeUniforms; i++) {
         ActiveInfo info;
         if (!m_context->getActiveUniform(objectOrZero(program), i, info))
@@ -3208,11 +3216,19 @@ bool WebGLRenderingContextBase::linkProgramWithoutInvalidatingAttribLocations(We
 
     RefPtr<WebGLShader> vertexShader = program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
     RefPtr<WebGLShader> fragmentShader = program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER);
-    if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid() || !m_context->precisionsMatch(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get())) || !m_context->checkVaryingsPacking(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get()))) {
+    if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid()) {
         program->setLinkStatus(false);
         return false;
     }
 
+#if !USE(ANGLE)
+    if (!m_context->precisionsMatch(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get()))
+        || !m_context->checkVaryingsPacking(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get()))) {
+        program->setLinkStatus(false);
+        return false;
+    }
+#endif
+
     m_context->linkProgram(objectOrZero(program));
     return true;
 }
index 49eba7a..3cf58eb 100644 (file)
@@ -71,6 +71,9 @@ typedef CGLContextObj PlatformGraphicsContext3D;
 
 #if USE(ANGLE)
 typedef void* PlatformGraphicsContext3D;
+typedef void* PlatformGraphicsContext3DDisplay;
+typedef void* PlatformGraphicsContext3DSurface;
+typedef void* PlatformGraphicsContext3DConfig;
 #endif // USE(ANGLE)
 
 OBJC_CLASS CALayer;
@@ -1054,14 +1057,18 @@ public:
     void getIntegerv(GC3Denum pname, GC3Dint* value);
     void getInteger64v(GC3Denum pname, GC3Dint64* value);
     void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value);
+#if !USE(ANGLE)
     void getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value);
+#endif // !USE(ANGLE)
     String getProgramInfoLog(Platform3DObject);
     String getUnmangledInfoLog(Platform3DObject[2], GC3Dsizei, const String&);
     void getRenderbufferParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
     void getShaderiv(Platform3DObject, GC3Denum pname, GC3Dint* value);
     String getShaderInfoLog(Platform3DObject);
     void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision);
+#if !USE(ANGLE)
     String getShaderSource(Platform3DObject);
+#endif // !USE(ANGLE)
     String getString(GC3Denum name);
     void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value);
     void getTexParameteriv(GC3Denum target, GC3Denum pname, GC3Dint* value);
@@ -1127,8 +1134,10 @@ public:
 
     void useProgram(Platform3DObject);
     void validateProgram(Platform3DObject);
+#if !USE(ANGLE)
     bool checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
     bool precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const;
+#endif
 
     void vertexAttrib1f(GC3Duint index, GC3Dfloat x);
     void vertexAttrib1fv(GC3Duint index, const GC3Dfloat* values);
@@ -1186,6 +1195,11 @@ public:
     void updateFramebufferTextureBackingStoreFromLayer();
     void updateCGLContext();
 #endif
+
+#if USE(ANGLE) && PLATFORM(MAC)
+    void allocateIOSurfaceBackingStore(IntSize);
+    void updateFramebufferTextureBackingStoreFromLayer();
+#endif
 #endif // PLATFORM(COCOA)
 
     void setContextVisibility(bool);
@@ -1362,7 +1376,10 @@ private:
 #if PLATFORM(COCOA)
     RetainPtr<WebGLLayer> m_webGLLayer;
     PlatformGraphicsContext3D m_contextObj { nullptr };
-#endif
+#if USE(ANGLE)
+    PlatformGraphicsContext3DDisplay m_displayObj { nullptr };
+#endif // USE(ANGLE)
+#endif // PLATFORM(COCOA)
 
 #if PLATFORM(WIN) && USE(CA)
     RefPtr<PlatformCALayer> m_webGLLayer;
@@ -1396,6 +1413,7 @@ private:
         }
     };
 
+#if !USE(ANGLE)
     // FIXME: Shaders are never removed from this map, even if they and their program are deleted.
     // This is bad, and it also relies on the fact we never reuse Platform3DObject numbers.
     typedef HashMap<Platform3DObject, ShaderSourceEntry> ShaderSourceMap;
@@ -1434,6 +1452,7 @@ private:
     Optional<String> originalSymbolInShaderSourceMap(Platform3DObject shader, ANGLEShaderSymbolType, const String& name);
 
     std::unique_ptr<ShaderNameHash> nameHashMapForShaders;
+#endif // !USE(ANGLE)
 
 #if !PLATFORM(COCOA) && USE(OPENGL_ES)
     friend class Extensions3DOpenGLES;
@@ -1453,7 +1472,9 @@ private:
     RenderStyle m_renderStyle;
     Vector<Vector<float>> m_vertexArray;
 
+#if !USE(ANGLE)
     ANGLEWebKitBridge m_compiler;
+#endif
 
     GC3Duint m_texture { 0 };
     GC3Duint m_fbo { 0 };
@@ -1469,6 +1490,10 @@ private:
     bool m_layerComposited { false };
     GC3Duint m_internalColorFormat { 0 };
 
+#if USE(ANGLE)
+    PlatformGraphicsContext3DSurface m_pbuffer;
+#endif
+
     struct GraphicsContext3DState {
         GC3Duint boundFBO { 0 };
         GC3Denum activeTextureUnit { GraphicsContext3D::TEXTURE0 };
index 5ef9011..aa143d0 100644 (file)
 
 #include <ANGLE/entry_points_gles_2_0_autogen.h>
 #include <ANGLE/entry_points_gles_3_0_autogen.h>
+// Skip the inclusion of ANGLE's explicit context entry points for now.
+#define GL_ANGLE_explicit_context
+#define GL_ANGLE_explicit_context_gles1
+typedef void* GLeglContext;
+#include <ANGLE/entry_points_gles_ext_autogen.h>
 
 // Note: this file can't be compiled in the same unified source file
 // as others which include the system's OpenGL headers.
@@ -51,8 +56,8 @@ Extensions3DANGLE::Extensions3DANGLE(GraphicsContext3D* context, bool useIndexed
 {
     // 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)));
+    m_vendor = String(reinterpret_cast<const char*>(gl::GetString(GL_VENDOR)));
+    m_renderer = String(reinterpret_cast<const char*>(gl::GetString(GL_RENDERER)));
 
     Vector<String> vendorComponents = m_vendor.convertToASCIILowercase().split(' ');
     if (vendorComponents.contains("nvidia"))
@@ -72,62 +77,22 @@ 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);
-        }
+    // Enable support in ANGLE (if not enabled already).
+    if (m_requestableExtensions.contains(name) && !m_enabledExtensions.contains(name)) {
+        m_context->makeContextCurrent();
+        gl::RequestExtensionANGLE(name.ascii().data());
+        m_enabledExtensions.add(name);
     }
 }
 
 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);
+    return m_availableExtensions.contains(name) || m_enabledExtensions.contains(name);
 }
 
 int Extensions3DANGLE::getGraphicsResetStatusARB()
@@ -137,51 +102,17 @@ int Extensions3DANGLE::getGraphicsResetStatusARB()
 
 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())
+    int sourceLength = 0;
+    m_context->getShaderiv(shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &sourceLength);
+    if (!sourceLength)
         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)
+    Vector<GLchar> name(sourceLength); // GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE includes null termination.
+    int returnedLength = 0;
+    gl::GetTranslatedShaderSourceANGLE(shader, sourceLength, &returnedLength, name.data());
+    if (!returnedLength)
         return emptyString();
-
-    return translatedShaderSource;
+    ASSERT(returnedLength == sourceLength);
+    return String(name.data(), returnedLength);
 }
 
 void Extensions3DANGLE::initializeAvailableExtensions()
@@ -190,11 +121,17 @@ void Extensions3DANGLE::initializeAvailableExtensions()
         GLint numExtensions = 0;
         gl::GetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
         for (GLint i = 0; i < numExtensions; ++i)
-            m_availableExtensions.add(glGetStringi(GL_EXTENSIONS, i));
+            m_availableExtensions.add(gl::GetStringi(GL_EXTENSIONS, i));
+        gl::GetIntegerv(GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE, &numExtensions);
+        for (GLint i = 0; i < numExtensions; ++i)
+            m_requestableExtensions.add(gl::GetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, i));
     } else {
         String extensionsString = getExtensions();
         for (auto& extension : extensionsString.split(' '))
             m_availableExtensions.add(extension);
+        extensionsString = String(reinterpret_cast<const char*>(gl::GetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)));
+        for (auto& extension : extensionsString.split(' '))
+            m_requestableExtensions.add(extension);
     }
     m_initializedAvailableExtensions = true;
 }
@@ -217,19 +154,19 @@ void Extensions3DANGLE::getnUniformivEXT(GC3Duint, int, GC3Dsizei, int *)
 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);
+    gl::BlitFramebufferANGLE(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);
+    gl::RenderbufferStorageMultisampleANGLE(target, samples, internalformat, width, height);
 }
 
 Platform3DObject Extensions3DANGLE::createVertexArrayOES()
 {
     m_context->makeContextCurrent();
     GLuint array = 0;
-    gl::GenVertexArrays(1, &array);
+    gl::GenVertexArraysOES(1, &array);
     return array;
 }
 
@@ -239,7 +176,7 @@ void Extensions3DANGLE::deleteVertexArrayOES(Platform3DObject array)
         return;
 
     m_context->makeContextCurrent();
-    gl::DeleteVertexArrays(1, &array);
+    gl::DeleteVertexArraysOES(1, &array);
 }
 
 GC3Dboolean Extensions3DANGLE::isVertexArrayOES(Platform3DObject array)
@@ -248,13 +185,13 @@ GC3Dboolean Extensions3DANGLE::isVertexArrayOES(Platform3DObject array)
         return GL_FALSE;
 
     m_context->makeContextCurrent();
-    return gl::IsVertexArray(array);
+    return gl::IsVertexArrayOES(array);
 }
 
 void Extensions3DANGLE::bindVertexArrayOES(Platform3DObject array)
 {
     m_context->makeContextCurrent();
-    gl::BindVertexArray(array);
+    gl::BindVertexArrayOES(array);
 }
 
 void Extensions3DANGLE::insertEventMarkerEXT(const String&)
@@ -277,30 +214,30 @@ void Extensions3DANGLE::popGroupMarkerEXT(void)
 
 bool Extensions3DANGLE::supportsExtension(const String& name)
 {
-    return m_availableExtensions.contains(name);
+    return m_availableExtensions.contains(name) || m_requestableExtensions.contains(name);
 }
 
 void Extensions3DANGLE::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
 {
-    gl::DrawBuffers(n, bufs);
+    gl::DrawBuffersEXT(n, bufs);
 }
 
 void Extensions3DANGLE::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
 {
     m_context->makeContextCurrent();
-    gl::DrawArraysInstanced(mode, first, count, primcount);
+    gl::DrawArraysInstancedANGLE(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);
+    gl::DrawElementsInstancedANGLE(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);
+    gl::VertexAttribDivisorANGLE(index, divisor);
 }
 
 String Extensions3DANGLE::getExtensions()
index dc29af6..23a7a28 100644 (file)
@@ -84,6 +84,8 @@ private:
     virtual void initializeAvailableExtensions();
     bool m_initializedAvailableExtensions;
     HashSet<String> m_availableExtensions;
+    HashSet<String> m_requestableExtensions;
+    HashSet<String> m_enabledExtensions;
 
     // Weak pointer back to GraphicsContext3D.
     GraphicsContext3D* m_context;
index 94e5af3..77a3e18 100644 (file)
 #include <Accelerate/Accelerate.h>
 #endif
 
+// Skip the inclusion of ANGLE's explicit context entry points for now.
+#define GL_ANGLE_explicit_context
+#define GL_ANGLE_explicit_context_gles1
+typedef void* GLeglContext;
 #include <ANGLE/entry_points_gles_2_0_autogen.h>
 #include <ANGLE/entry_points_gles_3_0_autogen.h>
+#include <ANGLE/entry_points_gles_ext_autogen.h>
+#include <ANGLE/gl2ext.h>
+#include <ANGLE/gl2ext_angle.h>
 
 // Note: this file can't be compiled in the same unified source file
 // as others which include the system's OpenGL headers.
@@ -64,6 +71,8 @@
 
 namespace WebCore {
 
+static const char* packedDepthStencilExtensionName = "GL_OES_packed_depth_stencil";
+
 void GraphicsContext3D::releaseShaderCompiler()
 {
     makeContextCurrent();
@@ -115,7 +124,7 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int
 
 void GraphicsContext3D::validateAttributes()
 {
-    validateDepthStencil("GL_EXT_packed_depth_stencil");
+    validateDepthStencil(packedDepthStencilExtensionName);
 }
 
 bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
@@ -137,7 +146,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
         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;
+            internalDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
         else
             internalDepthStencilFormat = GL_DEPTH_COMPONENT16;
     }
@@ -145,24 +154,30 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     // Resize multisample FBO.
     if (m_attrs.antialias) {
         GLint maxSampleCount;
-        gl::GetIntegerv(GL_MAX_SAMPLES_EXT, &maxSampleCount);
+        gl::GetIntegerv(GL_MAX_SAMPLES_ANGLE, &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);
+        getExtensions().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);
+            getExtensions().renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, internalDepthStencilFormat, width, height);
+            // WebGL 1.0's rules state that combined depth/stencil renderbuffers
+            // have to be attached to the synthetic DEPTH_STENCIL_ATTACHMENT point.
+            if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES)
+                gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer);
+            else {
+                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) {
+        if (gl::CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
             // FIXME: cleanup.
             notImplemented();
         }
@@ -174,33 +189,21 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 #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);
+    allocateIOSurfaceBackingStore(IntSize(width, height));
+    updateFramebufferTextureBackingStoreFromLayer();
+    gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, 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
+#error Unknown Cocoa 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
+
+#error Must port to non-Cocoa platforms
+
 #endif // PLATFORM(COCOA)
 
     attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
@@ -223,14 +226,20 @@ void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepth
     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);
+        // WebGL 1.0's rules state that combined depth/stencil renderbuffers
+        // have to be attached to the synthetic DEPTH_STENCIL_ATTACHMENT point.
+        if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES)
+            gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
+        else {
+            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) {
+    if (gl::CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
         // FIXME: cleanup
         notImplemented();
     }
@@ -240,15 +249,21 @@ 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);
+
+    GLint boundFrameBuffer;
+    gl::GetIntegerv(GL_FRAMEBUFFER_BINDING, &boundFrameBuffer);
+    gl::BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO);
+    gl::BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo);
 
     // FIXME: figure out more efficient solution for iOS.
     IntRect resolveRect = rect;
-    if (rect.isEmpty())
+    // When using an ES 2.0 context, the full framebuffer must always be
+    // resolved; partial blits are not allowed.
+    if (!isGLES2Compliant() || 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);
+    gl::BlitFramebufferANGLE(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
+    gl::BindFramebuffer(GL_FRAMEBUFFER, boundFrameBuffer);
 }
 
 void GraphicsContext3D::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
@@ -375,71 +390,25 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
 
 // 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)
 {
+    // Note there are no Extensions3D::ensureEnabled calls here. The ANGLE
+    // backend currently assumes at a fairly deep level that
+    // EGL_EXTENSIONS_ENABLED_ANGLE is set to true during context creation: for
+    // the allocation of rectangular textures, etc.
     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())
+        // FIXME: must adjust this when upgrading to WebGL 2.0 / OpenGL ES 3.0 support.
+        if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || !extensions.supports("GL_ANGLE_framebuffer_blit") || !extensions.supports("GL_OES_rgb8_rgba8") || isGLES2Compliant())
             m_attrs.antialias = false;
-        else
-            extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");
     }
 }
 
@@ -513,33 +482,9 @@ void GraphicsContext3D::prepareTexture()
 
     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();
 }
 
@@ -651,68 +596,6 @@ void GraphicsContext3D::reshape(int width, int height)
     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);
@@ -730,7 +613,6 @@ void GraphicsContext3D::attachShader(Platform3DObject program, Platform3DObject
     ASSERT(program);
     ASSERT(shader);
     makeContextCurrent();
-    m_shaderProgramSymbolCountMap.remove(program);
     gl::AttachShader(program, shader);
 }
 
@@ -738,10 +620,7 @@ void GraphicsContext3D::bindAttribLocation(Platform3DObject program, GC3Duint in
 {
     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());
+    gl::BindAttribLocation(program, index, name.utf8().data());
 }
 
 void GraphicsContext3D::bindBuffer(GC3Denum target, Platform3DObject buffer)
@@ -914,97 +793,12 @@ 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.");
-    }
+    gl::CompileShader(shader);
 }
 
 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.");
-    }
+    compileShader(shader);
 }
 
 void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
@@ -1054,7 +848,6 @@ void GraphicsContext3D::detachShader(Platform3DObject program, Platform3DObject
     ASSERT(program);
     ASSERT(shader);
     makeContextCurrent();
-    m_shaderProgramSymbolCountMap.remove(program);
     gl::DetachShader(program, shader);
 }
 
@@ -1150,14 +943,7 @@ bool GraphicsContext3D::getActiveAttribImpl(Platform3DObject program, GC3Duint i
     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.name = String(name.data(), nameLength);
     info.type = type;
     info.size = size;
     return true;
@@ -1165,17 +951,7 @@ bool GraphicsContext3D::getActiveAttribImpl(Platform3DObject program, GC3Duint i
 
 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);
+    return getActiveAttribImpl(program, index, info);
 }
 
 bool GraphicsContext3D::getActiveUniformImpl(Platform3DObject program, GC3Duint index, ActiveInfo& info)
@@ -1197,14 +973,7 @@ bool GraphicsContext3D::getActiveUniformImpl(Platform3DObject program, GC3Duint
     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.name = String(name.data(), nameLength);
     info.type = type;
     info.size = size;
     return true;
@@ -1212,17 +981,7 @@ bool GraphicsContext3D::getActiveUniformImpl(Platform3DObject program, GC3Duint
 
 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);
+    return getActiveUniformImpl(program, index, info);
 }
 
 void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei maxCount, GC3Dsizei* count, Platform3DObject* shaders)
@@ -1235,143 +994,6 @@ void GraphicsContext3D::getAttachedShaders(Platform3DObject program, GC3Dsizei m
     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)
@@ -1379,19 +1001,12 @@ int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String&
 
     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());
+    return gl::GetAttribLocation(program, name.utf8().data());
 }
 
 int GraphicsContext3D::getAttribLocationDirect(Platform3DObject program, const String& name)
 {
-    if (!program)
-        return -1;
-
-    makeContextCurrent();
-
-    return gl::GetAttribLocation(program, name.utf8().data());
+    return getAttribLocation(program, name);
 }
 
 GraphicsContext3DAttributes GraphicsContext3D::getContextAttributes()
@@ -1408,7 +1023,7 @@ bool GraphicsContext3D::moveErrorsToSyntheticErrorList()
     // 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();
+        GC3Denum error = gl::GetError();
         if (error == NO_ERROR)
             break;
         m_syntheticErrors.add(error);
@@ -1514,14 +1129,6 @@ 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);
 }
 
@@ -1555,11 +1162,10 @@ void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri
 
     makeContextCurrent();
 
-    ShaderSourceEntry entry;
-
-    entry.source = string;
-
-    m_shaderSourceMap.set(shader, entry);
+    const CString& shaderSourceCString = string.utf8();
+    const char* shaderSourcePtr = shaderSourceCString.data();
+    int shaderSourceLength = shaderSourceCString.length();
+    gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength);
 }
 
 void GraphicsContext3D::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask)
@@ -1878,80 +1484,20 @@ void GraphicsContext3D::getProgramiv(Platform3DObject program, GC3Denum pname, G
     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)
 {
+    UNUSED_PARAM(shaders);
+    UNUSED_PARAM(count);
     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());
@@ -1990,34 +1536,7 @@ void GraphicsContext3D::getShaderiv(Platform3DObject shader, GC3Denum pname, GC3
     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);
-    }
+    gl::GetShaderiv(shader, pname, value);
 }
 
 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
@@ -2025,15 +1544,6 @@ 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)
@@ -2047,20 +1557,6 @@ String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
     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();
@@ -2090,10 +1586,7 @@ GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const St
     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());
+    return gl::GetUniformLocation(program, name.utf8().data());
 }
 
 void GraphicsContext3D::getVertexAttribfv(GC3Duint index, GC3Denum pname, GC3Dfloat* value)
@@ -2144,7 +1637,7 @@ Platform3DObject GraphicsContext3D::createBuffer()
 {
     makeContextCurrent();
     GLuint o = 0;
-    glGenBuffers(1, &o);
+    gl::GenBuffers(1, &o);
     return o;
 }
 
@@ -2152,35 +1645,35 @@ Platform3DObject GraphicsContext3D::createFramebuffer()
 {
     makeContextCurrent();
     GLuint o = 0;
-    glGenFramebuffers(1, &o);
+    gl::GenFramebuffers(1, &o);
     return o;
 }
 
 Platform3DObject GraphicsContext3D::createProgram()
 {
     makeContextCurrent();
-    return glCreateProgram();
+    return gl::CreateProgram();
 }
 
 Platform3DObject GraphicsContext3D::createRenderbuffer()
 {
     makeContextCurrent();
     GLuint o = 0;
-    glGenRenderbuffers(1, &o);
+    gl::GenRenderbuffers(1, &o);
     return o;
 }
 
 Platform3DObject GraphicsContext3D::createShader(GC3Denum type)
 {
     makeContextCurrent();
-    return glCreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
+    return gl::CreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);
 }
 
 Platform3DObject GraphicsContext3D::createTexture()
 {
     makeContextCurrent();
     GLuint o = 0;
-    glGenTextures(1, &o);
+    gl::GenTextures(1, &o);
     m_state.textureSeedCount.add(o);
     return o;
 }
@@ -2188,7 +1681,7 @@ Platform3DObject GraphicsContext3D::createTexture()
 void GraphicsContext3D::deleteBuffer(Platform3DObject buffer)
 {
     makeContextCurrent();
-    glDeleteBuffers(1, &buffer);
+    gl::DeleteBuffers(1, &buffer);
 }
 
 void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer)
@@ -2199,26 +1692,25 @@ void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer)
         // operations after it gets deleted.
         bindFramebuffer(FRAMEBUFFER, 0);
     }
-    glDeleteFramebuffers(1, &framebuffer);
+    gl::DeleteFramebuffers(1, &framebuffer);
 }
 
 void GraphicsContext3D::deleteProgram(Platform3DObject program)
 {
     makeContextCurrent();
-    m_shaderProgramSymbolCountMap.remove(program);
-    glDeleteProgram(program);
+    gl::DeleteProgram(program);
 }
 
 void GraphicsContext3D::deleteRenderbuffer(Platform3DObject renderbuffer)
 {
     makeContextCurrent();
-    glDeleteRenderbuffers(1, &renderbuffer);
+    gl::DeleteRenderbuffers(1, &renderbuffer);
 }
 
 void GraphicsContext3D::deleteShader(Platform3DObject shader)
 {
     makeContextCurrent();
-    glDeleteShader(shader);
+    gl::DeleteShader(shader);
 }
 
 void GraphicsContext3D::deleteTexture(Platform3DObject texture)
@@ -2227,7 +1719,7 @@ void GraphicsContext3D::deleteTexture(Platform3DObject texture)
     m_state.boundTextureMap.removeIf([texture] (auto& keyValue) {
         return keyValue.value.first == texture;
     });
-    glDeleteTextures(1, &texture);
+    gl::DeleteTextures(1, &texture);
     m_state.textureSeedCount.removeAll(texture);
 }
 
@@ -2235,7 +1727,7 @@ 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.
+    // any errors from gl::Error before the error we are synthesizing.
     moveErrorsToSyntheticErrorList();
     m_syntheticErrors.add(error);
 }
index 2defba2..e3e287d 100644 (file)
 #import <OpenGL/CGLRenderers.h>
 #import <OpenGL/gl.h>
 #elif USE(ANGLE)
+#define EGL_EGL_PROTOTYPES 0
+// Skip the inclusion of ANGLE's explicit context entry points for now.
+#define GL_ANGLE_explicit_context
+#define GL_ANGLE_explicit_context_gles1
+typedef void* GLeglContext;
+#include <ANGLE/egl.h>
+#include <ANGLE/eglext.h>
+#include <ANGLE/eglext_angle.h>
+#include <ANGLE/entry_points_egl.h>
 #include <ANGLE/entry_points_gles_2_0_autogen.h>
+#include <ANGLE/entry_points_gles_ext_autogen.h>
+#include <ANGLE/gl2ext.h>
+#include <ANGLE/gl2ext_angle.h>
 #endif
 
 #if USE(OPENGL_ES) || USE(OPENGL)
@@ -254,10 +266,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     , 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);
+    // In the ANGLE backend, the only shader compiler instantiated is
+    // the one ANGLE uses internally.
 #else
 #if PLATFORM(IOS_FAMILY)
     if (m_attrs.isWebGL2)
@@ -368,13 +378,70 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART);
 
 #elif USE(ANGLE)
-
-    // FIXME: implement context setup via ANGLE.
     UNUSED_PARAM(hostWindow);
     UNUSED_PARAM(sharedContext);
 
-#endif
-    
+    m_displayObj = EGL_GetDisplay(EGL_DEFAULT_DISPLAY);
+    if (m_displayObj == EGL_NO_DISPLAY)
+        return;
+    EGLint majorVersion, minorVersion;
+    if (EGL_Initialize(m_displayObj, &majorVersion, &minorVersion) == EGL_FALSE) {
+        LOG(WebGL, "EGLDisplay Initialization failed.");
+        return;
+    }
+    LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion);
+    const char *displayExtensions = EGL_QueryString(m_displayObj, EGL_EXTENSIONS);
+    LOG(WebGL, "Extensions: %s", displayExtensions);
+
+    EGLConfig config;
+    EGLint configAttributes[] = {
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+        EGL_RED_SIZE, 8,
+        EGL_GREEN_SIZE, 8,
+        EGL_BLUE_SIZE, 8,
+        EGL_ALPHA_SIZE, 8,
+        EGL_NONE
+    };
+    EGLint numberConfigsReturned = 0;
+    EGL_ChooseConfig(m_displayObj, configAttributes, &config, 1, &numberConfigsReturned);
+    if (numberConfigsReturned != 1) {
+        LOG(WebGL, "EGLConfig Initialization failed.");
+        return;
+    }
+    LOG(WebGL, "Got EGLConfig");
+
+    EGL_BindAPI(EGL_OPENGL_ES_API);
+    if (EGL_GetError() != EGL_SUCCESS) {
+        LOG(WebGL, "Unable to bind to OPENGL_ES_API");
+        return;
+    }
+
+    std::vector<EGLint> contextAttributes;
+    contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
+    contextAttributes.push_back(2);
+    contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
+    contextAttributes.push_back(EGL_TRUE);
+    contextAttributes.push_back(EGL_EXTENSIONS_ENABLED_ANGLE);
+    contextAttributes.push_back(EGL_TRUE);
+    if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) {
+        contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
+        // EGL_LOW_POWER_ANGLE is the default. Change to
+        // EGL_HIGH_POWER_ANGLE if desired.
+        contextAttributes.push_back(EGL_LOW_POWER_ANGLE);
+    }
+    contextAttributes.push_back(EGL_NONE);
+
+    m_contextObj = EGL_CreateContext(m_displayObj, config, EGL_NO_CONTEXT, contextAttributes.data());
+    if (m_contextObj == EGL_NO_CONTEXT) {
+        LOG(WebGL, "EGLContext Initialization failed.");
+        return;
+    }
+    LOG(WebGL, "Got EGLContext");
+
+    EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
+
+#endif // #elif USE(ANGLE)
+
     validateAttributes();
 
     // Create the WebGLLayer
@@ -383,6 +450,9 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 #ifndef NDEBUG
         [m_webGLLayer setName:@"WebGL Layer"];
 #endif
+#if USE(ANGLE)
+        [m_webGLLayer setEGLDisplay:m_displayObj andConfig:config];
+#endif
     END_BLOCK_OBJC_EXCEPTIONS
 
 #if USE(OPENGL)
@@ -404,7 +474,13 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     ::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.
+    gl::GenTextures(1, &m_texture);
+    gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_texture);
+    gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0);
 #else
 #error Unsupported configuration
 #endif
@@ -427,9 +503,28 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         if (m_attrs.stencil || m_attrs.depth)
             ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     }
-#endif // USE(ANGLE) || USE(OPENGL_ES)
+#elif USE(ANGLE)
+    gl::GenFramebuffers(1, &m_fbo);
+    gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+    m_state.boundFBO = m_fbo;
+
+    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+        gl::GenRenderbuffers(1, &m_depthStencilBuffer);
+
+    // If necessary, create another framebuffer for the multisample results.
+    if (m_attrs.antialias) {
+        gl::GenFramebuffers(1, &m_multisampleFBO);
+        gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
+        m_state.boundFBO = m_multisampleFBO;
+        gl::GenRenderbuffers(1, &m_multisampleColorBuffer);
+        if (m_attrs.stencil || m_attrs.depth)
+            gl::GenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+    }
+
+#endif // USE(ANGLE)
 
-    // ANGLE initialization.
+#if !USE(ANGLE)
+    // ANGLE shader compiler initialization.
 
     ShBuiltInResources ANGLEResources;
     sh::InitBuiltInResources(&ANGLEResources);
@@ -450,6 +545,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
 
     m_compiler.setResources(ANGLEResources);
+#endif // !USE(ANGLE)
     
 #if USE(OPENGL)
     ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
@@ -459,6 +555,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 
 #if USE(OPENGL) || USE(OPENGL_ES)
     ::glClearColor(0, 0, 0, 0);
+#elif USE(ANGLE)
+    gl::ClearColor(0, 0, 0, 0);
 #endif
 
     LOG(WebGL, "Created a GraphicsContext3D (%p).", this);
@@ -477,7 +575,8 @@ GraphicsContext3D::~GraphicsContext3D()
         CGLSetCurrentContext(m_contextObj);
         ::glDeleteTextures(1, &m_texture);
 #elif USE(ANGLE)
-        // FIXME: make context current via ANGLE.
+        EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
+        gl::DeleteTextures(1, &m_texture);
 #endif
 
 #if USE(OPENGL) || USE(OPENGL_ES)
@@ -491,6 +590,17 @@ GraphicsContext3D::~GraphicsContext3D()
                 ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer);
         }
         ::glDeleteFramebuffersEXT(1, &m_fbo);
+#elif USE(ANGLE)
+        if (m_attrs.antialias) {
+            gl::DeleteRenderbuffers(1, &m_multisampleColorBuffer);
+            if (m_attrs.stencil || m_attrs.depth)
+                gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
+            gl::DeleteFramebuffers(1, &m_multisampleFBO);
+        } else {
+            if (m_attrs.stencil || m_attrs.depth)
+                gl::DeleteRenderbuffers(1, &m_depthStencilBuffer);
+        }
+        gl::DeleteFramebuffers(1, &m_fbo);
 #endif
 
 #if USE(OPENGL_ES)
@@ -500,7 +610,8 @@ GraphicsContext3D::~GraphicsContext3D()
         CGLSetCurrentContext(0);
         CGLDestroyContext(m_contextObj);
 #elif USE(ANGLE)
-        // FIXME: implement context teardown via ANGLE.
+        EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        EGL_DestroyContext(m_displayObj, m_contextObj);
 #endif
         [m_webGLLayer setContext:nullptr];
     }
@@ -537,7 +648,8 @@ bool GraphicsContext3D::makeContextCurrent()
     if (currentContext != m_contextObj)
         return CGLSetCurrentContext(m_contextObj) == kCGLNoError;
 #elif USE(ANGLE)
-    // FIXME: implement making context current via ANGLE.
+    if (EGL_GetCurrentContext() != m_contextObj)
+        return EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
 #endif
     return true;
 }
@@ -553,7 +665,7 @@ void GraphicsContext3D::checkGPUStatus()
 #elif USE(OPENGL_ES)
         [EAGLContext setCurrentContext:0];
 #elif USE(ANGLE)
-        // FIXME: implement forced context loss via ANGLE.
+        EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 #endif
         return;
     }
@@ -657,7 +769,21 @@ void GraphicsContext3D::setContextVisibility(bool isVisible)
             GraphicsContext3DManager::sharedManager().removeContextRequiringHighPerformance(this);
     }
 }
-#endif
+#endif // USE(OPENGL)
+
+#if USE(ANGLE)
+void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size)
+{
+    LOG(WebGL, "GraphicsContext3D::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this);
+    [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:m_attrs.alpha];
+}
+
+void GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer()
+{
+    LOG(WebGL, "GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer(). (%p)", this);
+    [m_webGLLayer bindFramebufferToNextAvailableSurface];
+}
+#endif // USE(ANGLE)
 
 bool GraphicsContext3D::isGLES2Compliant() const
 {
index 234e8e1..1d3b6d5 100644 (file)
@@ -50,13 +50,21 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 {
     WebCore::GraphicsContext3D* _context;
     float _devicePixelRatio;
-#if USE(OPENGL)
+#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
     std::unique_ptr<WebCore::IOSurface> _contentsBuffer;
     std::unique_ptr<WebCore::IOSurface> _drawingBuffer;
     std::unique_ptr<WebCore::IOSurface> _spareBuffer;
     WebCore::IntSize _bufferSize;
     BOOL _usingAlpha;
 #endif
+#if USE(ANGLE) && PLATFORM(MAC)
+    void* _eglDisplay;
+    void* _eglConfig;
+    void* _contentsPbuffer;
+    void* _drawingPbuffer;
+    void* _sparePbuffer;
+    void* _latchedPbuffer;
+#endif
 }
 
 @property (nonatomic) WebCore::GraphicsContext3D* context;
@@ -65,11 +73,16 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 
 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace;
 
-#if USE(OPENGL)
+#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha;
 - (void)bindFramebufferToNextAvailableSurface;
 #endif
 
+#if (USE(ANGLE) && PLATFORM(MAC))
+- (void)setEGLDisplay:(void*)eglDisplay andConfig:(void*)eglConfig;
+- (void)dealloc;
+#endif
+
 @end
 
 ALLOW_DEPRECATED_DECLARATIONS_END
index f4d2d00..85d8362 100644 (file)
 #import <OpenGL/gl.h>
 #endif
 
+#if USE(ANGLE)
+#define EGL_EGL_PROTOTYPES 0
+#include <ANGLE/egl.h>
+#include <ANGLE/eglext.h>
+#include <ANGLE/eglext_angle.h>
+#include <ANGLE/entry_points_egl.h>
+#include <ANGLE/entry_points_gles_2_0_autogen.h>
+// Skip the inclusion of ANGLE's explicit context entry points for now.
+#define GL_ANGLE_explicit_context
+#include <ANGLE/gl2ext.h>
+#include <ANGLE/gl2ext_angle.h>
+#endif
+
 @implementation WebGLLayer
 
 @synthesize context=_context;
@@ -52,7 +65,7 @@
     _context = context;
     self = [super init];
     _devicePixelRatio = context->getContextAttributes().devicePixelRatio;
-#if USE(OPENGL)
+#if USE(OPENGL) || USE(ANGLE) && PLATFORM(MAC)
     self.contentsOpaque = !context->getContextAttributes().alpha;
     self.transform = CATransform3DIdentity;
     self.contentsScale = _devicePixelRatio;
@@ -62,7 +75,7 @@
     return self;
 }
 
-#if USE(OPENGL)
+#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
 // When using an IOSurface as layer contents, we need to flip the
 // layer to take into account that the IOSurface provides content
 // in Y-up. This means that any incoming transform (unlikely, since
 {
     [super setAnchorPoint:CGPointMake(p.x, 1.0 - p.y)];
 }
+#endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
 
+#if USE(OPENGL)
 static void freeData(void *, const void *data, size_t /* size */)
 {
     fastFree(const_cast<void *>(data));
 }
-#endif
+#endif // USE(OPENGL)
 
 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace
 {
@@ -118,6 +133,7 @@ static void freeData(void *, const void *data, size_t /* size */)
     CGDataProviderRelease(provider);
     return image;
 #else
+    // FIXME: implement.
     UNUSED_PARAM(colorSpace);
     return nullptr;
 #endif
@@ -139,7 +155,23 @@ static void freeData(void *, const void *data, size_t /* size */)
 #elif USE(OPENGL_ES)
     _context->presentRenderbuffer();
 #elif USE(ANGLE)
-    // FIXME: display rendering results via ANGLE.
+    _context->prepareTexture();
+    if (_drawingBuffer) {
+        if (_latchedPbuffer) {
+            GC3Denum texture = _context->platformTexture();
+            gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture);
+            if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
+                // FIXME: report error.
+                notImplemented();
+            }
+            _latchedPbuffer = nullptr;
+        }
+        std::swap(_contentsBuffer, _drawingBuffer);
+        std::swap(_contentsPbuffer, _drawingPbuffer);
+        self.contents = _contentsBuffer->asLayerContents();
+        [self reloadValueForKeyPath:@"contents"];
+        [self bindFramebufferToNextAvailableSurface];
+    }
 #endif
 
     _context->markLayerComposited();
@@ -148,7 +180,23 @@ static void freeData(void *, const void *data, size_t /* size */)
         layer->owner()->platformCALayerLayerDidDisplay(layer);
 }
 
-#if USE(OPENGL)
+#if (USE(ANGLE) && PLATFORM(MAC))
+- (void)setEGLDisplay:(void*)display andConfig:(void*)config
+{
+    _eglDisplay = display;
+    _eglConfig = config;
+}
+
+- (void)dealloc
+{
+    EGL_DestroySurface(_eglDisplay, _contentsPbuffer);
+    EGL_DestroySurface(_eglDisplay, _drawingPbuffer);
+    EGL_DestroySurface(_eglDisplay, _sparePbuffer);
+    [super dealloc];
+}
+#endif
+
+#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha
 {
     _bufferSize = size;
@@ -164,10 +212,28 @@ static void freeData(void *, const void *data, size_t /* size */)
     _contentsBuffer->migrateColorSpaceToProperties();
     _drawingBuffer->migrateColorSpaceToProperties();
     _spareBuffer->migrateColorSpaceToProperties();
+
+#if USE(ANGLE) && PLATFORM(MAC)
+    const EGLint surfaceAttributes[] = {
+        EGL_WIDTH, size.width(),
+        EGL_HEIGHT, size.height(),
+        EGL_IOSURFACE_PLANE_ANGLE, 0,
+        EGL_TEXTURE_TARGET, EGL_TEXTURE_RECTANGLE_ANGLE,
+        EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, GL_BGRA_EXT,
+        EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
+        EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE,
+        EGL_NONE, EGL_NONE
+    };
+
+    _contentsPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _contentsBuffer->surface(), _eglConfig, surfaceAttributes);
+    _drawingPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _drawingBuffer->surface(), _eglConfig, surfaceAttributes);
+    _sparePbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _spareBuffer->surface(), _eglConfig, surfaceAttributes);
+#endif
 }
 
 - (void)bindFramebufferToNextAvailableSurface
 {
+#if USE(OPENGL)
     GC3Denum texture = _context->platformTexture();
     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
 
@@ -180,8 +246,32 @@ static void freeData(void *, const void *data, size_t /* size */)
     // Link the IOSurface to the texture.
     CGLError error = CGLTexImageIOSurface2D(_context->platformGraphicsContext3D(), GL_TEXTURE_RECTANGLE_ARB, internalFormat, _bufferSize.width(), _bufferSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, ioSurface, 0);
     ASSERT_UNUSED(error, error == kCGLNoError);
-}
+#elif USE(ANGLE)
+    GC3Denum texture = _context->platformTexture();
+    gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture);
+
+    if (_latchedPbuffer) {
+        if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
+            // FIXME: report error.
+            notImplemented();
+        }
+        _latchedPbuffer = nullptr;
+    }
+
+    if (_drawingBuffer && _drawingBuffer->isInUse()) {
+        std::swap(_drawingBuffer, _spareBuffer);
+        std::swap(_drawingPbuffer, _sparePbuffer);
+    }
+
+    // Link the IOSurface to the texture via the previously-created pbuffer.
+    if (!EGL_BindTexImage(_eglDisplay, _drawingPbuffer, EGL_BACK_BUFFER)) {
+        // FIXME: report error.
+        notImplemented();
+    }
+    _latchedPbuffer = _drawingPbuffer;
 #endif
+}
+#endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
 
 @end