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;
};