Add ANGLE backend for iOS device
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 18:58:06 +0000 (18:58 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 18:58:06 +0000 (18:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202159
<rdar://57000166>

Reviewed by Myles Maxfield.

Source/ThirdParty/ANGLE:

Add an OpenGLES backend over EAGL for iOS to ANGLE.

This is basically a copy of all the files in
libANGLE/renderer/gl/cgl into libANGLE/renderer/gl/eagl, then with
modifications to make it work on iOS's OpenGL ES. Most notably,
some format enums and the manner in which you bind an IOSurface to
a GL texture are different.

This introduces a few places where we have to do a compile time
switch for iOS, some of which might actually be applicable to
other OpenGL ES backends.

The biggest missing piece is support for the iOS simulator. At the moment
this backend relies on an IOSurface binding as a rendering target.
But the iOS Simulator does not have the required ability to have a
GL ES texture backed by an IOSurface.

The WindowSurfaceEAGL code is incomplete, but was not necessary
in order to get WebGL operational. And even if you are using ANGLE
directly, you can have the client code render into a CALayer without
going through the WindowSurface.

* ANGLE.xcodeproj/project.pbxproj:
* include/EGL/eglext_angle.h:
* src/common/PackedEnums.cpp:
(egl_gl::EGLTextureTargetToTextureType):
* src/common/platform.h:
* src/gpu_info_util/SystemInfo_ios.cpp: Added.
(angle::GetSystemInfo):
* src/gpu_info_util/SystemInfo_macos.cpp: Renamed from Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_mac.cpp.
(angle::GetSystemInfo):
* src/libANGLE/Caps.h:
* src/libANGLE/Display.cpp:
* src/libANGLE/formatutils.cpp:
(gl::BuildInternalFormatInfoMap):
* src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp:
* src/libANGLE/renderer/gl/cgl/DisplayCGL.mm:
* src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp:
(rx::IOSurfaceSurfaceCGL::bindTexImage):
* src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp:
* src/libANGLE/renderer/gl/cgl/RendererCGL.cpp:
* src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm:
* src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp: Added.
(rx::ContextEAGL::ContextEAGL):
* src/libANGLE/renderer/gl/eagl/ContextEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp: Added.
(rx::DeviceEAGL::DeviceEAGL):
(rx::DeviceEAGL::~DeviceEAGL):
(rx::DeviceEAGL::initialize):
(rx::DeviceEAGL::getAttribute):
(rx::DeviceEAGL::getType):
(rx::DeviceEAGL::generateExtensions const):
* src/libANGLE/renderer/gl/eagl/DeviceEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/DisplayEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm: Added.
(rx::FunctionsGLEAGL::FunctionsGLEAGL):
(rx::DisplayEAGL::DisplayEAGL):
(rx::DisplayEAGL::~DisplayEAGL):
(rx::DisplayEAGL::initialize):
(rx::DisplayEAGL::terminate):
(rx::DisplayEAGL::createWindowSurface):
(rx::DisplayEAGL::createPbufferSurface):
(rx::DisplayEAGL::createPbufferFromClientBuffer):
(rx::DisplayEAGL::createPixmapSurface):
(rx::DisplayEAGL::createContext):
(rx::DisplayEAGL::createDevice):
(rx::DisplayEAGL::generateConfigs):
(rx::DisplayEAGL::testDeviceLost):
(rx::DisplayEAGL::restoreLostDevice):
(rx::DisplayEAGL::isValidNativeWindow const):
(rx::DisplayEAGL::validateClientBuffer const):
(rx::DisplayEAGL::getVendorString const):
(rx::DisplayEAGL::getEAGLContext const):
(rx::DisplayEAGL::getEAGLPixelFormat const):
(rx::DisplayEAGL::generateExtensions const):
(rx::DisplayEAGL::generateCaps const):
(rx::DisplayEAGL::waitClient):
(rx::DisplayEAGL::waitNative):
(rx::DisplayEAGL::getMaxSupportedESVersion const):
(rx::DisplayEAGL::makeCurrentSurfaceless):
(rx::WorkerContextEAGL::WorkerContextEAGL):
(rx::WorkerContextEAGL::~WorkerContextEAGL):
(rx::WorkerContextEAGL::makeCurrent):
(rx::WorkerContextEAGL::unmakeCurrent):
(rx::DisplayEAGL::createWorkerContext):
(rx::DisplayEAGL::initializeFrontendFeatures const):
(rx::DisplayEAGL::populateFeatureList):
* src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp.
(rx::IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL):
(rx::IOSurfaceSurfaceEAGL::~IOSurfaceSurfaceEAGL):
(rx::IOSurfaceSurfaceEAGL::initialize):
(rx::IOSurfaceSurfaceEAGL::makeCurrent):
(rx::IOSurfaceSurfaceEAGL::unMakeCurrent):
(rx::IOSurfaceSurfaceEAGL::swap):
(rx::IOSurfaceSurfaceEAGL::postSubBuffer):
(rx::IOSurfaceSurfaceEAGL::querySurfacePointerANGLE):
(rx::IOSurfaceSurfaceEAGL::bindTexImage):
(rx::IOSurfaceSurfaceEAGL::releaseTexImage):
(rx::IOSurfaceSurfaceEAGL::setSwapInterval):
(rx::IOSurfaceSurfaceEAGL::getWidth const):
(rx::IOSurfaceSurfaceEAGL::getHeight const):
(rx::IOSurfaceSurfaceEAGL::isPostSubBufferSupported const):
(rx::IOSurfaceSurfaceEAGL::getSwapBehavior const):
(rx::IOSurfaceSurfaceEAGL::validateAttributes):
(rx::IOSurfaceFramebuffer::IOSurfaceFramebuffer):
(rx::IOSurfaceSurfaceEAGL::createDefaultFramebuffer):
(rx::IOSurfaceSurfaceEAGL::initializeAlphaChannel):
(rx::IOSurfaceSurfaceEAGL::hasEmulatedAlphaChannel const):
* src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp.
(rx::PbufferSurfaceEAGL::PbufferSurfaceEAGL):
(rx::PbufferSurfaceEAGL::~PbufferSurfaceEAGL):
(rx::PbufferSurfaceEAGL::initialize):
(rx::PbufferSurfaceEAGL::makeCurrent):
(rx::PbufferSurfaceEAGL::swap):
(rx::PbufferSurfaceEAGL::postSubBuffer):
(rx::PbufferSurfaceEAGL::querySurfacePointerANGLE):
(rx::PbufferSurfaceEAGL::bindTexImage):
(rx::PbufferSurfaceEAGL::releaseTexImage):
(rx::PbufferSurfaceEAGL::setSwapInterval):
(rx::PbufferSurfaceEAGL::getWidth const):
(rx::PbufferSurfaceEAGL::getHeight const):
(rx::PbufferSurfaceEAGL::isPostSubBufferSupported const):
(rx::PbufferSurfaceEAGL::getSwapBehavior const):
(rx::PbufferSurfaceEAGL::createDefaultFramebuffer):
* src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp: Added.
(rx::RendererEAGL::RendererEAGL):
(rx::RendererEAGL::~RendererEAGL):
(rx::RendererEAGL::createWorkerContext):
* src/libANGLE/renderer/gl/eagl/RendererEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h: Added.
* src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm.
(-[WebSwapLayer initWithSharedState:withContext:withFunctions:]):
(-[WebSwapLayer display]):
(rx::WindowSurfaceEAGL::WindowSurfaceEAGL):
(rx::WindowSurfaceEAGL::~WindowSurfaceEAGL):
(rx::WindowSurfaceEAGL::initialize):
(rx::WindowSurfaceEAGL::makeCurrent):
(rx::WindowSurfaceEAGL::swap):
(rx::WindowSurfaceEAGL::postSubBuffer):
(rx::WindowSurfaceEAGL::querySurfacePointerANGLE):
(rx::WindowSurfaceEAGL::bindTexImage):
(rx::WindowSurfaceEAGL::releaseTexImage):
(rx::WindowSurfaceEAGL::setSwapInterval):
(rx::WindowSurfaceEAGL::getWidth const):
(rx::WindowSurfaceEAGL::getHeight const):
(rx::WindowSurfaceEAGL::isPostSubBufferSupported const):
(rx::WindowSurfaceEAGL::getSwapBehavior const):
(rx::WindowSurfaceEAGL::createDefaultFramebuffer):
* src/libANGLE/renderer/gl/renderergl_utils.cpp:
(rx::nativegl_gl::GenerateCaps):
* src/libANGLE/validationES2.cpp:
(gl::ValidateFramebufferTexture2D):
* src/libGLESv2/entry_points_egl_ext.cpp:

Source/WebCore:

Use the ANGLE for iOS backend.

Mostly this was just moving some code around so that it would compile
on iOS when USE(ANGLE) is true. The actual code to render WebGL is
similar between macOS and iOS - both now using a CALayer with
a set of IOSurfaces that are used as swap textures.

The main difference is that macOS (OpenGL) binds to TEXTURE_RECTANGLE,
and iOS (OpenGL ES) binds to the regular TEXTURE_2D.

The remaining missing piece is getting video textures into ANGLE
efficiently (without leaving the GPU). We can ask CoreVideo
to give us raw GL textures, but with ANGLE we no longer have direct access
to the underlying OpenGL context.

This is not enabled in the builds yet, so no tests. However, when
enabled it will be tested against the official WebGL conformance suite.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::validateVertexAttributes):
* platform/cocoa/CoreVideoSoftLink.cpp:
* platform/cocoa/CoreVideoSoftLink.h:
* platform/graphics/GraphicsContext3D.h:
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::reshapeFBOs):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
(WebCore::GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer):
* platform/graphics/cocoa/WebGLLayer.h:
* platform/graphics/cocoa/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]):
(-[WebGLLayer display]):
(-[WebGLLayer setEGLDisplay:config:]):
(-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
(-[WebGLLayer bindFramebufferToNextAvailableSurface]):
(-[WebGLLayer setEGLDisplay:andConfig:]): Deleted.
* platform/graphics/cv/TextureCacheCV.mm:
(WebCore::TextureCacheCV::textureFromImage):
* platform/graphics/cv/VideoTextureCopierCV.cpp:
(WebCore::VideoTextureCopierCV::copyVideoTextureToPlatformTexture):
* platform/graphics/opengl/TemporaryOpenGLSetting.cpp:
* platform/graphics/opengl/TemporaryOpenGLSetting.h:

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

40 files changed:
Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
Source/ThirdParty/ANGLE/ChangeLog
Source/ThirdParty/ANGLE/include/EGL/eglext_angle.h
Source/ThirdParty/ANGLE/src/common/PackedEnums.cpp
Source/ThirdParty/ANGLE/src/common/platform.h
Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_ios.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_macos.cpp [moved from Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_mac.cpp with 97% similarity]
Source/ThirdParty/ANGLE/src/libANGLE/Caps.h
Source/ThirdParty/ANGLE/src/libANGLE/Display.cpp
Source/ThirdParty/ANGLE/src/libANGLE/formatutils.cpp
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm [new file with mode: 0644]
Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/renderergl_utils.cpp
Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp
Source/ThirdParty/ANGLE/src/libGLESv2/entry_points_egl_ext.cpp
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
Source/WebCore/platform/graphics/GraphicsContext3D.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
Source/WebCore/platform/graphics/cv/TextureCacheCV.mm
Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp
Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp
Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.h

index 2da05fe..7724a30 100644 (file)
                31012E8018B97B9B0039062F /* VersionGLSL.h in Headers */ = {isa = PBXBuildFile; fileRef = 31012E1118B97B9B0039062F /* VersionGLSL.h */; };
                312BDB0C15FECAC90097EBC7 /* ANGLE.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0915FEC91E0097EBC7 /* ANGLE.plist */; };
                312BDB0E15FECAE50097EBC7 /* LICENSE in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0A15FECA3A0097EBC7 /* LICENSE */; };
+               313BCE542361133A00FC39E5 /* DisplayEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE462361133800FC39E5 /* DisplayEAGL.h */; };
+               313BCE552361133A00FC39E5 /* IOSurfaceSurfaceEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE472361133800FC39E5 /* IOSurfaceSurfaceEAGL.h */; };
+               313BCE562361133A00FC39E5 /* PbufferSurfaceEAGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE482361133800FC39E5 /* PbufferSurfaceEAGL.cpp */; };
+               313BCE572361133A00FC39E5 /* RendererEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE492361133900FC39E5 /* RendererEAGL.h */; };
+               313BCE582361133A00FC39E5 /* ContextEAGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE4A2361133900FC39E5 /* ContextEAGL.cpp */; };
+               313BCE592361133A00FC39E5 /* RendererEAGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE4B2361133900FC39E5 /* RendererEAGL.cpp */; };
+               313BCE5A2361133A00FC39E5 /* DeviceEAGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE4C2361133900FC39E5 /* DeviceEAGL.cpp */; };
+               313BCE5B2361133A00FC39E5 /* DeviceEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE4D2361133900FC39E5 /* DeviceEAGL.h */; };
+               313BCE5C2361133A00FC39E5 /* IOSurfaceSurfaceEAGL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE4E2361133900FC39E5 /* IOSurfaceSurfaceEAGL.mm */; };
+               313BCE5D2361133A00FC39E5 /* PbufferSurfaceEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE4F2361133900FC39E5 /* PbufferSurfaceEAGL.h */; };
+               313BCE5E2361133A00FC39E5 /* WindowSurfaceEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE502361133900FC39E5 /* WindowSurfaceEAGL.h */; };
+               313BCE5F2361133A00FC39E5 /* ContextEAGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE512361133900FC39E5 /* ContextEAGL.h */; };
+               313BCE612361133A00FC39E5 /* DisplayEAGL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE532361133900FC39E5 /* DisplayEAGL.mm */; };
                315EBD3F1FCE43BD00AC7A89 /* uniform_type_info_autogen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 315EBD3E1FCE43BD00AC7A89 /* uniform_type_info_autogen.cpp */; };
                315EBD781FCE443600AC7A89 /* TranslatorVulkan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 315EBD401FCE442600AC7A89 /* TranslatorVulkan.cpp */; };
                315EBD7B1FCE443600AC7A89 /* UtilsHLSL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 315EBD431FCE442700AC7A89 /* UtilsHLSL.cpp */; };
                31A331C81EA5ED5F00FD2203 /* vector_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A331C51EA5ED5F00FD2203 /* vector_utils.h */; };
                31A331DC1EA5EDDA00FD2203 /* Severity.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A331D11EA5EDDA00FD2203 /* Severity.h */; };
                31A331E21EA5EFB800FD2203 /* trace_event.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A331E11EA5EFB800FD2203 /* trace_event.h */; };
+               31B15720236B7FAF00CAA4FD /* SystemInfo_ios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31B1571F236B7FAE00CAA4FD /* SystemInfo_ios.cpp */; };
+               31B15722236B803300CAA4FD /* SystemInfo_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 31B15721236B803300CAA4FD /* SystemInfo_internal.h */; };
+               31B15723236B82BB00CAA4FD /* WindowSurfaceEAGL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 313BCE522361133900FC39E5 /* WindowSurfaceEAGL.mm */; };
                5C1BAA9A1DFB60FF002906BB /* gl3.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1BAA961DFB60FF002906BB /* gl3.h */; settings = {ATTRIBUTES = (Public, ); }; };
                5C1BAA9B1DFB60FF002906BB /* gl3platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1BAA971DFB60FF002906BB /* gl3platform.h */; settings = {ATTRIBUTES = (Public, ); }; };
                5C1BAA9C1DFB60FF002906BB /* gl31.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1BAA981DFB60FF002906BB /* gl31.h */; settings = {ATTRIBUTES = (Public, ); }; };
                5CCD59932284FC400018F2D8 /* imageformats.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCD598B2284FC400018F2D8 /* imageformats.h */; };
                5CCD59942284FC400018F2D8 /* generatemip.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCD598C2284FC400018F2D8 /* generatemip.h */; };
                5CCD59952284FC400018F2D8 /* loadimage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD598D2284FC400018F2D8 /* loadimage.cpp */; };
