Unreviewed, rolling out r246501.
[WebKit-https.git] / Source / WebCore / platform / graphics / cocoa / GraphicsContext3DCocoa.mm
index 2defba2..77c5d6c 100644 (file)
 #if ENABLE(GRAPHICS_CONTEXT_3D)
 #import "GraphicsContext3D.h"
 
-#if PLATFORM(IOS_FAMILY) && !USE(ANGLE)
+#if PLATFORM(IOS_FAMILY)
 #import "GraphicsContext3DIOS.h"
 #endif
 
 #import "CanvasRenderingContext.h"
+#import "Extensions3DOpenGL.h"
 #import "GraphicsContext.h"
 #import "GraphicsContext3DManager.h"
 #import "HTMLCanvasElement.h"
 #import <OpenGLES/ES2/glext.h>
 #import <QuartzCore/QuartzCore.h>
 #import <pal/spi/ios/OpenGLESSPI.h>
-#elif USE(OPENGL)
+#else
 #import <IOKit/IOKitLib.h>
 #import <OpenGL/CGLRenderers.h>
 #import <OpenGL/gl.h>
-#elif USE(ANGLE)
-#include <ANGLE/entry_points_gles_2_0_autogen.h>
-#endif
-
-#if USE(OPENGL_ES) || USE(OPENGL)
-#include "Extensions3DOpenGL.h"
-#elif USE(ANGLE)
-#include "Extensions3DANGLE.h"
 #endif
 
 #if PLATFORM(MAC)
@@ -168,7 +161,7 @@ Ref<GraphicsContext3D> GraphicsContext3D::createShared(GraphicsContext3D& shared
     return context;
 }
 
-#if PLATFORM(MAC) && USE(OPENGL)
+#if PLATFORM(MAC)
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
 static void setGPUByRegistryID(PlatformGraphicsContext3D contextObj, CGLPixelFormatObj pixelFormatObj, IORegistryGPUID preferredGPUID)
@@ -247,18 +240,12 @@ static void setGPUByDisplayMask(PlatformGraphicsContext3D contextObj, CGLPixelFo
 }
 #endif
 
-#endif // PLATFORM(MAC) && USE(OPENGL)
+#endif // !PLATFORM(MAC)
 
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle, GraphicsContext3D* sharedContext)
     : m_attrs(attrs)
     , m_private(std::make_unique<GraphicsContext3DPrivate>(this))
 {
-#if USE(ANGLE)
-    if (m_attrs.isWebGL2)
-        m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC);
-    else
-        m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT);
-#else
 #if PLATFORM(IOS_FAMILY)
     if (m_attrs.isWebGL2)
         m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC);
@@ -267,8 +254,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 #else
     if (m_attrs.isWebGL2)
         m_compiler = ANGLEWebKitBridge(SH_GLSL_410_CORE_OUTPUT, SH_WEBGL2_SPEC);
-#endif // PLATFORM(IOS_FAMILY)
-#endif // USE(ANGLE)
+#endif
 
 #if USE(OPENGL_ES)
     UNUSED_PARAM(hostWindow);
@@ -281,7 +267,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
 
     if (m_attrs.isWebGL2)
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX);
-#elif USE(OPENGL)
+#else
     Vector<CGLPixelFormatAttribute> attribs;
     CGLPixelFormatObj pixelFormatObj = 0;
     GLint numPixelFormats = 0;
@@ -367,13 +353,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     if (m_isForWebGL2)
         ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART);
 
-#elif USE(ANGLE)
-
-    // FIXME: implement context setup via ANGLE.
-    UNUSED_PARAM(hostWindow);
-    UNUSED_PARAM(sharedContext);
-
-#endif
+#endif // !USE(OPENGL_ES)
     
     validateAttributes();
 
@@ -393,7 +373,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     // Create the texture that will be used for the framebuffer.
 #if USE(OPENGL_ES)
     ::glGenRenderbuffers(1, &m_texture);
-#elif USE(OPENGL)
+#else
     ::glGenTextures(1, &m_texture);
     // We bind to GL_TEXTURE_RECTANGLE_EXT rather than TEXTURE_2D because
     // that's what is required for a texture backed by IOSurface.
@@ -403,13 +383,8 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     ::glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     ::glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     ::glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0);
-#elif USE(ANGLE)
-    // FIXME: implement back buffer setup via ANGLE.
-#else
-#error Unsupported configuration
 #endif
 
-#if USE(OPENGL) || USE(OPENGL_ES)
     // Create the framebuffer object.
     ::glGenFramebuffersEXT(1, &m_fbo);
     ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
@@ -427,8 +402,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         if (m_attrs.stencil || m_attrs.depth)
             ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     }
