Coordinated Graphics: CoordinatedGraphicsLayer makes CoordinatedGraphicsScene perform...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2013 19:16:54 +0000 (19:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Mar 2013 19:16:54 +0000 (19:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108294

Patch by Gwang Yoon Hwang <ryumiel@company100.net> on 2013-03-05
Reviewed by Anders Carlsson.

Source/WebCore:

CoordinatedLayerTreeHostProxy has too many IPC messages (e.g. SyncCanvas and
CreateTile), and there is a long function chain from CoordinatedGraphicsLayer to
CoordinatedGraphicsScene (4 classes).
If we want to add a new message, we need to add similar functions into 4 classes.

Now CoordinatedLayerTreeHost has only one IPC message for CoordinatedGraphicsLayer:
CommitCoordinatedGraphicsState.
CoordinatedGraphicsLayer makes CoordinatedGraphicsScene run as follows:
1. CoordinatedGraphicsLayer makes a CoordinatedGraphicsLayerState.
2. CoordinatedLayerTreeHost stores all LayerStates.
3. CoordinatedLayerTreeHost sends GraphicsState includes LayerStates to CoordinatedLayerTreeHostProxy
at the moment of flushing via CommitCoordinatedGraphicsState message.
4. CoordinatedGraphicsScene applies all state changes to layers.

There is one big behavior change. All states changes (e.g.
UpdateTiles, SetLayerChildren, and etc..) are performed at the same time, when
CoordinatedGraphicsScene::commitCoordinatedGraphicsState is called.

This patch is based on Dongsung Huang, and Noam's work in
https://bugs.webkit.org/show_bug.cgi?id=108294

No new tests, covered by existing tests.

* Target.pri:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setPosition):
(WebCore::CoordinatedGraphicsLayer::setAnchorPoint):
(WebCore::CoordinatedGraphicsLayer::setSize):
(WebCore::CoordinatedGraphicsLayer::setTransform):
(WebCore::CoordinatedGraphicsLayer::setChildrenTransform):
(WebCore::CoordinatedGraphicsLayer::setPreserves3D):
(WebCore::CoordinatedGraphicsLayer::setMasksToBounds):
(WebCore::CoordinatedGraphicsLayer::setDrawsContent):
(WebCore::CoordinatedGraphicsLayer::setContentsVisible):
(WebCore::CoordinatedGraphicsLayer::setContentsOpaque):
(WebCore::CoordinatedGraphicsLayer::setBackfaceVisibility):
(WebCore::CoordinatedGraphicsLayer::setOpacity):
(WebCore::CoordinatedGraphicsLayer::setContentsRect):
(WebCore::CoordinatedGraphicsLayer::setFilters):
(WebCore::CoordinatedGraphicsLayer::setContentsToSolidColor):
(WebCore::CoordinatedGraphicsLayer::setShowDebugBorder):
(WebCore::CoordinatedGraphicsLayer::setShowRepaintCounter):
(WebCore::CoordinatedGraphicsLayer::setMaskLayer):
(WebCore::CoordinatedGraphicsLayer::setReplicatedByLayer):
(WebCore::CoordinatedGraphicsLayer::setFixedToViewport):
(WebCore::CoordinatedGraphicsLayer::syncChildren):
(WebCore::CoordinatedGraphicsLayer::syncFilters):
(WebCore::CoordinatedGraphicsLayer::syncImageBacking):
(WebCore::CoordinatedGraphicsLayer::syncLayerState):
(WebCore::CoordinatedGraphicsLayer::setDebugBorder):
(WebCore::CoordinatedGraphicsLayer::syncAnimations):
(WebCore::CoordinatedGraphicsLayer::syncCanvas):
(WebCore::CoordinatedGraphicsLayer::destroyCanvasIfNeeded):
(WebCore::CoordinatedGraphicsLayer::createCanvasIfNeeded):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::resetLayerState):
(WebCore):
(WebCore::CoordinatedGraphicsLayer::releaseImageBackingIfNeeded):
(WebCore::CoordinatedGraphicsLayer::setRootLayer):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStorePaintEnd):
(WebCore::CoordinatedGraphicsLayer::createTile):
(WebCore::CoordinatedGraphicsLayer::updateTile):
(WebCore::CoordinatedGraphicsLayer::removeTile):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayerClient):
(CoordinatedGraphicsLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::createCanvasIfNeeded):
(WebCore::CoordinatedGraphicsScene::syncCanvasIfNeeded):
(WebCore::CoordinatedGraphicsScene::destroyCanvasIfNeeded):
(WebCore::CoordinatedGraphicsScene::setLayerRepaintCountIfNeeded):
(WebCore::CoordinatedGraphicsScene::setLayerChildrenIfNeeded):
(WebCore::CoordinatedGraphicsScene::setLayerFiltersIfNeeded):
(WebCore::CoordinatedGraphicsScene::setLayerState):
(WebCore::CoordinatedGraphicsScene::deleteLayer):
(WebCore::CoordinatedGraphicsScene::createTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::removeTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::updateTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
(WebCore::CoordinatedGraphicsScene::commitSceneState):
(WebCore::CoordinatedGraphicsScene::setLayerAnimationsIfNeeded):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
(WebCore):
(CoordinatedGraphicsScene):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h: Added.
(WebCore):
(TileUpdateInfo):
(TileCreationInfo):
(WebCore::CoordinatedGraphicsLayerState::CoordinatedGraphicsLayerState):
(CoordinatedGraphicsLayerState):
(CoordinatedGraphicsState):
* platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
* platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h: Removed.
* platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h:

Source/WebKit2:

There are two changes in WK2.
1. Change CoordinatedLayerTreeHostProxy to use CoordinatedGraphicsState.
2. Add encode/decode of CoordinatedGraphicsState in CoordinatedGraphicsArgumentCoders.

This patch is based on Dongsung Huang, and Noam's work in
https://bugs.webkit.org/show_bug.cgi?id=108294

No new tests, covered by existing tests.

* Scripts/webkit2/messages.py:
(headers_for_type):
* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
    Encoding UpdateImageBacking and CreateUpdateAtlas can fail when
    encoding WebCoordinatedSurface::Handle fails, but we don't
    recover in the case.
(CoreIPC::::decode):
(CoreIPC):
* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h:
(WebCore):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
(WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState):
(WebKit):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
(WebCore):
(CoordinatedLayerTreeHostProxy):
(WebKit::CoordinatedLayerTreeHostProxy::coordinatedGraphicsScene):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
(WebKit::CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded):
(WebKit::CoordinatedLayerTreeHost::syncLayerState):
(WebKit::CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded):
(WebKit):
(WebKit::CoordinatedLayerTreeHost::updateImageBacking):
(WebKit::CoordinatedLayerTreeHost::setBackgroundColor):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
(CoordinatedLayerTreeHost):

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Target.pri
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h [new file with mode: 0644]
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h [deleted file]
Source/WebCore/platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

index 1ee1927..c165a5f 100644 (file)
@@ -1,3 +1,105 @@
+2013-03-05  Gwang Yoon Hwang  <ryumiel@company100.net>
+
+        Coordinated Graphics: CoordinatedGraphicsLayer makes CoordinatedGraphicsScene perform via CoordinatedGraphicsState.
+        https://bugs.webkit.org/show_bug.cgi?id=108294
+
+        Reviewed by Anders Carlsson.
+
+        CoordinatedLayerTreeHostProxy has too many IPC messages (e.g. SyncCanvas and
+        CreateTile), and there is a long function chain from CoordinatedGraphicsLayer to
+        CoordinatedGraphicsScene (4 classes).
+        If we want to add a new message, we need to add similar functions into 4 classes.
+
+        Now CoordinatedLayerTreeHost has only one IPC message for CoordinatedGraphicsLayer:
+        CommitCoordinatedGraphicsState.
+        CoordinatedGraphicsLayer makes CoordinatedGraphicsScene run as follows:
+        1. CoordinatedGraphicsLayer makes a CoordinatedGraphicsLayerState.
+        2. CoordinatedLayerTreeHost stores all LayerStates.
+        3. CoordinatedLayerTreeHost sends GraphicsState includes LayerStates to CoordinatedLayerTreeHostProxy
+        at the moment of flushing via CommitCoordinatedGraphicsState message.
+        4. CoordinatedGraphicsScene applies all state changes to layers.
+
+        There is one big behavior change. All states changes (e.g.
+        UpdateTiles, SetLayerChildren, and etc..) are performed at the same time, when
+        CoordinatedGraphicsScene::commitCoordinatedGraphicsState is called.
+
+        This patch is based on Dongsung Huang, and Noam's work in
+        https://bugs.webkit.org/show_bug.cgi?id=108294
+
+        No new tests, covered by existing tests.
+
+        * Target.pri:
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setPosition):
+        (WebCore::CoordinatedGraphicsLayer::setAnchorPoint):
+        (WebCore::CoordinatedGraphicsLayer::setSize):
+        (WebCore::CoordinatedGraphicsLayer::setTransform):
+        (WebCore::CoordinatedGraphicsLayer::setChildrenTransform):
+        (WebCore::CoordinatedGraphicsLayer::setPreserves3D):
+        (WebCore::CoordinatedGraphicsLayer::setMasksToBounds):
+        (WebCore::CoordinatedGraphicsLayer::setDrawsContent):
+        (WebCore::CoordinatedGraphicsLayer::setContentsVisible):
+        (WebCore::CoordinatedGraphicsLayer::setContentsOpaque):
+        (WebCore::CoordinatedGraphicsLayer::setBackfaceVisibility):
+        (WebCore::CoordinatedGraphicsLayer::setOpacity):
+        (WebCore::CoordinatedGraphicsLayer::setContentsRect):
+        (WebCore::CoordinatedGraphicsLayer::setFilters):
+        (WebCore::CoordinatedGraphicsLayer::setContentsToSolidColor):
+        (WebCore::CoordinatedGraphicsLayer::setShowDebugBorder):
+        (WebCore::CoordinatedGraphicsLayer::setShowRepaintCounter):
+        (WebCore::CoordinatedGraphicsLayer::setMaskLayer):
+        (WebCore::CoordinatedGraphicsLayer::setReplicatedByLayer):
+        (WebCore::CoordinatedGraphicsLayer::setFixedToViewport):
+        (WebCore::CoordinatedGraphicsLayer::syncChildren):
+        (WebCore::CoordinatedGraphicsLayer::syncFilters):
+        (WebCore::CoordinatedGraphicsLayer::syncImageBacking):
+        (WebCore::CoordinatedGraphicsLayer::syncLayerState):
+        (WebCore::CoordinatedGraphicsLayer::setDebugBorder):
+        (WebCore::CoordinatedGraphicsLayer::syncAnimations):
+        (WebCore::CoordinatedGraphicsLayer::syncCanvas):
+        (WebCore::CoordinatedGraphicsLayer::destroyCanvasIfNeeded):
+        (WebCore::CoordinatedGraphicsLayer::createCanvasIfNeeded):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        (WebCore::CoordinatedGraphicsLayer::resetLayerState):
+        (WebCore):
+        (WebCore::CoordinatedGraphicsLayer::releaseImageBackingIfNeeded):
+        (WebCore::CoordinatedGraphicsLayer::setRootLayer):
+        (WebCore::CoordinatedGraphicsLayer::tiledBackingStorePaintEnd):
+        (WebCore::CoordinatedGraphicsLayer::createTile):
+        (WebCore::CoordinatedGraphicsLayer::updateTile):
+        (WebCore::CoordinatedGraphicsLayer::removeTile):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        (CoordinatedGraphicsLayerClient):
+        (CoordinatedGraphicsLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
+        (WebCore::CoordinatedGraphicsScene::createCanvasIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::syncCanvasIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::destroyCanvasIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::setLayerRepaintCountIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::setLayerChildrenIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::setLayerFiltersIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::setLayerState):
+        (WebCore::CoordinatedGraphicsScene::deleteLayer):
+        (WebCore::CoordinatedGraphicsScene::createTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::removeTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::updateTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::assignImageBackingToLayer):
+        (WebCore::CoordinatedGraphicsScene::commitSceneState):
+        (WebCore::CoordinatedGraphicsScene::setLayerAnimationsIfNeeded):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
+        (WebCore):
+        (CoordinatedGraphicsScene):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h: Added.
+        (WebCore):
+        (TileUpdateInfo):
+        (TileCreationInfo):
+        (WebCore::CoordinatedGraphicsLayerState::CoordinatedGraphicsLayerState):
+        (CoordinatedGraphicsLayerState):
+        (CoordinatedGraphicsState):
+        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.h:
+        * platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h: Removed.
+        * platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h:
+
 2013-03-05  Roger Fong  <roger_fong@apple.com>
 
         Unreviewed. AppleWin VS2010 build fix.
index 3b06c04..1188a89 100644 (file)
@@ -4117,8 +4117,8 @@ use?(3D_GRAPHICS) {
         platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h \
         platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h \
         platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h \
+        platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h \
         platform/graphics/texmap/coordinated/CoordinatedImageBacking.h \
-        platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h \
         platform/graphics/texmap/coordinated/CoordinatedSurface.h \
         platform/graphics/texmap/coordinated/CoordinatedTile.h \
         platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h \
index 4c43aa7..6e90036 100644 (file)
@@ -192,6 +192,7 @@ void CoordinatedGraphicsLayer::setPosition(const FloatPoint& p)
         return;
 
     GraphicsLayer::setPosition(p);
+    m_layerState.positionChanged = true;
     didChangeGeometry();
 }
 
@@ -201,6 +202,7 @@ void CoordinatedGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
         return;
 
     GraphicsLayer::setAnchorPoint(p);
+    m_layerState.anchorPointChanged = true;
     didChangeGeometry();
 }
 
