[Texmap] Move TextureMapperGL to use GraphicsContext3D
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 22:30:16 +0000 (22:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 22:30:16 +0000 (22:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78672

Patch by Helder Correia  <helder.correia@nokia.com>, Roland Takacs <rtakacs@inf.u-szeged.hu> on 2012-08-24
Reviewed by Noam Rosenthal.

This is part of a several patch-refactoring.

Introduce additional logic in GraphicsContext3DQt to support a
new RenderToCurrentGLContext RenderStyle. This is necessary to
use GC3D for other things than WebGL, like TextureMapper.

The GC3D constructor now accepts a RenderStyle instead of the
boolean renderDirectlyToHostWindow and thus mimics create()'s
signature. This has been changed for all ports in this patch.

A new GC3D::createForCurrentGLContext() builder was
introduced to better abstract the goal of using GC3D with the
current context.

The patch was originally developed by Helder Correia and finished
by Roland Takacs.

No new tests, refactoring.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/chromium/support/GraphicsContext3DChromium.cpp
Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.h
Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp
Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

index 7e7d18e..aed3c04 100644 (file)
@@ -1,3 +1,29 @@
+2012-08-24  Helder Correia  <helder.correia@nokia.com>, Roland Takacs  <rtakacs@inf.u-szeged.hu>
+
+        [Texmap] Move TextureMapperGL to use GraphicsContext3D
+        https://bugs.webkit.org/show_bug.cgi?id=78672
+
+        Reviewed by Noam Rosenthal.
+
+        This is part of a several patch-refactoring.
+
+        Introduce additional logic in GraphicsContext3DQt to support a
+        new RenderToCurrentGLContext RenderStyle. This is necessary to
+        use GC3D for other things than WebGL, like TextureMapper.
+
+        The GC3D constructor now accepts a RenderStyle instead of the
+        boolean renderDirectlyToHostWindow and thus mimics create()'s
+        signature. This has been changed for all ports in this patch.
+
+        A new GC3D::createForCurrentGLContext() builder was
+        introduced to better abstract the goal of using GC3D with the
+        current context.
+
+        The patch was originally developed by Helder Correia and finished
+        by Roland Takacs.
+
+        No new tests, refactoring.
+
 2012-08-24  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r126620.
index 127fcfa..f8e46d8 100644 (file)
@@ -43,7 +43,7 @@
 
 namespace WebCore {
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle)
 {
 }
 
index f6b730d..0d571b4 100644 (file)
@@ -77,7 +77,7 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
 
 PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer)
 {
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, false /* onscreen */));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0));
 
     OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer));
     context->m_private = priv.release();
index f5e6f1f..10876ea 100644 (file)
@@ -458,7 +458,8 @@ public:
 
     enum RenderStyle {
         RenderOffscreen,
-        RenderDirectlyToHostWindow
+        RenderDirectlyToHostWindow,
+        RenderToCurrentGLContext
     };
 
     class ContextLostCallback {
@@ -477,6 +478,7 @@ public:
     void setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>);
 
     static PassRefPtr<GraphicsContext3D> create(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
+    static PassRefPtr<GraphicsContext3D> createForCurrentGLContext();
     ~GraphicsContext3D();
 
 #if PLATFORM(MAC)
@@ -867,7 +869,7 @@ public:
     static unsigned getChannelBitsByFormat(GC3Denum);
 
   private:
-    GraphicsContext3D(Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow);
+    GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
 
     // Each platform must provide an implementation of this method.
     //
@@ -982,6 +984,7 @@ public:
     friend class Extensions3DOpenGLCommon;
 
     Attributes m_attrs;
+    RenderStyle m_renderStyle;
     Vector<Vector<float> > m_vertexArray;
 
     GC3Duint m_texture;
index f1081ef..d3002cf 100644 (file)
@@ -47,10 +47,10 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(Attributes attribs, Host
     if (renderStyle == RenderDirectlyToHostWindow)
         return 0;
 
-    return adoptRef(new GraphicsContext3D(attribs, hostWindow, false));
+    return adoptRef(new GraphicsContext3D(attribs, hostWindow, renderStyle));
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, bool renderDirectlyToHostWindow)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_context(BlackBerry::Platform::Graphics::createWebGLContext())
@@ -67,7 +67,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
     , m_boundTexture0(0)
     , m_isImaginationHardware(0)
 {
-    if (!renderDirectlyToHostWindow) {
+    if (renderStyle != RenderDirectlyToHostWindow) {
 #if USE(ACCELERATED_COMPOSITING)
         m_compositingLayer = WebGLLayerWebKitThread::create();
 #endif
index 9822d4e..64a2faa 100644 (file)
@@ -61,11 +61,11 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
     if (!success)
         return 0;
 
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle));
     return context.release();
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_attrs(attributes)
index 4b4b0e3..abfbd47 100644 (file)
@@ -42,11 +42,11 @@ namespace WebCore {
 
 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
 {
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, false));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle));
     return context.release();
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
 {
     notImplemented();
 }