-#endif // USE(ANGLE) || USE(OPENGL_ES)
-
+    
     // ANGLE initialization.
 
     ShBuiltInResources ANGLEResources;
@@ -457,9 +431,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         ::glEnable(GL_POINT_SPRITE);
 #endif
 
-#if USE(OPENGL) || USE(OPENGL_ES)
     ::glClearColor(0, 0, 0, 0);
-#endif
 
     LOG(WebGL, "Created a GraphicsContext3D (%p).", this);
 }
@@ -473,14 +445,10 @@ GraphicsContext3D::~GraphicsContext3D()
         makeContextCurrent();
         [m_contextObj renderbufferStorage:GL_RENDERBUFFER fromDrawable:nil];
         ::glDeleteRenderbuffers(1, &m_texture);
-#elif USE(OPENGL)
+#else
         CGLSetCurrentContext(m_contextObj);
         ::glDeleteTextures(1, &m_texture);
-#elif USE(ANGLE)
-        // FIXME: make context current via ANGLE.
 #endif
-
-#if USE(OPENGL) || USE(OPENGL_ES)
         if (m_attrs.antialias) {
             ::glDeleteRenderbuffersEXT(1, &m_multisampleColorBuffer);
             if (m_attrs.stencil || m_attrs.depth)
@@ -491,16 +459,12 @@ GraphicsContext3D::~GraphicsContext3D()
                 ::glDeleteRenderbuffersEXT(1, &m_depthStencilBuffer);
         }
         ::glDeleteFramebuffersEXT(1, &m_fbo);
-#endif
-
 #if USE(OPENGL_ES)
         [EAGLContext setCurrentContext:0];
         [static_cast<EAGLContext*>(m_contextObj) release];
-#elif USE(OPENGL)
+#else
         CGLSetCurrentContext(0);
         CGLDestroyContext(m_contextObj);
-#elif USE(ANGLE)
-        // FIXME: implement context teardown via ANGLE.
 #endif
         [m_webGLLayer setContext:nullptr];
     }
@@ -532,12 +496,10 @@ bool GraphicsContext3D::makeContextCurrent()
 #if USE(OPENGL_ES)
     if ([EAGLContext currentContext] != m_contextObj)
         return [EAGLContext setCurrentContext:static_cast<EAGLContext*>(m_contextObj)];
-#elif USE(OPENGL)
+#else
     CGLContextObj currentContext = CGLGetCurrentContext();
     if (currentContext != m_contextObj)
         return CGLSetCurrentContext(m_contextObj) == kCGLNoError;
-#elif USE(ANGLE)
-    // FIXME: implement making context current via ANGLE.
 #endif
     return true;
 }
@@ -550,10 +512,8 @@ void GraphicsContext3D::checkGPUStatus()
         forceContextLost();
 #if USE(OPENGL)
         CGLSetCurrentContext(0);
-#elif USE(OPENGL_ES)
+#else
         [EAGLContext setCurrentContext:0];
-#elif USE(ANGLE)
-        // FIXME: implement forced context loss via ANGLE.
 #endif
         return;
     }
@@ -576,7 +536,7 @@ void GraphicsContext3D::checkGPUStatus()
         forceContextLost();
         CGLSetCurrentContext(0);
     }
-#elif USE(OPENGL_ES)
+#else
     EAGLContext* currentContext = static_cast<EAGLContext*>(PlatformGraphicsContext3D());
     [currentContext getParameter:kEAGLCPGPURestartStatus to:&restartStatus];
     if (restartStatus == kEAGLCPGPURestartStatusCaused || restartStatus == kEAGLCPGPURestartStatusBlacklisted) {
@@ -584,9 +544,6 @@ void GraphicsContext3D::checkGPUStatus()
         forceContextLost();
         [EAGLContext setCurrentContext:0];
     }
-#elif USE(ANGLE)
-    // FIXME: check via KHR_robustness.
-    restartStatus = 0;
 #endif
 }
 
@@ -703,19 +660,12 @@ void GraphicsContext3D::screenDidChange(PlatformDisplayID displayID)
 {
     if (!m_contextObj)
         return;
-#if USE(ANGLE)
-    UNUSED_PARAM(displayID);
-#else
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
-    // FIXME: figure out whether to integrate more code into ANGLE to have this effect.
-#if USE(OPENGL)
     if (!m_hasSwitchedToHighPerformanceGPU)
         setGPUByRegistryID(m_contextObj, CGLGetPixelFormat(m_contextObj), gpuIDForDisplay(displayID));
-#endif
 #else
     setGPUByDisplayMask(m_contextObj, CGLGetPixelFormat(m_contextObj), displayMaskForDisplay(displayID));
-#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
-#endif // USE(ANGLE)
+#endif
 }
 #endif // !PLATFORM(MAC)