-               5CCD599A2284FC750018F2D8 /* SystemInfo_mac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD59972284FC750018F2D8 /* SystemInfo_mac.cpp */; };
+               5CCD599A2284FC750018F2D8 /* SystemInfo_macos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD59972284FC750018F2D8 /* SystemInfo_macos.cpp */; };
                5CCD599B2284FC750018F2D8 /* SystemInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD59982284FC750018F2D8 /* SystemInfo.cpp */; };
                5CCD599C2284FC750018F2D8 /* SystemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCD59992284FC750018F2D8 /* SystemInfo.h */; };
                5CCD599E2284FCDE0018F2D8 /* Context_gles_1_0.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD599D2284FCDD0018F2D8 /* Context_gles_1_0.cpp */; };
                31012E1118B97B9B0039062F /* VersionGLSL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionGLSL.h; sourceTree = "<group>"; };
                312BDB0915FEC91E0097EBC7 /* ANGLE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ANGLE.plist; sourceTree = "<group>"; };
                312BDB0A15FECA3A0097EBC7 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
+               313BCE462361133800FC39E5 /* DisplayEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayEAGL.h; sourceTree = "<group>"; };
+               313BCE472361133800FC39E5 /* IOSurfaceSurfaceEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSurfaceSurfaceEAGL.h; sourceTree = "<group>"; };
+               313BCE482361133800FC39E5 /* PbufferSurfaceEAGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PbufferSurfaceEAGL.cpp; sourceTree = "<group>"; };
+               313BCE492361133900FC39E5 /* RendererEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RendererEAGL.h; sourceTree = "<group>"; };
+               313BCE4A2361133900FC39E5 /* ContextEAGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextEAGL.cpp; sourceTree = "<group>"; };
+               313BCE4B2361133900FC39E5 /* RendererEAGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RendererEAGL.cpp; sourceTree = "<group>"; };
+               313BCE4C2361133900FC39E5 /* DeviceEAGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceEAGL.cpp; sourceTree = "<group>"; };
+               313BCE4D2361133900FC39E5 /* DeviceEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceEAGL.h; sourceTree = "<group>"; };
+               313BCE4E2361133900FC39E5 /* IOSurfaceSurfaceEAGL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSurfaceSurfaceEAGL.mm; sourceTree = "<group>"; };
+               313BCE4F2361133900FC39E5 /* PbufferSurfaceEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PbufferSurfaceEAGL.h; sourceTree = "<group>"; };
+               313BCE502361133900FC39E5 /* WindowSurfaceEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowSurfaceEAGL.h; sourceTree = "<group>"; };
+               313BCE512361133900FC39E5 /* ContextEAGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextEAGL.h; sourceTree = "<group>"; };
+               313BCE522361133900FC39E5 /* WindowSurfaceEAGL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowSurfaceEAGL.mm; sourceTree = "<group>"; };
+               313BCE532361133900FC39E5 /* DisplayEAGL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayEAGL.mm; sourceTree = "<group>"; };
                315EBD3E1FCE43BD00AC7A89 /* uniform_type_info_autogen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uniform_type_info_autogen.cpp; sourceTree = "<group>"; };
                315EBD401FCE442600AC7A89 /* TranslatorVulkan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TranslatorVulkan.cpp; sourceTree = "<group>"; };
                315EBD431FCE442700AC7A89 /* UtilsHLSL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilsHLSL.cpp; sourceTree = "<group>"; };
                31A331C51EA5ED5F00FD2203 /* vector_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vector_utils.h; sourceTree = "<group>"; };
                31A331D11EA5EDDA00FD2203 /* Severity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Severity.h; sourceTree = "<group>"; };
                31A331E11EA5EFB800FD2203 /* trace_event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = trace_event.h; path = trace_event/trace_event.h; sourceTree = "<group>"; };
+               31B1571F236B7FAE00CAA4FD /* SystemInfo_ios.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemInfo_ios.cpp; sourceTree = "<group>"; };
+               31B15721236B803300CAA4FD /* SystemInfo_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemInfo_internal.h; sourceTree = "<group>"; };
                5C1BAA961DFB60FF002906BB /* gl3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl3.h; path = include/GLES3/gl3.h; sourceTree = "<group>"; };
                5C1BAA971DFB60FF002906BB /* gl3platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl3platform.h; path = include/GLES3/gl3platform.h; sourceTree = "<group>"; };
                5C1BAA981DFB60FF002906BB /* gl31.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl31.h; path = include/GLES3/gl31.h; sourceTree = "<group>"; };
                5CCD598B2284FC400018F2D8 /* imageformats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imageformats.h; sourceTree = "<group>"; };
                5CCD598C2284FC400018F2D8 /* generatemip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = generatemip.h; sourceTree = "<group>"; };
                5CCD598D2284FC400018F2D8 /* loadimage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = loadimage.cpp; sourceTree = "<group>"; };
-               5CCD59972284FC750018F2D8 /* SystemInfo_mac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemInfo_mac.cpp; sourceTree = "<group>"; };
+               5CCD59972284FC750018F2D8 /* SystemInfo_macos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemInfo_macos.cpp; sourceTree = "<group>"; };
                5CCD59982284FC750018F2D8 /* SystemInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemInfo.cpp; sourceTree = "<group>"; };
                5CCD59992284FC750018F2D8 /* SystemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemInfo.h; sourceTree = "<group>"; };
                5CCD599D2284FCDD0018F2D8 /* Context_gles_1_0.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Context_gles_1_0.cpp; sourceTree = "<group>"; };
                        name = misc;
                        sourceTree = "<group>";
                };
+               313BCE272360F78900FC39E5 /* eagl */ = {
+                       isa = PBXGroup;
+                       children = (
+                               313BCE4A2361133900FC39E5 /* ContextEAGL.cpp */,
+                               313BCE512361133900FC39E5 /* ContextEAGL.h */,
+                               313BCE4C2361133900FC39E5 /* DeviceEAGL.cpp */,
+                               313BCE4D2361133900FC39E5 /* DeviceEAGL.h */,
+                               313BCE462361133800FC39E5 /* DisplayEAGL.h */,
+                               313BCE532361133900FC39E5 /* DisplayEAGL.mm */,
+                               313BCE472361133800FC39E5 /* IOSurfaceSurfaceEAGL.h */,
+                               313BCE4E2361133900FC39E5 /* IOSurfaceSurfaceEAGL.mm */,
+                               313BCE482361133800FC39E5 /* PbufferSurfaceEAGL.cpp */,
+                               313BCE4F2361133900FC39E5 /* PbufferSurfaceEAGL.h */,
+                               313BCE4B2361133900FC39E5 /* RendererEAGL.cpp */,
+                               313BCE492361133900FC39E5 /* RendererEAGL.h */,
+                               313BCE502361133900FC39E5 /* WindowSurfaceEAGL.h */,
+                               313BCE522361133900FC39E5 /* WindowSurfaceEAGL.mm */,
+                       );
+                       path = eagl;
+                       sourceTree = "<group>";
+               };
                315EBE0B1FCE45AC00AC7A89 /* third_party */ = {
                        isa = PBXGroup;
                        children = (
                        children = (
                                5CCD59982284FC750018F2D8 /* SystemInfo.cpp */,
                                5CCD59992284FC750018F2D8 /* SystemInfo.h */,
-                               313BCE442360F9AD00FC39E5 /* SystemInfo_internal.h */,
-                               5CCD59972284FC750018F2D8 /* SystemInfo_mac.cpp */,
+                               31B15721236B803300CAA4FD /* SystemInfo_internal.h */,
+                               31B1571F236B7FAE00CAA4FD /* SystemInfo_ios.cpp */,
+                               5CCD59972284FC750018F2D8 /* SystemInfo_macos.cpp */,
                        );
                        name = gpuinfoutil;
                        path = gpu_info_util;
                                5C1DBDE31B0438D300235552 /* Context.h in Headers */,
                                A30307272305F7C4002DA972 /* Context.inl.h in Headers */,
                                5CCD597B2284FA830018F2D8 /* ContextCGL.h in Headers */,
-                               313BCE3D2360F78A00FC39E5 /* ContextEAGL.h in Headers */,
+                               313BCE5F2361133A00FC39E5 /* ContextEAGL.h in Headers */,
                                5CB3011D1DE39F1A00D2C405 /* ContextGL.h in Headers */,
                                5CB304DE1DE4164800D2C405 /* ContextImpl.h in Headers */,
                                5CCD598E2284FC400018F2D8 /* copyimage.h in Headers */,
                                5C55D68922826B9F00B5BA2C /* DeferGlobalInitializers.h in Headers */,
                                5C1DBDE71B0438D300235552 /* Device.h in Headers */,
                                6E31A0A4234EEED400C84784 /* DeviceCGL.h in Headers */,
-                               313BCE432360F78A00FC39E5 /* DeviceEAGL.h in Headers */,
+                               313BCE5B2361133A00FC39E5 /* DeviceEAGL.h in Headers */,
                                5CB304E01DE4164800D2C405 /* DeviceImpl.h in Headers */,
                                31012E2718B97B9B0039062F /* Diagnostics.h in Headers */,
                                A264F8AD16974DED006FAA5A /* DiagnosticsBase.h in Headers */,
                                315EBDBC1FCE44BF00AC7A89 /* DispatchTableGL_autogen.h in Headers */,
                                5C1DBDE91B0438D300235552 /* Display.h in Headers */,
                                5CB3014F1DE39F4700D2C405 /* DisplayCGL.h in Headers */,
-                               313BCE3B2360F78A00FC39E5 /* DisplayEAGL.h in Headers */,
+                               313BCE542361133A00FC39E5 /* DisplayEAGL.h in Headers */,
                                5CB3011F1DE39F1A00D2C405 /* DisplayGL.h in Headers */,
                                5CB304E21DE4164800D2C405 /* DisplayImpl.h in Headers */,
                                315EBDC91FCE44E400AC7A89 /* driver_utils.h in Headers */,
                                5C55D70822826CB300B5BA2C /* IntermNodePatternMatcher.h in Headers */,
                                5C55D70122826CB300B5BA2C /* IntermTraverse.h in Headers */,
                                5CCD59772284FA830018F2D8 /* IOSurfaceSurfaceCGL.h in Headers */,
-                               313BCE412360F78A00FC39E5 /* IOSurfaceSurfaceEAGL.h in Headers */,
+                               313BCE552361133A00FC39E5 /* IOSurfaceSurfaceEAGL.h in Headers */,
                                315EBD8E1FCE443600AC7A89 /* IsASTDepthBelowLimit.h in Headers */,
                                A264F8CD169762AA006FAA5A /* khrplatform.h in Headers */,
                                5C1DBC321B04375F00235552 /* length_limits.h in Headers */,
                                5CB3012E1DE39F1A00D2C405 /* PathGL.h in Headers */,
                                5CB304F11DE4164800D2C405 /* PathImpl.h in Headers */,
                                5CB301511DE39F4700D2C405 /* PbufferSurfaceCGL.h in Headers */,
-                               313BCE3C2360F78A00FC39E5 /* PbufferSurfaceEAGL.h in Headers */,
+                               313BCE5D2361133A00FC39E5 /* PbufferSurfaceEAGL.h in Headers */,
                                5C1DBBF51B0436EC00235552 /* platform.h in Headers */,
                                315EBE291FCF808C00AC7A89 /* PMurHash.h in Headers */,
                                5C55D7272282747700B5BA2C /* PoolAlloc.h in Headers */,
                                5CB304F51DE4164800D2C405 /* RenderbufferImpl_mock.h in Headers */,
                                5CB304F81DE4164800D2C405 /* renderer_utils.h in Headers */,
                                5CCD597C2284FA830018F2D8 /* RendererCGL.h in Headers */,
-                               313BCE3E2360F78A00FC39E5 /* RendererEAGL.h in Headers */,
+                               313BCE572361133A00FC39E5 /* RendererEAGL.h in Headers */,
                                5CB301381DE39F1A00D2C405 /* RendererGL.h in Headers */,
                                5CB301361DE39F1A00D2C405 /* renderergl_utils.h in Headers */,
                                A30307072305F636002DA972 /* ReplaceShadowingVariables.h in Headers */,
                                31A331C71EA5ED5F00FD2203 /* system_utils.h in Headers */,
                                5C55D72B2282747700B5BA2C /* system_utils_unittest_helper.h in Headers */,
                                5CCD599C2284FC750018F2D8 /* SystemInfo.h in Headers */,
-                               313BCE452360F9AD00FC39E5 /* SystemInfo_internal.h in Headers */,
+                               31B15722236B803300CAA4FD /* SystemInfo_internal.h in Headers */,
                                5C1DBF311B0438D300235552 /* Texture.h in Headers */,
                                315EBD9E1FCE443600AC7A89 /* TextureFunctionHLSL.h in Headers */,
                                5CB301421DE39F1A00D2C405 /* TextureGL.h in Headers */,
                                5C1DBF421B0438D300235552 /* VertexAttribute.h in Headers */,
                                5C55D70022826CB300B5BA2C /* Visit.h in Headers */,
                                A31B6183230B747F001610D7 /* WindowSurfaceCGL.h in Headers */,
-                               313BCE372360F78A00FC39E5 /* WindowSurfaceEAGL.h in Headers */,
+                               313BCE5E2361133A00FC39E5 /* WindowSurfaceEAGL.h in Headers */,
                                315EBDFA1FCE452D00AC7A89 /* WorkerThread.h in Headers */,
                                5C55D67522826B9F00B5BA2C /* WrapSwitchStatementsInBlocks.h in Headers */,
                                5CCD59512284ECD10018F2D8 /* xxhash.h in Headers */,
                                A30307242305F7C4002DA972 /* Context_gl.cpp in Sources */,
                                5CCD599E2284FCDE0018F2D8 /* Context_gles_1_0.cpp in Sources */,
                                5CCD59782284FA830018F2D8 /* ContextCGL.cpp in Sources */,
+                               313BCE582361133A00FC39E5 /* ContextEAGL.cpp in Sources */,
                                5CB3011C1DE39F1A00D2C405 /* ContextGL.cpp in Sources */,
                                5CB304DD1DE4164800D2C405 /* ContextImpl.cpp in Sources */,
                                5CCD598F2284FC400018F2D8 /* copyimage.cpp in Sources */,
                                5C55D6AF22826BC800B5BA2C /* DeferGlobalInitializers.cpp in Sources */,
                                5C1DBDE61B0438D300235552 /* Device.cpp in Sources */,
                                6E31A0A3234EEED400C84784 /* DeviceCGL.cpp in Sources */,
+                               313BCE5A2361133A00FC39E5 /* DeviceEAGL.cpp in Sources */,
                                5CB304DF1DE4164800D2C405 /* DeviceImpl.cpp in Sources */,
                                31012E2618B97B9B0039062F /* Diagnostics.cpp in Sources */,
                                A264F8AC16974DED006FAA5A /* DiagnosticsBase.cpp in Sources */,
                                315EBDBE1FCE44BF00AC7A89 /* DispatchTableGL_autogen.cpp in Sources */,
                                5C1DBDE81B0438D300235552 /* Display.cpp in Sources */,
                                5CCD596E2284F9510018F2D8 /* DisplayCGL.mm in Sources */,
+                               313BCE612361133A00FC39E5 /* DisplayEAGL.mm in Sources */,
                                5CB3011E1DE39F1A00D2C405 /* DisplayGL.cpp in Sources */,
                                5CB304E11DE4164800D2C405 /* DisplayImpl.cpp in Sources */,
                                315EBDCC1FCE44E400AC7A89 /* driver_utils.cpp in Sources */,
                                5C55D70422826CB300B5BA2C /* IntermNodePatternMatcher.cpp in Sources */,
                                5C55D70222826CB300B5BA2C /* IntermTraverse.cpp in Sources */,
                                5CCD59792284FA830018F2D8 /* IOSurfaceSurfaceCGL.cpp in Sources */,
+                               313BCE5C2361133A00FC39E5 /* IOSurfaceSurfaceEAGL.mm in Sources */,
                                315EBD9C1FCE443600AC7A89 /* IsASTDepthBelowLimit.cpp in Sources */,
                                A264F8B616974DED006FAA5A /* Lexer.cpp in Sources */,
                                5CB304EF1DE4164800D2C405 /* load_functions_table_autogen.cpp in Sources */,
                                5CCD817A1DBFE999006066B8 /* Path.cpp in Sources */,
                                5CB3012D1DE39F1A00D2C405 /* PathGL.cpp in Sources */,
                                5CCD596F2284F9550018F2D8 /* PbufferSurfaceCGL.cpp in Sources */,
+                               313BCE562361133A00FC39E5 /* PbufferSurfaceEAGL.cpp in Sources */,
                                5C1DBDFE1B0438D300235552 /* Platform.cpp in Sources */,
                                315EBE281FCF808C00AC7A89 /* PMurHash.cpp in Sources */,
                                31012E5618B97B9B0039062F /* PoolAlloc.cpp in Sources */,
                                5CB301331DE39F1A00D2C405 /* RenderbufferGL.cpp in Sources */,
                                5CB304F71DE4164800D2C405 /* renderer_utils.cpp in Sources */,
                                5CCD597A2284FA830018F2D8 /* RendererCGL.cpp in Sources */,
+                               313BCE592361133A00FC39E5 /* RendererEAGL.cpp in Sources */,
                                5CB301371DE39F1A00D2C405 /* RendererGL.cpp in Sources */,
                                5CB301351DE39F1A00D2C405 /* renderergl_utils.cpp in Sources */,
                                A30307052305F636002DA972 /* ReplaceShadowingVariables.cpp in Sources */,
                                5C55D7302282747700B5BA2C /* system_utils_posix.cpp in Sources */,
                                5C55D7202282747700B5BA2C /* system_utils_unittest_helper.cpp in Sources */,
                                5CCD599B2284FC750018F2D8 /* SystemInfo.cpp in Sources */,
-                               5CCD599A2284FC750018F2D8 /* SystemInfo_mac.cpp in Sources */,
+                               31B15720236B7FAF00CAA4FD /* SystemInfo_ios.cpp in Sources */,
+                               5CCD599A2284FC750018F2D8 /* SystemInfo_macos.cpp in Sources */,
                                5C1DBF301B0438D300235552 /* Texture.cpp in Sources */,
                                315EBD991FCE443600AC7A89 /* TextureFunctionHLSL.cpp in Sources */,
                                5CB301411DE39F1A00D2C405 /* TextureGL.cpp in Sources */,
                                5CB301451DE39F1A00D2C405 /* VertexArrayGL.cpp in Sources */,
                                5C1DBF411B0438D300235552 /* VertexAttribute.cpp in Sources */,
                                A31B6184230B747F001610D7 /* WindowSurfaceCGL.mm in Sources */,
+                               31B15723236B82BB00CAA4FD /* WindowSurfaceEAGL.mm in Sources */,
                                315EBDE71FCE452D00AC7A89 /* WorkerThread.cpp in Sources */,
                                5C55D6D522826BC800B5BA2C /* WrapSwitchStatementsInBlocks.cpp in Sources */,
                                5CCD59502284ECD10018F2D8 /* xxhash.c in Sources */,
index 41ee9e0..fa4561e 100644 (file)
@@ -1,3 +1,167 @@
+2019-11-07  Dean Jackson  <dino@apple.com>
+
+        Add ANGLE backend for iOS device
+        https://bugs.webkit.org/show_bug.cgi?id=202159
+        <rdar://57000166>
+
+        Reviewed by Myles Maxfield.
+
+        Add an OpenGLES backend over EAGL for iOS to ANGLE.
+
+        This is basically a copy of all the files in
+        libANGLE/renderer/gl/cgl into libANGLE/renderer/gl/eagl, then with
+        modifications to make it work on iOS's OpenGL ES. Most notably,
+        some format enums and the manner in which you bind an IOSurface to
+        a GL texture are different.
+
+        This introduces a few places where we have to do a compile time
+        switch for iOS, some of which might actually be applicable to
+        other OpenGL ES backends.
+
+        The biggest missing piece is support for the iOS simulator. At the moment
+        this backend relies on an IOSurface binding as a rendering target.
+        But the iOS Simulator does not have the required ability to have a
+        GL ES texture backed by an IOSurface.
+
+        The WindowSurfaceEAGL code is incomplete, but was not necessary
+        in order to get WebGL operational. And even if you are using ANGLE
+        directly, you can have the client code render into a CALayer without
+        going through the WindowSurface.
+
+        * ANGLE.xcodeproj/project.pbxproj:
+        * include/EGL/eglext_angle.h:
+        * src/common/PackedEnums.cpp:
+        (egl_gl::EGLTextureTargetToTextureType):
+        * src/common/platform.h:
+        * src/gpu_info_util/SystemInfo_ios.cpp: Added.
+        (angle::GetSystemInfo):
+        * src/gpu_info_util/SystemInfo_macos.cpp: Renamed from Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_mac.cpp.
+        (angle::GetSystemInfo):
+        * src/libANGLE/Caps.h:
+        * src/libANGLE/Display.cpp:
+        * src/libANGLE/formatutils.cpp:
+        (gl::BuildInternalFormatInfoMap):
+        * src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp:
+        * src/libANGLE/renderer/gl/cgl/DisplayCGL.mm:
+        * src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp:
+        (rx::IOSurfaceSurfaceCGL::bindTexImage):
+        * src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp:
+        * src/libANGLE/renderer/gl/cgl/RendererCGL.cpp:
+        * src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm:
+        * src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp: Added.
+        (rx::ContextEAGL::ContextEAGL):
+        * src/libANGLE/renderer/gl/eagl/ContextEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp: Added.
+        (rx::DeviceEAGL::DeviceEAGL):
+        (rx::DeviceEAGL::~DeviceEAGL):
+        (rx::DeviceEAGL::initialize):
+        (rx::DeviceEAGL::getAttribute):
+        (rx::DeviceEAGL::getType):
+        (rx::DeviceEAGL::generateExtensions const):
+        * src/libANGLE/renderer/gl/eagl/DeviceEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/DisplayEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm: Added.
+        (rx::FunctionsGLEAGL::FunctionsGLEAGL):
+        (rx::DisplayEAGL::DisplayEAGL):
+        (rx::DisplayEAGL::~DisplayEAGL):
+        (rx::DisplayEAGL::initialize):
+        (rx::DisplayEAGL::terminate):
+        (rx::DisplayEAGL::createWindowSurface):
+        (rx::DisplayEAGL::createPbufferSurface):
+        (rx::DisplayEAGL::createPbufferFromClientBuffer):
+        (rx::DisplayEAGL::createPixmapSurface):
+        (rx::DisplayEAGL::createContext):
+        (rx::DisplayEAGL::createDevice):
+        (rx::DisplayEAGL::generateConfigs):
+        (rx::DisplayEAGL::testDeviceLost):
+        (rx::DisplayEAGL::restoreLostDevice):
+        (rx::DisplayEAGL::isValidNativeWindow const):
+        (rx::DisplayEAGL::validateClientBuffer const):
+        (rx::DisplayEAGL::getVendorString const):
+        (rx::DisplayEAGL::getEAGLContext const):
+        (rx::DisplayEAGL::getEAGLPixelFormat const):
+        (rx::DisplayEAGL::generateExtensions const):
+        (rx::DisplayEAGL::generateCaps const):
+        (rx::DisplayEAGL::waitClient):
+        (rx::DisplayEAGL::waitNative):
+        (rx::DisplayEAGL::getMaxSupportedESVersion const):
+        (rx::DisplayEAGL::makeCurrentSurfaceless):
+        (rx::WorkerContextEAGL::WorkerContextEAGL):
+        (rx::WorkerContextEAGL::~WorkerContextEAGL):
+        (rx::WorkerContextEAGL::makeCurrent):
+        (rx::WorkerContextEAGL::unmakeCurrent):
+        (rx::DisplayEAGL::createWorkerContext):
+        (rx::DisplayEAGL::initializeFrontendFeatures const):
+        (rx::DisplayEAGL::populateFeatureList):
+        * src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp.
+        (rx::IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL):
+        (rx::IOSurfaceSurfaceEAGL::~IOSurfaceSurfaceEAGL):
+        (rx::IOSurfaceSurfaceEAGL::initialize):
+        (rx::IOSurfaceSurfaceEAGL::makeCurrent):
+        (rx::IOSurfaceSurfaceEAGL::unMakeCurrent):
+        (rx::IOSurfaceSurfaceEAGL::swap):
+        (rx::IOSurfaceSurfaceEAGL::postSubBuffer):
+        (rx::IOSurfaceSurfaceEAGL::querySurfacePointerANGLE):
+        (rx::IOSurfaceSurfaceEAGL::bindTexImage):
+        (rx::IOSurfaceSurfaceEAGL::releaseTexImage):
+        (rx::IOSurfaceSurfaceEAGL::setSwapInterval):
+        (rx::IOSurfaceSurfaceEAGL::getWidth const):
+        (rx::IOSurfaceSurfaceEAGL::getHeight const):
+        (rx::IOSurfaceSurfaceEAGL::isPostSubBufferSupported const):
+        (rx::IOSurfaceSurfaceEAGL::getSwapBehavior const):
+        (rx::IOSurfaceSurfaceEAGL::validateAttributes):
+        (rx::IOSurfaceFramebuffer::IOSurfaceFramebuffer):
+        (rx::IOSurfaceSurfaceEAGL::createDefaultFramebuffer):
+        (rx::IOSurfaceSurfaceEAGL::initializeAlphaChannel):
+        (rx::IOSurfaceSurfaceEAGL::hasEmulatedAlphaChannel const):
+        * src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp.
+        (rx::PbufferSurfaceEAGL::PbufferSurfaceEAGL):
+        (rx::PbufferSurfaceEAGL::~PbufferSurfaceEAGL):
+        (rx::PbufferSurfaceEAGL::initialize):
+        (rx::PbufferSurfaceEAGL::makeCurrent):
+        (rx::PbufferSurfaceEAGL::swap):
+        (rx::PbufferSurfaceEAGL::postSubBuffer):
+        (rx::PbufferSurfaceEAGL::querySurfacePointerANGLE):
+        (rx::PbufferSurfaceEAGL::bindTexImage):
+        (rx::PbufferSurfaceEAGL::releaseTexImage):
+        (rx::PbufferSurfaceEAGL::setSwapInterval):
+        (rx::PbufferSurfaceEAGL::getWidth const):
+        (rx::PbufferSurfaceEAGL::getHeight const):
+        (rx::PbufferSurfaceEAGL::isPostSubBufferSupported const):
+        (rx::PbufferSurfaceEAGL::getSwapBehavior const):
+        (rx::PbufferSurfaceEAGL::createDefaultFramebuffer):
+        * src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp: Added.
+        (rx::RendererEAGL::RendererEAGL):
+        (rx::RendererEAGL::~RendererEAGL):
+        (rx::RendererEAGL::createWorkerContext):
+        * src/libANGLE/renderer/gl/eagl/RendererEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h: Added.
+        * src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm: Copied from Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm.
+        (-[WebSwapLayer initWithSharedState:withContext:withFunctions:]):
+        (-[WebSwapLayer display]):
+        (rx::WindowSurfaceEAGL::WindowSurfaceEAGL):
+        (rx::WindowSurfaceEAGL::~WindowSurfaceEAGL):
+        (rx::WindowSurfaceEAGL::initialize):
+        (rx::WindowSurfaceEAGL::makeCurrent):
+        (rx::WindowSurfaceEAGL::swap):
+        (rx::WindowSurfaceEAGL::postSubBuffer):
+        (rx::WindowSurfaceEAGL::querySurfacePointerANGLE):
+        (rx::WindowSurfaceEAGL::bindTexImage):
+        (rx::WindowSurfaceEAGL::releaseTexImage):
+        (rx::WindowSurfaceEAGL::setSwapInterval):
+        (rx::WindowSurfaceEAGL::getWidth const):
+        (rx::WindowSurfaceEAGL::getHeight const):
+        (rx::WindowSurfaceEAGL::isPostSubBufferSupported const):
+        (rx::WindowSurfaceEAGL::getSwapBehavior const):
+        (rx::WindowSurfaceEAGL::createDefaultFramebuffer):
+        * src/libANGLE/renderer/gl/renderergl_utils.cpp:
+        (rx::nativegl_gl::GenerateCaps):
+        * src/libANGLE/validationES2.cpp:
+        (gl::ValidateFramebufferTexture2D):
+        * src/libGLESv2/entry_points_egl_ext.cpp:
+
 2019-11-06  Dean Jackson  <dino@apple.com>
 
         [ANGLE] IOSurfaceSurfaceCGL has format and internalFormat flipped
index ab5cb8d..d3dd23d 100644 (file)
@@ -259,6 +259,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribANGLE(EGLDisplay dpy, EGLint
 #define EGL_CGL_PIXEL_FORMAT_ANGLE 0x3486
 #endif
 
+#ifndef EGL_ANGLE_device_eagl
+#define EGL_ANGLE_device_eagl 1
+#define EGL_EAGL_CONTEXT_ANGLE 0x3487
+// FIXME: Do we need an EGL_PIXEL_FORMAT_ANGLE?
+// #define EGL_EAGL_PIXEL_FORMAT_ANGLE 0x3488
+#endif
+
 // clang-format on
 
 #endif  // INCLUDE_EGL_EGLEXT_ANGLE_
index d4bd028..8cb9e50 100644 (file)
@@ -374,7 +374,11 @@ gl::TextureType EGLTextureTargetToTextureType(EGLenum eglTarget)
             return gl::TextureType::_2D;
 
         case EGL_TEXTURE_RECTANGLE_ANGLE:
+#if defined(ANGLE_PLATFORM_IOS)
+            return gl::TextureType::_2D;
+#else
             return gl::TextureType::Rectangle;
+#endif
 
         default:
             UNREACHABLE();
index c4e1f8f..e957d12 100644 (file)
 #        define ANGLE_PLATFORM_MACOS 1
 #    elif TARGET_OS_IOS
 #        define ANGLE_PLATFORM_IOS 1
+#        define GLES_SILENCE_DEPRECATION
+#        if TARGET_OS_SIMULATOR
+#            define ANGLE_PLATFORM_IOS_SIMULATOR 1
+#        endif
 #    endif
 #endif
 
diff --git a/Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_ios.cpp b/Source/ThirdParty/ANGLE/src/gpu_info_util/SystemInfo_ios.cpp
new file mode 100644 (file)
index 0000000..dace74a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+// SystemInfo_ios.cpp: implementation of the iOS-specific parts of SystemInfo.h
+
+#include "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#include "gpu_info_util/SystemInfo_internal.h"
+
+namespace angle
+{
+
+bool GetSystemInfo(SystemInfo *info)
+{
+    {
+        // FIXME: Get the actual system version.
+        info->machineModelVersion = "0.0";
+    }
+
+    return true;
+}
+
+}  // namespace angle
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
@@ -4,11 +4,11 @@
 // found in the LICENSE file.
 //
 
-// SystemInfo_mac.cpp: implementation of the Mac-specific parts of SystemInfo.h
+// SystemInfo_macos.cpp: implementation of the macOS-specific parts of SystemInfo.h
 
-#if defined(__APPLE__)
-#include <TargetConditionals.h>
-#if TARGET_OS_OSX
+#include "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_MACOS)
 
 #include "gpu_info_util/SystemInfo_internal.h"
 
@@ -244,5 +244,4 @@ bool GetSystemInfo(SystemInfo *info)
 
 }  // namespace angle
 
-#endif  // TARGET_OS_OSX
-#endif  // __APPLE__
+#endif  // defined(ANGLE_PLATFORM_MACOS)
index 0e0b17e..35db454 100644 (file)
@@ -945,6 +945,9 @@ struct DeviceExtensions
 
     // EGL_ANGLE_device_cgl
     bool deviceCGL = false;
+
+    // EGL_ANGLE_device_eagl
+    bool deviceEAGL = false;
 };
 
 struct ClientExtensions
index f36d34d..b0ae518 100644 (file)
 #        include "libANGLE/renderer/gl/wgl/DisplayWGL.h"
 #    elif defined(ANGLE_USE_X11)
 #        include "libANGLE/renderer/gl/glx/DisplayGLX.h"
-#    elif defined(ANGLE_PLATFORM_APPLE)
+#    elif defined(ANGLE_PLATFORM_MACOS)
 #        include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
+#    elif defined(ANGLE_PLATFORM_IOS)
+#        include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
 #    elif defined(ANGLE_USE_OZONE)
 #        include "libANGLE/renderer/gl/egl/ozone/DisplayOzone.h"
 #    elif defined(ANGLE_PLATFORM_ANDROID)
@@ -232,8 +234,10 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap, const D
             impl = new rx::DisplayWGL(state);
 #    elif defined(ANGLE_USE_X11)
             impl = new rx::DisplayGLX(state);
-#    elif defined(ANGLE_PLATFORM_APPLE)
+#    elif defined(ANGLE_PLATFORM_MACOS)
             impl = new rx::DisplayCGL(state);
+#    elif defined(ANGLE_PLATFORM_IOS)
+            impl = new rx::DisplayEAGL(state);
 #    elif defined(ANGLE_USE_OZONE)
             // This might work but has never been tried, so disallow for now.
             impl = nullptr;
index 8780a85..c55d455 100644 (file)
@@ -975,7 +975,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
     AddRGBAFormat(&map, GL_RGBA,           false,  8,  8,  8,  8, 0, GL_RGBA,           GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                   NeverSupported,  NeverSupported,                                 NeverSupported);
     AddRGBAFormat(&map, GL_SRGB,           false,  8,  8,  8,  0, 0, GL_SRGB,           GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGB>,                    AlwaysSupported, NeverSupported,                                 NeverSupported);
     AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false,  8,  8,  8,  8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGB>,                    AlwaysSupported, RequireExt<&Extensions::sRGB>,                  NeverSupported);