@@ -210,6 +212,7 @@ void CoordinatedGraphicsLayer::setSize(const FloatSize& size)
         return;
 
     GraphicsLayer::setSize(size);
+    m_layerState.sizeChanged = true;
 
     if (maskLayer())
         maskLayer()->setSize(size);
@@ -222,6 +225,8 @@ void CoordinatedGraphicsLayer::setTransform(const TransformationMatrix& t)
         return;
 
     GraphicsLayer::setTransform(t);
+    m_layerState.transformChanged = true;
+
     didChangeGeometry();
 }
 
@@ -231,6 +236,8 @@ void CoordinatedGraphicsLayer::setChildrenTransform(const TransformationMatrix&
         return;
 
     GraphicsLayer::setChildrenTransform(t);
+    m_layerState.childrenTransformChanged = true;
+
     didChangeGeometry();
 }
 
@@ -240,6 +247,9 @@ void CoordinatedGraphicsLayer::setPreserves3D(bool b)
         return;
 
     GraphicsLayer::setPreserves3D(b);
+    m_layerState.preserves3D = b;
+    m_layerState.flagsChanged = true;
+
     didChangeGeometry();
 }
 
@@ -248,6 +258,9 @@ void CoordinatedGraphicsLayer::setMasksToBounds(bool b)
     if (masksToBounds() == b)
         return;
     GraphicsLayer::setMasksToBounds(b);
+    m_layerState.masksToBounds = b;
+    m_layerState.flagsChanged = true;
+
     didChangeGeometry();
 }
 
@@ -256,6 +269,8 @@ void CoordinatedGraphicsLayer::setDrawsContent(bool b)
     if (drawsContent() == b)
         return;
     GraphicsLayer::setDrawsContent(b);
+    m_layerState.drawsContent = b;
+    m_layerState.flagsChanged = true;
 
     didChangeLayerState();
 }
@@ -265,6 +280,9 @@ void CoordinatedGraphicsLayer::setContentsVisible(bool b)
     if (contentsAreVisible() == b)
         return;
     GraphicsLayer::setContentsVisible(b);
+    m_layerState.contentsVisible = b;
+    m_layerState.flagsChanged = true;
+
     if (maskLayer())
         maskLayer()->setContentsVisible(b);
 
@@ -278,6 +296,9 @@ void CoordinatedGraphicsLayer::setContentsOpaque(bool b)
     if (m_mainBackingStore)
         m_mainBackingStore->setSupportsAlpha(!b);
     GraphicsLayer::setContentsOpaque(b);
+    m_layerState.contentsOpaque = b;
+    m_layerState.flagsChanged = true;
+
     didChangeLayerState();
 }
 
@@ -287,6 +308,9 @@ void CoordinatedGraphicsLayer::setBackfaceVisibility(bool b)
         return;
 
     GraphicsLayer::setBackfaceVisibility(b);
+    m_layerState.backfaceVisible = b;
+    m_layerState.flagsChanged = true;
+
     didChangeLayerState();
 }
 
@@ -296,6 +320,9 @@ void CoordinatedGraphicsLayer::setOpacity(float opacity)
         return;
 
     GraphicsLayer::setOpacity(opacity);
+    m_layerState.opacity = opacity;
+    m_layerState.opacityChanged = true;
+
     didChangeLayerState();
 }
 
@@ -305,6 +332,9 @@ void CoordinatedGraphicsLayer::setContentsRect(const IntRect& r)
         return;
 
     GraphicsLayer::setContentsRect(r);
+    m_layerState.contentsRect = r;
+    m_layerState.contentsRectChanged = true;
+
     didChangeLayerState();
 }
 
@@ -356,16 +386,23 @@ bool CoordinatedGraphicsLayer::setFilters(const FilterOperations& newFilters)
 {
     if (filters() == newFilters)
         return true;
+
+    if (!GraphicsLayer::setFilters(newFilters))
+        return false;
+
     didChangeFilters();
-    return GraphicsLayer::setFilters(newFilters);
+    return true;
 }
 #endif
 
 void CoordinatedGraphicsLayer::setContentsToSolidColor(const Color& color)
 {
-    if (m_layerInfo.solidColor == color)
+    if (m_layerState.solidColor == color)
         return;
-    m_layerInfo.solidColor = color;
+
+    m_layerState.solidColor = color;
+    m_layerState.solidColorChanged = true;
+
     didChangeLayerState();
 }
 
@@ -375,6 +412,9 @@ void CoordinatedGraphicsLayer::setShowDebugBorder(bool show)
         return;
 
     GraphicsLayer::setShowDebugBorder(show);
+    m_layerState.showDebugBorders = true;
+    m_layerState.flagsChanged = true;
+
     didChangeLayerState();
 }
 
@@ -384,6 +424,9 @@ void CoordinatedGraphicsLayer::setShowRepaintCounter(bool show)
         return;
 
     GraphicsLayer::setShowRepaintCounter(show);
+    m_layerState.showRepaintCounter = true;
+    m_layerState.flagsChanged = true;
+
     didChangeLayerState();
 }
 
@@ -421,6 +464,10 @@ void CoordinatedGraphicsLayer::setMaskLayer(GraphicsLayer* layer)
     layer->setContentsVisible(contentsAreVisible());
     CoordinatedGraphicsLayer* coordinatedLayer = toCoordinatedGraphicsLayer(layer);
     coordinatedLayer->didChangeLayerState();
+
+    m_layerState.mask = coordinatedLayer->id();
+    m_layerState.maskChanged = true;
+
     didChangeLayerState();
 }
 
@@ -442,6 +489,8 @@ void CoordinatedGraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
         return;
 
     GraphicsLayer::setReplicatedByLayer(layer);
+    m_layerState.replica = toCoordinatedLayerID(layer);
+    m_layerState.replicaChanged = true;
     didChangeLayerState();
 }
 
@@ -471,6 +520,9 @@ void CoordinatedGraphicsLayer::setFixedToViewport(bool isFixed)
         return;
 
     m_fixedToViewport = isFixed;
+    m_layerState.fixedToViewport = isFixed;
+    m_layerState.flagsChanged = true;
+
     didChangeLayerState();
 }
 
@@ -504,11 +556,10 @@ void CoordinatedGraphicsLayer::syncChildren()
     if (!m_shouldSyncChildren)
         return;
     m_shouldSyncChildren = false;
-    Vector<CoordinatedLayerID> childIDs;
+    m_layerState.childrenChanged = true;
+    m_layerState.children.clear();
     for (size_t i = 0; i < children().size(); ++i)
-        childIDs.append(toCoordinatedLayerID(children()[i]));
-
-    m_coordinator->syncLayerChildren(m_id, childIDs);
+        m_layerState.children.append(toCoordinatedLayerID(children()[i]));
 }
 
 #if ENABLE(CSS_FILTERS)
@@ -517,7 +568,9 @@ void CoordinatedGraphicsLayer::syncFilters()
     if (!m_shouldSyncFilters)
         return;
     m_shouldSyncFilters = false;
-    m_coordinator->syncLayerFilters(m_id, filters());
+
+    m_layerState.filters = GraphicsLayer::filters();
+    m_layerState.filtersChanged = true;
 }
 #endif
 
@@ -538,14 +591,15 @@ void CoordinatedGraphicsLayer::syncImageBacking()
         if (!m_coordinatedImageBacking) {
             m_coordinatedImageBacking = m_coordinator->createImageBackingIfNeeded(m_compositedImage.get());
             m_coordinatedImageBacking->addHost(this);
-            m_layerInfo.imageID = m_coordinatedImageBacking->id();
+            m_layerState.imageID = m_coordinatedImageBacking->id();
         }
 
         m_coordinatedImageBacking->markDirty();
+        m_layerState.imageChanged = true;
     } else
         releaseImageBackingIfNeeded();
 
-    // syncImageBacking() changed m_layerInfo.imageID.
+    // syncImageBacking() changed m_layerState.imageID.
     didChangeLayerState();
 }
 
@@ -554,38 +608,34 @@ void CoordinatedGraphicsLayer::syncLayerState()
     if (!m_shouldSyncLayerState)
         return;
     m_shouldSyncLayerState = false;
-    m_layerInfo.fixedToViewport = fixedToViewport();
-
-    m_layerInfo.backfaceVisible = backfaceVisibility();
-    m_layerInfo.childrenTransform = childrenTransform();
-    m_layerInfo.contentsOpaque = contentsOpaque();
-    m_layerInfo.contentsRect = contentsRect();
-    m_layerInfo.drawsContent = drawsContent();
-    m_layerInfo.contentsVisible = contentsAreVisible();
-    m_layerInfo.mask = toCoordinatedLayerID(maskLayer());
-    m_layerInfo.masksToBounds = masksToBounds();
-    m_layerInfo.opacity = opacity();
-    m_layerInfo.preserves3D = preserves3D();
-    m_layerInfo.replica = toCoordinatedLayerID(replicaLayer());
-    m_layerInfo.transform = transform();
-
-    m_layerInfo.anchorPoint = m_adjustedAnchorPoint;
-    m_layerInfo.pos = m_adjustedPosition;
-    m_layerInfo.size = m_adjustedSize;
-
-    m_layerInfo.showDebugBorders = isShowingDebugBorder();
-    if (m_layerInfo.showDebugBorders)
-        updateDebugIndicators();
-    m_layerInfo.showRepaintCounter = isShowingRepaintCounter();
 
-    m_coordinator->syncLayerState(m_id, m_layerInfo);
+    m_layerState.childrenTransform = childrenTransform();
+    m_layerState.contentsRect = contentsRect();
+    m_layerState.mask = toCoordinatedLayerID(maskLayer());
+    m_layerState.opacity = opacity();
+    m_layerState.replica = toCoordinatedLayerID(replicaLayer());
+    m_layerState.transform = transform();
+
+    m_layerState.anchorPoint = m_adjustedAnchorPoint;
+    m_layerState.pos = m_adjustedPosition;
+    m_layerState.size = m_adjustedSize;
+
+    if (m_layerState.showDebugBorders)
+        updateDebugIndicators();
 }
 
 void CoordinatedGraphicsLayer::setDebugBorder(const Color& color, float width)
 {
-    ASSERT(m_layerInfo.showDebugBorders);
-    m_layerInfo.debugBorderColor = color;
-    m_layerInfo.debugBorderWidth = width;
+    ASSERT(m_layerState.showDebugBorders);
+    if (m_layerState.debugBorderColor != color) {
+        m_layerState.debugBorderColor = color;
+        m_layerState.debugBorderColorChanged = true;
+    }
+
+    if (m_layerState.debugBorderWidth != width) {
+        m_layerState.debugBorderWidth = width;
+        m_layerState.debugBorderWidthChanged = true;
+    }
 }
 
 void CoordinatedGraphicsLayer::syncAnimations()
@@ -594,8 +644,8 @@ void CoordinatedGraphicsLayer::syncAnimations()
         return;
 
     m_shouldSyncAnimations = false;
-
-    m_coordinator->setLayerAnimations(m_id, m_animations);
+    m_layerState.animations = m_animations.getActiveAnimations();
+    m_layerState.animationsChanged = true;
 }
 
 #if USE(GRAPHICS_SURFACE)
@@ -612,7 +662,9 @@ void CoordinatedGraphicsLayer::syncCanvas()
     if (!m_isValidCanvas)
         return;
 