index efe1a12..721d7c7 100644 (file)
@@ -36,12 +36,12 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
     if (!internal)
         return 0;
 
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToEvasGLObject));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
     context->m_private = internal.release();
     return context.release();
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
 {
index d570f48..68f4f24 100644 (file)
@@ -92,11 +92,11 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
     // This implementation doesn't currently support rendering directly to the HostWindow.
     if (renderStyle == RenderDirectlyToHostWindow)
         return 0;
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
     return context->m_contextObj ? context.release() : 0;
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_contextObj(0)
@@ -116,6 +116,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
     , m_private(adoptPtr(new GraphicsContext3DPrivate(this)))
 {
     UNUSED_PARAM(hostWindow);
+    UNUSED_PARAM(renderStyle);
 
     Vector<CGLPixelFormatAttribute> attribs;
     CGLPixelFormatObj pixelFormatObj = 0;
index e0c2d6e..923dd80 100644 (file)
 
 namespace WebCore {
 
+PassRefPtr<GraphicsContext3D> GraphicsContext3D::createForCurrentGLContext()
+{
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(Attributes(), 0, GraphicsContext3D::RenderToCurrentGLContext));
+    return context->m_private ? context.release() : 0;
+}
+
 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension)
 {
     Extensions3D* extensions = getExtensions();
index 8852ccd..98adec7 100644 (file)
@@ -61,7 +61,7 @@ class GraphicsContext3DPrivate
 #endif
 {
 public:
-    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
+    GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
     ~GraphicsContext3DPrivate();
 
 #if USE(ACCELERATED_COMPOSITING)
@@ -76,6 +76,8 @@ public:
     void blitMultisampleFramebuffer() const;
     void blitMultisampleFramebufferAndRestoreContext() const;
     bool makeCurrentIfNeeded() const;
+    void createOffscreenBuffers();
+    void initializeANGLE();
     void createGraphicsSurfaces(const IntSize&);
 
     GraphicsContext3D* m_context;
@@ -104,7 +106,7 @@ void GraphicsContext3D::releaseShaderCompiler()
 }
 #endif
 
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     : m_context(context)
     , m_hostWindow(hostWindow)
     , m_surface(0)
@@ -121,6 +123,12 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
         return;
     }
 
+    if (renderStyle == GraphicsContext3D::RenderToCurrentGLContext) {
+        m_platformContext = QOpenGLContext::currentContext();
+        m_surface = m_platformContext->surface();
+        return;
+    }
+
 #if USE(GRAPHICS_SURFACE)
     // FIXME: Find a way to create a QOpenGLContext without creating a QWindow at all.
     // We need to create a surface in order to create a QOpenGLContext and make it current.
@@ -145,12 +153,67 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
 #endif
 }
 
