GraphicsLayerCA::recomputeVisibleRects() shouldn't actually set the visible rect
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 00:18:44 +0000 (00:18 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 00:18:44 +0000 (00:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=113544

Reviewed by Tim Horton.

The functions added in r147058 to update the visible rects of GraphicsLayerCAs
should not have actually set the m_visibleRect on the layer, because this
caused a later call to adjustTiledLayerVisibleRect() to think that the visible
rect had not changed, so it did no expansion.

Clarify the logic to ask the GraphicsLayer whether, given a new visible
rect, it would need to make new tiles (which happens later during a flush).

Add a function to RenderLayerCompositor to call this code (but which has
no callers yet).

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::visibleRectChangeRequiresFlush): Make private.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush):
(WebCore::GraphicsLayerCA::visibleRectChangeRequiresFlush):
* platform/graphics/ca/GraphicsLayerCA.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::noteVisibleRectChanged):
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index c68f763..276332f 100644 (file)
@@ -1,3 +1,32 @@
+2013-03-28  Simon Fraser  <simon.fraser@apple.com>
+
+        GraphicsLayerCA::recomputeVisibleRects() shouldn't actually set the visible rect
+        https://bugs.webkit.org/show_bug.cgi?id=113544
+
+        Reviewed by Tim Horton.
+        
+        The functions added in r147058 to update the visible rects of GraphicsLayerCAs
+        should not have actually set the m_visibleRect on the layer, because this
+        caused a later call to adjustTiledLayerVisibleRect() to think that the visible
+        rect had not changed, so it did no expansion.
+        
+        Clarify the logic to ask the GraphicsLayer whether, given a new visible
+        rect, it would need to make new tiles (which happens later during a flush).
+        
+        Add a function to RenderLayerCompositor to call this code (but which has
+        no callers yet).
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::visibleRectChangeRequiresFlush): Make private.
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush):
+        (WebCore::GraphicsLayerCA::visibleRectChangeRequiresFlush):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::noteVisibleRectChanged):
+        * rendering/RenderLayerCompositor.h:
+        (RenderLayerCompositor):
+
 2013-03-28  Rafael Weinstein  <rafaelw@chromium.org>
 
         [HTMLTemplateElement] <template> should be able to be a foster parent
index 5d347e2..33bbb6f 100644 (file)
@@ -409,8 +409,9 @@ public:
     virtual void flushCompositingState(const FloatRect& /* clipRect */) { }
     virtual void flushCompositingStateForThisLayerOnly() { }
 
-    // Walk the layer tree, recomputing the visible rects of layer with TiledBacking, on platforms that use it.
-    virtual void recomputeVisibleRects(const FloatRect& /* clipRect */) { }
+    // If the exposed rect of this layer changes, returns true if this or descendant layers need a flush,
+    // for example to allocate new tiles.
+    virtual bool visibleRectChangeRequiresFlush(const FloatRect& /* clipRect */) const { return false; }
 
     // Return a string with a human readable form of the layer tree, If debug is true
     // pointers for the layers and timing data will be included in the returned string.
index b56d44c..7421502 100644 (file)
@@ -907,7 +907,7 @@ void GraphicsLayerCA::flushCompositingStateForThisLayerOnly()
         client()->didCommitChangesForLayer(this);
 }
 
