[Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deall...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Dec 2011 06:54:09 +0000 (06:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Dec 2011 06:54:09 +0000 (06:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73591

Patch by Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> on 2011-12-08
Reviewed by Noam Rosenthal.

Source/WebCore:

Implementation of helper function to remove all GL allocated tiles
when QQuickWebView gets removed from canvas.

Tested by new API test in WK2 (tst_QQuickWebView::removeFromCanvas).

* platform/graphics/texmap/TextureMapperNode.cpp:
(WebCore::TextureMapperNode::purgeNodeTexturesRecursive):
* platform/graphics/texmap/TextureMapperNode.h:

Source/WebKit2:

Implement deallocation of TextureMapper GL objects when QQuickWebPage paint node deallocated.
Also adds purging GraphicsLayer backing stores on WebProcess side in order to force repainting
when page becomes visible and painting resumes and fixes incorrect initialization of view
visibility state.

* UIProcess/API/qt/qquickwebpage.cpp:
(QQuickWebPagePrivate::resetPaintNode):
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
* UIProcess/API/qt/tests/html/direct-image-compositing.html: Added.
* UIProcess/API/qt/tests/html/resources/simple_image.png: Added.
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
(tst_QQuickWebView::showWebView):
(tst_QQuickWebView::removeFromCanvas):
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::layerTreeHostProxy):
* UIProcess/LayerTreeHostProxy.h:
* UIProcess/qt/LayerTreeHostProxyQt.cpp:
(WebKit::LayerTreeHostProxy::purgeGLResources):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::purgeGLResources):
* UIProcess/qt/QtWebPageProxy.h:
* WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
(WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
(WebCore::WebGraphicsLayer::purgeBackingStores):
(WebCore::WebGraphicsLayer::recreateBackingStoreIfNeeded):
* WebProcess/WebCoreSupport/WebGraphicsLayer.h:
* WebProcess/WebPage/LayerTreeHost.h:
(WebKit::LayerTreeHost::purgeBackingStores):
* WebProcess/WebPage/LayerTreeHost.messages.in:
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::LayerTreeHostQt):
(WebKit::LayerTreeHostQt::flushPendingLayerChanges):
(WebKit::LayerTreeHostQt::purgeBackingStores):
(WebKit::LayerTreeHostQt::recreateBackingStoreIfNeeded):
* WebProcess/WebPage/qt/LayerTreeHostQt.h:

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

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperNode.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/LayerTreeHostProxy.h
Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in
Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h

index e75e4e63694a0b3bb3f38ae255fb6f40231a79d3..2aad7e60a17ca34d886df6a5c69e9e12ad074921 100644 (file)
@@ -1,3 +1,19 @@
+2011-12-08  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
+
+        [Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deallocated.
+        https://bugs.webkit.org/show_bug.cgi?id=73591
+
+        Reviewed by Noam Rosenthal.
+
+        Implementation of helper function to remove all GL allocated tiles
+        when QQuickWebView gets removed from canvas.
+
+        Tested by new API test in WK2 (tst_QQuickWebView::removeFromCanvas).
+
+        * platform/graphics/texmap/TextureMapperNode.cpp:
+        (WebCore::TextureMapperNode::purgeNodeTexturesRecursive):
+        * platform/graphics/texmap/TextureMapperNode.h:
+
 2011-12-08  Leo Yang  <leo.yang@torchmobile.com.cn>
 
         Upstream platform/network/blackberry/DeferredData.{h, cpp}, NetworkJob.{h, cpp} and NetworkManager.{h, cpp}
index 42bd2ca602c1a5f3033978905c9368a3cc1b3411..9157e23acd68dc1ad841684a150bd614506e8305 100644 (file)
@@ -616,6 +616,14 @@ void TextureMapperNode::removeContentsTile(int id)
     m_externallyManagedTiles.remove(id);
 }
 
+void TextureMapperNode::purgeNodeTexturesRecursive()
+{
+    m_externallyManagedTiles.clear();
+
+    for (int i = m_children.size() - 1; i >= 0; --i)
+        m_children[i]->purgeNodeTexturesRecursive();
+}
+
 void TextureMapperNode::setTileBackBufferTextureForDirectlyCompositedImage(int id, const IntRect& sourceRect, const FloatRect& targetRect, BitmapTexture* texture)
 {
     HashMap<int, ExternallyManagedTile>::iterator it = m_externallyManagedTiles.find(id);
index eb9c692e5b8ae1937f4d6565dbab0cf8db10d926..fc479bac6a53b751d861507857735f5566246d97 100644 (file)
@@ -158,6 +158,7 @@ public:
     void setTileBackBufferTextureForDirectlyCompositedImage(int id, const IntRect& sourceRect, const FloatRect& targetRect, BitmapTexture*);
     void clearAllDirectlyCompositedImageTiles();
     bool collectVisibleContentsRects(NodeRectMap&, const FloatRect&);
+    void purgeNodeTexturesRecursive();
 #endif
     void setID(int id) { m_id = id; }
     int id() const { return m_id; }
index ebabc3f4ee360c788aa9ca007608466932c178db..d155c88e6b9b7fb69d9e71ae9e95fe3cb55a46ca 100644 (file)
@@ -1,3 +1,47 @@
+2011-12-08  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
+
+        [Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deallocated.
+        https://bugs.webkit.org/show_bug.cgi?id=73591
+
+        Reviewed by Noam Rosenthal.
+
+        Implement deallocation of TextureMapper GL objects when QQuickWebPage paint node deallocated.
+        Also adds purging GraphicsLayer backing stores on WebProcess side in order to force repainting
+        when page becomes visible and painting resumes and fixes incorrect initialization of view 
+        visibility state.
+
+        * UIProcess/API/qt/qquickwebpage.cpp:
+        (QQuickWebPagePrivate::resetPaintNode):
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        * UIProcess/API/qt/tests/html/direct-image-compositing.html: Added.
+        * UIProcess/API/qt/tests/html/resources/simple_image.png: Added.
+        * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
+        (tst_QQuickWebView::showWebView):
+        (tst_QQuickWebView::removeFromCanvas):
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::layerTreeHostProxy):
+        * UIProcess/LayerTreeHostProxy.h:
+        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
+        (WebKit::LayerTreeHostProxy::purgeGLResources):
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::purgeGLResources):
+        * UIProcess/qt/QtWebPageProxy.h:
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
+        (WebCore::WebGraphicsLayer::purgeBackingStores):
+        (WebCore::WebGraphicsLayer::recreateBackingStoreIfNeeded):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+        * WebProcess/WebPage/LayerTreeHost.h:
+        (WebKit::LayerTreeHost::purgeBackingStores):
+        * WebProcess/WebPage/LayerTreeHost.messages.in:
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
+        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
+        (WebKit::LayerTreeHostQt::purgeBackingStores):
+        (WebKit::LayerTreeHostQt::recreateBackingStoreIfNeeded):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
+
 2011-12-08  Simon Fraser  <simon.fraser@apple.com>
 
         Forced compositing mode breaks display of full-page PDFs in WK2
index fbd7dccf032f4acb6d0263547d502d5f5223d08a..ba36bc22520f599ba3594bbf32ac328bb0c0d273 100644 (file)
@@ -314,6 +314,7 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
 void QQuickWebPagePrivate::resetPaintNode()
 {
     m_paintNode = 0;
+    pageProxy->purgeGLResources();
 }
 
 QQuickWebPagePrivate::~QQuickWebPagePrivate()
index 0b0e040ea45d8b1e90cba451252ee26fd1911925..efc2e0285c340893c7c693bae051ae30dfb25d1b 100644 (file)
@@ -71,6 +71,9 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport, WKContextRef
 
     // Creates a page with the page creation parameters.
     pageProxy->init(eventHandler.data());
+
+    // Trigger setting of correct visibility flags after everything was allocated and initialized.
+    _q_onVisibleChanged();
 }
 
 QQuickWebViewPrivate::~QQuickWebViewPrivate()
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html b/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html
new file mode 100644 (file)
index 0000000..2fd9141
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Testing direct image layer optimisation</title>
+  <style type="text/css" media="screen">
+    img {
+      float: left;
+      width: 150px;
+      height: 150px;
+    }
+    img {
+      -webkit-transform: rotate3d(0, 0, 1, 0);
+    }
+    .test {
+      float: left;
+      height: 200px;
+      width: 260px;
+    }
+   </style>
+</head>
+<body>
+
+  <h1>Image optimisation in layers</h1>
+
+  <p>
+    This test exercises direct compositing of images with hardware acceleration. The visual results
+    using ACCELERATED_COMPOSITING and regular TOT should be identical. Running this test manually with
+    the correct debug options will show which elements are directly composited. See
+    <a href="https://bugs.webkit.org/show_bug.cgi?id=23361">https://bugs.webkit.org/show_bug.cgi?id=23361</a>
+  </p>
+
+  <div class="test">
+    <img src="resources/simple_image.png">
+    Basic image - no style - can be directly composited
+  </div>
+
+  <div class="test">
+    <img src="resources/simple_image.png" style="border: 5px solid blue;">
+    5px blue border - can NOT be directly composited
+  </div>
+
+  <div class="test">
+    <img src="resources/simple_image.png" style="margin: 5px 5px;">
+    margin - can NOT be directly composited
+  </div>
+
+  <div class="test">
+    <img src="resources/simple_image.png" style="background-color: grey;">
+    solid background - can be directly composited
+  </div>
+
+  <div class="test">
+    <img src="resources/simple_image.png" style="background: orange url(resources/simple_image.png) -50px -50px;">
+    background image - can NOT be directly composited
+  </div>
+
+  <div class="test">
+    <img src="resources/simple_image.png" style="-webkit-transform: rotate3d(0, 0, 1, 10deg);">
+    rotated but otherwise no style - can be directly composited
+  </div>
+
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png
new file mode 100644 (file)
index 0000000..4685399
Binary files /dev/null and b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png differ
index 2ef9d1c36d9f29b2a9f2872af3661a8f57a37cea..a924218e09b705973f1425625aee375308a0659e 100644 (file)
@@ -50,6 +50,7 @@ private slots:
 
     void show();
     void showWebView();
