Get rid of "non-composited contents" in CoordinatedLayerTreeHost
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2013 16:24:18 +0000 (16:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2013 16:24:18 +0000 (16:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110355

Patch by Noam Rosenthal <noam@webkit.org> on 2013-04-29
Reviewed by Jocelyn Turcotte.

Source/WebCore:

When in force compositing mode, always assume that the main layer needs
a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
recursive so that they don't rely on a specialized layer.

No new testable behavior, changes to coverRect and trajectory vector only
affect tiling latency in rare cases that are not trivial to test.

* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
    Make the trajectory vector recursive, though limited only to layers with
    translate/identity. This allows us to keep the trajectory vector while removing
    the non-composited contents specialization.

(WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
    Added accumulatedCoverRect, so that the coverRect calculations for the UI process
    are not bound to the non-composited contents layer.

(WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
    Instead of saving a reference to the non-composited contents layer, we assume that
    the first layer we found recursively which has contents is the one to be used for
    coverRect/trajectory calculations.

(WebCore):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayer):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintsIntoWindow):
    Always create a layer for the non-composited contents when in forceCompositing mode.

Source/WebKit2:

Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
a proper GraphicsLayer for that content.
CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
the trajectory vector and applying the cover rect.

* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
    Don't create the non-composited layer, instead keep a raw pointer to the root
    compositing layer created by the WebCore compositor.

(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
(WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
(WebKit::CoordinatedLayerTreeHost::sizeDidChange):
(WebKit::CoordinatedLayerTreeHost::paintContents):
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
    Remove non-composited layer specialization.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149292 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/WebCore/rendering/RenderLayerBacking.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

index 99f5cb1..e610efe 100644 (file)
@@ -1,3 +1,39 @@
+2013-04-29  Noam Rosenthal  <noam@webkit.org>
+
+        Get rid of "non-composited contents" in CoordinatedLayerTreeHost
+        https://bugs.webkit.org/show_bug.cgi?id=110355
+
+        Reviewed by Jocelyn Turcotte.
+
+        When in force compositing mode, always assume that the main layer needs
+        a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
+        recursive so that they don't rely on a specialized layer.
+
+        No new testable behavior, changes to coverRect and trajectory vector only
+        affect tiling latency in rare cases that are not trivial to test.
+
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
+            Make the trajectory vector recursive, though limited only to layers with
+            translate/identity. This allows us to keep the trajectory vector while removing
+            the non-composited contents specialization.
+
+        (WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
+            Added accumulatedCoverRect, so that the coverRect calculations for the UI process
+            are not bound to the non-composited contents layer.
+
+        (WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
+            Instead of saving a reference to the non-composited contents layer, we assume that
+            the first layer we found recursively which has contents is the one to be used for
+            coverRect/trajectory calculations.
+
+        (WebCore):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+        (CoordinatedGraphicsLayer):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintsIntoWindow):
+            Always create a layer for the non-composited contents when in forceCompositing mode.
+
 2013-04-29  Dirk Schulze  <krit@webkit.org>
 
         Animate clip rect() between different Length types
index 586e47b..a0e916f 100644 (file)
@@ -836,6 +836,20 @@ void CoordinatedGraphicsLayer::tiledBackingStorePaintBegin()
 {
 }
 
+CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively()
+{
+    if (shouldHaveBackingStore())
+        return this;
+
+    for (size_t i = 0; i < children().size(); ++i) {
+        CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
+        if (layer)
+            return layer;
+    }
+
+    return 0;
+}
+
 void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
 {
     if (!m_mainBackingStore)
index 9c63c08..4d70cd2 100644 (file)
@@ -148,6 +148,7 @@ public:
     bool hasPendingVisibleChanges();
 
     static void setShouldSupportContentsTiling(bool);
+    CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
 
 private:
 #if USE(GRAPHICS_SURFACE)
index 947441e..0f43414 100644 (file)
@@ -1845,7 +1845,7 @@ bool RenderLayerBacking::paintsIntoWindow() const
         return false;
 
     if (m_owningLayer->isRootLayer()) {
-#if PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY) || USE(COORDINATED_GRAPHICS)
         if (compositor()->inForcedCompositingMode())
             return false;
 #endif
index b2a61fa..e8397d2 100644 (file)
@@ -1,3 +1,30 @@
+2013-04-29  Noam Rosenthal  <noam@webkit.org>
+
+        Get rid of "non-composited contents" in CoordinatedLayerTreeHost
+        https://bugs.webkit.org/show_bug.cgi?id=110355
+
+        Reviewed by Jocelyn Turcotte.
+
+        Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
+        a proper GraphicsLayer for that content.
+        CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
+        the trajectory vector and applying the cover rect.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+        (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
+            Don't create the non-composited layer, instead keep a raw pointer to the root
+            compositing layer created by the WebCore compositor.
+
+        (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
+        (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
+        (WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
+        (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
+        (WebKit::CoordinatedLayerTreeHost::paintContents):
+        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
+            Remove non-composited layer specialization.
+
 2013-04-29  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
 
         [Qt] Build fix. Enabling c++11 for Qt WK2 after r149259.
index f41b2c9..1c0ba24 100644 (file)
@@ -80,6 +80,7 @@ CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost()
 
 CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
     : LayerTreeHost(webPage)
+    , m_rootCompositingLayer(0)
     , m_notifyAfterScheduledLayerFlush(false)
     , m_isValid(true)
     , m_isPurging(false)
@@ -99,25 +100,12 @@ CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
 
     // Create a root layer.
     m_rootLayer = GraphicsLayer::create(this, this);
-    CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get());
 #ifndef NDEBUG
     m_rootLayer->setName("CoordinatedLayerTreeHost root layer");
 #endif
     m_rootLayer->setDrawsContent(false);
     m_rootLayer->setSize(m_webPage->size());
-    m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id();
-
-    m_nonCompositedContentLayer = GraphicsLayer::create(this, this);
-#ifndef NDEBUG
-    m_nonCompositedContentLayer->setName("CoordinatedLayerTreeHost non-composited content");
-#endif
-    m_nonCompositedContentLayer->setDrawsContent(true);
-    m_nonCompositedContentLayer->setSize(m_webPage->size());
-
-    m_nonCompositedContentLayer->setShowDebugBorder(m_webPage->corePage()->settings()->showDebugBorders());
-    m_nonCompositedContentLayer->setShowRepaintCounter(m_webPage->corePage()->settings()->showRepaintCounter());
-
-    m_rootLayer->addChild(m_nonCompositedContentLayer.get());
+    m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
 
@@ -167,12 +155,12 @@ void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool
 
 void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
 {
-    m_nonCompositedContentLayer->removeAllChildren();
-    m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
+    if (m_rootCompositingLayer)
+        m_rootCompositingLayer->removeFromParent();
 
-    // Add the accelerated layer tree hierarchy.
-    if (graphicsLayer)
-        m_nonCompositedContentLayer->addChild(graphicsLayer);
+    m_rootCompositingLayer = graphicsLayer;
+    if (m_rootCompositingLayer)
+        m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
 }
 
 void CoordinatedLayerTreeHost::invalidate()
@@ -184,32 +172,6 @@ void CoordinatedLayerTreeHost::invalidate()
     m_isValid = false;
 }
 
-void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay()
-{
-    m_nonCompositedContentLayer->setNeedsDisplay();
-    if (m_pageOverlayLayer)
-        m_pageOverlayLayer->setNeedsDisplay();
-
-    scheduleLayerFlush();
-}
-
-void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect& rect)
-{
-    m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
-    if (m_pageOverlayLayer)
-        m_pageOverlayLayer->setNeedsDisplayInRect(rect);
-
-    scheduleLayerFlush();
-}
-
-void CoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&)
-{
-    if (!m_webPage->useFixedLayout())
-        setNonCompositedContentsNeedDisplay();
-
-    scheduleLayerFlush();
-}
-
 void CoordinatedLayerTreeHost::forceRepaint()
 {
     // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
@@ -233,27 +195,7 @@ bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
 
 void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
 {
-    if (m_rootLayer->size() == newSize)
-        return;
-
     m_rootLayer->setSize(newSize);
-
-    // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
-    // for those newly exposed areas.
-    FloatSize oldSize = m_nonCompositedContentLayer->size();
-    m_nonCompositedContentLayer->setSize(newSize);
-
-    if (newSize.width() > oldSize.width()) {
-        float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
-        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
-    }
-
-    if (newSize.height() > oldSize.height())
-        m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
-
-    if (m_pageOverlayLayer)
-        m_pageOverlayLayer->setSize(newSize);
-
     scheduleLayerFlush();
 }
 
@@ -296,25 +238,26 @@ bool CoordinatedLayerTreeHost::flushPendingLayerChanges()
     TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
 
     createCompositingLayers();
-
     initializeRootCompositingLayerIfNeeded();
 
     m_rootLayer->flushCompositingStateForThisLayerOnly();
-    m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
     if (m_pageOverlayLayer)
         m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
 
     bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes();
 
     flushPendingImageBackingChanges();
-
     deleteCompositingLayers();
 
     if (m_shouldSyncFrame) {
         didSync = true;
 
-        m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
-        m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
+        if (m_rootCompositingLayer) {
+            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
+            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+                m_state.coveredRect = contentsLayer->coverRect();
+        }
+
         m_state.scrollPosition = m_visibleContentsRect.location();
 
         m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state));
@@ -594,11 +537,6 @@ void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*
 
 void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
 {
-    if (graphicsLayer == m_nonCompositedContentLayer) {
-        m_webPage->drawRect(graphicsContext, clipRect);
-        return;
-    }
-
     if (graphicsLayer == m_pageOverlayLayer) {
         // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
         graphicsContext.clearRect(clipRect);
@@ -660,10 +598,19 @@ WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const
     return m_visibleContentsRect;
 }
 
+CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()
+{
+    if (!m_rootCompositingLayer)
+        return 0;
+
+    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
+}
+
 void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
 {
     // A zero trajectoryVector indicates that tiles all around the viewport are requested.
-    toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
+    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+        contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
 
     bool contentsRectDidChange = rect != m_visibleContentsRect;
     if (contentsRectDidChange) {
@@ -686,7 +633,6 @@ void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, con
 void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
 {
     m_rootLayer->deviceOrPageScaleFactorChanged();
-    m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
     if (m_pageOverlayLayer)
         m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
 }
index 76ac653..6c05bb9 100644 (file)
@@ -65,9 +65,9 @@ public:
     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
     virtual void invalidate();
 
-    virtual void setNonCompositedContentsNeedDisplay() OVERRIDE;
-    virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE;
-    virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE;
+    virtual void setNonCompositedContentsNeedDisplay() OVERRIDE { }
+    virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE { }
+    virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE { }
     virtual void forceRepaint();
     virtual bool forceRepaintAsync(uint64_t callbackID);
     virtual void sizeDidChange(const WebCore::IntSize& newSize);
@@ -88,6 +88,7 @@ public:
     virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
     virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
     virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
+    WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     virtual void scheduleAnimation() OVERRIDE;
@@ -143,7 +144,6 @@ private:
     void performScheduledLayerFlush();
     void didPerformScheduledLayerFlush();
     void syncDisplayState();
-
     void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
 
     void scheduleReleaseInactiveAtlases();
@@ -164,9 +164,7 @@ private:
 #endif
 
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
-
-    // The layer which contains all non-composited content.
-    OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
+    WebCore::GraphicsLayer* m_rootCompositingLayer;
 
     // The page overlay layer. Will be null if there's no page overlay.
     OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;