-    m_coordinator->syncCanvas(m_id, m_canvasPlatformLayer);
+    ASSERT(m_canvasPlatformLayer);
+    m_layerState.canvasFrontBuffer = m_canvasPlatformLayer->copyToGraphicsSurface();
+    m_layerState.canvasShouldSwapBuffers = true;
 }
 
 void CoordinatedGraphicsLayer::destroyCanvasIfNeeded()
@@ -621,8 +673,9 @@ void CoordinatedGraphicsLayer::destroyCanvasIfNeeded()
         return;
 
     if (m_isValidCanvas) {
-        m_coordinator->destroyCanvas(m_id);
         m_isValidCanvas = false;
+        m_layerState.canvasToken = GraphicsSurfaceToken();
+        m_layerState.canvasChanged = true;
     }
 
     m_pendingCanvasOperation &= ~DestroyCanvas;
@@ -635,7 +688,9 @@ void CoordinatedGraphicsLayer::createCanvasIfNeeded()
 
     ASSERT(m_canvasPlatformLayer);
     if (!m_isValidCanvas) {
-        m_coordinator->createCanvas(m_id, m_canvasPlatformLayer);
+        m_layerState.canvasSize = m_canvasPlatformLayer->platformLayerSize();
+        m_layerState.canvasToken = m_canvasPlatformLayer->graphicsSurfaceToken();
+        m_layerState.canvasChanged = true;
         m_isValidCanvas = true;
     }
 
@@ -667,11 +722,23 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
 #if USE(GRAPHICS_SURFACE)
     syncCanvas();
 #endif
+
+    m_coordinator->syncLayerState(m_id, m_layerState);
+    resetLayerState();
+
     // Only unset m_movingVisibleRect after we have updated the visible rect after the animation stopped.
     if (!hasActiveTransformAnimation)
         m_movingVisibleRect = false;
 }
 
+void CoordinatedGraphicsLayer::resetLayerState()
+{
+    m_layerState.changeMask = 0;
+    m_layerState.tilesToCreate.clear();
+    m_layerState.tilesToRemove.clear();
+    m_layerState.tilesToUpdate.clear();
+}
+
 bool CoordinatedGraphicsLayer::imageBackingVisible()
 {
     ASSERT(m_coordinatedImageBacking);
@@ -686,7 +753,8 @@ void CoordinatedGraphicsLayer::releaseImageBackingIfNeeded()
     ASSERT(m_coordinator);
     m_coordinatedImageBacking->removeHost(this);
     m_coordinatedImageBacking.clear();
-    m_layerInfo.imageID = InvalidCoordinatedImageBackingID;
+    m_layerState.imageID = InvalidCoordinatedImageBackingID;
+    m_layerState.imageChanged = true;
 }
 
 void CoordinatedGraphicsLayer::tiledBackingStorePaintBegin()
@@ -695,7 +763,8 @@ void CoordinatedGraphicsLayer::tiledBackingStorePaintBegin()
 
 void CoordinatedGraphicsLayer::setRootLayer(bool isRoot)
 {
-    m_layerInfo.isRootLayer = isRoot;
+    m_layerState.isRootLayer = isRoot;
+    m_layerState.flagsChanged = true;
     didChangeLayerState();
 }
 
@@ -751,8 +820,11 @@ void CoordinatedGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context,
 
 void CoordinatedGraphicsLayer::tiledBackingStorePaintEnd(const Vector<IntRect>& updatedRects)
 {
-    if (isShowingRepaintCounter() && !updatedRects.isEmpty())
-        m_coordinator->setLayerRepaintCount(id(), incrementRepaintCount());
+    if (!isShowingRepaintCounter() || updatedRects.isEmpty())
+        return;
+
+    m_layerState.repaintCount = incrementRepaintCount();
+    m_layerState.repaintCountChanged = true;
 }
 
 void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation()
@@ -811,21 +883,32 @@ void CoordinatedGraphicsLayer::createTile(uint32_t tileID, const SurfaceUpdateIn
 {
     ASSERT(m_coordinator);
     ASSERT(m_coordinator->isFlushingLayerChanges());
-    m_coordinator->createTile(id(), tileID, updateInfo, tileRect);
+
+    TileCreationInfo creationInfo;
+    creationInfo.tileID = tileID;
+    creationInfo.scale = updateInfo.scaleFactor;
+
+    m_layerState.tilesToCreate.append(creationInfo);
+    updateTile(tileID, updateInfo, tileRect);
 }
 
 void CoordinatedGraphicsLayer::updateTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect)
 {
     ASSERT(m_coordinator);
     ASSERT(m_coordinator->isFlushingLayerChanges());
-    m_coordinator->updateTile(id(), tileID, updateInfo, tileRect);
+
+    TileUpdateInfo tileUpdateInfo;
+    tileUpdateInfo.tileID = tileID;
+    tileUpdateInfo.tileRect = tileRect;
+    tileUpdateInfo.updateInfo = updateInfo;
+    m_layerState.tilesToUpdate.append(tileUpdateInfo);
 }
 
 void CoordinatedGraphicsLayer::removeTile(uint32_t tileID)
 {
     ASSERT(m_coordinator);
     ASSERT(m_coordinator->isFlushingLayerChanges() || m_isPurging);
-    m_coordinator->removeTile(id(), tileID);
+    m_layerState.tilesToRemove.append(tileID);
 }
 
 void CoordinatedGraphicsLayer::updateContentBuffers()
index e5aa47a..790fe96 100644 (file)
@@ -21,8 +21,8 @@
 #ifndef CoordinatedGraphicsLayer_h
 #define CoordinatedGraphicsLayer_h
 
+#include "CoordinatedGraphicsState.h"
 #include "CoordinatedImageBacking.h"
-#include "CoordinatedLayerInfo.h"
 #include "CoordinatedTile.h"
 #include "FloatPoint3D.h"
 #include "GraphicsLayer.h"
@@ -48,31 +48,12 @@ class GraphicsLayerAnimations;
 class CoordinatedGraphicsLayerClient {
 public:
     virtual bool isFlushingLayerChanges() const = 0;
-
-    // CoordinatedTileClient
-    virtual void createTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
-    virtual void updateTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
-    virtual void removeTile(CoordinatedLayerID, uint32_t tileID) = 0;
-
     virtual FloatRect visibleContentsRect() const = 0;
     virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
-    virtual void syncLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&) = 0;
-    virtual void syncLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&) = 0;
-#if ENABLE(CSS_FILTERS)
-    virtual void syncLayerFilters(CoordinatedLayerID, const FilterOperations&) = 0;
-#endif
-#if USE(GRAPHICS_SURFACE)
-    virtual void createCanvas(CoordinatedLayerID, PlatformLayer*) = 0;
-    virtual void syncCanvas(CoordinatedLayerID, PlatformLayer*) = 0;
-    virtual void destroyCanvas(CoordinatedLayerID) = 0;
-#endif
-
-    virtual void setLayerRepaintCount(CoordinatedLayerID, int) = 0;
-
-    virtual void setLayerAnimations(CoordinatedLayerID, const GraphicsLayerAnimations&) = 0;
-
     virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
     virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&) = 0;
+
+    virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0;
 };
 
 class CoordinatedGraphicsLayer : public GraphicsLayer
@@ -190,6 +171,7 @@ private:
 #endif
     void didChangeImageBacking();
 
+    void resetLayerState();
     void syncLayerState();
     void syncAnimations();
     void syncChildren();
@@ -216,7 +198,7 @@ private:
     void animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*);
 
     CoordinatedLayerID m_id;
-    CoordinatedLayerInfo m_layerInfo;
+    CoordinatedGraphicsLayerState m_layerState;
     GraphicsLayerTransform m_layerTransform;
     TransformationMatrix m_cachedInverseTransform;
     FloatSize m_pixelAlignmentOffset;
index 8624513..9f08053 100644 (file)
@@ -196,54 +196,63 @@ void CoordinatedGraphicsScene::adjustPositionForFixedLayers()
 }
 
 #if USE(GRAPHICS_SURFACE)
-void CoordinatedGraphicsScene::createCanvas(CoordinatedLayerID id, const IntSize&, PassRefPtr<GraphicsSurface> surface)
+void CoordinatedGraphicsScene::createCanvasIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    ASSERT(m_textureMapper);
-    GraphicsLayer* layer = layerByID(id);
-    ASSERT(!m_surfaceBackingStores.contains(id));
+    if (!state.canvasToken.isValid())
+        return;
 
     RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore(TextureMapperSurfaceBackingStore::create());
-    m_surfaceBackingStores.set(id, canvasBackingStore);
+    m_surfaceBackingStores.set(layer, canvasBackingStore);
 
-    canvasBackingStore->setGraphicsSurface(surface);
+    GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
+    canvasBackingStore->setGraphicsSurface(GraphicsSurface::create(state.canvasSize, surfaceFlags, state.canvasToken));
     layer->setContentsToMedia(canvasBackingStore.get());
 }
 
-void CoordinatedGraphicsScene::syncCanvas(CoordinatedLayerID id, uint32_t frontBuffer)
+void CoordinatedGraphicsScene::syncCanvasIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
     ASSERT(m_textureMapper);
-    ASSERT(m_surfaceBackingStores.contains(id));
 
-    SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(id);
-    RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore = it->value;
+    if (state.canvasChanged) {
+        destroyCanvasIfNeeded(layer, state);
+        createCanvasIfNeeded(layer, state);
+    }
 
-    canvasBackingStore->swapBuffersIfNeeded(frontBuffer);
+    if (state.canvasShouldSwapBuffers) {
+        ASSERT(m_surfaceBackingStores.contains(layer));
+        SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(layer);
+        RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore = it->value;
+        canvasBackingStore->swapBuffersIfNeeded(state.canvasFrontBuffer);
+    }
 }
 
-void CoordinatedGraphicsScene::destroyCanvas(CoordinatedLayerID id)
+void CoordinatedGraphicsScene::destroyCanvasIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    ASSERT(m_textureMapper);
-    GraphicsLayer* layer = layerByID(id);
-    ASSERT(m_surfaceBackingStores.contains(id));
+    if (state.canvasToken.isValid())
+        return;
 
-    m_surfaceBackingStores.remove(id);
+    m_surfaceBackingStores.remove(layer);
     layer->setContentsToMedia(0);
 }
 #endif
 
-void CoordinatedGraphicsScene::setLayerRepaintCount(CoordinatedLayerID id, int value)
+void CoordinatedGraphicsScene::setLayerRepaintCountIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(id);
-    toGraphicsLayerTextureMapper(layer)->setRepaintCount(value);
+    if (!layer->isShowingRepaintCounter() || !state.repaintCountChanged)
+        return;
+
+    toGraphicsLayerTextureMapper(layer)->setRepaintCount(state.repaintCount);
 }
 
-void CoordinatedGraphicsScene::setLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& childIDs)
+void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(id);
+    if (!state.childrenChanged)
+        return;
+
     Vector<GraphicsLayer*> children;
 
-    for (size_t i = 0; i < childIDs.size(); ++i) {
-        CoordinatedLayerID childID = childIDs[i];
+    for (size_t i = 0; i < state.children.size(); ++i) {
+        CoordinatedLayerID childID = state.children[i];
         GraphicsLayer* child = layerByID(childID);
         children.append(child);
     }
@@ -251,14 +260,15 @@ void CoordinatedGraphicsScene::setLayerChildren(CoordinatedLayerID id, const Vec
 }
 
 #if ENABLE(CSS_FILTERS)
-void CoordinatedGraphicsScene::setLayerFilters(CoordinatedLayerID id, const FilterOperations& filters)
+void CoordinatedGraphicsScene::setLayerFiltersIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(id);
+    if (!state.filtersChanged)
+        return;
 
 #if ENABLE(CSS_SHADERS)
-    injectCachedCustomFilterPrograms(filters);
+    injectCachedCustomFilterPrograms(state.filters);
 #endif
-    layer->setFilters(filters);
+    layer->setFilters(state.filters);
 }
 #endif
 
@@ -294,43 +304,80 @@ void CoordinatedGraphicsScene::removeCustomFilterProgram(int id)
 }
 #endif // ENABLE(CSS_SHADERS)
 
