Title: [103703] trunk/Source/WebCore
Revision
103703
Author
[email protected]
Date
2011-12-27 00:25:12 -0800 (Tue, 27 Dec 2011)

Log Message

[chromium] Bypass the shadow texture copy for accelerated
canvas when running the compositor in single threaded mode.
https://bugs.webkit.org/show_bug.cgi?id=75146

The texture copy fails on Windows as glCopyTexImage2D() doesn't
support BGRA source textures. 
This change also modified Canvas2DLayerChromium::updateCompositorResources
to call glCopyTexSubImage2D() instead of glCopyTexImage2D() so that
the copy can work with texture allocated via the glTexStorage2D
extension.

Reviewed by James Robinson.


* platform/graphics/chromium/Canvas2DLayerChromium.cpp:
(WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium):
(WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
(WebCore::Canvas2DLayerChromium::paintContentsIfDirty):
(WebCore::Canvas2DLayerChromium::setTextureManager):
(WebCore::Canvas2DLayerChromium::updateCompositorResources):
(WebCore::Canvas2DLayerChromium::pushPropertiesTo):
(WebCore::Canvas2DLayerChromium::unreserveContentsTexture):
(WebCore::Canvas2DLayerChromium::cleanupResources):
* platform/graphics/chromium/Canvas2DLayerChromium.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103702 => 103703)


--- trunk/Source/WebCore/ChangeLog	2011-12-27 07:30:19 UTC (rev 103702)
+++ trunk/Source/WebCore/ChangeLog	2011-12-27 08:25:12 UTC (rev 103703)
@@ -1,3 +1,30 @@
+2011-12-22  Vangelis Kokkevis  <[email protected]>
+
+        [chromium] Bypass the shadow texture copy for accelerated
+        canvas when running the compositor in single threaded mode.
+        https://bugs.webkit.org/show_bug.cgi?id=75146
+
+        The texture copy fails on Windows as glCopyTexImage2D() doesn't
+        support BGRA source textures. 
+        This change also modified Canvas2DLayerChromium::updateCompositorResources
+        to call glCopyTexSubImage2D() instead of glCopyTexImage2D() so that
+        the copy can work with texture allocated via the glTexStorage2D
+        extension.
+
+        Reviewed by James Robinson.
+
+
+        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
+        (WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium):
+        (WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
+        (WebCore::Canvas2DLayerChromium::paintContentsIfDirty):
+        (WebCore::Canvas2DLayerChromium::setTextureManager):
+        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
+        (WebCore::Canvas2DLayerChromium::pushPropertiesTo):
+        (WebCore::Canvas2DLayerChromium::unreserveContentsTexture):
+        (WebCore::Canvas2DLayerChromium::cleanupResources):
+        * platform/graphics/chromium/Canvas2DLayerChromium.h:
+
 2011-12-26  Gyuyoung Kim  <[email protected]>
 
         [EFL][WK2] Implement context menu for EFL port.

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp (103702 => 103703)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-12-27 07:30:19 UTC (rev 103702)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp	2011-12-27 08:25:12 UTC (rev 103703)
@@ -58,13 +58,16 @@
     , m_size(size)
     , m_backTextureId(0)
     , m_fbo(0)
+    , m_useDoubleBuffering(CCProxy::hasImplThread())
 {
-    GLC(m_context, m_fbo = m_context->createFramebuffer());
+    if (m_useDoubleBuffering)
+        GLC(m_context, m_fbo = m_context->createFramebuffer());
 }
 
 Canvas2DLayerChromium::~Canvas2DLayerChromium()
 {
-    GLC(m_context, m_context->deleteFramebuffer(m_fbo));
+    if (m_useDoubleBuffering && m_fbo)
+       GLC(m_context, m_context->deleteFramebuffer(m_fbo));
 }
 
 void Canvas2DLayerChromium::setTextureId(unsigned textureId)
@@ -92,7 +95,8 @@
     if (!drawsContent())
         return;
 
-    m_frontTexture->reserve(m_size, GraphicsContext3D::RGBA);
+    if (m_useDoubleBuffering)
+        m_frontTexture->reserve(m_size, GraphicsContext3D::RGBA);
 
     if (!needsDisplay())
         return;
@@ -121,7 +125,7 @@
 
 void Canvas2DLayerChromium::setTextureManager(TextureManager* textureManager)
 {
-    if (textureManager)
+    if (textureManager && m_useDoubleBuffering)
         m_frontTexture = ManagedTexture::create(textureManager);
     else
         m_frontTexture.clear();
@@ -129,14 +133,16 @@
 
 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
 {
-    if (!m_backTextureId || !m_frontTexture->isValid(m_size, GraphicsContext3D::RGBA))
+    if (!m_backTextureId || !m_frontTexture || !m_frontTexture->isValid(m_size, GraphicsContext3D::RGBA))
         return;
 
     m_frontTexture->bindTexture(context, updater.allocator());
 
     GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo));
     GLC(context, context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_backTextureId, 0));
-    GLC(context, context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, m_size.width(), m_size.height(), 0));
+    // FIXME: The copy operation will fail if the m_backTexture is allocated as BGRA since glCopyTex(Sub)Image2D doesn't
+    //        support the BGRA format. See bug https://bugs.webkit.org/show_bug.cgi?id=75142
+    GLC(context, context->copyTexSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, 0, 0, m_size.width(), m_size.height()));
     GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
     GLC(context, context->flush());
 }
@@ -146,17 +152,22 @@
     CanvasLayerChromium::pushPropertiesTo(layer);
 
     CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer);
-    canvasLayer->setTextureId(m_frontTexture->textureId());
+    if (m_useDoubleBuffering)
+        canvasLayer->setTextureId(m_frontTexture->textureId());
+    else
+        canvasLayer->setTextureId(m_backTextureId);
 }
 
 void Canvas2DLayerChromium::unreserveContentsTexture()
 {
-    m_frontTexture->unreserve();
+    if (m_useDoubleBuffering)
+        m_frontTexture->unreserve();
 }
 
 void Canvas2DLayerChromium::cleanupResources()
 {
-    m_frontTexture.clear();
+    if (m_useDoubleBuffering)
+        m_frontTexture.clear();
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h (103702 => 103703)


--- trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2011-12-27 07:30:19 UTC (rev 103702)
+++ trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h	2011-12-27 08:25:12 UTC (rev 103703)
@@ -71,6 +71,10 @@
     IntSize m_size;
     unsigned m_backTextureId;
     Platform3DObject m_fbo;
+    // When m_useDoubleBuffering is true, the compositor will draw using a copy of the
+    // canvas' backing texture. This option should be used with the compositor doesn't
+    // synchronize its draws with the canvas updates.
+    bool m_useDoubleBuffering;
     OwnPtr<ManagedTexture> m_frontTexture;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to