Title: [107236] trunk/Source/WebKit2
Revision
107236
Author
[email protected]
Date
2012-02-09 06:38:44 -0800 (Thu, 09 Feb 2012)

Log Message

[Qt] Control the lifetime of TiledBackingStores in WebGraphicsLayer.
https://bugs.webkit.org/show_bug.cgi?id=78005

Reviewed by Noam Rosenthal.

This makes sure that no empty tiles are generated for layers without contents and that
no interaction is made with the TiledBackingStore until we got a WebGraphicsLayerClient.

- Create the main TiledBackingStore only when the layer has drawsContent and has no
  directly composited image
- Removed recreateBackingStoreIfNeeded and do the (re)creation of the backing stores
  in updateContentBuffers
- Call purgeBackingStores on registered layers instead of passing it down the layer tree

* WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
(WebCore::WebGraphicsLayer::WebGraphicsLayer):
(WebCore::WebGraphicsLayer::~WebGraphicsLayer):
(WebCore::WebGraphicsLayer::setDrawsContent):
(WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
(WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
(WebCore::WebGraphicsLayer::setVisibleContentRectTrajectoryVector):
(WebCore::WebGraphicsLayer::tiledBackingStoreContentsRect):
(WebCore::WebGraphicsLayer::updateContentBuffers):
(WebCore::WebGraphicsLayer::purgeBackingStores):
(WebCore::WebGraphicsLayer::setWebGraphicsLayerClient):
(WebCore::WebGraphicsLayer::computeTransformedVisibleRect):
* WebProcess/WebCoreSupport/WebGraphicsLayer.h:
(WebGraphicsLayer):
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::LayerTreeHostQt):
(WebKit::LayerTreeHostQt::flushPendingLayerChanges):
(WebKit):
(WebKit::LayerTreeHostQt::purgeBackingStores):
* WebProcess/WebPage/qt/LayerTreeHostQt.h:
(LayerTreeHostQt):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (107235 => 107236)


--- trunk/Source/WebKit2/ChangeLog	2012-02-09 14:37:12 UTC (rev 107235)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-09 14:38:44 UTC (rev 107236)
@@ -1,3 +1,41 @@
+2012-02-09  Jocelyn Turcotte  <[email protected]>
+
+        [Qt] Control the lifetime of TiledBackingStores in WebGraphicsLayer.
+        https://bugs.webkit.org/show_bug.cgi?id=78005
+
+        Reviewed by Noam Rosenthal.
+
+        This makes sure that no empty tiles are generated for layers without contents and that
+        no interaction is made with the TiledBackingStore until we got a WebGraphicsLayerClient.
+
+        - Create the main TiledBackingStore only when the layer has drawsContent and has no
+          directly composited image
+        - Removed recreateBackingStoreIfNeeded and do the (re)creation of the backing stores
+          in updateContentBuffers
+        - Call purgeBackingStores on registered layers instead of passing it down the layer tree
+
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::WebGraphicsLayer::WebGraphicsLayer):
+        (WebCore::WebGraphicsLayer::~WebGraphicsLayer):
+        (WebCore::WebGraphicsLayer::setDrawsContent):
+        (WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
+        (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
+        (WebCore::WebGraphicsLayer::setVisibleContentRectTrajectoryVector):
+        (WebCore::WebGraphicsLayer::tiledBackingStoreContentsRect):
+        (WebCore::WebGraphicsLayer::updateContentBuffers):
+        (WebCore::WebGraphicsLayer::purgeBackingStores):
+        (WebCore::WebGraphicsLayer::setWebGraphicsLayerClient):
+        (WebCore::WebGraphicsLayer::computeTransformedVisibleRect):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+        (WebGraphicsLayer):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
+        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
+        (WebKit):
+        (WebKit::LayerTreeHostQt::purgeBackingStores):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
+        (LayerTreeHostQt):
+
 2012-02-08  Jocelyn Turcotte  <[email protected]>
 
         [Qt] Remove WebGraphicsLayer::updateTileBuffersRecursively

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (107235 => 107236)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-02-09 14:37:12 UTC (rev 107235)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-02-09 14:38:44 UTC (rev 107236)
@@ -88,11 +88,9 @@
     , m_inUpdateMode(false)
 #if USE(TILED_BACKING_STORE)
     , m_webGraphicsLayerClient(0)
-    , m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))))
     , m_contentsScale(1.f)
 #endif
 {
-    m_mainBackingStore->setContentsScale(1.0);
     static WebLayerID nextLayerID = 1;
     m_layerInfo.id = nextLayerID++;
     layerByIDMap().add(id(), this);
@@ -102,11 +100,10 @@
 {
     layerByIDMap().remove(id());
 
-    // This would tell the UI process to release the backing store.
-    setContentsToImage(0);
-
-    if (m_webGraphicsLayerClient)
+    if (m_webGraphicsLayerClient) {
+        purgeBackingStores();
         m_webGraphicsLayerClient->detachLayer(this);
+    }
 }
 
 bool WebGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
@@ -247,8 +244,6 @@
         return;
     GraphicsLayer::setDrawsContent(b);
 
-    if (b)
-        setNeedsDisplay();
     notifyChange();
 }
 