-void GraphicsLayerCA::recursiveComputeVisibleRect(const TransformState& state)
+bool GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush(const TransformState& state) const
 {
     TransformState localState = state;
     
@@ -915,16 +915,16 @@ void GraphicsLayerCA::recursiveComputeVisibleRect(const TransformState& state)
     // for animating transforms.
     FloatRect visibleRect = computeVisibleRect(localState, 0);
     if (visibleRect != m_visibleRect) {
-        m_visibleRect = visibleRect;
         if (TiledBacking* tiledBacking = this->tiledBacking()) {
-            if (tiledBacking->tilesWouldChangeForVisibleRect(m_visibleRect))
-                noteLayerPropertyChanged(VisibleRectChanged);
+            if (tiledBacking->tilesWouldChangeForVisibleRect(visibleRect))
+                return true;
         }
     }
 
     if (m_maskLayer) {
         GraphicsLayerCA* maskLayerCA = static_cast<GraphicsLayerCA*>(m_maskLayer);
-        maskLayerCA->recursiveComputeVisibleRect(localState);
+        if (maskLayerCA->recursiveVisibleRectChangeRequiresFlush(localState))
+            return true;
     }
 
     const Vector<GraphicsLayer*>& childLayers = children();
@@ -932,17 +932,21 @@ void GraphicsLayerCA::recursiveComputeVisibleRect(const TransformState& state)
     
     for (size_t i = 0; i < numChildren; ++i) {
         GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
-        curChild->recursiveComputeVisibleRect(localState);
+        if (curChild->recursiveVisibleRectChangeRequiresFlush(localState))
+            return true;
     }
 
     if (m_replicaLayer)
-        static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveComputeVisibleRect(localState);
+        if (static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveVisibleRectChangeRequiresFlush(localState))
+            return true;
+    
+    return false;
 }
 
-void GraphicsLayerCA::recomputeVisibleRects(const FloatRect& clipRect)
+bool GraphicsLayerCA::visibleRectChangeRequiresFlush(const FloatRect& clipRect) const
 {
     TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
-    recursiveComputeVisibleRect(state);
+    return recursiveVisibleRectChangeRequiresFlush(state);
 }
 
 TiledBacking* GraphicsLayerCA::tiledBacking() const
index 7695ae5..d732594 100644 (file)
@@ -142,8 +142,7 @@ public:
     virtual void flushCompositingState(const FloatRect&);
     virtual void flushCompositingStateForThisLayerOnly();
 
-    void recursiveComputeVisibleRect(const TransformState&);
-    virtual void recomputeVisibleRects(const FloatRect& clipRect);
+    virtual bool visibleRectChangeRequiresFlush(const FloatRect& visibleRect) const OVERRIDE;
 
     virtual TiledBacking* tiledBacking() const OVERRIDE;
 
@@ -253,6 +252,8 @@ private:
     
     FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatSize& oldSize) const;
 
+    bool recursiveVisibleRectChangeRequiresFlush(const TransformState&) const;
+
     // Used to track the path down the tree for replica layers.
     struct ReplicaState {
         static const size_t maxReplicaDepth = 16;
index c1c5428..4cb77ac 100644 (file)
@@ -373,6 +373,21 @@ void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer* layer, const Gr
         fixedRootBackgroundLayerChanged();
 }
 
+void RenderLayerCompositor::didChangeVisibleRect()
+{
+    GraphicsLayer* rootLayer = rootGraphicsLayer();
+    if (!rootLayer)
+        return;
+
+    FrameView* frameView = m_renderView ? m_renderView->frameView() : 0;
+    if (!frameView)
+        return;
+
+    IntRect visibleRect = m_clipLayer ? IntRect(IntPoint(), frameView->contentsSize()) : frameView->visibleContentRect();
+    if (rootLayer->visibleRectChangeRequiresFlush(visibleRect))
+        scheduleLayerFlush();
+}
+
 void RenderLayerCompositor::notifyFlushBeforeDisplayRefresh(const GraphicsLayer*)
 {
     if (!m_layerUpdater) {
index 8ded558..b8cdf61 100644 (file)
@@ -135,6 +135,9 @@ public:
 
     // Called when the GraphicsLayer for the given RenderLayer has flushed changes inside of flushPendingLayerChanges().
     void didFlushChangesForLayer(RenderLayer*, const GraphicsLayer*);
+
+    // Called when something outside WebKit affects the visible rect (e.g. delegated scrolling). Might schedule a layer flush.
+    void didChangeVisibleRect();
     
     // Rebuild the tree of compositing layers
     void updateCompositingLayers(CompositingUpdateType, RenderLayer* updateRoot = 0);