+#if defined(ANGLE_PLATFORM_IOS)
+    AddRGBAFormat(&map, GL_BGRA_EXT,       false,  8,  8,  8,  8, 0, GL_BGRA_EXT,       GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>,   AlwaysSupported, RequireES<2, 0>, NeverSupported);
+#else
     AddRGBAFormat(&map, GL_BGRA_EXT,       false,  8,  8,  8,  8, 0, GL_BGRA_EXT,       GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>,   AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, NeverSupported);
+#endif
 
     // Unsized integer formats
     //                 |Internal format |sized | R | G | B | A |S | Format         | Type                          | Component type | SRGB | Texture supported | Filterable    | Texture attachment | Renderbuffer |
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp
new file mode 100644 (file)
index 0000000..638ee2e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// ContextEAGL:
+//   iOS-specific subclass of ContextGL.
+//
+
+#include "libANGLE/renderer/gl/eagl/ContextEAGL.h"
+
+#include "libANGLE/Context.h"
+#include "libANGLE/Display.h"
+#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+namespace rx
+{
+
+ContextEAGL::ContextEAGL(const gl::State &state,
+                       gl::ErrorSet *errorSet,
+                       const std::shared_ptr<RendererGL> &renderer)
+    : ContextGL(state, errorSet, renderer)
+{
+}
+
+}  // namespace rx
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/ContextEAGL.h
new file mode 100644 (file)
index 0000000..27f69d8
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+// ContextEAGL:
+//   iOS-specific subclass of ContextGL.
+//
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
+
+#include "libANGLE/renderer/gl/ContextGL.h"
+#include "libANGLE/renderer/gl/RendererGL.h"
+
+namespace rx
+{
+
+class ContextEAGL : public ContextGL
+{
+  public:
+    ContextEAGL(const gl::State &state,
+               gl::ErrorSet *errorSet,
+               const std::shared_ptr<RendererGL> &renderer);
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_CONTEXTEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.cpp
new file mode 100644 (file)
index 0000000..8e76b14
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// DeviceEAGL.cpp: EAGL implementation of egl::Device
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#include "libANGLE/renderer/gl/eagl/DeviceEAGL.h"
+
+#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+#include <EGL/eglext.h>
+
+namespace rx
+{
+
+DeviceEAGL::DeviceEAGL() {}
+
+DeviceEAGL::~DeviceEAGL() {}
+
+egl::Error DeviceEAGL::initialize()
+{
+    return egl::NoError();
+}
+
+egl::Error DeviceEAGL::getAttribute(const egl::Display *display, EGLint attribute, void **outValue)
+{
+    DisplayEAGL *displayImpl = GetImplAs<DisplayEAGL>(display);
+
+    switch (attribute)
+    {
+        case EGL_EAGL_CONTEXT_ANGLE:
+            *outValue = displayImpl->getEAGLContext();
+            break;
+        default:
+            return egl::EglBadAttribute();
+    }
+
+    return egl::NoError();
+}
+
+EGLint DeviceEAGL::getType()
+{
+    return 0;
+}
+
+void DeviceEAGL::generateExtensions(egl::DeviceExtensions *outExtensions) const
+{
+    outExtensions->deviceEAGL = true;
+}
+
+}  // namespace rx
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DeviceEAGL.h
new file mode 100644 (file)
index 0000000..254b086
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// DeviceEAGL.h: EAGL implementation of egl::Device
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
+
+#include "libANGLE/Device.h"
+#include "libANGLE/renderer/DeviceImpl.h"
+
+namespace rx
+{
+class DeviceEAGL : public DeviceImpl
+{
+  public:
+    DeviceEAGL();
+    ~DeviceEAGL() override;
+
+    egl::Error initialize() override;
+    egl::Error getAttribute(const egl::Display *display,
+                            EGLint attribute,
+                            void **outValue) override;
+    EGLint getType() override;
+    void generateExtensions(egl::DeviceExtensions *outExtensions) const override;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_DEVICEEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.h
new file mode 100644 (file)
index 0000000..3ff995c
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// DisplayEAGL.h: EAGL implementation of egl::Display
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
+
+#include "libANGLE/renderer/gl/DisplayGL.h"
+
+#ifdef __OBJC__
+@class EAGLContext;
+typedef EAGLContext* EAGLContextObj;
+#else
+typedef void* EAGLContextObj;
+#endif
+
+namespace rx
+{
+
+class WorkerContext;
+
+class DisplayEAGL : public DisplayGL
+{
+  public:
+    DisplayEAGL(const egl::DisplayState &state);
+    ~DisplayEAGL() override;
+
+    egl::Error initialize(egl::Display *display) override;
+    void terminate() override;
+
+    SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
+                                     EGLNativeWindowType window,
+                                     const egl::AttributeMap &attribs) override;
+    SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
+                                      const egl::AttributeMap &attribs) override;
+    SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
+                                               EGLenum buftype,
+                                               EGLClientBuffer clientBuffer,
+                                               const egl::AttributeMap &attribs) override;
+    SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
+                                     NativePixmapType nativePixmap,
+                                     const egl::AttributeMap &attribs) override;
+
+    ContextImpl *createContext(const gl::State &state,
+                               gl::ErrorSet *errorSet,
+                               const egl::Config *configuration,
+                               const gl::Context *shareContext,
+                               const egl::AttributeMap &attribs) override;
+
+    egl::ConfigSet generateConfigs() override;
+
+    bool testDeviceLost() override;
+    egl::Error restoreLostDevice(const egl::Display *display) override;
+
+    bool isValidNativeWindow(EGLNativeWindowType window) const override;
+    egl::Error validateClientBuffer(const egl::Config *configuration,
+                                    EGLenum buftype,
+                                    EGLClientBuffer clientBuffer,
+                                    const egl::AttributeMap &attribs) const override;
+
+    DeviceImpl *createDevice() override;
+
+    std::string getVendorString() const override;
+
+    egl::Error waitClient(const gl::Context *context) override;
+    egl::Error waitNative(const gl::Context *context, EGLint engine) override;
+
+    gl::Version getMaxSupportedESVersion() const override;
+
+    EAGLContextObj getEAGLContext() const;
+
+    WorkerContext *createWorkerContext(std::string *infoLog);
+
+    void initializeFrontendFeatures(angle::FrontendFeatures *features) const override;
+
+    void populateFeatureList(angle::FeatureList *features) override;
+
+  private:
+    egl::Error makeCurrentSurfaceless(gl::Context *context) override;
+
+    void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
+    void generateCaps(egl::Caps *outCaps) const override;
+
+    std::shared_ptr<RendererGL> mRenderer;
+
+    egl::Display *mEGLDisplay;
+    EAGLContextObj mContext;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_DISPLAYEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm
new file mode 100644 (file)
index 0000000..9507aac
--- /dev/null
@@ -0,0 +1,405 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// DisplayEAGL.cpp: EAGL implementation of egl::Display
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#import "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+#import "common/debug.h"
+#import "gpu_info_util/SystemInfo.h"
+#import "libANGLE/Display.h"
+#import "libANGLE/renderer/gl/eagl/ContextEAGL.h"
+#import "libANGLE/renderer/gl/eagl/DeviceEAGL.h"
+#import "libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h"
+#import "libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h"
+#import "libANGLE/renderer/gl/eagl/RendererEAGL.h"
+#import "libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h"
+
+#import <Foundation/Foundation.h>
+#import <OpenGLES/EAGL.h>
+#import <QuartzCore/QuartzCore.h>
+#import <dlfcn.h>
+
+#define GLES_SILENCE_DEPRECATION
+
+#if !defined(ANGLE_PLATFORM_IOS_SIMULATOR)
+
+namespace
+{
+
+const char *kOpenGLESDylibName =
+    "/System/Library/Frameworks/OpenGLES.framework/OpenGLES";
+
+}
+
+#endif
+
+namespace rx
+{
+
+class FunctionsGLEAGL : public FunctionsGL
+{
+  public:
+    FunctionsGLEAGL(void *dylibHandle) : mDylibHandle(dylibHandle) {}
+
+    ~FunctionsGLEAGL() override { dlclose(mDylibHandle); }
+
+  private:
+    void *loadProcAddress(const std::string &function) const override
+    {
+        return dlsym(mDylibHandle, function.c_str());
+    }
+
+    void *mDylibHandle;
+};
+
+DisplayEAGL::DisplayEAGL(const egl::DisplayState &state)
+    : DisplayGL(state),
+      mEGLDisplay(nullptr),
+      mContext(nullptr)
+{}
+
+DisplayEAGL::~DisplayEAGL() {}
+
+egl::Error DisplayEAGL::initialize(egl::Display *display)
+{
+    mEGLDisplay = display;
+
+#if defined(ANGLE_PLATFORM_IOS_SIMULATOR)
+    return egl::EglNotInitialized() << "ANGLE with EAGL not supported on iOS Simulator due to lack of IOSurface support.";
+#else
+    angle::SystemInfo info;
+    if (!angle::GetSystemInfo(&info))
+    {
+        return egl::EglNotInitialized() << "Unable to query ANGLE's SystemInfo.";
+    }
+
+    mContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
+    if (mContext == nullptr)
+    {
+        return egl::EglNotInitialized() << "Could not create the EAGL context.";
+    }
+    [EAGLContext setCurrentContext:mContext];
+
+    // There is no equivalent getProcAddress in EAGL so we open the dylib directly
+    void *handle = dlopen(kOpenGLESDylibName, RTLD_NOW);
+    if (!handle)
+    {
+        return egl::EglNotInitialized() << "Could not open the OpenGLES Framework.";
+    }
+
+    std::unique_ptr<FunctionsGL> functionsGL(new FunctionsGLEAGL(handle));
+    functionsGL->initialize(display->getAttributeMap());
+
+    mRenderer.reset(new RendererEAGL(std::move(functionsGL), display->getAttributeMap(), this));
+
+    const gl::Version &maxVersion = mRenderer->getMaxSupportedESVersion();
+    if (maxVersion < gl::Version(2, 0))
+    {
+        return egl::EglNotInitialized() << "OpenGL ES 2.0 is not supportable.";
+    }
+
+    return DisplayGL::initialize(display);
+#endif
+}
+
+void DisplayEAGL::terminate()
+{
+    DisplayGL::terminate();
+
+    mRenderer.reset();
+    if (mContext != nullptr)
+    {
+        [EAGLContext setCurrentContext:nil];
+        [mContext release];
+        mContext = nullptr;
+    }
+}
+
+SurfaceImpl *DisplayEAGL::createWindowSurface(const egl::SurfaceState &state,
+                                             EGLNativeWindowType window,
+                                             const egl::AttributeMap &attribs)
+{
+    return new WindowSurfaceEAGL(state, mRenderer.get(), window, mContext);
+}
+
+SurfaceImpl *DisplayEAGL::createPbufferSurface(const egl::SurfaceState &state,
+                                              const egl::AttributeMap &attribs)
+{
+    EGLint width  = static_cast<EGLint>(attribs.get(EGL_WIDTH, 0));
+    EGLint height = static_cast<EGLint>(attribs.get(EGL_HEIGHT, 0));
+    return new PbufferSurfaceEAGL(state, mRenderer.get(), width, height);
+}
+
+SurfaceImpl *DisplayEAGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
+                                                       EGLenum buftype,
+                                                       EGLClientBuffer clientBuffer,
+                                                       const egl::AttributeMap &attribs)
+{
+    ASSERT(buftype == EGL_IOSURFACE_ANGLE);
+    return new IOSurfaceSurfaceEAGL(state, mContext, clientBuffer, attribs);
+}
+
+SurfaceImpl *DisplayEAGL::createPixmapSurface(const egl::SurfaceState &state,
+                                             NativePixmapType nativePixmap,
+                                             const egl::AttributeMap &attribs)
+{
+    UNIMPLEMENTED();
+    return nullptr;
+}
+
+ContextImpl *DisplayEAGL::createContext(const gl::State &state,
+                                       gl::ErrorSet *errorSet,
+                                       const egl::Config *configuration,
+                                       const gl::Context *shareContext,
+                                       const egl::AttributeMap &attribs)
+{
+    return new ContextEAGL(state, errorSet, mRenderer);
+}
+
+DeviceImpl *DisplayEAGL::createDevice()
+{
+    return new DeviceEAGL();
+}
+
+egl::ConfigSet DisplayEAGL::generateConfigs()
+{
+    // TODO(cwallez): generate more config permutations
+    egl::ConfigSet configs;
+
+    const gl::Version &maxVersion = getMaxSupportedESVersion();
+    ASSERT(maxVersion >= gl::Version(2, 0));
+    bool supportsES3 = maxVersion >= gl::Version(3, 0);
+
+    egl::Config config;
+
+    // Native stuff
+    config.nativeVisualID   = 0;
+    config.nativeVisualType = 0;
+    config.nativeRenderable = EGL_TRUE;
+
+    // Buffer sizes
+    config.redSize     = 8;
+    config.greenSize   = 8;
+    config.blueSize    = 8;
+    config.alphaSize   = 8;
+    config.depthSize   = 24;
+    config.stencilSize = 8;
+
+    config.colorBufferType = EGL_RGB_BUFFER;
+    config.luminanceSize   = 0;
+    config.alphaMaskSize   = 0;
+
+    config.bufferSize = config.redSize + config.greenSize + config.blueSize + config.alphaSize;
+
+    config.transparentType = EGL_NONE;
+
+    // Pbuffer
+    config.maxPBufferWidth  = 4096;
+    config.maxPBufferHeight = 4096;
+    config.maxPBufferPixels = 4096 * 4096;
+
+    // Caveat
+    config.configCaveat = EGL_NONE;
+
+    // Misc
+    config.sampleBuffers     = 0;
+    config.samples           = 0;
+    config.level             = 0;
+    config.bindToTextureRGB  = EGL_FALSE;
+    config.bindToTextureRGBA = EGL_FALSE;
+
+    config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
+
+    config.minSwapInterval = 1;
+    config.maxSwapInterval = 1;
+
+    config.renderTargetFormat = GL_RGBA8;
+    config.depthStencilFormat = GL_DEPTH24_STENCIL8;
+
+    config.conformant     = EGL_OPENGL_ES2_BIT | (supportsES3 ? EGL_OPENGL_ES3_BIT_KHR : 0);
+    config.renderableType = config.conformant;
+
+    config.matchNativePixmap = EGL_NONE;
+
+    config.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
+
+    configs.add(config);
+    return configs;
+}
+
+bool DisplayEAGL::testDeviceLost()
+{
+    // TODO(cwallez) investigate implementing this
+    return false;
+}
+
+egl::Error DisplayEAGL::restoreLostDevice(const egl::Display *display)
+{
+    UNIMPLEMENTED();
+    return egl::EglBadDisplay();
+}
+
+bool DisplayEAGL::isValidNativeWindow(EGLNativeWindowType window) const
+{
+    NSObject *layer = reinterpret_cast<NSObject *>(window);
+    return [layer isKindOfClass:[CALayer class]];
+}
+
+egl::Error DisplayEAGL::validateClientBuffer(const egl::Config *configuration,
+                                            EGLenum buftype,
+                                            EGLClientBuffer clientBuffer,
+                                            const egl::AttributeMap &attribs) const
+{
+    ASSERT(buftype == EGL_IOSURFACE_ANGLE);
+
+    if (!IOSurfaceSurfaceEAGL::validateAttributes(clientBuffer, attribs))
+    {
+        return egl::EglBadAttribute();
+    }
+
+    return egl::NoError();
+}
+
+std::string DisplayEAGL::getVendorString() const
+{
+    // TODO(cwallez) find a useful vendor string
+    return "";
+}
+
+EAGLContextObj DisplayEAGL::getEAGLContext() const
+{
+    return mContext;
+}
+
+void DisplayEAGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
+{
+    outExtensions->iosurfaceClientBuffer = true;
+    outExtensions->surfacelessContext    = true;
+    outExtensions->deviceQuery           = true;
+
+    // Contexts are virtualized so textures can be shared globally
+    outExtensions->displayTextureShareGroup = true;
+
+    outExtensions->powerPreference = false;
+
+    DisplayGL::generateExtensions(outExtensions);
+}
+
+void DisplayEAGL::generateCaps(egl::Caps *outCaps) const
+{
+    outCaps->textureNPOT = true;
+}
+
+egl::Error DisplayEAGL::waitClient(const gl::Context *context)
+{
+    // TODO(cwallez) UNIMPLEMENTED()
+    return egl::NoError();
+}
+
+egl::Error DisplayEAGL::waitNative(const gl::Context *context, EGLint engine)
+{
+    // TODO(cwallez) UNIMPLEMENTED()
+    return egl::NoError();
+}
+
+gl::Version DisplayEAGL::getMaxSupportedESVersion() const
+{
+    return mRenderer->getMaxSupportedESVersion();
+}
+
+egl::Error DisplayEAGL::makeCurrentSurfaceless(gl::Context *context)
+{
+    // We have nothing to do as mContext is always current, and that EAGL is surfaceless by
+    // default.
+    return egl::NoError();
+}
+
+class WorkerContextEAGL final : public WorkerContext
+{
+  public:
+    WorkerContextEAGL(EAGLContextObj context);
+    ~WorkerContextEAGL() override;
+
+    bool makeCurrent() override;
+    void unmakeCurrent() override;
+
+  private:
+    EAGLContextObj mContext;
+};
+
+WorkerContextEAGL::WorkerContextEAGL(EAGLContextObj context) : mContext(context) {}
+
+WorkerContextEAGL::~WorkerContextEAGL()
+{
+    [EAGLContext setCurrentContext:nil];
+    [mContext release];
+    mContext = nullptr;
+}
+
+bool WorkerContextEAGL::makeCurrent()
+{
+    if (![EAGLContext setCurrentContext:static_cast<EAGLContext*>(mContext)])
+    {
+        ERR() << "Unable to make gl context current.";
+        return false;
+    }
+    return true;
+}
+
+void WorkerContextEAGL::unmakeCurrent()
+{
+    [EAGLContext setCurrentContext:nil];
+}
+
+WorkerContext *DisplayEAGL::createWorkerContext(std::string *infoLog)
+{
+    EAGLContextObj context = nullptr;
+    context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
+    if (!context)
+    {
+        *infoLog += "Could not create the EAGL context.";
+        return nullptr;
+    }
+
+    return new WorkerContextEAGL(context);
+}
+
+void DisplayEAGL::initializeFrontendFeatures(angle::FrontendFeatures *features) const
+{
+    mRenderer->initializeFrontendFeatures(features);
+}
+
+void DisplayEAGL::populateFeatureList(angle::FeatureList *features)
+{
+    mRenderer->getFeatures().populateFeatureList(features);
+}
+}
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h
new file mode 100644 (file)
index 0000000..2c4000a
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
+
+#include "libANGLE/renderer/gl/SurfaceGL.h"
+#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+struct __IOSurface;
+typedef __IOSurface *IOSurfaceRef;
+
+namespace egl
+{
+class AttributeMap;
+}  // namespace egl
+
+namespace rx
+{
+
+class DisplayEAGL;
+class FunctionsGL;
+class StateManagerGL;
+
+class IOSurfaceSurfaceEAGL : public SurfaceGL
+{
+  public:
+    IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
+                        EAGLContextObj cglContext,
+                        EGLClientBuffer buffer,
+                        const egl::AttributeMap &attribs);
+    ~IOSurfaceSurfaceEAGL() override;
+
+    egl::Error initialize(const egl::Display *display) override;
+    egl::Error makeCurrent(const gl::Context *context) override;
+    egl::Error unMakeCurrent(const gl::Context *context) override;
+
+    egl::Error swap(const gl::Context *context) override;
+    egl::Error postSubBuffer(const gl::Context *context,
+                             EGLint x,
+                             EGLint y,
+                             EGLint width,
+                             EGLint height) override;
+    egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
+    egl::Error bindTexImage(const gl::Context *context,
+                            gl::Texture *texture,
+                            EGLint buffer) override;
+    egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
+    void setSwapInterval(EGLint interval) override;
+
+    EGLint getWidth() const override;
+    EGLint getHeight() const override;
+
+    EGLint isPostSubBufferSupported() const override;
+    EGLint getSwapBehavior() const override;
+
+    static bool validateAttributes(EGLClientBuffer buffer, const egl::AttributeMap &attribs);
+    FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
+                                              const gl::FramebufferState &state) override;
+
+    bool hasEmulatedAlphaChannel() const override;
+
+  private:
+    angle::Result initializeAlphaChannel(const gl::Context *context, GLuint texture);
+
+    EAGLContextObj mEAGLContext;
+    IOSurfaceRef mIOSurface;
+    int mWidth;
+    int mHeight;
+    int mPlane;
+    int mFormatIndex;
+
+    bool mAlphaInitialized;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_IOSURFACESURFACEEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.mm
new file mode 100644 (file)
index 0000000..d5a44ad
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#import "libANGLE/renderer/gl/eagl/IOSurfaceSurfaceEAGL.h"
+
+#import "common/debug.h"
+#import "libANGLE/AttributeMap.h"
+#import "libANGLE/renderer/gl/BlitGL.h"
+#import "libANGLE/renderer/gl/FramebufferGL.h"
+#import "libANGLE/renderer/gl/FunctionsGL.h"
+#import "libANGLE/renderer/gl/RendererGL.h"
+#import "libANGLE/renderer/gl/StateManagerGL.h"
+#import "libANGLE/renderer/gl/TextureGL.h"
+#import "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+#import <IOSurface/IOSurface.h>
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/EAGLIOSurface.h>
+#import <OpenGLES/EAGLDrawable.h>
+
+namespace rx
+{
+
+namespace
+{
+
+struct IOSurfaceFormatInfo
+{
+    GLenum internalFormat;
+    GLenum type;
+
+    size_t componentBytes;
+
+    GLenum nativeInternalFormat;
+    GLenum nativeFormat;
+    GLenum nativeType;
+};
+
+// clang-format off
+
+static const IOSurfaceFormatInfo kIOSurfaceFormats[] = {
+    {GL_RED,      GL_UNSIGNED_BYTE,  1, GL_RED,  GL_RED,  GL_UNSIGNED_BYTE },
+    {GL_R16UI,    GL_UNSIGNED_SHORT, 2, GL_RED,  GL_RED,  GL_UNSIGNED_SHORT},
+    {GL_RG,       GL_UNSIGNED_BYTE,  2, GL_RG,   GL_RG,   GL_UNSIGNED_BYTE },
+    {GL_RGB,      GL_UNSIGNED_BYTE,  4, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE },
+    {GL_BGRA_EXT, GL_UNSIGNED_BYTE,  4, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE },
+    {GL_RGBA,     GL_HALF_FLOAT,     8, GL_RGBA, GL_RGBA, GL_HALF_FLOAT    },
+};
+
+// clang-format on
+
+int FindIOSurfaceFormatIndex(GLenum internalFormat, GLenum type)
+{
+    for (int i = 0; i < static_cast<int>(ArraySize(kIOSurfaceFormats)); ++i)
+    {
+        const auto &formatInfo = kIOSurfaceFormats[i];
+        if (formatInfo.internalFormat == internalFormat && formatInfo.type == type)
+        {
+            return i;
+        }
+    }
+    return -1;
+}
+
+}  // anonymous namespace
+
+IOSurfaceSurfaceEAGL::IOSurfaceSurfaceEAGL(const egl::SurfaceState &state,
+                                         EAGLContextObj cglContext,
+                                         EGLClientBuffer buffer,
+                                         const egl::AttributeMap &attribs)
+    : SurfaceGL(state),
+      mEAGLContext(cglContext),
+      mIOSurface(nullptr),
+      mWidth(0),
+      mHeight(0),
+      mPlane(0),
+      mFormatIndex(-1),
+      mAlphaInitialized(false)
+{
+    // Keep reference to the IOSurface so it doesn't get deleted while the pbuffer exists.
+    mIOSurface = reinterpret_cast<IOSurfaceRef>(buffer);
+    CFRetain(mIOSurface);
+
+    // Extract attribs useful for the call to EAGLTexImageIOSurface2D
+    mWidth  = static_cast<int>(attribs.get(EGL_WIDTH));
+    mHeight = static_cast<int>(attribs.get(EGL_HEIGHT));
+    mPlane  = static_cast<int>(attribs.get(EGL_IOSURFACE_PLANE_ANGLE));
+
+    EGLAttrib internalFormat = attribs.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE);
+    EGLAttrib type           = attribs.get(EGL_TEXTURE_TYPE_ANGLE);
+    mFormatIndex =
+        FindIOSurfaceFormatIndex(static_cast<GLenum>(internalFormat), static_cast<GLenum>(type));
+    ASSERT(mFormatIndex >= 0);
+
+    mAlphaInitialized = !hasEmulatedAlphaChannel();
+}
+
+IOSurfaceSurfaceEAGL::~IOSurfaceSurfaceEAGL()
+{
+    if (mIOSurface != nullptr)
+    {
+        CFRelease(mIOSurface);
+        mIOSurface = nullptr;
+    }
+}
+
+egl::Error IOSurfaceSurfaceEAGL::initialize(const egl::Display *display)
+{
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::makeCurrent(const gl::Context *context)
+{
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::unMakeCurrent(const gl::Context *context)
+{
+    GetFunctionsGL(context)->flush();
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::swap(const gl::Context *context)
+{
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::postSubBuffer(const gl::Context *context,
+                                              EGLint x,
+                                              EGLint y,
+                                              EGLint width,
+                                              EGLint height)
+{
+    UNREACHABLE();
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::querySurfacePointerANGLE(EGLint attribute, void **value)
+{
+    UNREACHABLE();
+    return egl::NoError();
+}
+
+egl::Error IOSurfaceSurfaceEAGL::bindTexImage(const gl::Context *context,
+                                             gl::Texture *texture,
+                                             EGLint)
+{
+#if !defined(ANGLE_PLATFORM_IOS_SIMULATOR)
+    StateManagerGL *stateManager = GetStateManagerGL(context);
+
+    const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
+    GLuint textureID           = textureGL->getTextureID();
+    stateManager->bindTexture(gl::TextureType::_2D, textureID);
+    const auto &format = kIOSurfaceFormats[mFormatIndex];
+
+    if (![mEAGLContext texImageIOSurface:mIOSurface target:GL_TEXTURE_2D internalFormat:format.nativeInternalFormat width:mWidth height:mHeight format:format.nativeFormat type:format.nativeType plane:mPlane]) {
+        return egl::EglContextLost() << "EAGLContext texImageIOSurface2D failed.";
+    }
+
+    if (IsError(initializeAlphaChannel(context, textureID)))
+    {
+        return egl::EglContextLost() << "Failed to initialize IOSurface alpha channel.";
+    }
+
+    return egl::NoError();
+#else
+    return egl::EglContextLost() << "EAGLContext IOSurface not supported in the simulator.";
+#endif
+}
+
+
+egl::Error IOSurfaceSurfaceEAGL::releaseTexImage(const gl::Context *context, EGLint buffer)
+{
+    const FunctionsGL *functions = GetFunctionsGL(context);
+    functions->flush();
+    return egl::NoError();
+}
+
+void IOSurfaceSurfaceEAGL::setSwapInterval(EGLint interval)
+{
+    UNREACHABLE();
+}
+
+EGLint IOSurfaceSurfaceEAGL::getWidth() const
+{
+    return mWidth;
+}
+
+EGLint IOSurfaceSurfaceEAGL::getHeight() const
+{
+    return mHeight;
+}
+
+EGLint IOSurfaceSurfaceEAGL::isPostSubBufferSupported() const
+{
+    UNREACHABLE();
+    return EGL_FALSE;
+}
+
+EGLint IOSurfaceSurfaceEAGL::getSwapBehavior() const
+{
+    // N/A because you can't MakeCurrent an IOSurface, return any valid value.
+    return EGL_BUFFER_PRESERVED;
+}
+
+// static
+bool IOSurfaceSurfaceEAGL::validateAttributes(EGLClientBuffer buffer,
+                                             const egl::AttributeMap &attribs)
+{
+#if !defined(ANGLE_PLATFORM_IOS_SIMULATOR)
+    IOSurfaceRef ioSurface = reinterpret_cast<IOSurfaceRef>(buffer);
+
+    // The plane must exist for this IOSurface. IOSurfaceGetPlaneCount can return 0 for non-planar
+    // ioSurfaces but we will treat non-planar like it is a single plane.
+    size_t surfacePlaneCount = std::max(size_t(1), IOSurfaceGetPlaneCount(ioSurface));
+    EGLAttrib plane          = attribs.get(EGL_IOSURFACE_PLANE_ANGLE);
+    if (plane < 0 || static_cast<size_t>(plane) >= surfacePlaneCount)
+    {
+        return false;
+    }
+
+    // The width height specified must be at least (1, 1) and at most the plane size
+    EGLAttrib width  = attribs.get(EGL_WIDTH);
+    EGLAttrib height = attribs.get(EGL_HEIGHT);
+    if (width <= 0 || static_cast<size_t>(width) > IOSurfaceGetWidthOfPlane(ioSurface, plane) ||
+        height <= 0 || static_cast<size_t>(height) > IOSurfaceGetHeightOfPlane(ioSurface, plane))
+    {
+        return false;
+    }
+
+    // Find this IOSurface format
+    EGLAttrib internalFormat = attribs.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE);
+    EGLAttrib type           = attribs.get(EGL_TEXTURE_TYPE_ANGLE);
+
+    int formatIndex =
+        FindIOSurfaceFormatIndex(static_cast<GLenum>(internalFormat), static_cast<GLenum>(type));
+
+    if (formatIndex < 0)
+    {
+        return false;
+    }
+
+    // Check that the format matches this IOSurface plane
+    if (IOSurfaceGetBytesPerElementOfPlane(ioSurface, plane) !=
+        kIOSurfaceFormats[formatIndex].componentBytes)
+    {
+        return false;
+    }
+
+    return true;
+#else
+    return false;
+#endif
+}
+
+// Wraps a FramebufferGL to hook the destroy function to delete the texture associated with the
+// framebuffer.
+class IOSurfaceFramebuffer : public FramebufferGL
+{
+  public:
+    IOSurfaceFramebuffer(const gl::FramebufferState &data,
+                         GLuint id,
+                         GLuint textureId,
+                         bool isDefault,
+                         bool emulatedAlpha)
+        : FramebufferGL(data, id, isDefault, emulatedAlpha), mTextureId(textureId)
+    {}
+    void destroy(const gl::Context *context) override
+    {
+        GetFunctionsGL(context)->deleteTextures(1, &mTextureId);
+        FramebufferGL::destroy(context);
+    }
+
+  private:
+    GLuint mTextureId;
+};
+
+FramebufferImpl *IOSurfaceSurfaceEAGL::createDefaultFramebuffer(const gl::Context *context,
+                                                               const gl::FramebufferState &state)
+{
+    const FunctionsGL *functions = GetFunctionsGL(context);
+    StateManagerGL *stateManager = GetStateManagerGL(context);
+
+    GLuint texture = 0;
+    functions->genTextures(1, &texture);
+    stateManager->bindTexture(gl::TextureType::_2D, texture);
+
+#if !defined(ANGLE_PLATFORM_IOS_SIMULATOR)
+    const auto &format = kIOSurfaceFormats[mFormatIndex];
+
+    if (![mEAGLContext texImageIOSurface:mIOSurface target:GL_TEXTURE_2D internalFormat:format.nativeInternalFormat width:mWidth height:mHeight format:format.nativeFormat type:format.nativeType plane:mPlane]) {
+        ERR() << "[EAGLContext texImageIOSurface] failed";
+        return nullptr;
+    }
+#else
+    ERR() << "IOSurfaces not supported on iOS Simulator";
+#endif
+
+    if (IsError(initializeAlphaChannel(context, texture)))
+    {
+        ERR() << "Failed to initialize IOSurface alpha channel.";
+        return nullptr;
+    }
+
+    GLuint framebuffer = 0;
+    functions->genFramebuffers(1, &framebuffer);
+    stateManager->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
+    stateManager->bindTexture(gl::TextureType::_2D, texture);
+    functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+
+    return new IOSurfaceFramebuffer(state, framebuffer, texture, true, hasEmulatedAlphaChannel());
+}
+
+angle::Result IOSurfaceSurfaceEAGL::initializeAlphaChannel(const gl::Context *context,
+                                                          GLuint texture)
+{
+    if (mAlphaInitialized)
+    {
+        return angle::Result::Continue;
+    }
+
+    BlitGL *blitter = GetBlitGL(context);
+    ANGLE_TRY(blitter->clearRenderableTextureAlphaToOne(context, texture,
+                                                        gl::TextureTarget::Rectangle, 0));
+    mAlphaInitialized = true;
+    return angle::Result::Continue;
+}
+
+bool IOSurfaceSurfaceEAGL::hasEmulatedAlphaChannel() const
+{
+    const auto &format = kIOSurfaceFormats[mFormatIndex];
+    return format.internalFormat == GL_RGB;
+}
+
+}  // namespace rx
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.cpp
new file mode 100644 (file)
index 0000000..58e861e
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// PBufferSurfaceEAGL.cpp: an implementation of egl::Surface for PBuffers for the CLG backend,
+//                      currently implemented using renderbuffers
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#include "libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h"
+
+#include "common/debug.h"
+#include "libANGLE/renderer/gl/FunctionsGL.h"
+#include "libANGLE/renderer/gl/FramebufferGL.h"
+#include "libANGLE/renderer/gl/RendererGL.h"
+#include "libANGLE/renderer/gl/StateManagerGL.h"
+
+namespace rx
+{
+
+PbufferSurfaceEAGL::PbufferSurfaceEAGL(const egl::SurfaceState &state,
+                                     RendererGL *renderer,
+                                     EGLint width,
+                                     EGLint height)
+    : SurfaceGL(state),
+      mWidth(width),
+      mHeight(height),
+      mFunctions(renderer->getFunctions()),
+      mStateManager(renderer->getStateManager()),
+      mColorRenderbuffer(0),
+      mDSRenderbuffer(0)
+{
+}
+
+PbufferSurfaceEAGL::~PbufferSurfaceEAGL()
+{
+    if (mColorRenderbuffer != 0)
+    {
+        mFunctions->deleteRenderbuffers(1, &mColorRenderbuffer);
+        mColorRenderbuffer = 0;
+    }
+    if (mDSRenderbuffer != 0)
+    {
+        mFunctions->deleteRenderbuffers(1, &mDSRenderbuffer);
+        mDSRenderbuffer = 0;
+    }
+}
+
+egl::Error PbufferSurfaceEAGL::initialize(const egl::Display *display)
+{
+    mFunctions->genRenderbuffers(1, &mColorRenderbuffer);
+    mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mColorRenderbuffer);
+    mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, mWidth, mHeight);
+
+    mFunctions->genRenderbuffers(1, &mDSRenderbuffer);
+    mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mDSRenderbuffer);
+    mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, mWidth, mHeight);
+
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::makeCurrent(const gl::Context *context)
+{
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::swap(const gl::Context *context)
+{
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::postSubBuffer(const gl::Context *context,
+                                            EGLint x,
+                                            EGLint y,
+                                            EGLint width,
+                                            EGLint height)
+{
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::querySurfacePointerANGLE(EGLint attribute, void **value)
+{
+    UNIMPLEMENTED();
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::bindTexImage(const gl::Context *context,
+                                           gl::Texture *texture,
+                                           EGLint buffer)
+{
+    ERR() << "PbufferSurfaceEAGL::bindTexImage";
+    UNIMPLEMENTED();
+    return egl::NoError();
+}
+
+egl::Error PbufferSurfaceEAGL::releaseTexImage(const gl::Context *context, EGLint buffer)
+{
+    UNIMPLEMENTED();
+    return egl::NoError();
+}
+
+void PbufferSurfaceEAGL::setSwapInterval(EGLint interval)
+{
+}
+
+EGLint PbufferSurfaceEAGL::getWidth() const
+{
+    return mWidth;
+}
+
+EGLint PbufferSurfaceEAGL::getHeight() const
+{
+    return mHeight;
+}
+
+EGLint PbufferSurfaceEAGL::isPostSubBufferSupported() const
+{
+    UNIMPLEMENTED();
+    return EGL_FALSE;
+}
+
+EGLint PbufferSurfaceEAGL::getSwapBehavior() const
+{
+    return EGL_BUFFER_PRESERVED;
+}
+
+FramebufferImpl *PbufferSurfaceEAGL::createDefaultFramebuffer(const gl::Context *context,
+                                                             const gl::FramebufferState &state)
+{
+    const FunctionsGL *functions = GetFunctionsGL(context);
+    StateManagerGL *stateManager = GetStateManagerGL(context);
+
+    GLuint framebuffer = 0;
+    functions->genFramebuffers(1, &framebuffer);
+    stateManager->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
+    functions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
+                                       mColorRenderbuffer);
+    functions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
+                                       mDSRenderbuffer);
+
+    return new FramebufferGL(state, framebuffer, true, false);
+}
+
+}  // namespace rx
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/PbufferSurfaceEAGL.h
new file mode 100644 (file)
index 0000000..9cd71eb
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// PBufferSurfaceEAGL.h: an implementation of egl::Surface for PBuffers for the CLG backend,
+//                      currently implemented using renderbuffers
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
+
+#include "libANGLE/renderer/gl/SurfaceGL.h"
+
+namespace rx
+{
+
+class FunctionsGL;
+class RendererGL;
+class StateManagerGL;
+
+class PbufferSurfaceEAGL : public SurfaceGL
+{
+  public:
+    PbufferSurfaceEAGL(const egl::SurfaceState &state,
+                      RendererGL *renderer,
+                      EGLint width,
+                      EGLint height);
+    ~PbufferSurfaceEAGL() override;
+
+    egl::Error initialize(const egl::Display *display) override;
+    egl::Error makeCurrent(const gl::Context *context) override;
+
+    egl::Error swap(const gl::Context *context) override;
+    egl::Error postSubBuffer(const gl::Context *context,
+                             EGLint x,
+                             EGLint y,
+                             EGLint width,
+                             EGLint height) override;
+    egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
+    egl::Error bindTexImage(const gl::Context *context,
+                            gl::Texture *texture,
+                            EGLint buffer) override;
+    egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
+    void setSwapInterval(EGLint interval) override;
+
+    EGLint getWidth() const override;
+    EGLint getHeight() const override;
+
+    EGLint isPostSubBufferSupported() const override;
+    EGLint getSwapBehavior() const override;
+
+    FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
+                                              const gl::FramebufferState &state) override;
+
+  private:
+    unsigned mWidth;
+    unsigned mHeight;
+
+    // TODO(geofflang): Don't store these, they are potentially specific to a single GL context.
+    // http://anglebug.com/2464
+    const FunctionsGL *mFunctions;
+    StateManagerGL *mStateManager;
+
+    GLuint mColorRenderbuffer;
+    GLuint mDSRenderbuffer;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_PBUFFERSURFACEEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.cpp
new file mode 100644 (file)
index 0000000..726c86f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RendererEAGL.mm: Implements the class methods for RendererEAGL.
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+#include "libANGLE/renderer/gl/eagl/RendererEAGL.h"
+
+namespace rx
+{
+
+RendererEAGL::RendererEAGL(std::unique_ptr<FunctionsGL> functions,
+                         const egl::AttributeMap &attribMap,
+                         DisplayEAGL *display)
+    : RendererGL(std::move(functions), attribMap, display), mDisplay(display)
+{}
+
+RendererEAGL::~RendererEAGL() {}
+
+WorkerContext *RendererEAGL::createWorkerContext(std::string *infoLog)
+{
+    return mDisplay->createWorkerContext(infoLog);
+}
+
+}  // namespace rx
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/RendererEAGL.h
new file mode 100644 (file)
index 0000000..b1567b8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RendererEAGL.h: implements createWorkerContext for RendererGL.
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_RENDEREREAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_RENDEREREAGL_H_
+
+#include "libANGLE/renderer/gl/RendererGL.h"
+
+namespace rx
+{
+
+class DisplayEAGL;
+
+class RendererEAGL : public RendererGL
+{
+  public:
+    RendererEAGL(std::unique_ptr<FunctionsGL> functions,
+                const egl::AttributeMap &attribMap,
+                DisplayEAGL *display);
+    ~RendererEAGL() override;
+
+  private:
+    WorkerContext *createWorkerContext(std::string *infoLog) override;
+
+    DisplayEAGL *mDisplay;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_GLX_RENDERERGLX_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h
new file mode 100644 (file)
index 0000000..10d77b3
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// WindowSurfaceEAGL.h: EAGL implementation of egl::Surface
+
+#ifndef LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
+#define LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
+
+#include "libANGLE/renderer/gl/SurfaceGL.h"
+
+#ifdef __OBJC__
+@class EAGLContext;
+typedef EAGLContext* EAGLContextObj;
+#else
+typedef void* EAGLContextObj;
+#endif
+@class CALayer;
+struct __IOSurface;
+typedef __IOSurface *IOSurfaceRef;
+
+// WebKit's build process requires that every Objective-C class name has the prefix "Web".
+@class WebSwapLayer;
+
+namespace rx
+{
+
+class DisplayEAGL;
+class FramebufferGL;
+class FunctionsGL;
+class RendererGL;
+class StateManagerGL;
+
+struct SharedSwapState
+{
+    struct SwapTexture
+    {
+        GLuint texture;
+        unsigned int width;
+        unsigned int height;
+        uint64_t swapId;
+    };
+
+    SwapTexture textures[3];
+
+    // This code path is not going to be used by Chrome so we take the liberty
+    // to use pthreads directly instead of using mutexes and condition variables
+    // via the Platform API.
+    pthread_mutex_t mutex;
+    // The following members should be accessed only when holding the mutex
+    // (or doing construction / destruction)
+    SwapTexture *beingRendered;
+    SwapTexture *lastRendered;
+    SwapTexture *beingPresented;
+};
+
+class WindowSurfaceEAGL : public SurfaceGL
+{
+  public:
+    WindowSurfaceEAGL(const egl::SurfaceState &state,
+                     RendererGL *renderer,
+                     EGLNativeWindowType layer,
+                     EAGLContextObj context);
+    ~WindowSurfaceEAGL() override;
+
+    egl::Error initialize(const egl::Display *display) override;
+    egl::Error makeCurrent(const gl::Context *context) override;
+
+    egl::Error swap(const gl::Context *context) override;
+    egl::Error postSubBuffer(const gl::Context *context,
+                             EGLint x,
+                             EGLint y,
+                             EGLint width,
+                             EGLint height) override;
+    egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
+    egl::Error bindTexImage(const gl::Context *context,
+                            gl::Texture *texture,
+                            EGLint buffer) override;
+    egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
+    void setSwapInterval(EGLint interval) override;
+
+    EGLint getWidth() const override;
+    EGLint getHeight() const override;
+
+    EGLint isPostSubBufferSupported() const override;
+    EGLint getSwapBehavior() const override;
+
+    FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
+                                              const gl::FramebufferState &state) override;
+
+  private:
+    WebSwapLayer *mSwapLayer;
+    SharedSwapState mSwapState;
+    uint64_t mCurrentSwapId;
+
+    CALayer *mLayer;
+    EAGLContextObj mContext;
+    const FunctionsGL *mFunctions;
+    StateManagerGL *mStateManager;
+
+    GLuint mDSRenderbuffer;
+};
+
+}  // namespace rx
+
+#endif  // LIBANGLE_RENDERER_GL_EAGL_WINDOWSURFACEEAGL_H_
diff --git a/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm b/Source/ThirdParty/ANGLE/src/libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.mm
new file mode 100644 (file)
index 0000000..766e82c
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// WindowSurfaceEAGL.cpp: EAGL implementation of egl::Surface
+
+#import "common/platform.h"
+
+#if defined(ANGLE_PLATFORM_IOS)
+
+#import "libANGLE/renderer/gl/eagl/WindowSurfaceEAGL.h"
+
+#import "common/debug.h"
+#import "libANGLE/Context.h"
+#import "libANGLE/renderer/gl/FramebufferGL.h"
+#import "libANGLE/renderer/gl/RendererGL.h"
+#import "libANGLE/renderer/gl/StateManagerGL.h"
+#import "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
+
+#import <OpenGLES/EAGL.h>
+#import <QuartzCore/QuartzCore.h>
+
+// FIXME: It's not clear why this needs to be an EAGLLayer.
+
+@interface WebSwapLayer : CAEAGLLayer {
+    EAGLContextObj mDisplayContext;
+
+    bool initialized;
+    rx::SharedSwapState *mSwapState;
+    const rx::FunctionsGL *mFunctions;
+
+    GLuint mReadFramebuffer;
+}
+- (id)initWithSharedState:(rx::SharedSwapState *)swapState
+              withContext:(EAGLContextObj)displayContext
+            withFunctions:(const rx::FunctionsGL *)functions;
+@end
+
+@implementation WebSwapLayer
+- (id)initWithSharedState:(rx::SharedSwapState *)swapState
+              withContext:(EAGLContextObj)displayContext
+            withFunctions:(const rx::FunctionsGL *)functions
+{
+    self = [super init];
+    if (self != nil)
+    {
+        mDisplayContext   = displayContext;
+
+        initialized = false;
+        mSwapState  = swapState;
+        mFunctions  = functions;
+
+        [self setFrame:CGRectMake(0, 0, mSwapState->textures[0].width,
+                                  mSwapState->textures[0].height)];
+    }
+    return self;
+}
+
+- (void)display
+{
+    pthread_mutex_lock(&mSwapState->mutex);
+    {
+        if (mSwapState->lastRendered->swapId > mSwapState->beingPresented->swapId)
+        {
+            std::swap(mSwapState->lastRendered, mSwapState->beingPresented);
+        }
+    }
+    pthread_mutex_unlock(&mSwapState->mutex);
+
+    [EAGLContext setCurrentContext:mDisplayContext];
+
+    if (!initialized)
+    {
+        initialized = true;
+
+        mFunctions->genFramebuffers(1, &mReadFramebuffer);
+    }
+
+    const auto &texture = *mSwapState->beingPresented;
+
+    if ([self frame].size.width != texture.width || [self frame].size.height != texture.height)
+    {
+        [self setFrame:CGRectMake(0, 0, texture.width, texture.height)];
+
+        // FIXME: If this continues to remain an EAGLLayer, then this is where we'd
+        // probably want to create the renderbuffer storage.
+        [self setNeedsDisplay];
+    }
+
+    // TODO(cwallez) support 2.1 contexts too that don't have blitFramebuffer nor the
+    // GL_DRAW_FRAMEBUFFER_BINDING query
+    GLint drawFBO;
+    mFunctions->getIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFBO);
+
+    mFunctions->bindFramebuffer(GL_FRAMEBUFFER, mReadFramebuffer);
+    mFunctions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                                     texture.texture, 0);
+
+    mFunctions->bindFramebuffer(GL_READ_FRAMEBUFFER, mReadFramebuffer);
+    mFunctions->bindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFBO);
+    mFunctions->blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width,
+                                texture.height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+    mFunctions->bindRenderbuffer(GL_RENDERBUFFER, texture.texture);
+    [mDisplayContext presentRenderbuffer:GL_RENDERBUFFER];
+    [EAGLContext setCurrentContext:nil];
+}
+@end
+
+namespace rx
+{
+
+WindowSurfaceEAGL::WindowSurfaceEAGL(const egl::SurfaceState &state,
+                                   RendererGL *renderer,
+                                   EGLNativeWindowType layer,
+                                   EAGLContextObj context)
+    : SurfaceGL(state),
+      mSwapLayer(nil),
+      mCurrentSwapId(0),
+      mLayer(reinterpret_cast<CALayer *>(layer)),
+      mContext(context),
+      mFunctions(renderer->getFunctions()),
+      mStateManager(renderer->getStateManager()),
+      mDSRenderbuffer(0)
+{
+    pthread_mutex_init(&mSwapState.mutex, nullptr);
+}
+
+WindowSurfaceEAGL::~WindowSurfaceEAGL()
+{
+    pthread_mutex_destroy(&mSwapState.mutex);
+
+    if (mDSRenderbuffer != 0)
+    {
+        mFunctions->deleteRenderbuffers(1, &mDSRenderbuffer);
+        mDSRenderbuffer = 0;
+    }
+
+    if (mSwapLayer != nil)
+    {
+        [mSwapLayer removeFromSuperlayer];
+        [mSwapLayer release];
+        mSwapLayer = nil;
+    }
+
+    for (size_t i = 0; i < ArraySize(mSwapState.textures); ++i)
+    {
+        if (mSwapState.textures[i].texture != 0)
+        {
+            mFunctions->deleteTextures(1, &mSwapState.textures[i].texture);
+            mSwapState.textures[i].texture = 0;
+        }
+    }
+}
+
+egl::Error WindowSurfaceEAGL::initialize(const egl::Display *display)
+{
+    unsigned width  = getWidth();
+    unsigned height = getHeight();
+
+    for (size_t i = 0; i < ArraySize(mSwapState.textures); ++i)
+    {
+        mFunctions->genTextures(1, &mSwapState.textures[i].texture);
+        mStateManager->bindTexture(gl::TextureType::_2D, mSwapState.textures[i].texture);
+        mFunctions->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
+                               GL_UNSIGNED_BYTE, nullptr);
+        mSwapState.textures[i].width  = width;
+        mSwapState.textures[i].height = height;
+        mSwapState.textures[i].swapId = 0;
+    }
+    mSwapState.beingRendered  = &mSwapState.textures[0];
+    mSwapState.lastRendered   = &mSwapState.textures[1];
+    mSwapState.beingPresented = &mSwapState.textures[2];
+
+    mSwapLayer = [[WebSwapLayer alloc] initWithSharedState:&mSwapState
+                                               withContext:mContext
+                                             withFunctions:mFunctions];
+    [mLayer addSublayer:mSwapLayer];
+
+    mFunctions->genRenderbuffers(1, &mDSRenderbuffer);
+    mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mDSRenderbuffer);
+    mFunctions->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
+
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::makeCurrent(const gl::Context *context)
+{
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::swap(const gl::Context *context)
+{
+    const FunctionsGL *functions = GetFunctionsGL(context);
+    StateManagerGL *stateManager = GetStateManagerGL(context);
+
+    functions->flush();
+    mSwapState.beingRendered->swapId = ++mCurrentSwapId;
+
+    pthread_mutex_lock(&mSwapState.mutex);
+    {
+        std::swap(mSwapState.beingRendered, mSwapState.lastRendered);
+    }
+    pthread_mutex_unlock(&mSwapState.mutex);
+
+    unsigned width  = getWidth();
+    unsigned height = getHeight();
+    auto &texture   = *mSwapState.beingRendered;
+
+    if (texture.width != width || texture.height != height)
+    {
+        stateManager->bindTexture(gl::TextureType::_2D, texture.texture);
+        functions->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
+                              GL_UNSIGNED_BYTE, nullptr);
+
+        stateManager->bindRenderbuffer(GL_RENDERBUFFER, mDSRenderbuffer);
+        functions->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
+
+        texture.width  = width;
+        texture.height = height;
+    }
+
+    FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(context->getFramebuffer({0}));
+    stateManager->bindFramebuffer(GL_FRAMEBUFFER, framebufferGL->getFramebufferID());
+    functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                                    mSwapState.beingRendered->texture, 0);
+
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::postSubBuffer(const gl::Context *context,
+                                           EGLint x,
+                                           EGLint y,
+                                           EGLint width,
+                                           EGLint height)
+{
+    UNIMPLEMENTED();
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::querySurfacePointerANGLE(EGLint attribute, void **value)
+{
+    UNIMPLEMENTED();
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::bindTexImage(const gl::Context *context,
+                                          gl::Texture *texture,
+                                          EGLint buffer)
+{
+    UNIMPLEMENTED();
+    return egl::Error(EGL_SUCCESS);
+}
+
+egl::Error WindowSurfaceEAGL::releaseTexImage(const gl::Context *context, EGLint buffer)
+{
+    UNIMPLEMENTED();
+    return egl::Error(EGL_SUCCESS);
+}
+
+void WindowSurfaceEAGL::setSwapInterval(EGLint interval)
+{
+    // TODO(cwallez) investigate implementing swap intervals other than 0
+}
+
+EGLint WindowSurfaceEAGL::getWidth() const
+{
+    return (EGLint)CGRectGetWidth([mLayer frame]);
+}
+
+EGLint WindowSurfaceEAGL::getHeight() const
+{
+    return (EGLint)CGRectGetHeight([mLayer frame]);
+}
+
+EGLint WindowSurfaceEAGL::isPostSubBufferSupported() const
+{
+    UNIMPLEMENTED();
+    return EGL_FALSE;
+}
+
+EGLint WindowSurfaceEAGL::getSwapBehavior() const
+{
+    return EGL_BUFFER_DESTROYED;
+}
+
+FramebufferImpl *WindowSurfaceEAGL::createDefaultFramebuffer(const gl::Context *context,
+                                                            const gl::FramebufferState &state)
+{
+    const FunctionsGL *functions = GetFunctionsGL(context);
+    StateManagerGL *stateManager = GetStateManagerGL(context);
+
+    GLuint framebuffer = 0;
+    functions->genFramebuffers(1, &framebuffer);
+    stateManager->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
+    functions->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                                    mSwapState.beingRendered->texture, 0);
+    functions->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
+                                       mDSRenderbuffer);
+
+    return new FramebufferGL(state, framebuffer, true, false);
+}
+
+}  // namespace rx
+
+#endif  // defined(ANGLE_PLATFORM_IOS)
index f6da105..6020a60 100644 (file)
@@ -1258,7 +1258,7 @@ void GenerateCaps(const FunctionsGL *functions,
     extensions->textureSRGBDecode = functions->hasGLExtension("GL_EXT_texture_sRGB_decode") ||
                                     functions->hasGLESExtension("GL_EXT_texture_sRGB_decode");
 
-#if defined(ANGLE_PLATFORM_APPLE)
+#if defined(ANGLE_PLATFORM_MACOS)
     VendorID vendor = GetVendorID(functions);
     if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
     {
index afab5ee..7174588 100644 (file)
@@ -6387,7 +6387,12 @@ bool ValidateFramebufferTexture2D(Context *context,
                     context->validationError(GL_INVALID_VALUE, kInvalidMipLevel);
                     return false;
                 }
-                if (tex->getType() != TextureType::Rectangle)
+#if defined(ANGLE_PLATFORM_IOS)
+                const TextureType expectedType { TextureType::_2D };
+#else
+                const TextureType expectedType { TextureType::Rectangle };
+#endif
+                if (tex->getType() != expectedType)
                 {
                     context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch);
                     return false;
index 64142da..366ae72 100644 (file)
@@ -301,6 +301,15 @@ EGLBoolean EGLAPIENTRY EGL_QueryDeviceAttribEXT(EGLDeviceEXT device,
             }
             error = dev->getAttribute(attribute, value);
             break;
+        case EGL_EAGL_CONTEXT_ANGLE:
+            if (!dev->getExtensions().deviceEAGL)
+            {
+                thread->setError(EglBadAttribute(), GetDebug(), "eglQueryDeviceAttribEXT",
+                                 GetDeviceIfValid(dev));
+                return EGL_FALSE;
+            }
+            error = dev->getAttribute(attribute, value);
+            break;
         case EGL_CGL_CONTEXT_ANGLE:
         case EGL_CGL_PIXEL_FORMAT_ANGLE:
             if (!dev->getExtensions().deviceCGL)
index 4b84c24..5ddb763 100644 (file)
@@ -1,3 +1,55 @@
+2019-11-07  Dean Jackson  <dino@apple.com>
+
+        Add ANGLE backend for iOS device
+        https://bugs.webkit.org/show_bug.cgi?id=202159
+        <rdar://57000166>
+
+        Reviewed by Myles Maxfield.
+
+        Use the ANGLE for iOS backend.
+
+        Mostly this was just moving some code around so that it would compile
+        on iOS when USE(ANGLE) is true. The actual code to render WebGL is
+        similar between macOS and iOS - both now using a CALayer with
+        a set of IOSurfaces that are used as swap textures.
+
+        The main difference is that macOS (OpenGL) binds to TEXTURE_RECTANGLE,
+        and iOS (OpenGL ES) binds to the regular TEXTURE_2D.
+
+        The remaining missing piece is getting video textures into ANGLE
+        efficiently (without leaving the GPU). We can ask CoreVideo
+        to give us raw GL textures, but with ANGLE we no longer have direct access
+        to the underlying OpenGL context.
+
+        This is not enabled in the builds yet, so no tests. However, when
+        enabled it will be tested against the official WebGL conformance suite.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::validateVertexAttributes):
+        * platform/cocoa/CoreVideoSoftLink.cpp:
+        * platform/cocoa/CoreVideoSoftLink.h:
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/angle/GraphicsContext3DANGLE.cpp:
+        (WebCore::GraphicsContext3D::reshapeFBOs):
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore):
+        (WebCore::GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer):
+        * platform/graphics/cocoa/WebGLLayer.h:
+        * platform/graphics/cocoa/WebGLLayer.mm:
+        (-[WebGLLayer initWithGraphicsContext3D:]):
+        (-[WebGLLayer display]):
+        (-[WebGLLayer setEGLDisplay:config:]):
+        (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]):
+        (-[WebGLLayer bindFramebufferToNextAvailableSurface]):
+        (-[WebGLLayer setEGLDisplay:andConfig:]): Deleted.
+        * platform/graphics/cv/TextureCacheCV.mm:
+        (WebCore::TextureCacheCV::textureFromImage):
+        * platform/graphics/cv/VideoTextureCopierCV.cpp:
+        (WebCore::VideoTextureCopierCV::copyVideoTextureToPlatformTexture):
+        * platform/graphics/opengl/TemporaryOpenGLSetting.cpp:
+        * platform/graphics/opengl/TemporaryOpenGLSetting.h:
+
 2019-11-08  Chris Dumez  <cdumez@apple.com>
 
         Regression r252209: Layout Test fast/workers/worker-close-more.html is failing