@@ -403,8 +398,8 @@
 
 void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
 {
-    recreateBackingStoreIfNeeded();
-    m_mainBackingStore->invalidate(IntRect(rect));
+    if (m_mainBackingStore)
+        m_mainBackingStore->invalidate(IntRect(rect));
     notifyChange();
 }
 
@@ -462,10 +457,6 @@
     for (size_t i = 0; i < children().size(); ++i)
         m_layerInfo.children.append(toWebLayerID(children()[i]));
 
-    ASSERT(m_webGraphicsLayerClient);
-    if (m_layerInfo.imageIsUpdated && m_image && !m_layerInfo.imageBackingStoreID)
-        m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
-
     m_webGraphicsLayerClient->didSyncCompositingStateForLayer(m_layerInfo);
     m_modified = false;
     m_layerInfo.imageIsUpdated = false;
@@ -488,7 +479,8 @@
 
 void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
 {
-    m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector);
+    if (m_mainBackingStore)
+        m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector);
 }
 
 void WebGraphicsLayer::setVisibleContentRectAndScale(const IntRect& pageVisibleRect, float scale)
@@ -528,8 +520,6 @@
 
 IntRect WebGraphicsLayer::tiledBackingStoreContentsRect()
 {
-    if (!drawsContent())
-        return IntRect();
     return IntRect(0, 0, size().width(), size().height());
 }
 
@@ -575,54 +565,40 @@
 
 void WebGraphicsLayer::updateContentBuffers()
 {
-    // Backing-stores for directly composited images is handled in LayerTreeHost.
-    if (m_image)
-        return;
+    // The remote image might have been released by purgeBackingStores.
+    if (m_image) {
+        if (!m_layerInfo.imageBackingStoreID) {
+            m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
+            m_layerInfo.imageIsUpdated = true;
+        }
+    }
 
-    if (!drawsContent())
+    if (!drawsContent()) {
+        m_mainBackingStore.clear();
+        m_previousBackingStore.clear();
         return;
+    }
 
     m_inUpdateMode = true;
+    // This is the only place we (re)create the main tiled backing store,
+    // once we have a remote client and we are ready to send our data to the UI process.
+    if (!m_mainBackingStore) {
+        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
+        m_mainBackingStore->setContentsScale(m_contentsScale);
+    }
     m_mainBackingStore->updateTileBuffers();
     m_inUpdateMode = false;
 }
 
 void WebGraphicsLayer::purgeBackingStores()
 {
-    for (size_t i = 0; i < children().size(); ++i) {
-        WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
-        layer->purgeBackingStores();
-    }
+    m_mainBackingStore.clear();
+    m_previousBackingStore.clear();
 
-    if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer()))
-        mask->purgeBackingStores();
-
-    if (m_mainBackingStore)
-        m_mainBackingStore.clear();
-
-    if (!m_layerInfo.imageBackingStoreID)
-        return;
-
-    m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
-    m_layerInfo.imageBackingStoreID = 0;
-}
-
-void WebGraphicsLayer::recreateBackingStoreIfNeeded()
-{
-    for (size_t i = 0; i < children().size(); ++i) {
-        WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
-        layer->recreateBackingStoreIfNeeded();
+    if (m_layerInfo.imageBackingStoreID) {
+        m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
+        m_layerInfo.imageBackingStoreID = 0;
     }
-    if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer()))
-        mask->recreateBackingStoreIfNeeded();
-
-    if (!m_mainBackingStore) {
-        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
-        m_mainBackingStore->setContentsScale(m_contentsScale);
-    }
-
-    if (m_image)
-        setContentsNeedsDisplay();
 }
 
 void WebGraphicsLayer::setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient* client)