+    void removeFromCanvas();
 
 private:
     inline QQuickWebView* webView() const;
@@ -244,7 +245,7 @@ void tst_QQuickWebView::showWebView()
 {
     webView()->setSize(QSizeF(300, 400));
 
-    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html")));
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/direct-image-compositing.html")));
     QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
 
     m_window->show();
@@ -255,6 +256,20 @@ void tst_QQuickWebView::showWebView()
     QTest::qWait(200);
 }
 
+void tst_QQuickWebView::removeFromCanvas()
+{
+    showWebView();
+
+    // This should not crash.
+    QQuickItem* parent = webView()->parentItem();
+    QQuickItem noCanvasItem;
+    webView()->setParentItem(&noCanvasItem);
+    QTest::qWait(200);
+    webView()->setParentItem(parent);
+    webView()->setVisible(true);
+    QTest::qWait(200);
+}
+
 void tst_QQuickWebView::scrollRequest()
 {
     webView()->setSize(QSizeF(300, 400));
index eb574988fe1d4ead6861d81695439371b6885834..2f5832287026cabfd099ef94e200a90f23ca2926 100644 (file)
@@ -88,6 +88,7 @@ public:
     virtual WebCore::IntRect contentsRect() const;
     virtual bool isBackingStoreReady() const { return true; }
     virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity) { }
