Diff
Modified: trunk/Source/WebCore/ChangeLog (135199 => 135200)
--- trunk/Source/WebCore/ChangeLog 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebCore/ChangeLog 2012-11-19 22:54:22 UTC (rev 135200)
@@ -1,3 +1,32 @@
+2012-11-19 Huang Dongsung <[email protected]>
+
+ Coordinated Graphics: refactor syncCanvas to handle the lifecycle clearly.
+ https://bugs.webkit.org/show_bug.cgi?id=102664
+
+ Reviewed by Noam Rosenthal.
+
+ As refactoring Coordinated Graphics in WebKit2, code related to
+ TextureMapper is changed.
+
+ No new tests. Refactoring only.
+
+ * platform/graphics/qt/GraphicsContext3DQt.cpp:
+ (GraphicsContext3DPrivate):
+ (WebCore::GraphicsContext3DPrivate::platformLayerSize):
+ We need to know the size of a texture mapper platform layer.
+ (WebCore):
+ * platform/graphics/texmap/TextureMapperBackingStore.cpp:
+ Because CoordinatedGraphicsLayer handles the canvas GraphicsSurface
+ lifecycle, TextureMapperSurfaceBackingStore does not need to know
+ GraphicsSurfaceToken.
+ (WebCore::TextureMapperSurfaceBackingStore::setGraphicsSurface):
+ (WebCore::TextureMapperSurfaceBackingStore::swapBuffersIfNeeded):
+ (WebCore::TextureMapperSurfaceBackingStore::paintToTextureMapper):
+ * platform/graphics/texmap/TextureMapperBackingStore.h:
+ (TextureMapperSurfaceBackingStore):
+ * platform/graphics/texmap/TextureMapperPlatformLayer.h:
+ (WebCore::TextureMapperPlatformLayer::platformLayerSize):
+
2012-11-19 Alpha Lam <[email protected]>
[chromium] Lazy image decoding without cache
Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (135199 => 135200)
--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -68,6 +68,7 @@
virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
#endif
#if USE(GRAPHICS_SURFACE)
+ virtual IntSize platformLayerSize() const;
virtual uint32_t copyToGraphicsSurface();
virtual GraphicsSurfaceToken graphicsSurfaceToken() const;
#endif
@@ -277,6 +278,11 @@
#endif // USE(ACCELERATED_COMPOSITING)
#if USE(GRAPHICS_SURFACE)
+IntSize GraphicsContext3DPrivate::platformLayerSize() const
+{
+ return IntSize(m_context->m_currentWidth, m_context->m_currentHeight);
+}
+
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
{
if (!m_graphicsSurface)
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp (135199 => 135200)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -34,19 +34,15 @@
namespace WebCore {
#if USE(GRAPHICS_SURFACE)
-void TextureMapperSurfaceBackingStore::setGraphicsSurface(const GraphicsSurfaceToken& graphicsSurfaceToken, const IntSize& surfaceSize, uint32_t frontBuffer)
+void TextureMapperSurfaceBackingStore::setGraphicsSurface(PassRefPtr<GraphicsSurface> surface)
{
- if (graphicsSurfaceToken != m_graphicsSurfaceToken) {
- GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget
- | GraphicsSurface::SupportsSharing;
- setSurface(GraphicsSurface::create(surfaceSize, surfaceFlags, graphicsSurfaceToken));
- m_graphicsSurfaceSize = surfaceSize;
- }
+ m_graphicsSurface = surface;
+}
- RefPtr<WebCore::GraphicsSurface> surface = graphicsSurface();
- if (surface && surface->frontBuffer() != frontBuffer)
- surface->swapBuffers();
-
+void TextureMapperSurfaceBackingStore::swapBuffersIfNeeded(uint32_t frontBuffer)
+{
+ if (m_graphicsSurface && m_graphicsSurface->frontBuffer() != frontBuffer)
+ m_graphicsSurface->swapBuffers();
}
PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
@@ -61,17 +57,6 @@
if (m_graphicsSurface)
m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
}
-
-void TextureMapperSurfaceBackingStore::setSurface(PassRefPtr<GraphicsSurface> surface)
-{
- if (surface) {
- m_graphicsSurface = surface;
- m_graphicsSurfaceToken = m_graphicsSurface->exportToken();
- } else {
- m_graphicsSurface = RefPtr<GraphicsSurface>();
- m_graphicsSurfaceToken = GraphicsSurfaceToken();
- }
-}
#endif
void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h (135199 => 135200)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -50,23 +50,18 @@
class TextureMapperSurfaceBackingStore : public TextureMapperBackingStore {
public:
static PassRefPtr<TextureMapperSurfaceBackingStore> create() { return adoptRef(new TextureMapperSurfaceBackingStore); }
- void setGraphicsSurface(const GraphicsSurfaceToken&, const IntSize& surfaceSize, uint32_t frontBuffer);
- PassRefPtr<WebCore::GraphicsSurface> graphicsSurface() const { return m_graphicsSurface; }
+ void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
+ void swapBuffersIfNeeded(uint32_t frontBuffer);
virtual PassRefPtr<BitmapTexture> texture() const;
virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
virtual ~TextureMapperSurfaceBackingStore() { }
-protected:
- void setSurface(PassRefPtr<GraphicsSurface>);
-
private:
TextureMapperSurfaceBackingStore()
: TextureMapperBackingStore()
{ }
- GraphicsSurfaceToken m_graphicsSurfaceToken;
- RefPtr<WebCore::GraphicsSurface> m_graphicsSurface;
- IntSize m_graphicsSurfaceSize;
+ RefPtr<GraphicsSurface> m_graphicsSurface;
};
#endif
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h (135199 => 135200)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -37,6 +37,7 @@
virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
virtual void swapBuffers() { }
#if USE(GRAPHICS_SURFACE)
+ virtual IntSize platformLayerSize() const { return IntSize(); }
virtual uint32_t copyToGraphicsSurface() { return 0; }
virtual GraphicsSurfaceToken graphicsSurfaceToken() const { return GraphicsSurfaceToken(); }
#endif
Modified: trunk/Source/WebKit2/ChangeLog (135199 => 135200)
--- trunk/Source/WebKit2/ChangeLog 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-19 22:54:22 UTC (rev 135200)
@@ -1,3 +1,54 @@
+2012-11-19 Huang Dongsung <[email protected]>
+
+ Coordinated Graphics: refactor syncCanvas to handle the lifecycle clearly.
+ https://bugs.webkit.org/show_bug.cgi?id=102664
+
+ Reviewed by Noam Rosenthal.
+
+ This patch makes sync canvas code handle the lifecycle of the canvas
+ GraphicsSurface in the similar style to a directly image compositing and
+ an update atlas code. This patch moves the canvas lifecycle handling
+ code from LayerTreeRenderer to CoordinatedGraphicsLayer, because
+ CoordinatedGraphicsLayer knows best when to create and remove the canvas
+ GraphicsSurface.
+
+ After this patch, we can remove the canvas GraphicsSurface in UI Process as soon
+ as the canvas platform layer is unset in Web Process.
+
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
+ (WebKit::LayerTreeCoordinatorProxy::createCanvas):
+ (WebKit):
+ (WebKit::LayerTreeCoordinatorProxy::syncCanvas):
+ (WebKit::LayerTreeCoordinatorProxy::destroyCanvas):
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
+ (LayerTreeCoordinatorProxy):
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
+ (WebKit::LayerTreeRenderer::createCanvas):
+ (WebKit):
+ (WebKit::LayerTreeRenderer::syncCanvas):
+ (WebKit::LayerTreeRenderer::destroyCanvas):
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
+ (LayerTreeRenderer):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
+ (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
+ (WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay):
+ (WebCore::CoordinatedGraphicsLayer::setContentsToCanvas):
+ (WebCore::CoordinatedGraphicsLayer::syncCanvas):
+ (WebCore):
+ (WebCore::CoordinatedGraphicsLayer::destroyCanvasIfNeeded):
+ (WebCore::CoordinatedGraphicsLayer::createCanvasIfNeeded):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
+ (CoordinatedGraphicsLayerClient):
+ (CoordinatedGraphicsLayer):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
+ (WebKit::LayerTreeCoordinator::createCanvas):
+ (WebKit):
+ (WebKit::LayerTreeCoordinator::syncCanvas):
+ (WebKit::LayerTreeCoordinator::destroyCanvas):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
+ (LayerTreeCoordinator):
+
2012-11-19 Brady Eidson <[email protected]>
Replace an unneeded #include with a forward declaration after r135179.
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp (135199 => 135200)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -29,6 +29,7 @@
#include "WebLayerTreeInfo.h"
#include "WebPageProxy.h"
#include "WebProcessProxy.h"
+#include <WebCore/GraphicsSurface.h>
#if ENABLE(CSS_SHADERS)
#include "CustomFilterProgramInfo.h"
@@ -212,10 +213,21 @@
}
#if USE(GRAPHICS_SURFACE)
-void LayerTreeCoordinatorProxy::syncCanvas(uint32_t id, const IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer)
+void LayerTreeCoordinatorProxy::createCanvas(WebLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token)
{
- dispatchUpdate(bind(&LayerTreeRenderer::syncCanvas, m_renderer.get(), id, canvasSize, token, frontBuffer));
+ GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
+ dispatchUpdate(bind(&LayerTreeRenderer::createCanvas, m_renderer.get(), id, canvasSize, GraphicsSurface::create(canvasSize, surfaceFlags, token)));
}
+
+void LayerTreeCoordinatorProxy::syncCanvas(WebLayerID id, uint32_t frontBuffer)
+{
+ dispatchUpdate(bind(&LayerTreeRenderer::syncCanvas, m_renderer.get(), id, frontBuffer));
+}
+
+void LayerTreeCoordinatorProxy::destroyCanvas(WebLayerID id)
+{
+ dispatchUpdate(bind(&LayerTreeRenderer::destroyCanvas, m_renderer.get(), id));
+}
#endif
void LayerTreeCoordinatorProxy::purgeBackingStores()
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h (135199 => 135200)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -79,7 +79,9 @@
void renderNextFrame();
void didChangeScrollPosition(const WebCore::IntPoint& position);
#if USE(GRAPHICS_SURFACE)
- void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer);
+ void createCanvas(WebLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&);
+ void syncCanvas(WebLayerID, uint32_t frontBuffer);
+ void destroyCanvas(WebLayerID);
#endif
void purgeBackingStores();
LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in (135199 => 135200)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in 2012-11-19 22:54:22 UTC (rev 135200)
@@ -48,7 +48,9 @@
#endif
#if USE(GRAPHICS_SURFACE)
- SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token, uint32_t frontBuffer)
+ CreateCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token)
+ SyncCanvas(uint32_t id, uint32_t frontBuffer)
+ DestroyCanvas(uint32_t id)
#endif
SetBackgroundColor(WebCore::Color color)
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp (135199 => 135200)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -242,25 +242,41 @@
}
#if USE(GRAPHICS_SURFACE)
-void LayerTreeRenderer::syncCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer)
+void LayerTreeRenderer::createCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, PassRefPtr<GraphicsSurface> surface)
{
- if (canvasSize.isEmpty() || !m_textureMapper)
- return;
-
- ensureLayer(id);
+ ASSERT(m_textureMapper);
GraphicsLayer* layer = layerByID(id);
+ ASSERT(layer);
+ ASSERT(!m_surfaceBackingStores.contains(id));
- RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore;
- SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(id);
- if (it == m_surfaceBackingStores.end()) {
- canvasBackingStore = TextureMapperSurfaceBackingStore::create();
- m_surfaceBackingStores.set(id, canvasBackingStore);
- } else
- canvasBackingStore = it->value;
+ RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore(TextureMapperSurfaceBackingStore::create());
+ m_surfaceBackingStores.set(id, canvasBackingStore);
- canvasBackingStore->setGraphicsSurface(token, canvasSize, frontBuffer);
+ canvasBackingStore->setGraphicsSurface(surface);
layer->setContentsToMedia(canvasBackingStore.get());
}
+
+void LayerTreeRenderer::syncCanvas(WebLayerID id, uint32_t frontBuffer)
+{
+ ASSERT(m_textureMapper);
+ ASSERT(m_surfaceBackingStores.contains(id));
+
+ SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(id);
+ RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore = it->value;
+
+ canvasBackingStore->swapBuffersIfNeeded(frontBuffer);
+}
+
+void LayerTreeRenderer::destroyCanvas(WebLayerID id)
+{
+ ASSERT(m_textureMapper);
+ GraphicsLayer* layer = layerByID(id);
+ ASSERT(layer);
+ ASSERT(m_surfaceBackingStores.contains(id));
+
+ m_surfaceBackingStores.remove(id);
+ layer->setContentsToMedia(0);
+}
#endif
void LayerTreeRenderer::setLayerChildren(WebLayerID id, const Vector<WebLayerID>& childIDs)
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h (135199 => 135200)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -75,7 +75,9 @@
void setVisibleContentsRect(const WebCore::FloatRect&);
void didChangeScrollPosition(const WebCore::IntPoint& position);
#if USE(GRAPHICS_SURFACE)
- void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer);
+ void createCanvas(WebLayerID, const WebCore::IntSize&, PassRefPtr<WebCore::GraphicsSurface>);
+ void syncCanvas(WebLayerID, uint32_t frontBuffer);
+ void destroyCanvas(WebLayerID);
#endif
void detach();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp (135199 => 135200)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -117,6 +117,8 @@
, m_shouldSyncAnimations(true)
, m_fixedToViewport(false)
, m_canvasNeedsDisplay(false)
+ , m_canvasNeedsCreate(false)
+ , m_canvasNeedsDestroy(false)
, m_coordinator(0)
, m_contentsScale(1)
, m_compositedNativeImagePtr(0)
@@ -322,17 +324,38 @@
void CoordinatedGraphicsLayer::setContentsNeedsDisplay()
{
- m_canvasNeedsDisplay = true;
+ if (m_canvasPlatformLayer)
+ m_canvasNeedsDisplay = true;
if (client())
client()->notifyFlushRequired(this);
}
void CoordinatedGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer)
{
+#if USE(GRAPHICS_SURFACE)
+ if (m_canvasPlatformLayer) {
+ ASSERT(m_canvasToken.isValid());
+ if (!platformLayer)
+ m_canvasNeedsDestroy = true;
+ else if (m_canvasToken != platformLayer->graphicsSurfaceToken()) {
+ // m_canvasToken can be different to platformLayer->graphicsSurfaceToken(), even if m_canvasPlatformLayer equals platformLayer.
+ m_canvasNeedsDestroy = true;
+ m_canvasNeedsCreate = true;
+ }
+ } else {
+ if (platformLayer)
+ m_canvasNeedsCreate = true;
+ }
+
m_canvasPlatformLayer = platformLayer;
- m_canvasNeedsDisplay = true;
+ // m_canvasToken is updated only here. In detail, when GraphicsContext3D is changed or reshaped, m_canvasToken is changed and setContentsToCanvas() is always called.
+ m_canvasToken = m_canvasPlatformLayer ? m_canvasPlatformLayer->graphicsSurfaceToken() : GraphicsSurfaceToken();
+ ASSERT(!(!m_canvasToken.isValid() && m_canvasPlatformLayer));
+ if (m_canvasPlatformLayer)
+ m_canvasNeedsDisplay = true;
if (client())
client()->notifyFlushRequired(this);
+#endif
}
#if ENABLE(CSS_FILTERS)
@@ -530,19 +553,40 @@
void CoordinatedGraphicsLayer::syncCanvas()
{
+ destroyCanvasIfNeeded();
+ createCanvasIfNeeded();
+
if (!m_canvasNeedsDisplay)
return;
- if (!m_canvasPlatformLayer)
+ ASSERT(m_canvasPlatformLayer);
+#if USE(GRAPHICS_SURFACE)
+ m_coordinator->syncCanvas(m_id, m_canvasPlatformLayer);
+#endif
+ m_canvasNeedsDisplay = false;
+}
+
+void CoordinatedGraphicsLayer::destroyCanvasIfNeeded()
+{
+ if (!m_canvasNeedsDestroy)
return;
#if USE(GRAPHICS_SURFACE)
- uint32_t frontBuffer = m_canvasPlatformLayer->copyToGraphicsSurface();
- GraphicsSurfaceToken token = m_canvasPlatformLayer->graphicsSurfaceToken();
+ m_coordinator->destroyCanvas(m_id);
+#endif
+ m_canvasNeedsDestroy = false;
+}
- m_coordinator->syncCanvas(m_id, IntSize(size().width(), size().height()), token, frontBuffer);
+void CoordinatedGraphicsLayer::createCanvasIfNeeded()
+{
+ if (!m_canvasNeedsCreate)
+ return;
+
+ ASSERT(m_canvasPlatformLayer);
+#if USE(GRAPHICS_SURFACE)
+ m_coordinator->createCanvas(m_id, m_canvasPlatformLayer);
#endif
- m_canvasNeedsDisplay = false;
+ m_canvasNeedsCreate = false;
}
void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h (135199 => 135200)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -27,7 +27,6 @@
#include "GraphicsLayer.h"
#include "GraphicsLayerAnimation.h"
#include "GraphicsLayerTransform.h"
-#include "GraphicsSurface.h"
#include "Image.h"
#include "IntSize.h"
#include "ShareableBitmap.h"
@@ -37,6 +36,9 @@
#include "UpdateInfo.h"
#include "WebLayerTreeInfo.h"
#include "WebProcess.h"
+#if USE(GRAPHICS_SURFACE)
+#include <WebCore/GraphicsSurfaceToken.h>
+#endif
#include <WebCore/RunLoop.h>
#include <wtf/text/StringHash.h>
@@ -64,7 +66,9 @@
virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&) = 0;
#endif
#if USE(GRAPHICS_SURFACE)
- virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer) = 0;
+ virtual void createCanvas(WebLayerID, WebCore::PlatformLayer*) = 0;
+ virtual void syncCanvas(WebLayerID, WebCore::PlatformLayer*) = 0;
+ virtual void destroyCanvas(WebLayerID) = 0;
#endif
virtual void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&) = 0;
@@ -185,6 +189,9 @@
void createBackingStore();
void releaseImageBackingIfNeeded();
+ void destroyCanvasIfNeeded();
+ void createCanvasIfNeeded();
+
bool selfOrAncestorHaveNonAffineTransforms();
bool shouldUseTiledBackingStore();
void adjustContentsScale();
@@ -208,6 +215,8 @@
bool m_shouldSyncAnimations: 1;
bool m_fixedToViewport : 1;
bool m_canvasNeedsDisplay : 1;
+ bool m_canvasNeedsCreate : 1;
+ bool m_canvasNeedsDestroy : 1;
WebKit::CoordinatedGraphicsLayerClient* m_coordinator;
OwnPtr<TiledBackingStore> m_mainBackingStore;
@@ -219,6 +228,9 @@
RefPtr<WebKit::CoordinatedImageBacking> m_coordinatedImageBacking;
PlatformLayer* m_canvasPlatformLayer;
+#if USE(GRAPHICS_SURFACE)
+ GraphicsSurfaceToken m_canvasToken;
+#endif
Timer<CoordinatedGraphicsLayer> m_animationStartedTimer;
GraphicsLayerAnimations m_animations;
double m_lastAnimationStartTime;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp (135199 => 135200)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-11-19 22:54:22 UTC (rev 135200)
@@ -41,12 +41,14 @@
#include "WebPageProxyMessages.h"
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
+#include <WebCore/GraphicsSurface.h>
#include <WebCore/Page.h>
#include <WebCore/RenderLayer.h>
#include <WebCore/RenderLayerBacking.h>
#include <WebCore/RenderLayerCompositor.h>
#include <WebCore/RenderView.h>
#include <WebCore/Settings.h>
+#include <WebCore/TextureMapperPlatformLayer.h>
#include <wtf/TemporaryChange.h>
#if ENABLE(CSS_SHADERS)
@@ -321,11 +323,29 @@
}
#if USE(GRAPHICS_SURFACE)
-void LayerTreeCoordinator::syncCanvas(WebLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token, uint32_t frontBuffer)
+void LayerTreeCoordinator::createCanvas(WebLayerID id, PlatformLayer* canvasPlatformLayer)
{
m_shouldSyncFrame = true;
- m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, canvasSize, token, frontBuffer));
+ GraphicsSurfaceToken token = canvasPlatformLayer->graphicsSurfaceToken();
+ IntSize canvasSize = canvasPlatformLayer->platformLayerSize();
+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateCanvas(id, canvasSize, token));
}
+
+void LayerTreeCoordinator::syncCanvas(WebLayerID id, PlatformLayer* canvasPlatformLayer)
+{
+ m_shouldSyncFrame = true;
+ uint32_t frontBuffer = canvasPlatformLayer->copyToGraphicsSurface();
+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::SyncCanvas(id, frontBuffer));
+}
+
+void LayerTreeCoordinator::destroyCanvas(WebLayerID id)
+{
+ if (m_isPurging)
+ return;
+
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyCanvas(id));
+}
#endif
#if ENABLE(CSS_FILTERS)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h (135199 => 135200)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-11-19 22:44:20 UTC (rev 135199)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-11-19 22:54:22 UTC (rev 135200)
@@ -30,7 +30,6 @@
#include "UpdateAtlas.h"
#include <WebCore/GraphicsLayerClient.h>
#include <WebCore/GraphicsLayerFactory.h>
-#include <WebCore/GraphicsSurface.h>
#include <wtf/OwnPtr.h>
#if ENABLE(CSS_SHADERS)
@@ -97,7 +96,9 @@
virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&);
#endif
#if USE(GRAPHICS_SURFACE)
- virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, const WebCore::GraphicsSurfaceToken&, uint32_t frontBuffer) OVERRIDE;
+ virtual void createCanvas(WebLayerID, WebCore::PlatformLayer*) OVERRIDE;
+ virtual void syncCanvas(WebLayerID, WebCore::PlatformLayer*) OVERRIDE;
+ virtual void destroyCanvas(WebLayerID) OVERRIDE;
#endif
virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);
virtual void syncFixedLayers();