@@ -639,9 +615,11 @@
         layer->setWebGraphicsLayerClient(client);
     }
 
-    // Have to force detach from remote layer here if layer tile client changes.
-    if (m_webGraphicsLayerClient)
+    // We have to release resources on the UI process here if the remote client has changed or is removed.
+    if (m_webGraphicsLayerClient) {
+        purgeBackingStores();
         m_webGraphicsLayerClient->detachLayer(this);
+    }
     m_webGraphicsLayerClient = client;
     if (client)
         client->attachLayer(this);
@@ -658,7 +636,8 @@
     m_layerTransform.setChildrenTransform(childrenTransform());
     m_layerTransform.combineTransforms(parent() ? toWebGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix());
     // The combined transform will be used in tiledBackingStoreVisibleRect.
-    m_mainBackingStore->adjustVisibleRect();
+    if (m_mainBackingStore)
+        m_mainBackingStore->adjustVisibleRect();
 }
 #endif
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h (107235 => 107236)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h	2012-02-09 14:37:12 UTC (rev 107235)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h	2012-02-09 14:38:44 UTC (rev 107236)
@@ -140,7 +140,6 @@
     bool isReadyForTileBufferSwap() const;
     void updateContentBuffers();
     void purgeBackingStores();
-    void recreateBackingStoreIfNeeded();
 #endif
 
 private:

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (107235 => 107236)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-02-09 14:37:12 UTC (rev 107235)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-02-09 14:38:44 UTC (rev 107236)
@@ -74,7 +74,6 @@
     , m_shouldSyncRootLayer(true)
     , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
     , m_layerFlushSchedulingEnabled(true)
-    , m_shouldRecreateBackingStore(false)
 {
     // Create a root layer.
     m_rootLayer = GraphicsLayer::create(this);
@@ -221,8 +220,6 @@
 
 bool LayerTreeHostQt::flushPendingLayerChanges()
 {
-    recreateBackingStoreIfNeeded();
-
     bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
     m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
     if (m_pageOverlayLayer)
@@ -411,6 +408,7 @@
 {
     m_webPage->send(Messages::LayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, updateInfo));
 }
+
 void LayerTreeHostQt::removeTile(WebLayerID layerID, int tileID)
 {
     m_webPage->send(Messages::LayerTreeHostProxy::RemoveTileForLayer(layerID, tileID));
@@ -447,22 +445,12 @@
 
 void LayerTreeHostQt::purgeBackingStores()
 {
-    m_shouldRecreateBackingStore = true;
-    WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
-    webRootLayer->purgeBackingStores();
+    HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
+    for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it)
+        (*it)->purgeBackingStores();
 
     ASSERT(!m_directlyCompositedImageRefCounts.size());
 }
-
-void LayerTreeHostQt::recreateBackingStoreIfNeeded()
-{
-    if (!m_shouldRecreateBackingStore)
-        return;
-
-    m_shouldRecreateBackingStore = false;
-    WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
-    webRootLayer->recreateBackingStoreIfNeeded();
-}
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h (107235 => 107236)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	2012-02-09 14:37:12 UTC (rev 107235)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	2012-02-09 14:38:44 UTC (rev 107236)
@@ -97,7 +97,6 @@
     void cancelPendingLayerFlush();
     void performScheduledLayerFlush();
     void sendLayersToUI();
-    void recreateBackingStoreIfNeeded();
 
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
 
@@ -124,7 +123,6 @@
     void layerFlushTimerFired(WebCore::Timer<LayerTreeHostQt>*);
     WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer;
     bool m_layerFlushSchedulingEnabled;
-    bool m_shouldRecreateBackingStore;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to