[Coordinated Graphics] Prevent a recursive painting in CoordinatedGraphicsLayer
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 13:33:43 +0000 (13:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 13:33:43 +0000 (13:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117222

Patch by Gwang Yoon Hwang <ryumiel@company100.net> on 2013-06-05
Reviewed by Noam Rosenthal.

CoordinatedGraphicsLayer::flushCompositingState() will cross frame
boundaries if the GraphicsLayers are connected. In this case,
updateContentBuffers will invoke a painting of a sub-frame that causes
flushCompositingState recursively.

Source/WebCore:

To prevent this behavior this patch extracts updateContentBuffers from
flushCompositingState, and places it in
updateContentBuffersIncludeSublayers, which is another tree traveler for
painting.

No new tests, covered by existing tests.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Source/WebKit2:

To prevent this behavior this patch extracts updateContentBuffers from
flushCompositingState, and places it in
updateContentBuffersIncludeSublayers, which traverses the tree
separately from flushing the state for painting.

No new tests, covered by existing tests.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

index 0aaacef..698afd4 100644 (file)
@@ -1,3 +1,28 @@
+2013-06-05  Gwang Yoon Hwang  <ryumiel@company100.net>
+
+        [Coordinated Graphics] Prevent a recursive painting in CoordinatedGraphicsLayer
+        https://bugs.webkit.org/show_bug.cgi?id=117222
+
+        Reviewed by Noam Rosenthal.
+
+        CoordinatedGraphicsLayer::flushCompositingState() will cross frame
+        boundaries if the GraphicsLayers are connected. In this case,
+        updateContentBuffers will invoke a painting of a sub-frame that causes
+        flushCompositingState recursively.
+
+        To prevent this behavior this patch extracts updateContentBuffers from
+        flushCompositingState, and places it in
+        updateContentBuffersIncludeSublayers, which is another tree traveler for
+        painting.
+
+        No new tests, covered by existing tests.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2013-06-05  Andreas Kling  <akling@apple.com>
 
         Fix some inefficiencies in AnimationController's composite animation map.
index a0e916f..735a3f6 100644 (file)
@@ -790,19 +790,24 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
 #if ENABLE(CSS_FILTERS)
     syncFilters();
 #endif
-    updateContentBuffers();
 #if USE(GRAPHICS_SURFACE)
     syncCanvas();
 #endif
 
+    // Only unset m_movingVisibleRect after we have updated the visible rect after the animation stopped.
+    if (!hasActiveTransformAnimation)
+        m_movingVisibleRect = false;
+}
+
+void CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers()
+{
     if (m_layerState.hasPendingChanges()) {
         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;
+    for (size_t i = 0; i < children().size(); ++i)
+        toCoordinatedGraphicsLayer(children()[i])->syncPendingStateChangesIncludingSubLayers();
 }
 
 void CoordinatedGraphicsLayer::resetLayerState()
@@ -993,6 +998,20 @@ void CoordinatedGraphicsLayer::removeTile(uint32_t tileID)
     m_layerState.tilesToRemove.append(tileID);
 }
 
+void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
+{
+    if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer()))
+        mask->updateContentBuffers();
+
+    if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
+        replica->updateContentBuffers();
+
+    updateContentBuffers();
+
+    for (size_t i = 0; i < children().size(); ++i)
+        toCoordinatedGraphicsLayer(children()[i])->updateContentBuffersIncludingSubLayers();
+}
+
 void CoordinatedGraphicsLayer::updateContentBuffers()
 {
     if (!shouldHaveBackingStore()) {
index 4d70cd2..67b8424 100644 (file)
@@ -111,6 +111,9 @@ public:
     virtual void suspendAnimations(double time) OVERRIDE;
     virtual void resumeAnimations() OVERRIDE;
 
+    void syncPendingStateChangesIncludingSubLayers();
+    void updateContentBuffersIncludingSubLayers();
+
     FloatPoint computePositionRelativeToBase();
     void computePixelAlignment(FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset);
 
index 2d998f8..a8c5ece 100644 (file)
@@ -1,5 +1,27 @@
 2013-06-05  Gwang Yoon Hwang  <ryumiel@company100.net>
 
+        [Coordinated Graphics] Prevent a recursive painting in CoordinatedGraphicsLayer
+        https://bugs.webkit.org/show_bug.cgi?id=117222
+
+        Reviewed by Noam Rosenthal.
+
+        CoordinatedGraphicsLayer::flushCompositingState() will cross frame
+        boundaries if the GraphicsLayers are connected. In this case,
+        updateContentBuffers will invoke a painting of a sub-frame that causes
+        flushCompositingState recursively.
+
+        To prevent this behavior this patch extracts updateContentBuffers from
+        flushCompositingState, and places it in
+        updateContentBuffersIncludeSublayers, which traverses the tree
+        separately from flushing the state for painting.
+
+        No new tests, covered by existing tests.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
+
+2013-06-05  Gwang Yoon Hwang  <ryumiel@company100.net>
+
         [Coordinated Graphics] Rename client classes for CoordinatedImageBacking and UpdateAtlas.
         https://bugs.webkit.org/show_bug.cgi?id=111948
 
index d1b6a35..0647db7 100644 (file)
@@ -248,6 +248,9 @@ bool CoordinatedLayerTreeHost::flushPendingLayerChanges()
 
     bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes();
 
+    toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers();
+    toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers();
+
     flushPendingImageBackingChanges();
 
     if (m_shouldSyncFrame) {