index 211c6da..77a6128 100644 (file)
@@ -2059,7 +2059,10 @@ bool WebGLRenderingContextBase::validateIndexArrayPrecise(GC3Dsizei count, GC3De
 
 bool WebGLRenderingContextBase::validateVertexAttributes(unsigned elementCount, unsigned primitiveCount)
 {
-#if !USE(ANGLE)
+#if USE(ANGLE)
+    UNUSED_PARAM(elementCount);
+    UNUSED_PARAM(primitiveCount);
+#else
     if (!m_currentProgram)
         return false;
 
@@ -2127,9 +2130,6 @@ bool WebGLRenderingContextBase::validateVertexAttributes(unsigned elementCount,
             return false;
         }
     }
-#else
-    UNUSED_PARAM(elementCount);
-    UNUSED_PARAM(primitiveCount);
 #endif
     
     return true;
index a64a0a9..4f603bd 100644 (file)
@@ -72,10 +72,8 @@ SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureCacheCreateTe
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureCacheFlush, void, (CVOpenGLESTextureCacheRef textureCache, CVOptionFlags options), (textureCache, options))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureGetTarget, GLenum, (CVOpenGLESTextureRef image), (image))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureGetName, GLuint, (CVOpenGLESTextureRef image), (image))
-SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferCreate, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, pixelBufferAttributes, pixelBufferOut))
-SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferCreateWithBytes, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void* data, size_t bytesPerRow, void (*releaseCallback)(void*, const void*), void* releasePointer, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, data, bytesPerRow, releaseCallback, releasePointer, pixelBufferAttributes, pixelBufferOut))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLESTextureGetCleanTexCoords, void, (CVOpenGLESTextureRef image, GLfloat lowerLeft[2], GLfloat lowerRight[2], GLfloat upperLeft[2], GLfloat upperRight[2]), (image, lowerLeft, lowerRight, upperLeft, upperRight))
-#else
+#elif USE(OPENGL)
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CGLContextObj cglContext, CGLPixelFormatObj cglPixelFormat, CFDictionaryRef textureAttributes, CVOpenGLTextureCacheRef* cacheOut), (allocator, cacheAttributes, cglContext, cglPixelFormat, textureAttributes, cacheOut))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLTextureCacheCreateTextureFromImage, CVReturn, (CFAllocatorRef allocator, CVOpenGLTextureCacheRef textureCache, CVImageBufferRef sourceImage, CFDictionaryRef attributes, CVOpenGLTextureRef* textureOut), (allocator, textureCache, sourceImage, attributes, textureOut))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVOpenGLTextureCacheFlush, void, (CVOpenGLTextureCacheRef textureCache, CVOptionFlags options), (textureCache, options))
@@ -91,6 +89,8 @@ SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferExtendedPixelsBo
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferOpenGLCompatibilityKey, CFStringRef)
 #endif
 
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferCreate, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, pixelBufferAttributes, pixelBufferOut))
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferCreateWithBytes, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void* data, size_t bytesPerRow, void (*releaseCallback)(void*, const void*), void* releasePointer, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, data, bytesPerRow, releaseCallback, releasePointer, pixelBufferAttributes, pixelBufferOut))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreVideo, CVPixelBufferCreateWithIOSurface, CVReturn, (CFAllocatorRef allocator, IOSurfaceRef surface, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef * pixelBufferOut), (allocator, surface, pixelBufferAttributes, pixelBufferOut))
 
 #endif // HAVE(CORE_VIDEO)