+    LayerTreeHostProxy* layerTreeHostProxy() const { return m_layerTreeHostProxy.get(); }
 
 #if USE(TILED_BACKING_STORE)
     virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale) { }
index 9ce0dd915966d3aec7fd792f053f512eb40dadff..871e3bf09de02825301aeedfcbe8fa95b09ea509 100644 (file)
@@ -55,6 +55,7 @@ public:
     void setRootCompositingLayer(WebLayerID);
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     void paintToCurrentGLContext(const TransformationMatrix&, float);
+    void purgeGLResources();
     void setVisibleContentsRectAndScale(const IntRect&, float);
     void setVisibleContentRectTrajectoryVector(const FloatPoint&);
 #if USE(TILED_BACKING_STORE)
index 8558457644eecbf3f10b90febb68556ca15e2b15..a1dd272a75d22322c84d55adc228b3ae123bdee7 100644 (file)
@@ -619,5 +619,17 @@ void LayerTreeHostProxy::setVisibleContentsRectAndScale(const IntRect& rect, flo
     m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectAndScale(rect, scale), m_drawingAreaProxy->page()->pageID());
 }
 
+void LayerTreeHostProxy::purgeGLResources()
+{
+    TextureMapperNode* node = toTextureMapperNode(rootLayer());
+
+    node->purgeNodeTexturesRecursive();
+    m_directlyCompositedImages.clear();
+
+    m_textureMapper.clear();
+
+    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
+}
+
 }
 #endif
