Title: [127044] trunk/Source/WebCore
Revision
127044
Author
[email protected]
Date
2012-08-29 13:41:03 -0700 (Wed, 29 Aug 2012)

Log Message

[TexMap][cairo] Add GC3D::RenderToCurrentGLContext support
https://bugs.webkit.org/show_bug.cgi?id=92441

Reviewed by Noam Rosenthal.

Add a RenderToCurrentGLContext for the Cairo GraphicsContext3D. This will allow
TextureMapperGL to be rewritten on top of GraphicsContext3D by exposing the GC3D
interface for the widget's GL context.

No new tests. This will be covered by the existing AC tests after the patch on
bug 78672 lands.

* platform/graphics/cairo/GraphicsContext3DCairo.cpp:
(WebCore::GraphicsContext3D::GraphicsContext3D): Only create the offscreen
rendering buffers if we are rendering offscreen. Pass the rendering style to
the private data factory.
(WebCore::GraphicsContext3D::~GraphicsContext3D): Only destroy the offscreen
rendering buffers if we are rendering offscreen.
* platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
(WebCore::GraphicsContext3DPrivate::create): Pass the rendering style through.
(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): If we are using
a "current GL context" rendering style, we don't need to create a GL context.
We'll always just use the one that's currently active.
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Assert that we only
do this with the offscreen rendering style.
* platform/graphics/cairo/GraphicsContext3DPrivate.h: Update method definitions
and expose the rendering style member GraphicsContext3D.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127043 => 127044)


--- trunk/Source/WebCore/ChangeLog	2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/ChangeLog	2012-08-29 20:41:03 UTC (rev 127044)
@@ -1,3 +1,33 @@
+2012-08-29  Martin Robinson  <[email protected]>
+
+        [TexMap][cairo] Add GC3D::RenderToCurrentGLContext support
+        https://bugs.webkit.org/show_bug.cgi?id=92441
+
+        Reviewed by Noam Rosenthal.
+
+        Add a RenderToCurrentGLContext for the Cairo GraphicsContext3D. This will allow
+        TextureMapperGL to be rewritten on top of GraphicsContext3D by exposing the GC3D
+        interface for the widget's GL context.
+
+        No new tests. This will be covered by the existing AC tests after the patch on
+        bug 78672 lands.
+
+        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
+        (WebCore::GraphicsContext3D::GraphicsContext3D): Only create the offscreen
+        rendering buffers if we are rendering offscreen. Pass the rendering style to
+        the private data factory.
+        (WebCore::GraphicsContext3D::~GraphicsContext3D): Only destroy the offscreen
+        rendering buffers if we are rendering offscreen.
+        * platform/graphics/cairo/GraphicsContext3DPrivate.cpp:
+        (WebCore::GraphicsContext3DPrivate::create): Pass the rendering style through.
+        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): If we are using
+        a "current GL context" rendering style, we don't need to create a GL context.
+        We'll always just use the one that's currently active.
+        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Assert that we only
+        do this with the offscreen rendering style.
+        * platform/graphics/cairo/GraphicsContext3DPrivate.h: Update method definitions
+        and expose the rendering style member GraphicsContext3D.
+
 2012-08-29  Martin Leutelt  <[email protected]>
 
         [Qt] Implement CompositeDifference

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp (127043 => 127044)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp	2012-08-29 20:41:03 UTC (rev 127044)
@@ -65,7 +65,7 @@
     return context.release();
 }
 
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle)
+GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
     , m_attrs(attributes)
@@ -78,37 +78,39 @@
     , m_multisampleFBO(0)
     , m_multisampleDepthStencilBuffer(0)
     , m_multisampleColorBuffer(0)
-    , m_private(GraphicsContext3DPrivate::create(this))
+    , m_private(GraphicsContext3DPrivate::create(this, renderStyle))
 {
     makeContextCurrent();
 
     validateAttributes();
 
-    // Create a texture to render into.
-    ::glGenTextures(1, &m_texture);
-    ::glBindTexture(GL_TEXTURE_2D, m_texture);
-    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-    ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-    ::glBindTexture(GL_TEXTURE_2D, 0);
+    if (renderStyle == RenderOffscreen) {
+        // Create a texture to render into.
+        ::glGenTextures(1, &m_texture);
+        ::glBindTexture(GL_TEXTURE_2D, m_texture);
+        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+        ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+        ::glBindTexture(GL_TEXTURE_2D, 0);
 
-    // Create an FBO.
-    ::glGenFramebuffersEXT(1, &m_fbo);
-    ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
+        // Create an FBO.
+        ::glGenFramebuffersEXT(1, &m_fbo);
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
 
-    m_boundFBO = m_fbo;
-    if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
-        ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
-    
-    // Create a multisample FBO.
-    if (m_attrs.antialias) {
-        ::glGenFramebuffersEXT(1, &m_multisampleFBO);
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-        m_boundFBO = m_multisampleFBO;
-        ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
-        if (m_attrs.stencil || m_attrs.depth)
-            ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+        m_boundFBO = m_fbo;
+        if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
+            ::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
+
+        // Create a multisample FBO.
+        if (m_attrs.antialias) {
+            ::glGenFramebuffersEXT(1, &m_multisampleFBO);
+            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
+            m_boundFBO = m_multisampleFBO;
+            ::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
+            if (m_attrs.stencil || m_attrs.depth)
+                ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
+        }
     }
 
     // ANGLE initialization.
@@ -134,6 +136,9 @@
 
 GraphicsContext3D::~GraphicsContext3D()
 {
+    if (m_private->renderStyle() == RenderToCurrentGLContext)
+        return;
+
     makeContextCurrent();
     ::glDeleteTextures(1, &m_texture);
     if (m_attrs.antialias) {

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp (127043 => 127044)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp	2012-08-29 20:41:03 UTC (rev 127044)
@@ -36,15 +36,25 @@
 
 namespace WebCore {
 
-PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context)
+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
 {
-    return adoptPtr(new GraphicsContext3DPrivate(context));
+    return adoptPtr(new GraphicsContext3DPrivate(context, renderStyle));
 }
 
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context)
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
     : m_context(context)
-    , m_glContext(GLContext::createOffscreenContext(GLContext::sharingContext()))
+    , m_renderStyle(renderStyle)
 {
+    switch (renderStyle) {
+    case GraphicsContext3D::RenderOffscreen:
+        m_glContext = GLContext::createOffscreenContext(GLContext::sharingContext());
+        break;
+    case GraphicsContext3D::RenderToCurrentGLContext:
+        break;
+    case GraphicsContext3D::RenderDirectlyToHostWindow:
+        ASSERT_NOT_REACHED();
+        break;
+    }
 }
 
 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
@@ -67,6 +77,8 @@
     if (!m_glContext)
         return;
 
+    ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
+
     // FIXME: We do not support mask for the moment with TextureMapperImageBuffer.
     if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
         GraphicsContext* context = textureMapper->graphicsContext();

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h (127043 => 127044)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h	2012-08-29 20:40:38 UTC (rev 127043)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h	2012-08-29 20:41:03 UTC (rev 127044)
@@ -36,20 +36,23 @@
 #endif
 {
 public:
-    static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*);
+    static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
     ~GraphicsContext3DPrivate();
     bool makeContextCurrent();
     PlatformGraphicsContext3D platformContext();
 
+    GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
+
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
 #endif
 
 private:
-    GraphicsContext3DPrivate(GraphicsContext3D*);
+    GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
 
     GraphicsContext3D* m_context;
     OwnPtr<GLContext> m_glContext;
+    GraphicsContext3D::RenderStyle m_renderStyle;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to