index 6d0bf4f..cf5f89a 100644 (file)
@@ -93,6 +93,10 @@ SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferYCbCrMa
 #define kCVImageBufferYCbCrMatrix_P3_D65 get_CoreVideo_kCVImageBufferYCbCrMatrix_P3_D65()
 SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, CoreVideo, kCVImageBufferYCbCrMatrix_ITU_R_2020, CFStringRef)
 #define kCVImageBufferYCbCrMatrix_ITU_R_2020 get_CoreVideo_kCVImageBufferYCbCrMatrix_ITU_R_2020()
+SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferCGBitmapContextCompatibilityKey, CFStringRef)
+#define kCVPixelBufferCGBitmapContextCompatibilityKey get_CoreVideo_kCVPixelBufferCGBitmapContextCompatibilityKey()
+SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferCGImageCompatibilityKey, CFStringRef)
+#define kCVPixelBufferCGImageCompatibilityKey get_CoreVideo_kCVPixelBufferCGImageCompatibilityKey()
 
 #if USE(OPENGL_ES)
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CVEAGLContext eaglContext, CFDictionaryRef textureAttributes, CVOpenGLESTextureCacheRef* cacheOut), (allocator, cacheAttributes, eaglContext, textureAttributes, cacheOut))
@@ -105,20 +109,12 @@ SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureGetTarget, GL
 #define CVOpenGLESTextureGetTarget softLink_CoreVideo_CVOpenGLESTextureGetTarget
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureGetName, GLuint, (CVOpenGLESTextureRef image), (image))
 #define CVOpenGLESTextureGetName softLink_CoreVideo_CVOpenGLESTextureGetName
-SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferCreate, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, pixelBufferAttributes, pixelBufferOut))
-#define CVPixelBufferCreate softLink_CoreVideo_CVPixelBufferCreate
-SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferCreateWithBytes, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void* data, size_t bytesPerRow, void (*releaseCallback)(void*, const void*), void* releasePointer, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, data, bytesPerRow, releaseCallback, releasePointer, pixelBufferAttributes, pixelBufferOut))
-#define CVPixelBufferCreateWithBytes softLink_CoreVideo_CVPixelBufferCreateWithBytes
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLESTextureGetCleanTexCoords, void, (CVOpenGLESTextureRef image, GLfloat lowerLeft[2], GLfloat lowerRight[2], GLfloat upperLeft[2], GLfloat upperRight[2]), (image, lowerLeft, lowerRight, upperLeft, upperRight))
 #define CVOpenGLESTextureGetCleanTexCoords softLink_CoreVideo_CVOpenGLESTextureGetCleanTexCoords
 
-SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferCGBitmapContextCompatibilityKey, CFStringRef)
-#define kCVPixelBufferCGBitmapContextCompatibilityKey get_CoreVideo_kCVPixelBufferCGBitmapContextCompatibilityKey()
-SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferCGImageCompatibilityKey, CFStringRef)
-#define kCVPixelBufferCGImageCompatibilityKey get_CoreVideo_kCVPixelBufferCGImageCompatibilityKey()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey, CFStringRef)
 #define kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey get_CoreVideo_kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey()