-void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& layerInfo)
+void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState)
 {
     ASSERT(m_rootLayerID != InvalidCoordinatedLayerID);
     GraphicsLayer* layer = layerByID(id);
 
-    layer->setReplicatedByLayer(getLayerByIDIfExists(layerInfo.replica));
-    layer->setMaskLayer(getLayerByIDIfExists(layerInfo.mask));
-
-    layer->setAnchorPoint(layerInfo.anchorPoint);
-    layer->setPosition(layerInfo.pos);
-    layer->setSize(layerInfo.size);
-
-    layer->setTransform(layerInfo.transform);
-    layer->setChildrenTransform(layerInfo.childrenTransform);
-    layer->setBackfaceVisibility(layerInfo.backfaceVisible);
-    layer->setContentsOpaque(layerInfo.contentsOpaque);
-    layer->setContentsRect(layerInfo.contentsRect);
-    layer->setContentsToSolidColor(layerInfo.solidColor);
-    layer->setDrawsContent(layerInfo.drawsContent);
-    layer->setContentsVisible(layerInfo.contentsVisible);
-    toGraphicsLayerTextureMapper(layer)->setFixedToViewport(layerInfo.fixedToViewport);
-    layer->setShowDebugBorder(layerInfo.showDebugBorders);
-    layer->setDebugBorder(layerInfo.debugBorderColor, layerInfo.debugBorderWidth);
-    layer->setShowRepaintCounter(layerInfo.showRepaintCounter);
-
-    if (layerInfo.fixedToViewport)
+    if (layerState.positionChanged)
+        layer->setPosition(layerState.pos);
+
+    if (layerState.anchorPointChanged)
+        layer->setAnchorPoint(layerState.anchorPoint);
+
+    if (layerState.sizeChanged)
+        layer->setSize(layerState.size);
+
+    if (layerState.transformChanged)
+        layer->setTransform(layerState.transform);
+
+    if (layerState.childrenTransformChanged)
+        layer->setChildrenTransform(layerState.childrenTransform);
+
+    if (layerState.contentsRectChanged)
+        layer->setContentsRect(layerState.contentsRect);
+
+    if (layerState.opacityChanged)
+        layer->setOpacity(layerState.opacity);
+
+    if (layerState.solidColorChanged)
+        layer->setContentsToSolidColor(layerState.solidColor);
+
+    if (layerState.debugBorderColorChanged || layerState.debugBorderWidthChanged)
+        layer->setDebugBorder(layerState.debugBorderColor, layerState.debugBorderWidth);
+
+    if (layerState.replicaChanged)
+        layer->setReplicatedByLayer(getLayerByIDIfExists(layerState.replica));
+
+    if (layerState.maskChanged)
+        layer->setMaskLayer(getLayerByIDIfExists(layerState.mask));
+
+    if (layerState.imageChanged)
+        assignImageBackingToLayer(layer, layerState.imageID);
+
+    if (layerState.flagsChanged) {
+        layer->setContentsOpaque(layerState.contentsOpaque);
+        layer->setDrawsContent(layerState.drawsContent);
+        layer->setContentsVisible(layerState.contentsVisible);
+        layer->setBackfaceVisibility(layerState.backfaceVisible);
+
+        // Never clip the root layer.
+        layer->setMasksToBounds(layerState.isRootLayer ? false : layerState.masksToBounds);
+        layer->setPreserves3D(layerState.preserves3D);
+
+        toGraphicsLayerTextureMapper(layer)->setFixedToViewport(layerState.fixedToViewport);
+        layer->setShowDebugBorder(layerState.showDebugBorders);
+        layer->setShowRepaintCounter(layerState.showRepaintCounter);
+    }
+
+    if (layerState.fixedToViewport)
         m_fixedLayers.add(id, layer);
     else
         m_fixedLayers.remove(id);
 
-    assignImageBackingToLayer(id, layer, layerInfo.imageID);
     prepareContentBackingStore(layer);
 
-    // Never make the root layer clip.
-    layer->setMasksToBounds(layerInfo.isRootLayer ? false : layerInfo.masksToBounds);
-    layer->setOpacity(layerInfo.opacity);
-    layer->setPreserves3D(layerInfo.preserves3D);
+    // Apply Operations.
+    setLayerChildrenIfNeeded(layer, layerState);
+    createTilesIfNeeded(layer, layerState);
+    removeTilesIfNeeded(layer, layerState);
+    updateTilesIfNeeded(layer, layerState);
+#if ENABLE(CSS_FILTERS)
+    setLayerFiltersIfNeeded(layer, layerState);
+#endif
+    setLayerAnimationsIfNeeded(layer, layerState);
+    syncCanvasIfNeeded(layer, layerState);
+    setLayerRepaintCountIfNeeded(layer, layerState);
 }
 
 GraphicsLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLayerID id)
@@ -365,7 +412,7 @@ void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID)
     m_backingStores.remove(layer.get());
     m_fixedLayers.remove(layerID);
 #if USE(GRAPHICS_SURFACE)
-    m_surfaceBackingStores.remove(layerID);
+    m_surfaceBackingStores.remove(layer.get());
 #endif
 }
 
@@ -419,36 +466,51 @@ void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(GraphicsLayer* g
     m_backingStoresWithPendingBuffers.add(backingStore);
 }
 
-void CoordinatedGraphicsScene::createTile(CoordinatedLayerID layerID, uint32_t tileID, float scale)
+void CoordinatedGraphicsScene::createTilesIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(layerID);
+    if (state.tilesToCreate.isEmpty())
+        return;
+
     RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
     ASSERT(backingStore);
-    backingStore->createTile(tileID, scale);
+
+    for (size_t i = 0; i < state.tilesToCreate.size(); ++i)
+        backingStore->createTile(state.tilesToCreate[i].tileID, state.tilesToCreate[i].scale);
 }
 
-void CoordinatedGraphicsScene::removeTile(CoordinatedLayerID layerID, uint32_t tileID)
+void CoordinatedGraphicsScene::removeTilesIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(layerID);
+    if (state.tilesToRemove.isEmpty())
+        return;
+
     RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
     if (!backingStore)
         return;
 
-    backingStore->removeTile(tileID);
+    for (size_t i = 0; i < state.tilesToRemove.size(); ++i)
+        backingStore->removeTile(state.tilesToRemove[i]);
+
     m_backingStoresWithPendingBuffers.add(backingStore);
 }
 
-void CoordinatedGraphicsScene::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const TileUpdate& update)
+void CoordinatedGraphicsScene::updateTilesIfNeeded(GraphicsLayer* layer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayer* layer = layerByID(layerID);
+    if (state.tilesToUpdate.isEmpty())
+        return;
+
     RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
     ASSERT(backingStore);
 
-    SurfaceMap::iterator it = m_surfaces.find(update.atlasID);
-    ASSERT(it != m_surfaces.end());
+    for (size_t i = 0; i < state.tilesToUpdate.size(); ++i) {
+        const TileUpdateInfo& tileInfo = state.tilesToUpdate[i];
+        const SurfaceUpdateInfo& surfaceUpdateInfo = tileInfo.updateInfo;
 
-    backingStore->updateTile(tileID, update.sourceRect, update.tileRect, it->value, update.offset);
-    m_backingStoresWithPendingBuffers.add(backingStore);
+        SurfaceMap::iterator surfaceIt = m_surfaces.find(surfaceUpdateInfo.atlasID);
+        ASSERT(surfaceIt != m_surfaces.end());
+
+        backingStore->updateTile(tileInfo.tileID, surfaceUpdateInfo.updateRect, tileInfo.tileRect, surfaceIt->value, surfaceUpdateInfo.surfaceOffset);
+        m_backingStoresWithPendingBuffers.add(backingStore);
+    }
 }
 
 void CoordinatedGraphicsScene::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> surface)
@@ -504,10 +566,10 @@ void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imag
     m_releasedImageBackings.append(m_imageBackings.take(imageID));
 }
 
-void CoordinatedGraphicsScene::assignImageBackingToLayer(CoordinatedLayerID id, GraphicsLayer* layer, CoordinatedImageBackingID imageID)
+void CoordinatedGraphicsScene::assignImageBackingToLayer(GraphicsLayer* layer, CoordinatedImageBackingID imageID)
 {
 #if USE(GRAPHICS_SURFACE)
-    if (m_surfaceBackingStores.contains(id))
+    if (m_surfaceBackingStores.contains(layer))
         return;
 #endif
 
@@ -534,13 +596,25 @@ void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()
     m_backingStoresWithPendingBuffers.clear();
 }
 
-void CoordinatedGraphicsScene::flushLayerChanges(const FloatPoint& scrollPosition)
+void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state)
 {
-    m_renderedContentsScrollPosition = scrollPosition;
+    m_renderedContentsScrollPosition = state.scrollPosition;
 
     // Since the frame has now been rendered, we can safely unlock the animations until the next layout.
     setAnimationsLocked(false);
 
+    if (state.rootCompositingLayer != m_rootLayerID)
+        setRootLayerID(state.rootCompositingLayer);
+
+    if (state.backgroundColor != m_backgroundColor)
+        setBackgroundColor(state.backgroundColor);
+
+    for (size_t i = 0; i < state.imagesToUpdate.size(); ++i)
+        updateImageBacking(state.imagesToUpdate[i].first, state.imagesToUpdate[i].second);
+
+    for (size_t i = 0; i < state.layersToUpdate.size(); ++i)
+        setLayerState(state.layersToUpdate[i].first, state.layersToUpdate[i].second);
+
     m_rootLayer->flushCompositingState(FloatRect());
     commitPendingBackingStoreOperations();
     removeReleasedImageBackingsIfNeeded();
@@ -616,12 +690,16 @@ void CoordinatedGraphicsScene::purgeBackingStores()
         m_client->purgeBackingStores();
 }
 