index 3d1d2b8036e3522f1e4558016f36181fe23bf3ff..f5c966a87e54bfd2ee5d32a34615c25c1f9ddfed 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "DownloadProxy.h"
 #include "DrawingAreaProxyImpl.h"
+#include "LayerTreeHostProxy.h"
 #include "qwkhistory.h"
 #include "qwkhistory_p.h"
 #include "QtDownloadManager.h"
@@ -426,6 +427,13 @@ void QtWebPageProxy::renderToCurrentGLContext(const TransformationMatrix& transf
         drawingArea->paintToCurrentGLContext(transform, opacity);
 }
 
+void QtWebPageProxy::purgeGLResources()
+{
+    DrawingAreaProxy* drawingArea = m_webPageProxy->drawingArea();
+    if (drawingArea && drawingArea->layerTreeHostProxy())
+        drawingArea->layerTreeHostProxy()->purgeGLResources();
+}
+
 void QtWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
 {
     if (!m_webPageProxy->drawingArea())
index 1e458038f797696401ee1ae67fd91f11e21424a4..ed487aa006faa0df205cc97452cc80303ef5be51 100644 (file)
@@ -137,6 +137,7 @@ public:
     void setVisibleContentRectAndScale(const QRectF&, float);
     void setVisibleContentRectTrajectoryVector(const QPointF&);
     void renderToCurrentGLContext(const WebCore::TransformationMatrix&, float);
+    void purgeGLResources();
 
     QWKHistory* history() const;
 
index 58bd12c7315785bfd6fea574e38561d47641b7e2..9220c5c30dfd180ead2df3bb4aa4a26bc0b35992 100644 (file)
@@ -368,6 +368,7 @@ void WebGraphicsLayer::setNeedsDisplay()
 
 void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
 {
+    recreateBackingStoreIfNeeded();
     m_mainBackingStore->invalidate(IntRect(rect));
     notifyChange();
 }
@@ -574,6 +575,38 @@ void WebGraphicsLayer::updateContentBuffers()
     m_inUpdateMode = false;
 }
 
+void WebGraphicsLayer::purgeBackingStores()
+{
+    for (size_t i = 0; i < children().size(); ++i) {
+        WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
+        layer->purgeBackingStores();
+    }
+
+    if (m_mainBackingStore)
+        m_mainBackingStore.clear();
+
+    if (!m_layerInfo.imageBackingStoreID)
+        return;
+
+    layerTreeTileClient()->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_mainBackingStore) {
+        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
+        m_mainBackingStore->setContentsScale(m_contentsScale);
+    }
+
+    if (m_image)
+        setContentsNeedsDisplay();
+}
 #endif
 
 static PassOwnPtr<GraphicsLayer> createWebGraphicsLayer(GraphicsLayerClient* client)