-#else
+#elif USE(OPENGL)
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLTextureCacheCreate, CVReturn, (CFAllocatorRef allocator, CFDictionaryRef cacheAttributes, CGLContextObj cglContext, CGLPixelFormatObj cglPixelFormat, CFDictionaryRef textureAttributes, CVOpenGLTextureCacheRef* cacheOut), (allocator, cacheAttributes, cglContext, cglPixelFormat, textureAttributes, cacheOut))
 #define CVOpenGLTextureCacheCreate softLink_CoreVideo_CVOpenGLTextureCacheCreate
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVOpenGLTextureCacheCreateTextureFromImage, CVReturn, (CFAllocatorRef allocator, CVOpenGLTextureCacheRef textureCache, CVImageBufferRef sourceImage, CFDictionaryRef attributes, CVOpenGLTextureRef* textureOut), (allocator, textureCache, sourceImage, attributes, textureOut))
@@ -145,6 +141,10 @@ SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferOpenGLCompatibil
 #define kCVPixelBufferOpenGLCompatibilityKey get_CoreVideo_kCVPixelBufferOpenGLCompatibilityKey()
 #endif
 
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferCreate, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, pixelBufferAttributes, pixelBufferOut))
+#define CVPixelBufferCreate softLink_CoreVideo_CVPixelBufferCreate
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferCreateWithBytes, CVReturn, (CFAllocatorRef allocator, size_t width, size_t height, OSType pixelFormatType, void* data, size_t bytesPerRow, void (*releaseCallback)(void*, const void*), void* releasePointer, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef *pixelBufferOut), (allocator, width, height, pixelFormatType, data, bytesPerRow, releaseCallback, releasePointer, pixelBufferAttributes, pixelBufferOut))
+#define CVPixelBufferCreateWithBytes softLink_CoreVideo_CVPixelBufferCreateWithBytes
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreVideo, CVPixelBufferCreateWithIOSurface, CVReturn, (CFAllocatorRef allocator, IOSurfaceRef surface, CFDictionaryRef pixelBufferAttributes, CVPixelBufferRef * pixelBufferOut), (allocator, surface, pixelBufferAttributes, pixelBufferOut))
 #define CVPixelBufferCreateWithIOSurface softLink_CoreVideo_CVPixelBufferCreateWithIOSurface
 