-void CoordinatedGraphicsScene::setLayerAnimations(CoordinatedLayerID id, const GraphicsLayerAnimations& animations)
+void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(GraphicsLayer* graphicsLayer, const CoordinatedGraphicsLayerState& state)
 {
-    GraphicsLayerTextureMapper* layer = toGraphicsLayerTextureMapper(layerByID(id));
+    if (!state.animationsChanged)
+        return;
+
+    GraphicsLayerTextureMapper* layer = toGraphicsLayerTextureMapper(graphicsLayer);
+
 #if ENABLE(CSS_SHADERS)
-    for (size_t i = 0; i < animations.animations().size(); ++i) {
-        const KeyframeValueList& keyframes = animations.animations().at(i).keyframes();
+    for (size_t i = 0; i < state.animations.animations().size(); ++i) {
+        const KeyframeValueList& keyframes = state.animations.animations().at(i).keyframes();
         if (keyframes.property() != AnimatedPropertyWebkitFilter)
             continue;
         for (size_t j = 0; j < keyframes.size(); ++j) {
@@ -630,7 +708,7 @@ void CoordinatedGraphicsScene::setLayerAnimations(CoordinatedLayerID id, const G
         }
     }
 #endif
-    layer->setAnimations(animations);
+    layer->setAnimations(state.animations);
 }
 
 void CoordinatedGraphicsScene::setAnimationsLocked(bool locked)
index 9c921a7..ed5dbe0 100644 (file)
@@ -21,7 +21,7 @@
 #define CoordinatedGraphicsScene_h
 
 #if USE(COORDINATED_GRAPHICS)
-#include "CoordinatedLayerInfo.h"
+#include "CoordinatedGraphicsState.h"
 #include "CoordinatedSurface.h"
 #include "GraphicsContext.h"
 #include "GraphicsLayer.h"
@@ -46,7 +46,6 @@
 namespace WebCore {
 
 class CoordinatedBackingStore;
-class CoordinatedLayerInfo;
 class CustomFilterProgram;
 class CustomFilterProgramInfo;
 class TextureMapperLayer;
@@ -64,31 +63,11 @@ public:
 
 class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public GraphicsLayerClient {
 public:
-    struct TileUpdate {
-        IntRect sourceRect;
-        IntRect tileRect;
-        uint32_t atlasID;
-        IntPoint offset;
-        TileUpdate(const IntRect& source, const IntRect& tile, uint32_t atlas, const IntPoint& newOffset)
-            : sourceRect(source)
-            , tileRect(tile)
-            , atlasID(atlas)
-            , offset(newOffset)
-        {
-        }
-    };
     explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*);
     virtual ~CoordinatedGraphicsScene();
     void paintToCurrentGLContext(const TransformationMatrix&, float, const FloatRect&, TextureMapper::PaintFlags = 0);
     void paintToGraphicsContext(PlatformGraphicsContext*);
     void setScrollPosition(const FloatPoint&);
-#if USE(GRAPHICS_SURFACE)
-    void createCanvas(CoordinatedLayerID, const IntSize&, PassRefPtr<GraphicsSurface>);
-    void syncCanvas(CoordinatedLayerID, uint32_t frontBuffer);
-    void destroyCanvas(CoordinatedLayerID);
-#endif
-    void setLayerRepaintCount(CoordinatedLayerID, int value);
-
     void detach();
     void appendUpdate(const Function<void()>&);
 
@@ -97,31 +76,23 @@ public:
     void purgeGLResources();
     void setActive(bool);
 
+    void commitSceneState(const CoordinatedGraphicsState&);
+
     void createLayers(const Vector<CoordinatedLayerID>&);
     void deleteLayers(const Vector<CoordinatedLayerID>&);
-    void setRootLayerID(CoordinatedLayerID);
-    void setLayerChildren(CoordinatedLayerID, const Vector<CoordinatedLayerID>&);
-    void setLayerState(CoordinatedLayerID, const CoordinatedLayerInfo&);
-#if ENABLE(CSS_FILTERS)
-    void setLayerFilters(CoordinatedLayerID, const FilterOperations&);
-#endif
+
 #if ENABLE(CSS_SHADERS)
     void injectCachedCustomFilterPrograms(const FilterOperations& filters) const;
     void createCustomFilterProgram(int id, const CustomFilterProgramInfo&);
     void removeCustomFilterProgram(int id);
 #endif
 
-    void createTile(CoordinatedLayerID, uint32_t tileID, float scale);
-    void removeTile(CoordinatedLayerID, uint32_t tileID);
-    void updateTile(CoordinatedLayerID, uint32_t tileID, const TileUpdate&);
     void createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>);
     void removeUpdateAtlas(uint32_t atlasID);
-    void flushLayerChanges(const FloatPoint& scrollPosition);
     void createImageBacking(CoordinatedImageBackingID);
     void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>);
     void clearImageBackingContents(CoordinatedImageBackingID);
     void removeImageBacking(CoordinatedImageBackingID);
-    void setLayerAnimations(CoordinatedLayerID, const GraphicsLayerAnimations&);
     void setAnimationsLocked(bool);
     void setBackgroundColor(const Color&);
     void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
@@ -131,6 +102,23 @@ public:
 #endif
 
 private:
+    void setRootLayerID(CoordinatedLayerID);
+    void setLayerState(CoordinatedLayerID, const CoordinatedGraphicsLayerState&);
+    void setLayerChildrenIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+    void updateTilesIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+    void createTilesIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+    void removeTilesIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+#if ENABLE(CSS_FILTERS)
+    void setLayerFiltersIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+#endif
+    void setLayerAnimationsIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+#if USE(GRAPHICS_SURFACE)
+    void createCanvasIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+    void syncCanvasIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+    void destroyCanvasIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+#endif
+    void setLayerRepaintCountIfNeeded(GraphicsLayer*, const CoordinatedGraphicsLayerState&);
+
     GraphicsLayer* layerByID(CoordinatedLayerID id)
     {
         ASSERT(m_layers.contains(id));
@@ -159,7 +147,7 @@ private:
     void createLayer(CoordinatedLayerID);
     void deleteLayer(CoordinatedLayerID);
 
-    void assignImageBackingToLayer(CoordinatedLayerID, GraphicsLayer*, CoordinatedImageBackingID);
+    void assignImageBackingToLayer(GraphicsLayer*, CoordinatedImageBackingID);
     void removeReleasedImageBackingsIfNeeded();
     void ensureRootLayer();
     void commitPendingBackingStoreOperations();
@@ -185,7 +173,7 @@ private:
     HashSet<RefPtr<CoordinatedBackingStore> > m_backingStoresWithPendingBuffers;
 
 #if USE(GRAPHICS_SURFACE)
-    typedef HashMap<CoordinatedLayerID, RefPtr<TextureMapperSurfaceBackingStore> > SurfaceBackingStoreMap;
+    typedef HashMap<GraphicsLayer*, RefPtr<TextureMapperSurfaceBackingStore> > SurfaceBackingStoreMap;
     SurfaceBackingStoreMap m_surfaceBackingStores;
 #endif
 
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
new file mode 100644 (file)
index 0000000..2686605
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CoordinatedGraphicsState_h
+#define CoordinatedGraphicsState_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "Color.h"
+#include "FloatRect.h"
+#include "FloatSize.h"
+#include "GraphicsLayerAnimation.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "SurfaceUpdateInfo.h"
+#include "TransformationMatrix.h"
+
+#if ENABLE(CSS_FILTERS)
+#include "FilterOperations.h"
+#endif
+
+#if USE(GRAPHICS_SURFACE)
+#include "GraphicsSurfaceToken.h"
+#endif
+
+namespace WebCore {
+
+class CoordinatedSurface;
+
+typedef uint32_t CoordinatedLayerID;
+enum { InvalidCoordinatedLayerID = 0 };
+
+typedef uint64_t CoordinatedImageBackingID;
+enum { InvalidCoordinatedImageBackingID = 0 };
+
+struct TileUpdateInfo {
+    uint32_t tileID;
+    IntRect tileRect;
+    WebCore::SurfaceUpdateInfo updateInfo;
+};
+
+struct TileCreationInfo {
+    uint32_t tileID;
+    float scale;
+};
+
+struct CoordinatedGraphicsLayerState {
+    union {
+        struct {
+            bool positionChanged: 1;
+            bool anchorPointChanged: 1;
+            bool sizeChanged: 1;
+            bool transformChanged: 1;
+            bool childrenTransformChanged: 1;
+            bool contentsRectChanged: 1;
+            bool opacityChanged: 1;
+            bool solidColorChanged: 1;
+            bool debugBorderColorChanged: 1;
+            bool debugBorderWidthChanged: 1;
+            bool replicaChanged: 1;
+            bool maskChanged: 1;
+            bool imageChanged: 1;
+            bool flagsChanged: 1;
+            bool animationsChanged: 1;
+            bool filtersChanged: 1;
+            bool childrenChanged: 1;
+            bool repaintCountChanged : 1;
+            bool canvasChanged: 1;
+            bool canvasShouldSwapBuffers: 1;
+        };
+        unsigned changeMask;
+    };
+    union {
+        struct {
+            bool contentsOpaque : 1;
+            bool drawsContent : 1;
+            bool contentsVisible : 1;
+            bool backfaceVisible : 1;
+            bool masksToBounds : 1;
+            bool preserves3D : 1;
+            bool isRootLayer: 1;
+            bool fixedToViewport : 1;
+            bool showDebugBorders : 1;
+            bool showRepaintCounter : 1;
+        };
+        unsigned flags;
+    };
+
+    CoordinatedGraphicsLayerState()
+        : changeMask(0)
+        , contentsOpaque(false)
+        , drawsContent(false)
+        , contentsVisible(true)
+        , backfaceVisible(true)
+        , masksToBounds(false)
+        , preserves3D(false)
+        , isRootLayer(false)
+        , fixedToViewport(false)
+        , showDebugBorders(false)
+        , showRepaintCounter(false)
+        , opacity(0)
+        , debugBorderWidth(0)
+        , replica(InvalidCoordinatedLayerID)
+        , mask(InvalidCoordinatedLayerID)
+        , imageID(InvalidCoordinatedImageBackingID)
+        , canvasFrontBuffer(0)
+    {
+    }
+
+    FloatPoint pos;
+    FloatPoint3D anchorPoint;
+    FloatSize size;
+    TransformationMatrix transform;
+    TransformationMatrix childrenTransform;
+    IntRect contentsRect;
+    float opacity;
+    Color solidColor;
+    Color debugBorderColor;
+    float debugBorderWidth;
+#if ENABLE(CSS_FILTERS)
+    FilterOperations filters;
+#endif
+    GraphicsLayerAnimations animations;
+    Vector<uint32_t> children;
+    Vector<TileCreationInfo> tilesToCreate;
+    Vector<uint32_t> tilesToRemove;
+    CoordinatedLayerID replica;
+    CoordinatedLayerID mask;
+    CoordinatedImageBackingID imageID;
+
+    unsigned repaintCount;
+    Vector<TileUpdateInfo> tilesToUpdate;
+
+#if USE(GRAPHICS_SURFACE)
+    IntSize canvasSize;
+    GraphicsSurfaceToken canvasToken;
+    uint32_t canvasFrontBuffer;
+#endif
+};
+
+struct CoordinatedGraphicsState {
+    uint32_t rootCompositingLayer;
+    Color backgroundColor;
+    FloatPoint scrollPosition;
+    IntSize contentsSize;
+    IntRect coveredRect;
+
+    Vector<std::pair<CoordinatedLayerID, CoordinatedGraphicsLayerState> > layersToUpdate;
+    Vector<std::pair<CoordinatedImageBackingID, RefPtr<CoordinatedSurface> > > imagesToUpdate;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsState_h
index 5b5b57a..369e239 100644 (file)
@@ -28,7 +28,7 @@
 #define CoordinatedImageBacking_h
 
 #if USE(COORDINATED_GRAPHICS)
-#include "CoordinatedLayerInfo.h"
+#include "CoordinatedGraphicsState.h"
 #include "CoordinatedSurface.h"
 #include "Image.h"
 #include "Timer.h"
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedLayerInfo.h
deleted file mode 100644 (file)
index 0fa2a12..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB.  If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#ifndef CoordinatedLayerInfo_h
-#define CoordinatedLayerInfo_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "Color.h"
-#include "FloatRect.h"
-#include "FloatSize.h"
-#include "IntRect.h"
-#include "TransformationMatrix.h"
-
-namespace WebCore {
-
-typedef uint32_t CoordinatedLayerID;
-enum { InvalidCoordinatedLayerID = 0 };
-
-typedef uint64_t CoordinatedImageBackingID;
-enum { InvalidCoordinatedImageBackingID = 0 };
-
-// NOTE: CoordinatedLayerInfo should only use POD types, as to make serialization faster.
-struct CoordinatedLayerInfo {
-    CoordinatedLayerInfo()
-        : replica(InvalidCoordinatedLayerID)
-        , mask(InvalidCoordinatedLayerID)
-        , imageID(InvalidCoordinatedImageBackingID)
-        , opacity(0)
-        , debugBorderWidth(0)
-        , flags(0) { }
-
-    CoordinatedLayerID replica;
-    CoordinatedLayerID mask;
-    CoordinatedImageBackingID imageID;
-
-    FloatPoint pos;
-    FloatPoint3D anchorPoint;
-    FloatSize size;
-    TransformationMatrix transform;
-    TransformationMatrix childrenTransform;
-    IntRect contentsRect;
-    float opacity;
-    Color solidColor;
-    Color debugBorderColor;
-    float debugBorderWidth;
-
-    union {
-        struct {
-            bool contentsOpaque : 1;
-            bool drawsContent : 1;
-            bool contentsVisible : 1;
-            bool backfaceVisible : 1;
-            bool masksToBounds : 1;
-            bool preserves3D : 1;
-            bool isRootLayer: 1;
-            bool fixedToViewport : 1;
-            bool showDebugBorders : 1;
-            bool showRepaintCounter : 1;
-        };
-        unsigned flags;
-    };
-};
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
-
-#endif // CoordinatedLayerInfo_h
index 6ab384a..5af069a 100644 (file)
 #if USE(COORDINATED_GRAPHICS)
 
 #include "IntRect.h"
-#include <wtf/Noncopyable.h>
 
 namespace WebCore {
 
 class SurfaceUpdateInfo {
-    WTF_MAKE_NONCOPYABLE(SurfaceUpdateInfo);
 
 public:
     SurfaceUpdateInfo() { }
index 5d73052..8b3eba5 100644 (file)
@@ -1,3 +1,49 @@
+2013-03-05  Gwang Yoon Hwang  <ryumiel@company100.net>
+
+        Coordinated Graphics: CoordinatedGraphicsLayer makes CoordinatedGraphicsScene perform via CoordinatedGraphicsState.
+        https://bugs.webkit.org/show_bug.cgi?id=108294
+
+        Reviewed by Anders Carlsson.
+
+        There are two changes in WK2.
+        1. Change CoordinatedLayerTreeHostProxy to use CoordinatedGraphicsState.
+        2. Add encode/decode of CoordinatedGraphicsState in CoordinatedGraphicsArgumentCoders.
+
+        This patch is based on Dongsung Huang, and Noam's work in
+        https://bugs.webkit.org/show_bug.cgi?id=108294
+
+        No new tests, covered by existing tests.
+
+        * Scripts/webkit2/messages.py:
+        (headers_for_type):
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (CoreIPC::::encode):
+            Encoding UpdateImageBacking and CreateUpdateAtlas can fail when
+            encoding WebCoordinatedSurface::Handle fails, but we don't
+            recover in the case.
+        (CoreIPC::::decode):
+        (CoreIPC):
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.h:
+        (WebCore):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
+        (WebKit::CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState):
+        (WebKit):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
+        (WebCore):
+        (CoordinatedLayerTreeHostProxy):
+        (WebKit::CoordinatedLayerTreeHostProxy::coordinatedGraphicsScene):
+        * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in:
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
+        (WebKit::CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded):
+        (WebKit::CoordinatedLayerTreeHost::syncLayerState):
+        (WebKit::CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded):
+        (WebKit):
+        (WebKit::CoordinatedLayerTreeHost::updateImageBacking):
+        (WebKit::CoordinatedLayerTreeHost::setBackgroundColor):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        (CoordinatedLayerTreeHost):
+
 2013-03-05  Sam Weinig  <sam@webkit.org>
 
         Follow up to https://bugs.webkit.org/show_bug.cgi?id=111453, forgot to mark the files as Private.
index b690a01..86804b1 100644 (file)
@@ -398,7 +398,6 @@ def headers_for_type(type):
     special_cases = {
         'WTF::String': ['<wtf/text/WTFString.h>'],
         'WebCore::CompositionUnderline': ['<WebCore/Editor.h>'],
-        'WebCore::CoordinatedLayerID': ['<WebCore/CoordinatedLayerInfo.h>'],
         'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'],
         'WebCore::GraphicsLayerAnimations': ['<WebCore/GraphicsLayerAnimation.h>'],
         'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'],
index 5a06d11..80c7259 100644 (file)
 #include "CoordinatedGraphicsArgumentCoders.h"
 
 #if USE(COORDINATED_GRAPHICS)
+#include "WebCoordinatedSurface.h"
 #include "WebCoreArgumentCoders.h"
 #include <WebCore/Animation.h>
 #include <WebCore/Color.h>
-#include <WebCore/CoordinatedLayerInfo.h>
+#include <WebCore/CoordinatedGraphicsState.h>
 #include <WebCore/FloatPoint3D.h>
 #include <WebCore/GraphicsLayerAnimation.h>
 #include <WebCore/IdentityTransformOperation.h>
@@ -73,9 +74,7 @@
 #endif
 
 using namespace WebCore;
-#if ENABLE(CSS_SHADERS)
 using namespace WebKit;
-#endif
 
 namespace CoreIPC {
 
@@ -815,24 +814,261 @@ bool ArgumentCoder<WebCore::GraphicsSurfaceToken>::decode(ArgumentDecoder& decod
 }
 #endif
 
-void ArgumentCoder<CoordinatedLayerInfo>::encode(ArgumentEncoder& encoder, const CoordinatedLayerInfo& coordinatedLayerInfo)
+void ArgumentCoder<SurfaceUpdateInfo>::encode(ArgumentEncoder& encoder, const SurfaceUpdateInfo& surfaceUpdateInfo)
 {
-    SimpleArgumentCoder<CoordinatedLayerInfo>::encode(encoder, coordinatedLayerInfo);
+    SimpleArgumentCoder<SurfaceUpdateInfo>::encode(encoder, surfaceUpdateInfo);
 }
 
-bool ArgumentCoder<CoordinatedLayerInfo>::decode(ArgumentDecoder& decoder, CoordinatedLayerInfo& coordinatedLayerInfo)
+bool ArgumentCoder<SurfaceUpdateInfo>::decode(ArgumentDecoder& decoder, SurfaceUpdateInfo& surfaceUpdateInfo)
 {
-    return SimpleArgumentCoder<CoordinatedLayerInfo>::decode(decoder, coordinatedLayerInfo);
+    return SimpleArgumentCoder<SurfaceUpdateInfo>::decode(decoder, surfaceUpdateInfo);
 }
 
-void ArgumentCoder<SurfaceUpdateInfo>::encode(ArgumentEncoder& encoder, const SurfaceUpdateInfo& surfaceUpdateInfo)
+void ArgumentCoder<CoordinatedGraphicsLayerState>::encode(ArgumentEncoder& encoder, const CoordinatedGraphicsLayerState& state)
 {
-    SimpleArgumentCoder<SurfaceUpdateInfo>::encode(encoder, surfaceUpdateInfo);
+    encoder << state.changeMask;
+
+    if (state.flagsChanged)
+        encoder << state.flags;
+
+    if (state.positionChanged)
+        encoder << state.pos;
+
+    if (state.anchorPointChanged)
+        encoder << state.anchorPoint;
+
+    if (state.sizeChanged)
+        encoder << state.size;
+
+    if (state.transformChanged)
+        encoder << state.transform;
+
+    if (state.childrenTransformChanged)
+        encoder << state.childrenTransform;
+
+    if (state.contentsRectChanged)
+        encoder << state.contentsRect;
+
+    if (state.opacityChanged)
+        encoder << state.opacity;
+
+    if (state.solidColorChanged)
+        encoder << state.solidColor;
+
+    if (state.debugBorderColorChanged)
+        encoder << state.debugBorderColor;
+
+    if (state.debugBorderWidthChanged)
+        encoder << state.debugBorderWidth;
+
+#if ENABLE(CSS_FILTERS)
+    if (state.filtersChanged)
+        encoder << state.filters;
+#endif
+
+    if (state.animationsChanged)
+        encoder << state.animations;
+
+    if (state.childrenChanged)
+        encoder << state.children;
+
+    encoder << state.tilesToCreate;
+    encoder << state.tilesToRemove;
+
+    if (state.replicaChanged)
+        encoder << state.replica;
+
+    if (state.maskChanged)
+        encoder << state.mask;
+
+    if (state.imageChanged)
+        encoder << state.imageID;
+
+    if (state.repaintCountChanged)
+        encoder << state.repaintCount;
+
+    encoder << state.tilesToUpdate;
+
+#if USE(GRAPHICS_SURFACE)
+    if (state.canvasChanged) {
+        encoder << state.canvasSize;
+        encoder << state.canvasToken;
+        encoder << state.canvasFrontBuffer;
+    }
+#endif
 }
 
-bool ArgumentCoder<SurfaceUpdateInfo>::decode(ArgumentDecoder& decoder, SurfaceUpdateInfo& surfaceUpdateInfo)
+bool ArgumentCoder<CoordinatedGraphicsLayerState>::decode(ArgumentDecoder& decoder, CoordinatedGraphicsLayerState& state)
 {
-    return SimpleArgumentCoder<SurfaceUpdateInfo>::decode(decoder, surfaceUpdateInfo);
+    if (!decoder.decode(state.changeMask))
+        return false;
+
+    if (state.flagsChanged && !decoder.decode(state.flags))
+        return false;
+
+    if (state.positionChanged && !decoder.decode(state.pos))
+        return false;
+
+    if (state.anchorPointChanged && !decoder.decode(state.anchorPoint))
+        return false;
+
+    if (state.sizeChanged && !decoder.decode(state.size))
+        return false;
+
+    if (state.transformChanged && !decoder.decode(state.transform))
+        return false;
+
+    if (state.childrenTransformChanged && !decoder.decode(state.childrenTransform))
+        return false;
+
+    if (state.contentsRectChanged && !decoder.decode(state.contentsRect))
+        return false;
+
+    if (state.opacityChanged && !decoder.decode(state.opacity))
+        return false;
+
+    if (state.solidColorChanged && !decoder.decode(state.solidColor))
+        return false;
+
+    if (state.debugBorderColorChanged && !decoder.decode(state.debugBorderColor))
+        return false;
+
+    if (state.debugBorderWidthChanged && !decoder.decode(state.debugBorderWidth))
+        return false;
+
+#if ENABLE(CSS_FILTERS)
+    if (state.filtersChanged && !decoder.decode(state.filters))
+        return false;
+#endif
+
+    if (state.animationsChanged && !decoder.decode(state.animations))
+        return false;
+
+    if (state.childrenChanged && !decoder.decode(state.children))
+        return false;
+
+    if (!decoder.decode(state.tilesToCreate))
+        return false;
+
+    if (!decoder.decode(state.tilesToRemove))
+        return false;
+
+    if (state.replicaChanged && !decoder.decode(state.replica))
+        return false;
+
+    if (state.maskChanged && !decoder.decode(state.mask))
+        return false;
+
+    if (state.imageChanged && !decoder.decode(state.imageID))
+        return false;
+
+    if (state.repaintCountChanged && !decoder.decode(state.repaintCount))
+        return false;
+
+    if (!decoder.decode(state.tilesToUpdate))
+        return false;
+
+#if USE(GRAPHICS_SURFACE)
+    if (state.canvasChanged) {
+        if (!decoder.decode(state.canvasSize))
+            return false;
+
+        if (!decoder.decode(state.canvasToken))
+            return false;
+
+        if (!decoder.decode(state.canvasFrontBuffer))
+            return false;
+    }
+#endif
+
+    return true;
+}
+
+void ArgumentCoder<TileUpdateInfo>::encode(ArgumentEncoder& encoder, const TileUpdateInfo& updateInfo)
+{
+    SimpleArgumentCoder<TileUpdateInfo>::encode(encoder, updateInfo);
+}
+
+bool ArgumentCoder<TileUpdateInfo>::decode(ArgumentDecoder& decoder, TileUpdateInfo& updateInfo)
+{
+    return SimpleArgumentCoder<TileUpdateInfo>::decode(decoder, updateInfo);
+}
+
+void ArgumentCoder<TileCreationInfo>::encode(ArgumentEncoder& encoder, const TileCreationInfo& updateInfo)
+{
+    SimpleArgumentCoder<TileCreationInfo>::encode(encoder, updateInfo);
+}
+
+bool ArgumentCoder<TileCreationInfo>::decode(ArgumentDecoder& decoder, TileCreationInfo& updateInfo)
+{
+    return SimpleArgumentCoder<TileCreationInfo>::decode(decoder, updateInfo);
+}
+
+void ArgumentCoder<CoordinatedGraphicsState>::encode(ArgumentEncoder& encoder, const CoordinatedGraphicsState& state)
+{
+    encoder << state.rootCompositingLayer;
+    encoder << state.backgroundColor;
+    encoder << state.scrollPosition;
+    encoder << state.contentsSize;
+    encoder << state.coveredRect;
+    encoder << state.layersToUpdate;
+
+    // We need to encode WebCoordinatedSurface::Handle right after it's creation.
+    // That's why we cannot use simple std::pair encoder.
+    encoder << state.imagesToUpdate.size();
+
+    typedef Vector<std::pair<CoordinatedImageBackingID, RefPtr<CoordinatedSurface> > > SurfaceUpdatePairVector;
+    SurfaceUpdatePairVector::const_iterator end = state.imagesToUpdate.end();
+    for (SurfaceUpdatePairVector::const_iterator it = state.imagesToUpdate.begin(); it != end; ++it) {
+
+        WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(it->second.get());
+        WebCoordinatedSurface::Handle handle;
+        if (!webCoordinatedSurface->createHandle(handle))
+            return;
+
+        encoder << it->first;
+        encoder << handle;
+    }
+}
+
+bool ArgumentCoder<CoordinatedGraphicsState>::decode(ArgumentDecoder& decoder, CoordinatedGraphicsState& state)
+{
+    if (!decoder.decode(state.rootCompositingLayer))
+        return false;
+
+    if (!decoder.decode(state.backgroundColor))
+        return false;
+
+    if (!decoder.decode(state.scrollPosition))
+        return false;
+
+    if (!decoder.decode(state.contentsSize))
+        return false;
+
+    if (!decoder.decode(state.coveredRect))
+        return false;
+
+    if (!decoder.decode(state.layersToUpdate))
+        return false;
+
+    size_t sizeOfImagesToUpdate;
+    if (!decoder.decode(sizeOfImagesToUpdate))
+        return false;
+
+    for (size_t i = 0; i < sizeOfImagesToUpdate; i++) {
+        CoordinatedImageBackingID imageID;
+        if (!decoder.decode(imageID))
+            return false;
+
+        WebCoordinatedSurface::Handle handle;
+        if (!decoder.decode(handle))
+            return false;
+
+        RefPtr<CoordinatedSurface> surface = WebCoordinatedSurface::create(handle);
+        state.imagesToUpdate.append(std::make_pair(imageID, surface.release()));
+    }
+
+    return true;
 }
 
 } // namespace CoreIPC
index 8e7deef..d42ae79 100644 (file)
 #include "ArgumentCoders.h"
 
 namespace WebCore {
+struct CoordinatedGraphicsLayerState;
+struct CoordinatedGraphicsState;
 class FloatPoint3D;
 class GraphicsLayerAnimation;
 class GraphicsLayerAnimations;
 class SurfaceUpdateInfo;
+struct TileCreationInfo;
+struct TileUpdateInfo;
 class TransformationMatrix;
 class TransformOperations;
-struct CoordinatedLayerInfo;
 struct Length;
 
 #if ENABLE(CSS_FILTERS)
@@ -107,16 +110,31 @@ template<> struct ArgumentCoder<WebCore::GraphicsSurfaceToken> {
 };
 #endif
 
-template<> struct ArgumentCoder<WebCore::CoordinatedLayerInfo> {
-    static void encode(ArgumentEncoder&, const WebCore::CoordinatedLayerInfo&);
-    static bool decode(ArgumentDecoder&, WebCore::CoordinatedLayerInfo&);
-};
-
 template<> struct ArgumentCoder<WebCore::SurfaceUpdateInfo> {
     static void encode(ArgumentEncoder&, const WebCore::SurfaceUpdateInfo&);
     static bool decode(ArgumentDecoder&, WebCore::SurfaceUpdateInfo&);
 };
 
+template<> struct ArgumentCoder<WebCore::CoordinatedGraphicsLayerState> {
+    static void encode(ArgumentEncoder&, const WebCore::CoordinatedGraphicsLayerState&);
+    static bool decode(ArgumentDecoder&, WebCore::CoordinatedGraphicsLayerState&);
+};
+
+template<> struct ArgumentCoder<WebCore::TileUpdateInfo> {
+    static void encode(ArgumentEncoder&, const WebCore::TileUpdateInfo&);
+    static bool decode(ArgumentDecoder&, WebCore::TileUpdateInfo&);
+};
+
+template<> struct ArgumentCoder<WebCore::TileCreationInfo> {
+    static void encode(ArgumentEncoder&, const WebCore::TileCreationInfo&);
+    static bool decode(ArgumentDecoder&, WebCore::TileCreationInfo&);
+};
+
+template<> struct ArgumentCoder<WebCore::CoordinatedGraphicsState> {
+    static void encode(ArgumentEncoder&, const WebCore::CoordinatedGraphicsState&);
+    static bool decode(ArgumentDecoder&, WebCore::CoordinatedGraphicsState&);
+};
+
 } // namespace CoreIPC
 
 #endif // USE(COORDINATED_GRAPHICS)
index c5f7e87..018bd17 100644 (file)
@@ -27,7 +27,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebPageProxy.h"
 #include "WebProcessProxy.h"
-#include <WebCore/CoordinatedLayerInfo.h>
+#include <WebCore/CoordinatedGraphicsState.h>
 #include <WebCore/GraphicsSurface.h>
 #include <WebCore/SurfaceUpdateInfo.h>
 
@@ -62,22 +62,6 @@ void CoordinatedLayerTreeHostProxy::dispatchUpdate(const Function<void()>& funct
     m_scene->appendUpdate(function);
 }
 
-void CoordinatedLayerTreeHostProxy::createTileForLayer(CoordinatedLayerID layerID, uint32_t tileID, const IntRect& tileRect, const SurfaceUpdateInfo& updateInfo)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::createTile, m_scene.get(), layerID, tileID, updateInfo.scaleFactor));
-    updateTileForLayer(layerID, tileID, tileRect, updateInfo);
-}
-
-void CoordinatedLayerTreeHostProxy::updateTileForLayer(CoordinatedLayerID layerID, uint32_t tileID, const IntRect& tileRect, const SurfaceUpdateInfo& updateInfo)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::updateTile, m_scene.get(), layerID, tileID, CoordinatedGraphicsScene::TileUpdate(updateInfo.updateRect, tileRect, updateInfo.atlasID, updateInfo.surfaceOffset)));
-}
-
-void CoordinatedLayerTreeHostProxy::removeTileForLayer(CoordinatedLayerID layerID, uint32_t tileID)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::removeTile, m_scene.get(), layerID, tileID));
-}
-
 void CoordinatedLayerTreeHostProxy::createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle& handle)
 {
     dispatchUpdate(bind(&CoordinatedGraphicsScene::createUpdateAtlas, m_scene.get(), atlasID, WebCoordinatedSurface::create(handle)));
@@ -98,28 +82,6 @@ void CoordinatedLayerTreeHostProxy::deleteCompositingLayers(const Vector<Coordin
     dispatchUpdate(bind(&CoordinatedGraphicsScene::deleteLayers, m_scene.get(), ids));
 }
 
-void CoordinatedLayerTreeHostProxy::setRootCompositingLayer(CoordinatedLayerID id)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setRootLayerID, m_scene.get(), id));
-}
-
-void CoordinatedLayerTreeHostProxy::setCompositingLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setLayerState, m_scene.get(), id, info));
-}
-
-void CoordinatedLayerTreeHostProxy::setCompositingLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setLayerChildren, m_scene.get(), id, children));
-}
-
-#if ENABLE(CSS_FILTERS)
-void CoordinatedLayerTreeHostProxy::setCompositingLayerFilters(CoordinatedLayerID id, const FilterOperations& filters)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setLayerFilters, m_scene.get(), id, filters));
-}
-#endif
-
 #if ENABLE(CSS_SHADERS)
 void CoordinatedLayerTreeHostProxy::removeCustomFilterProgram(int id)
 {
@@ -131,15 +93,12 @@ void CoordinatedLayerTreeHostProxy::createCustomFilterProgram(int id, const Cust
 }
 #endif
 
-void CoordinatedLayerTreeHostProxy::didRenderFrame(const FloatPoint& scrollPosition, const IntSize& contentsSize, const IntRect& coveredRect)
+void CoordinatedLayerTreeHostProxy::commitCoordinatedGraphicsState(const CoordinatedGraphicsState& graphicsState)
 {
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::flushLayerChanges, m_scene.get(), scrollPosition));
+    dispatchUpdate(bind(&CoordinatedGraphicsScene::commitSceneState, m_scene.get(), graphicsState));
     updateViewport();
 #if USE(TILED_BACKING_STORE)