index ac0558edac0b63e03e9fe8c7ec4e0de812b25ea0..52955de1e7b7d645797bd6af76c0cac2ad422af0 100644 (file)
@@ -131,6 +131,8 @@ public:
     void updateTileBuffersRecursively();
     void setContentsScale(float);
     void updateContentBuffers();
+    void purgeBackingStores();
+    void recreateBackingStoreIfNeeded();
 #endif
 
 private:
index 9860a7a06e18ba1c914ac21d92cefdcb7f4c2e3d..61fbe2fc3475cda49145bd21e82c8baf44735d2d 100644 (file)
@@ -84,6 +84,7 @@ public:
     virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&) { }
     virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&) { }
     virtual void renderNextFrame() { }
+    virtual void purgeBackingStores() { }
     virtual void didReceiveLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
 #endif
 
index 6b9139c1d27dbd11728d407fb3426cfdeb476d7a..d2e9c384e24b8df3bc17c1a0dcea2fdd3070fb9c 100644 (file)
@@ -24,5 +24,6 @@ messages -> LayerTreeHost {
     SetVisibleContentRectTrajectoryVector(WebCore::FloatPoint trajectoryVectory)
     SetVisibleContentRectAndScale(WebCore::IntRect contentRect, float scale)
     RenderNextFrame()
+    PurgeBackingStores()
 }
 #endif
index 12a1b99c188e12965feff133dd2b0ddfbc466211..266a3a95dd0bc9a572e74a6546fe6e10b103624f 100644 (file)
@@ -66,6 +66,7 @@ LayerTreeHostQt::LayerTreeHostQt(WebPage* webPage)
     , m_shouldSyncRootLayer(true)
     , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
     , m_layerFlushSchedulingEnabled(true)
+    , m_shouldRecreateBackingStore(false)
 {
     // Create a root layer.
     m_rootLayer = GraphicsLayer::create(this);
@@ -212,6 +213,8 @@ void LayerTreeHostQt::setPageOverlayNeedsDisplay(const WebCore::IntRect& rect)
 
 bool LayerTreeHostQt::flushPendingLayerChanges()
 {
+    recreateBackingStoreIfNeeded();
+
     bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
     m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
     if (m_pageOverlayLayer)
@@ -427,6 +430,24 @@ bool LayerTreeHostQt::layerTreeTileUpdatesAllowed() const
     return !m_isSuspended && !m_waitingForUIProcess;
 }
 
+void LayerTreeHostQt::purgeBackingStores()
+{
+    m_shouldRecreateBackingStore = true;
+    WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
+    webRootLayer->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
index 31011c6a5d7179b189f2a7eddcdca1a61304bb6d..8527c528b8b7032caad102e5811c375c68250f9c 100644 (file)
@@ -71,6 +71,7 @@ public:
     virtual void removeTile(WebLayerID, int tileID);
     virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&);
     virtual void renderNextFrame();
+    virtual void purgeBackingStores();
     virtual bool layerTreeTileUpdatesAllowed() const;
     virtual void setVisibleContentRectAndScale(const IntRect&, float scale);
     virtual void setVisibleContentRectTrajectoryVector(const FloatPoint&);
@@ -96,6 +97,7 @@ private:
     void cancelPendingLayerFlush();
     void performScheduledLayerFlush();
     void sendLayersToUI();
+    void recreateBackingStoreIfNeeded();
 
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
 
@@ -119,6 +121,7 @@ private:
     void layerFlushTimerFired(WebCore::Timer<LayerTreeHostQt>*);
     WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer;
     bool m_layerFlushSchedulingEnabled;
+    bool m_shouldRecreateBackingStore;
 };
 
 }