index 3e804a6..8adb636 100644 (file)
@@ -1198,7 +1198,7 @@ public:
     void updateCGLContext();
 #endif
 
-#if USE(ANGLE) && PLATFORM(MAC)
+#if USE(ANGLE)
     void allocateIOSurfaceBackingStore(IntSize);
     void updateFramebufferTextureBackingStoreFromLayer();
 #endif
@@ -1360,7 +1360,7 @@ private:
     void readRenderingResults(unsigned char* pixels, int pixelsSize);
     void readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels);
 
-#if PLATFORM(IOS_FAMILY)
+#if USE(OPENGL_ES)
     void setRenderbufferStorageFromDrawable(GC3Dsizei width, GC3Dsizei height);
 #endif
 
index 7cbdffe..f161ea5 100644 (file)
@@ -186,24 +186,13 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     // resize regular FBO
     gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
     ASSERT(m_texture);
-#if PLATFORM(COCOA)
 
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
     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 Cocoa platform
-#endif
-#else
-
-#error Must port to non-Cocoa platforms
-
+#error FIXME: Port to non-Cocoa platforms.
 #endif // PLATFORM(COCOA)
 
     attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height);
index 1d8bc3e..d1af803 100644 (file)
@@ -69,6 +69,7 @@ typedef void* GLeglContext;
 #include <ANGLE/eglext.h>
 #include <ANGLE/eglext_angle.h>
 #include <ANGLE/entry_points_egl.h>
+#include <ANGLE/entry_points_egl_ext.h>
 #include <ANGLE/entry_points_gles_2_0_autogen.h>
 #include <ANGLE/entry_points_gles_ext_autogen.h>
 #include <ANGLE/gl2ext.h>
@@ -287,6 +288,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART);
 
 #elif USE(ANGLE)
+
     UNUSED_PARAM(hostWindow);
     UNUSED_PARAM(sharedContext);
 
@@ -338,6 +340,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     }
     contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_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
@@ -355,30 +358,23 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 
     EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj);
 
-    static constexpr const char* requiredExtensions[] = {
-        "GL_ANGLE_texture_rectangle", // For IOSurface-backed textures
-        "GL_EXT_texture_format_BGRA8888", // For creating the EGL surface from an IOSurface
-    };
+#if PLATFORM(MAC)
+    Extensions3D& extensions = getExtensions();
 
-    static constexpr const char* optionalExtensions[] = {
-        "GL_EXT_debug_marker",
+    static constexpr const char* requiredExtensions[] = {
+        "GL_ANGLE_texture_rectangle", // For IOSurface-backed textures.
+        "GL_EXT_texture_format_BGRA8888", // For creating the EGL surface from an IOSurface.
     };
 
-    Extensions3D& extensions = getExtensions();
-
     for (size_t i = 0; i < WTF_ARRAY_LENGTH(requiredExtensions); ++i) {
         if (!extensions.supports(requiredExtensions[i])) {
-            LOG(WebGL, "Missing required extension.");
+            LOG(WebGL, "Missing required extension. %s", requiredExtensions[i]);
             return;
         }
 
         extensions.ensureEnabled(requiredExtensions[i]);
     }
-
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(optionalExtensions); ++i) {
-        if (extensions.supports(optionalExtensions[i]))
-            extensions.ensureEnabled(optionalExtensions[i]);
-    }
+#endif // PLATFORM(MAC)
 
 #endif // #elif USE(ANGLE)
 
@@ -391,7 +387,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         [m_webGLLayer setName:@"WebGL Layer"];
 #endif
 #if USE(ANGLE)
-        [m_webGLLayer setEGLDisplay:m_displayObj andConfig:config];
+        [m_webGLLayer setEGLDisplay:m_displayObj config:config];
 #endif
     END_BLOCK_OBJC_EXCEPTIONS
 
@@ -414,13 +410,20 @@ 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)
+
+#if PLATFORM(MAC)
+    GLenum textureType = GL_TEXTURE_RECTANGLE_ANGLE;
+#else
+    GLenum textureType = GL_TEXTURE_2D;
+#endif
+
     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);
+    gl::BindTexture(textureType, m_texture);
+    gl::TexParameteri(textureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    gl::TexParameteri(textureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    gl::TexParameteri(textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    gl::TexParameteri(textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    gl::BindTexture(textureType, 0);
 #else
 #error Unsupported configuration
 #endif
@@ -717,14 +720,20 @@ void GraphicsContext3D::setContextVisibility(bool isVisible)
 #if USE(ANGLE)
 void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size)
 {
+#if HAVE(IOSURFACE)
     LOG(WebGL, "GraphicsContext3D::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this);
     [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:m_attrs.alpha];
+#else
+    UNUSED_PARAM(size);
+#endif
 }
 
 void GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer()
 {
+#if HAVE(IOSURFACE)
     LOG(WebGL, "GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer(). (%p)", this);
     [m_webGLLayer bindFramebufferToNextAvailableSurface];
+#endif
 }
 #endif // USE(ANGLE)
 
index 1d3b6d5..e6c45fb 100644 (file)
@@ -40,24 +40,22 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 @interface WebGLLayer : CALayer
 #elif USE(OPENGL_ES)
 @interface WebGLLayer : CAEAGLLayer
-#elif USE(ANGLE) && PLATFORM(MAC)
+#elif USE(ANGLE)
 @interface WebGLLayer : CALayer
-#elif USE(ANGLE) && PLATFORM(IOS_FAMILY)
-@interface WebGLLayer : CAEAGLLayer
 #else
 #error Unsupported platform
 #endif
 {
     WebCore::GraphicsContext3D* _context;
     float _devicePixelRatio;
-#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#if HAVE(IOSURFACE) && (USE(OPENGL) || USE(ANGLE))
     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)
+#if USE(ANGLE)
     void* _eglDisplay;
     void* _eglConfig;
     void* _contentsPbuffer;
@@ -73,13 +71,13 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 
 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace;
 
-#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#if HAVE(IOSURFACE) && (USE(OPENGL) || USE(ANGLE))
 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha;
 - (void)bindFramebufferToNextAvailableSurface;
 #endif
 
-#if (USE(ANGLE) && PLATFORM(MAC))
-- (void)setEGLDisplay:(void*)eglDisplay andConfig:(void*)eglConfig;
+#if USE(ANGLE)
+- (void)setEGLDisplay:(void*)eglDisplay config:(void*)eglConfig;
 - (void)dealloc;
 #endif
 
index 8780860..e7017de 100644 (file)
 #define GL_ANGLE_explicit_context
 #include <ANGLE/gl2ext.h>
 #include <ANGLE/gl2ext_angle.h>
+#if PLATFORM(MAC)
+const GLenum ioSurfaceTextureType = GL_TEXTURE_RECTANGLE_ANGLE;
+#else
+const GLenum ioSurfaceTextureType = GL_TEXTURE_2D;
+#endif
 #endif
 
 @implementation WebGLLayer
@@ -66,7 +71,7 @@
     _context = context;
     self = [super init];
     _devicePixelRatio = context->getContextAttributes().devicePixelRatio;
-#if USE(OPENGL) || USE(ANGLE) && PLATFORM(MAC)
+#if USE(OPENGL) || USE(ANGLE)
     self.contentsOpaque = !context->getContextAttributes().alpha;
     self.transform = CATransform3DIdentity;
     self.contentsScale = _devicePixelRatio;
@@ -76,7 +81,7 @@
     return self;
 }
 
-#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#if USE(OPENGL) || USE(ANGLE)
 // 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
@@ -92,7 +97,7 @@
 {
     [super setAnchorPoint:CGPointMake(p.x, 1.0 - p.y)];
 }
-#endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#endif // USE(OPENGL) || USE(ANGLE)
 
 #if USE(OPENGL)
 static void freeData(void *, const void *data, size_t /* size */)
@@ -155,12 +160,13 @@ static void freeData(void *, const void *data, size_t /* size */)
     }
 #elif USE(OPENGL_ES)
     _context->presentRenderbuffer();
-#elif USE(ANGLE)
+#elif HAVE(IOSURFACE) && USE(ANGLE)
     _context->prepareTexture();
     if (_drawingBuffer) {
         if (_latchedPbuffer) {
+
             GC3Denum texture = _context->platformTexture();
-            gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture);
+            gl::BindTexture(ioSurfaceTextureType, texture);
             if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
                 // FIXME: report error.
                 notImplemented();
@@ -181,8 +187,8 @@ static void freeData(void *, const void *data, size_t /* size */)
         layer->owner()->platformCALayerLayerDidDisplay(layer);
 }
 
-#if (USE(ANGLE) && PLATFORM(MAC))
-- (void)setEGLDisplay:(void*)display andConfig:(void*)config
+#if USE(ANGLE)
+- (void)setEGLDisplay:(void*)display config:(void*)config
 {
     _eglDisplay = display;
     _eglConfig = config;
@@ -197,7 +203,7 @@ static void freeData(void *, const void *data, size_t /* size */)
 }
 #endif
 
-#if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#if HAVE(IOSURFACE) & (USE(OPENGL) || USE(ANGLE))
 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha
 {
     _bufferSize = size;
@@ -214,13 +220,13 @@ static void freeData(void *, const void *data, size_t /* size */)
     _drawingBuffer->migrateColorSpaceToProperties();
     _spareBuffer->migrateColorSpaceToProperties();
 
-#if USE(ANGLE) && PLATFORM(MAC)
+#if USE(ANGLE)
     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, usingAlpha ? GL_BGRA_EXT : GL_RGB,
+        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
@@ -249,7 +255,8 @@ static void freeData(void *, const void *data, size_t /* size */)
     ASSERT_UNUSED(error, error == kCGLNoError);
 #elif USE(ANGLE)
     GC3Denum texture = _context->platformTexture();
-    gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture);
+
+    gl::BindTexture(ioSurfaceTextureType, texture);
 
     if (_latchedPbuffer) {
         if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) {
@@ -272,7 +279,7 @@ static void freeData(void *, const void *data, size_t /* size */)
     _latchedPbuffer = _drawingPbuffer;
 #endif
 }
-#endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC))
+#endif // USE(OPENGL) || USE(ANGLE)
 
 @end
 
index 9f1f66b..019d239 100644 (file)
@@ -61,6 +61,16 @@ TextureCacheCV::TextureCacheCV(GraphicsContext3D& context, RetainPtr<TextureCach
 
 RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelBufferRef image, GC3Denum outputTarget, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type)
 {
+#if USE(ANGLE)
+    // FIXME: figure out how to do this integrating via ANGLE.
+    UNUSED_PARAM(image);
+    UNUSED_PARAM(outputTarget);
+    UNUSED_PARAM(level);
+    UNUSED_PARAM(internalFormat);
+    UNUSED_PARAM(format);
+    UNUSED_PARAM(type);
+    return nullptr;
+#else
     TextureType bareVideoTexture = nullptr;
 #if USE(OPENGL_ES)
     size_t width = CVPixelBufferGetWidth(image);
@@ -75,15 +85,6 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB
     UNUSED_PARAM(type);
     if (kCVReturnSuccess != CVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_cache.get(), image, nullptr, &bareVideoTexture))
         return nullptr;
-#elif USE(ANGLE)
-    // FIXME: figure out how to do this integrating via ANGLE.
-    UNUSED_PARAM(image);
-    UNUSED_PARAM(outputTarget);
-    UNUSED_PARAM(level);
-    UNUSED_PARAM(internalFormat);
-    UNUSED_PARAM(format);
-    UNUSED_PARAM(type);
-    return nullptr;
 #endif
     RetainPtr<TextureType> videoTexture = adoptCF(bareVideoTexture);
 
@@ -91,16 +92,17 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB
     dispatch_async(dispatch_get_main_queue(), [weakThis] {
         if (!weakThis)
             return;
-        
+
         if (auto cache = weakThis->m_cache.get())
 #if USE(OPENGL_ES)
             CVOpenGLESTextureCacheFlush(cache, 0);
-#else
+#elif USE(OPENGL)
             CVOpenGLTextureCacheFlush(cache, 0);
 #endif
     });
 
     return videoTexture;
+#endif
 }
 
 }
index d975dfc..d7a6ba1 100644 (file)
@@ -874,20 +874,36 @@ bool VideoTextureCopierCV::copyVideoTextureToPlatformTexture(TextureType inputVi
     GLfloat lowerRight[2] = { 0, 0 };
     GLfloat upperRight[2] = { 0, 0 };
     GLfloat upperLeft[2] = { 0, 0 };
+    Platform3DObject videoTextureName;
+    GC3Denum videoTextureTarget;
+
 #if USE(OPENGL_ES)
-    Platform3DObject videoTextureName = CVOpenGLESTextureGetName(inputVideoTexture);
-    GC3Denum videoTextureTarget = CVOpenGLESTextureGetTarget(inputVideoTexture);
+    videoTextureName = CVOpenGLESTextureGetName(inputVideoTexture);
+    videoTextureTarget = CVOpenGLESTextureGetTarget(inputVideoTexture);
     CVOpenGLESTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft);
 #elif USE(OPENGL)
-    Platform3DObject videoTextureName = CVOpenGLTextureGetName(inputVideoTexture);
-    GC3Denum videoTextureTarget = CVOpenGLTextureGetTarget(inputVideoTexture);
+    videoTextureName = CVOpenGLTextureGetName(inputVideoTexture);
+    videoTextureTarget = CVOpenGLTextureGetTarget(inputVideoTexture);
     CVOpenGLTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft);
 #elif USE(ANGLE)
-    Platform3DObject videoTextureName = CVOpenGLTextureGetName(inputVideoTexture);
-    GC3Denum videoTextureTarget = CVOpenGLTextureGetTarget(inputVideoTexture);
-    CVOpenGLTextureGetCleanTexCoords(inputVideoTexture, lowerLeft, lowerRight, upperRight, upperLeft);
+    UNUSED_PARAM(lowerLeft);
+    UNUSED_PARAM(lowerRight);
+    UNUSED_PARAM(upperLeft);
+    UNUSED_PARAM(upperRight);
+    UNUSED_PARAM(width);
+    UNUSED_PARAM(height);
+    UNUSED_PARAM(outputTexture);
+    UNUSED_PARAM(outputTarget);
+    UNUSED_PARAM(level);
+    UNUSED_PARAM(internalFormat);
+    UNUSED_PARAM(format);
+    UNUSED_PARAM(type);
+    UNUSED_PARAM(premultiplyAlpha);
+    UNUSED_PARAM(flipY);
+    UNUSED_PARAM(swapColorChannels);
     // FIXME: determine how to access rectangular textures via ANGLE.
-    ASSERT_NOT_REACHED();
+    UNIMPLEMENTED();
+    return false;
 #endif
 
     if (lowerLeft[1] < upperRight[1])
index 2ffa6b7..bcd7246 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "config.h"
 
-#if ENABLE(GRAPHICS_CONTEXT_3D)
+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES))
 #include "TemporaryOpenGLSetting.h"
 
 #if USE(LIBEPOXY)
@@ -36,7 +36,7 @@
 
 #if USE(OPENGL_ES)
 #include <OpenGLES/ES2/gl.h>
-#else
+#elif USE(OPENGL)
 #include <OpenGL/gl.h>
 #endif
 
index cb51695..3b85431 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TemporaryOpenGLSetting_h
-#define TemporaryOpenGLSetting_h
+#pragma once
 
 #include "GraphicsTypes3D.h"
 
+#if ENABLE(GRAPHICS_CONTEXT_3D) && (USE(OPENGL) || USE(OPENGL_ES))
+
 #include <wtf/Noncopyable.h>
 
 namespace WebCore {