-    m_drawingAreaProxy->page()->didRenderFrame(contentsSize, coveredRect);
-#else
-    UNUSED_PARAM(contentsSize);
-    UNUSED_PARAM(coveredRect);
+    m_drawingAreaProxy->page()->didRenderFrame(graphicsState.contentsSize, graphicsState.coveredRect);
 #endif
 }
 
@@ -163,11 +122,6 @@ void CoordinatedLayerTreeHostProxy::removeImageBacking(CoordinatedImageBackingID
     dispatchUpdate(bind(&CoordinatedGraphicsScene::removeImageBacking, m_scene.get(), imageID));
 }
 
-void CoordinatedLayerTreeHostProxy::setLayerAnimations(CoordinatedLayerID id, const GraphicsLayerAnimations& animations)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setLayerAnimations, m_scene.get(), id, animations));
-}
-
 void CoordinatedLayerTreeHostProxy::setAnimationsLocked(bool locked)
 {
     dispatchUpdate(bind(&CoordinatedGraphicsScene::setAnimationsLocked, m_scene.get(), locked));
@@ -204,29 +158,6 @@ void CoordinatedLayerTreeHostProxy::animationFrameReady()
 }
 #endif
 
-#if USE(GRAPHICS_SURFACE)
-void CoordinatedLayerTreeHostProxy::createCanvas(CoordinatedLayerID id, const IntSize& canvasSize, const GraphicsSurfaceToken& token)
-{
-    GraphicsSurface::Flags surfaceFlags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::createCanvas, m_scene.get(), id, canvasSize, GraphicsSurface::create(canvasSize, surfaceFlags, token)));
-}
-
-void CoordinatedLayerTreeHostProxy::syncCanvas(CoordinatedLayerID id, uint32_t frontBuffer)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::syncCanvas, m_scene.get(), id, frontBuffer));
-}
-
-void CoordinatedLayerTreeHostProxy::destroyCanvas(CoordinatedLayerID id)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::destroyCanvas, m_scene.get(), id));
-}
-#endif
-
-void CoordinatedLayerTreeHostProxy::setLayerRepaintCount(CoordinatedLayerID id, int value)
-{
-    dispatchUpdate(bind(&CoordinatedGraphicsScene::setLayerRepaintCount, m_scene.get(), id, value));
-}
-
 void CoordinatedLayerTreeHostProxy::purgeBackingStores()
 {
     m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
index 946b399..d168bcd 100644 (file)
@@ -41,7 +41,8 @@
 #include <wtf/Vector.h>
 
 namespace WebCore {
-class CoordinatedLayerInfo;
+class CoordinatedGraphicsLayerState;
+class CoordinatedGraphicsState;
 class SurfaceUpdateInfo;
 }
 
@@ -53,43 +54,31 @@ class CoordinatedLayerTreeHostProxy : public WebCore::CoordinatedGraphicsSceneCl
 public:
     explicit CoordinatedLayerTreeHostProxy(DrawingAreaProxy*);
     virtual ~CoordinatedLayerTreeHostProxy();
-    void setCompositingLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedLayerInfo&);
-    void setCompositingLayerChildren(WebCore::CoordinatedLayerID, const Vector<WebCore::CoordinatedLayerID>&);
-#if ENABLE(CSS_FILTERS)
-    void setCompositingLayerFilters(WebCore::CoordinatedLayerID, const WebCore::FilterOperations&);
-#endif
+
+    // Messages From CoordinatedLayerTreeHost
+    void createCompositingLayers(const Vector<WebCore::CoordinatedLayerID>&);
+    void deleteCompositingLayers(const Vector<WebCore::CoordinatedLayerID>&);
 #if ENABLE(CSS_SHADERS)
     void createCustomFilterProgram(int id, const WebCore::CustomFilterProgramInfo&);
     void removeCustomFilterProgram(int id);
 #endif