+void GraphicsContext3DPrivate::createOffscreenBuffers()
+{
+    glGenFramebuffers(/* count */ 1, &m_context->m_fbo);
+
+    glGenTextures(1, &m_context->m_texture);
+    glBindTexture(GraphicsContext3D::TEXTURE_2D, m_context->m_texture);
+    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+    glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+
+    // Create a multisample FBO.
+    if (m_context->m_attrs.antialias) {
+        glGenFramebuffers(1, &m_context->m_multisampleFBO);
+        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO);
+        m_context->m_boundFBO = m_context->m_multisampleFBO;
+        glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer);
+        if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
+            glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer);
+    } else {
+        // Bind canvas FBO.
+        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
+        m_context->m_boundFBO = m_context->m_fbo;
+#if USE(OPENGL_ES_2)
+        if (m_context->m_attrs.depth)
+            glGenRenderbuffers(1, &m_context->m_depthBuffer);
+        if (m_context->m_attrs.stencil)
+            glGenRenderbuffers(1, &m_context->m_stencilBuffer);
+#endif
+        if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
+            glGenRenderbuffers(1, &m_context->m_depthStencilBuffer);
+    }
+}
+
+void GraphicsContext3DPrivate::initializeANGLE()
+{
+    ShBuiltInResources ANGLEResources;
+    ShInitBuiltInResources(&ANGLEResources);
+
+    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
+    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
+    m_context->getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
+    m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
+    m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
+    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
+    m_context->getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
+
+    // Always set to 1 for OpenGL ES.
+    ANGLEResources.MaxDrawBuffers = 1;
+    m_context->m_compiler.setResources(ANGLEResources);
+}
+
 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
 {
-    delete m_surface;
-    m_surface = 0;
-    // Platform context is assumed to be owned by surface.
-    m_platformContext = 0;
+    if (m_hostWindow) {
+        delete m_surface;
+        m_surface = 0;
+        // Platform context is assumed to be owned by surface.
+        m_platformContext = 0;
+    }
 }
 
 static inline quint32 swapBgrToRgb(quint32 pixel)
@@ -291,15 +354,16 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
     // This implementation doesn't currently support rendering directly to the HostWindow.
     if (renderStyle == RenderDirectlyToHostWindow)
         return 0;
-    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
+    RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
     return context->m_private ? context.release() : 0;
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
     , m_attrs(attrs)
+    , m_renderStyle(renderStyle)
     , m_texture(0)
     , m_compositorTexture(0)
     , m_fbo(0)
@@ -316,7 +380,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
     , m_multisampleFBO(0)
     , m_multisampleDepthStencilBuffer(0)
     , m_multisampleColorBuffer(0)
-    , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow)))
+    , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
 {
     validateAttributes();
 
@@ -337,54 +401,10 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
         return;
     }
 
-    // Create buffers for the canvas FBO.
-    glGenFramebuffers(/* count */ 1, &m_fbo);
+    if (renderStyle == RenderOffscreen)
+        m_private->createOffscreenBuffers();
 
-    glGenTextures(1, &m_texture);
-    glBindTexture(GraphicsContext3D::TEXTURE_2D, m_texture);
-    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
-    glTexParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
-    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
-    glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
-    glBindTexture(GraphicsContext3D::TEXTURE_2D, 0);
-
-    // Create a multisample FBO.
-    if (m_attrs.antialias) {
-        glGenFramebuffers(1, &m_multisampleFBO);
-        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
-        m_boundFBO = m_multisampleFBO;
-        glGenRenderbuffers(1, &m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth)
-            glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
-    } else {
-        // Bind canvas FBO.
-        glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
-        m_boundFBO = m_fbo;
-#if USE(OPENGL_ES_2)
-        if (m_attrs.depth)
-            glGenRenderbuffers(1, &m_depthBuffer);
-        if (m_attrs.stencil)
-            glGenRenderbuffers(1, &m_stencilBuffer);
-#endif
-        if (m_attrs.stencil || m_attrs.depth)
-            glGenRenderbuffers(1, &m_depthStencilBuffer);
-    }
-
-    // ANGLE initialization.
-    ShBuiltInResources ANGLEResources;
-    ShInitBuiltInResources(&ANGLEResources);
-
-    getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
-    getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
-    getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
-    getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
-    getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits); 
-    getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
-    getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
-
-    // Always set to 1 for OpenGL ES.
-    ANGLEResources.MaxDrawBuffers = 1;
-    m_compiler.setResources(ANGLEResources);
+    m_private->initializeANGLE();
 
 #if !USE(OPENGL_ES_2)
     glEnable(GL_POINT_SPRITE);
@@ -438,7 +458,7 @@ PlatformLayer* GraphicsContext3D::platformLayer() const
 
 bool GraphicsContext3D::makeContextCurrent()
 {
-    if (!m_private)
+    if (!m_private || m_renderStyle == RenderToCurrentGLContext)
         return false;
     return m_private->makeCurrentIfNeeded();
 }