-    void createCompositingLayers(const Vector<WebCore::CoordinatedLayerID>&);
-    void deleteCompositingLayers(const Vector<WebCore::CoordinatedLayerID>&);
-    void setRootCompositingLayer(WebCore::CoordinatedLayerID);
-    void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint& trajectoryVector);
-    void didRenderFrame(const WebCore::FloatPoint& scrollPosition, const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect);
-    void createTileForLayer(WebCore::CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const WebCore::SurfaceUpdateInfo&);
-    void updateTileForLayer(WebCore::CoordinatedLayerID, uint32_t tileID, const WebCore::IntRect&, const WebCore::SurfaceUpdateInfo&);
-    void removeTileForLayer(WebCore::CoordinatedLayerID, uint32_t tileID);
     void createUpdateAtlas(uint32_t atlasID, const WebCoordinatedSurface::Handle&);
     void removeUpdateAtlas(uint32_t atlasID);
     void createImageBacking(WebCore::CoordinatedImageBackingID);
     void updateImageBacking(WebCore::CoordinatedImageBackingID, const WebCoordinatedSurface::Handle&);
     void clearImageBackingContents(WebCore::CoordinatedImageBackingID);
     void removeImageBacking(WebCore::CoordinatedImageBackingID);
-#if USE(GRAPHICS_SURFACE)
-    void createCanvas(WebCore::CoordinatedLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&);
-    void syncCanvas(WebCore::CoordinatedLayerID, uint32_t frontBuffer);
-    void destroyCanvas(WebCore::CoordinatedLayerID);
-#endif
-    void setLayerRepaintCount(WebCore::CoordinatedLayerID, int value);
-    WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene() const { return m_scene.get(); }
-    void setLayerAnimations(WebCore::CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&);
+
+    void commitCoordinatedGraphicsState(const WebCore::CoordinatedGraphicsState&);
     void setAnimationsLocked(bool);
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     void requestAnimationFrame();
 #endif
     void setBackgroundColor(const WebCore::Color&);
 
+    void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint& trajectoryVector);
+    WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene() const { return m_scene.get(); }
+
     // CoordinatedGraphicsSceneClient Methods.
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     virtual void animationFrameReady() OVERRIDE;
index 5ce1283..3a764f1 100644 (file)
 
 #if USE(COORDINATED_GRAPHICS)
 messages -> CoordinatedLayerTreeHostProxy {
-    SetCompositingLayerState(uint32_t id, WebCore::CoordinatedLayerInfo layerInfo)
-    SetCompositingLayerChildren(uint32_t id, Vector<uint32_t> children)
-#if ENABLE(CSS_FILTERS)
-    SetCompositingLayerFilters(uint32_t id, WebCore::FilterOperations filters)
-#endif
+
+    CommitCoordinatedGraphicsState(WebCore::CoordinatedGraphicsState state)
+
+    CreateCompositingLayers(Vector<uint32_t> ids)
+    DeleteCompositingLayers(Vector<uint32_t> ids)
+
 #if ENABLE(CSS_SHADERS)
     CreateCustomFilterProgram(int id, WebCore::CustomFilterProgramInfo programInfo)
     RemoveCustomFilterProgram(int id)
 #endif
-    SetRootCompositingLayer(uint32_t id)
-    CreateCompositingLayers(Vector<uint32_t> ids)
-    DeleteCompositingLayers(Vector<uint32_t> ids)
-    CreateTileForLayer(uint32_t layerID, uint32_t tileID, WebCore::IntRect tileRect, WebCore::SurfaceUpdateInfo updateInfo)
-    UpdateTileForLayer(uint32_t layerID, uint32_t tileID, WebCore::IntRect tileRect, WebCore::SurfaceUpdateInfo updateInfo)
-    RemoveTileForLayer(uint32_t layerID, uint32_t tileID)
     CreateUpdateAtlas(uint32_t atlasID, WebKit::WebCoordinatedSurface::Handle handle)
     RemoveUpdateAtlas(uint32_t atlasID)
     CreateImageBacking(uint64_t imageID)
     UpdateImageBacking(uint64_t imageID, WebKit::WebCoordinatedSurface::Handle handle)
     ClearImageBackingContents(uint64_t imageID)
     RemoveImageBacking(uint64_t imageID)
-    DidRenderFrame(WebCore::FloatPoint scrollPosition, WebCore::IntSize contentsSize, WebCore::IntRect coveredRect)
-    SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations)
+
     SetAnimationsLocked(bool locked)
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     RequestAnimationFrame()
 #endif
 
-#if USE(GRAPHICS_SURFACE)
-    CreateCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token)
-    SyncCanvas(uint32_t id, uint32_t frontBuffer)
-    DestroyCanvas(uint32_t id)
-#endif
-
-    SetLayerRepaintCount(uint32_t layerID, int value)
-
     SetBackgroundColor(WebCore::Color color)
 }
 #endif
index 7acef30..45fd395 100644 (file)
@@ -301,9 +301,15 @@ bool CoordinatedLayerTreeHost::flushPendingLayerChanges()
     if (m_shouldSyncFrame) {
         didSync = true;
 
-        IntSize contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
-        IntRect coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
-        m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::DidRenderFrame(m_visibleContentsRect.location(), contentsSize, coveredRect));
+        m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
+        m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
+        m_state.scrollPosition = m_visibleContentsRect.location();
+
+        m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state));
+
+        m_state.layersToUpdate.clear();
+        m_state.imagesToUpdate.clear();
+
         m_waitingForUIProcess = true;
         m_shouldSyncFrame = false;
     } else
@@ -356,66 +362,42 @@ void CoordinatedLayerTreeHost::initializeRootCompositingLayerIfNeeded()
     if (m_didInitializeRootCompositingLayer)
         return;
 
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetRootCompositingLayer(toCoordinatedGraphicsLayer(m_rootLayer.get())->id()));
+    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
     m_didInitializeRootCompositingLayer = true;
     m_shouldSyncFrame = true;
 }
 
-void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, const CoordinatedLayerInfo& info)
-{
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetCompositingLayerState(id, info));
-}
-
-void CoordinatedLayerTreeHost::syncLayerChildren(CoordinatedLayerID id, const Vector<CoordinatedLayerID>& children)
-{
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetCompositingLayerChildren(id, children));
-}
-
-#if USE(GRAPHICS_SURFACE)
-void CoordinatedLayerTreeHost::createCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer)
-{
-    m_shouldSyncFrame = true;
-    GraphicsSurfaceToken token = canvasPlatformLayer->graphicsSurfaceToken();
-    IntSize canvasSize = canvasPlatformLayer->platformLayerSize();
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CreateCanvas(id, canvasSize, token));
-}
-
-void CoordinatedLayerTreeHost::syncCanvas(CoordinatedLayerID id, PlatformLayer* canvasPlatformLayer)
+void CoordinatedLayerTreeHost::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state)
 {
     m_shouldSyncFrame = true;
-    uint32_t frontBuffer = canvasPlatformLayer->copyToGraphicsSurface();
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SyncCanvas(id, frontBuffer));
-}
-
-void CoordinatedLayerTreeHost::destroyCanvas(CoordinatedLayerID id)
-{
-    if (m_isPurging)
-        return;
 
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::DestroyCanvas(id));
-}
+#if ENABLE(CSS_SHADERS)
+    prepareCustomFilterProxiesIfNeeded(state);
 #endif
 
-void CoordinatedLayerTreeHost::setLayerRepaintCount(CoordinatedLayerID id, int value)
-{
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetLayerRepaintCount(id, value));
+    m_state.layersToUpdate.append(std::make_pair(id, state));
 }
 
-#if ENABLE(CSS_FILTERS)
-void CoordinatedLayerTreeHost::syncLayerFilters(CoordinatedLayerID id, const FilterOperations& filters)
-{
-    m_shouldSyncFrame = true;
 #if ENABLE(CSS_SHADERS)
-    checkCustomFilterProgramProxies(filters);
-#endif
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetCompositingLayerFilters(id, filters));
+void CoordinatedLayerTreeHost::prepareCustomFilterProxiesIfNeeded(CoordinatedGraphicsLayerState& state)
+{
+    if (state.animationsChanged) {
+        GraphicsLayerAnimations& activeAnimations = state.animations;
+        for (size_t i = 0; i < activeAnimations.animations().size(); ++i) {
+            const KeyframeValueList& keyframes = activeAnimations.animations().at(i).keyframes();
+            if (keyframes.property() != AnimatedPropertyWebkitFilter)
+                continue;
+            for (size_t j = 0; j < keyframes.size(); ++j) {
+                const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));
+                checkCustomFilterProgramProxies(*filterValue->value());
+            }
+        }
+    }
+
+    if (state.filtersChanged)
+        checkCustomFilterProgramProxies(state.filters);
 }
-#endif
 
-#if ENABLE(CSS_SHADERS)
 void CoordinatedLayerTreeHost::checkCustomFilterProgramProxies(const FilterOperations& filters)
 {
     // We need to create the WebCustomFilterProgramProxy objects before we get to serialize the
@@ -466,7 +448,7 @@ void CoordinatedLayerTreeHost::disconnectCustomFilterPrograms()
     for (; iter != m_customFilterPrograms.end(); ++iter)
         (*iter)->setClient(0);
 }
-#endif
+#endif // ENABLE(CSS_SHADERS)
 
 void CoordinatedLayerTreeHost::detachLayer(CoordinatedGraphicsLayer* layer)
 {
@@ -585,7 +567,8 @@ bool CoordinatedLayerTreeHost::updateImageBacking(CoordinatedImageBackingID imag
     WebCoordinatedSurface::Handle handle;
     if (!webCoordinatedSurface->createHandle(handle))
         return false;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::UpdateImageBacking(imageID, handle));
+
+    m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
     return true;
 }
 
@@ -668,26 +651,6 @@ bool LayerTreeHost::supportsAcceleratedCompositing()
     return true;
 }
 
-void CoordinatedLayerTreeHost::createTile(CoordinatedLayerID layerID, uint32_t tileID, const WebCore::SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect)
-{
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CreateTileForLayer(layerID, tileID, tileRect, updateInfo));
-}
-
-void CoordinatedLayerTreeHost::updateTile(CoordinatedLayerID layerID, uint32_t tileID, const WebCore::SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect)
-{
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, tileRect, updateInfo));
-}
-
-void CoordinatedLayerTreeHost::removeTile(CoordinatedLayerID layerID, uint32_t tileID)
-{
-    if (m_isPurging)
-        return;
-    m_shouldSyncFrame = true;
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::RemoveTileForLayer(layerID, tileID));
-}
-
 bool CoordinatedLayerTreeHost::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
 {
     WebCoordinatedSurface* webCoordinatedSurface = static_cast<WebCoordinatedSurface*>(coordinatedSurface.get());
@@ -710,25 +673,6 @@ WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const
     return m_visibleContentsRect;
 }
 
-
-void CoordinatedLayerTreeHost::setLayerAnimations(CoordinatedLayerID layerID, const GraphicsLayerAnimations& animations)
-{
-    m_shouldSyncFrame = true;
-    GraphicsLayerAnimations activeAnimations = animations.getActiveAnimations();
-#if ENABLE(CSS_SHADERS)
-    for (size_t i = 0; i < activeAnimations.animations().size(); ++i) {
-        const KeyframeValueList& keyframes = animations.animations().at(i).keyframes();
-        if (keyframes.property() != AnimatedPropertyWebkitFilter)
-            continue;
-        for (size_t j = 0; j < keyframes.size(); ++j) {
-            const FilterAnimationValue* filterValue = static_cast<const FilterAnimationValue*>(keyframes.at(i));
-            checkCustomFilterProgramProxies(*filterValue->value());
-        }
-    }
-#endif
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetLayerAnimations(layerID, activeAnimations));
-}
-
 void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
 {
     // A zero trajectoryVector indicates that tiles all around the viewport are requested.
@@ -851,7 +795,8 @@ void CoordinatedLayerTreeHost::releaseInactiveAtlasesTimerFired(Timer<Coordinate
 
 void CoordinatedLayerTreeHost::setBackgroundColor(const WebCore::Color& color)
 {
-    m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::SetBackgroundColor(color));
+    m_shouldSyncFrame = true;
+    m_state.backgroundColor = color;
 }
 
 } // namespace WebKit
index b605289..6536ad7 100644 (file)
@@ -26,6 +26,7 @@
 #include "LayerTreeHost.h"
 #include "Timer.h"
 #include <WebCore/CoordinatedGraphicsLayer.h>
+#include <WebCore/CoordinatedGraphicsState.h>
 #include <WebCore/CoordinatedImageBacking.h>
 #include <WebCore/GraphicsLayerClient.h>
 #include <WebCore/GraphicsLayerFactory.h>
@@ -80,39 +81,13 @@ public:
     virtual void pauseRendering() { m_isSuspended = true; }
     virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); }
     virtual void deviceOrPageScaleFactorChanged() OVERRIDE;
-    virtual PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE;
 
-    virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }
-    virtual void createTile(WebCore::CoordinatedLayerID, uint32_t tileID, const WebCore::SurfaceUpdateInfo&, const WebCore::IntRect&);
-    virtual void updateTile(WebCore::CoordinatedLayerID, uint32_t tileID, const WebCore::SurfaceUpdateInfo&, const WebCore::IntRect&);
-    virtual void removeTile(WebCore::CoordinatedLayerID, uint32_t tileID);
-    virtual WebCore::FloatRect visibleContentsRect() const;
     virtual void renderNextFrame();
     virtual void purgeBackingStores();
     virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
     virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
 
-    virtual void syncLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedLayerInfo&);
-    virtual void syncLayerChildren(WebCore::CoordinatedLayerID, const Vector<WebCore::CoordinatedLayerID>&);
-    virtual void setLayerAnimations(WebCore::CoordinatedLayerID, const WebCore::GraphicsLayerAnimations&);
-#if ENABLE(CSS_FILTERS)
-    virtual void syncLayerFilters(WebCore::CoordinatedLayerID, const WebCore::FilterOperations&);
-#endif
-#if USE(GRAPHICS_SURFACE)
-    virtual void createCanvas(WebCore::CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE;
-    virtual void syncCanvas(WebCore::CoordinatedLayerID, WebCore::PlatformLayer*) OVERRIDE;
-    virtual void destroyCanvas(WebCore::CoordinatedLayerID) OVERRIDE;
-#endif
-    virtual void setLayerRepaintCount(WebCore::CoordinatedLayerID, int) OVERRIDE;
-    virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);
-
-    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);
-
-    // UpdateAtlasClient
-    virtual bool createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;
-    virtual void removeUpdateAtlas(uint32_t atlasID);
-
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     virtual void scheduleAnimation() OVERRIDE;
 #endif
@@ -139,6 +114,18 @@ private:
 
     void flushPendingImageBackingChanges();
 
+    // CoordinatedGraphicsLayerClient
+    virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }
+    virtual WebCore::FloatRect visibleContentsRect() const;
+    virtual PassRefPtr<WebCore::CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE;
+    virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);
+    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);
+    virtual void syncLayerState(WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayerState&);
+
+    // UpdateAtlasClient
+    virtual bool createUpdateAtlas(uint32_t atlasID, PassRefPtr<WebCore::CoordinatedSurface>) OVERRIDE;
+    virtual void removeUpdateAtlas(uint32_t atlasID);
+
     // GraphicsLayerFactory
     virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE;
 
@@ -166,6 +153,8 @@ private:
     void releaseInactiveAtlasesTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
 
 #if ENABLE(CSS_SHADERS)
+    void prepareCustomFilterProxiesIfNeeded(WebCore::CoordinatedGraphicsLayerState&);
+
     // WebCustomFilterProgramProxyClient
     void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*);
 
@@ -181,6 +170,8 @@ private:
     // The page overlay layer. Will be null if there's no page overlay.
     OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
 
+    WebCore::CoordinatedGraphicsState m_state;
+
     HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers;
     Vector<WebCore::CoordinatedLayerID> m_layersToCreate;
     Vector<WebCore::CoordinatedLayerID> m_layersToDelete;