Changeset 102435 in webkit


Ignore:
Timestamp:
Dec 8, 2011 10:54:09 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deallocated.
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:
Location:
trunk/Source
Files:
3 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102433 r102435  
     12011-12-08  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
     2
     3        [Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deallocated.
     4        https://bugs.webkit.org/show_bug.cgi?id=73591
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Implementation of helper function to remove all GL allocated tiles
     9        when QQuickWebView gets removed from canvas.
     10
     11        Tested by new API test in WK2 (tst_QQuickWebView::removeFromCanvas).
     12
     13        * platform/graphics/texmap/TextureMapperNode.cpp:
     14        (WebCore::TextureMapperNode::purgeNodeTexturesRecursive):
     15        * platform/graphics/texmap/TextureMapperNode.h:
     16
    1172011-12-08  Leo Yang  <leo.yang@torchmobile.com.cn>
    218
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.cpp

    r102113 r102435  
    615615{
    616616    m_externallyManagedTiles.remove(id);
     617}
     618
     619void TextureMapperNode::purgeNodeTexturesRecursive()
     620{
     621    m_externallyManagedTiles.clear();
     622
     623    for (int i = m_children.size() - 1; i >= 0; --i)
     624        m_children[i]->purgeNodeTexturesRecursive();
    617625}
    618626
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperNode.h

    r100922 r102435  
    159159    void clearAllDirectlyCompositedImageTiles();
    160160    bool collectVisibleContentsRects(NodeRectMap&, const FloatRect&);
     161    void purgeNodeTexturesRecursive();
    161162#endif
    162163    void setID(int id) { m_id = id; }
  • trunk/Source/WebKit2/ChangeLog

    r102407 r102435  
     12011-12-08  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
     2
     3        [Qt] [WK2] Webkit should release TextureMapper GL objects if page paint node is deallocated.
     4        https://bugs.webkit.org/show_bug.cgi?id=73591
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Implement deallocation of TextureMapper GL objects when QQuickWebPage paint node deallocated.
     9        Also adds purging GraphicsLayer backing stores on WebProcess side in order to force repainting
     10        when page becomes visible and painting resumes and fixes incorrect initialization of view
     11        visibility state.
     12
     13        * UIProcess/API/qt/qquickwebpage.cpp:
     14        (QQuickWebPagePrivate::resetPaintNode):
     15        * UIProcess/API/qt/qquickwebview.cpp:
     16        (QQuickWebViewPrivate::QQuickWebViewPrivate):
     17        * UIProcess/API/qt/tests/html/direct-image-compositing.html: Added.
     18        * UIProcess/API/qt/tests/html/resources/simple_image.png: Added.
     19        * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
     20        (tst_QQuickWebView::showWebView):
     21        (tst_QQuickWebView::removeFromCanvas):
     22        * UIProcess/DrawingAreaProxy.h:
     23        (WebKit::DrawingAreaProxy::layerTreeHostProxy):
     24        * UIProcess/LayerTreeHostProxy.h:
     25        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
     26        (WebKit::LayerTreeHostProxy::purgeGLResources):
     27        * UIProcess/qt/QtWebPageProxy.cpp:
     28        (QtWebPageProxy::purgeGLResources):
     29        * UIProcess/qt/QtWebPageProxy.h:
     30        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
     31        (WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
     32        (WebCore::WebGraphicsLayer::purgeBackingStores):
     33        (WebCore::WebGraphicsLayer::recreateBackingStoreIfNeeded):
     34        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
     35        * WebProcess/WebPage/LayerTreeHost.h:
     36        (WebKit::LayerTreeHost::purgeBackingStores):
     37        * WebProcess/WebPage/LayerTreeHost.messages.in:
     38        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
     39        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
     40        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
     41        (WebKit::LayerTreeHostQt::purgeBackingStores):
     42        (WebKit::LayerTreeHostQt::recreateBackingStoreIfNeeded):
     43        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
     44
    1452011-12-08  Simon Fraser  <simon.fraser@apple.com>
    246
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp

    r102337 r102435  
    315315{
    316316    m_paintNode = 0;
     317    pageProxy->purgeGLResources();
    317318}
    318319
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp

    r102340 r102435  
    7272    // Creates a page with the page creation parameters.
    7373    pageProxy->init(eventHandler.data());
     74
     75    // Trigger setting of correct visibility flags after everything was allocated and initialized.
     76    _q_onVisibleChanged();
    7477}
    7578
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp

    r102035 r102435  
    5151    void show();
    5252    void showWebView();
     53    void removeFromCanvas();
    5354
    5455private:
     
    245246    webView()->setSize(QSizeF(300, 400));
    246247
    247     webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html")));
     248    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/direct-image-compositing.html")));
    248249    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
    249250
     
    256257}
    257258
     259void tst_QQuickWebView::removeFromCanvas()
     260{
     261    showWebView();
     262
     263    // This should not crash.
     264    QQuickItem* parent = webView()->parentItem();
     265    QQuickItem noCanvasItem;
     266    webView()->setParentItem(&noCanvasItem);
     267    QTest::qWait(200);
     268    webView()->setParentItem(parent);
     269    webView()->setVisible(true);
     270    QTest::qWait(200);
     271}
     272
    258273void tst_QQuickWebView::scrollRequest()
    259274{
  • trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h

    r102407 r102435  
    8989    virtual bool isBackingStoreReady() const { return true; }
    9090    virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity) { }
     91    LayerTreeHostProxy* layerTreeHostProxy() const { return m_layerTreeHostProxy.get(); }
    9192
    9293#if USE(TILED_BACKING_STORE)
  • trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h

    r100922 r102435  
    5656    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
    5757    void paintToCurrentGLContext(const TransformationMatrix&, float);
     58    void purgeGLResources();
    5859    void setVisibleContentsRectAndScale(const IntRect&, float);
    5960    void setVisibleContentRectTrajectoryVector(const FloatPoint&);
  • trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp

    r102336 r102435  
    620620}
    621621
     622void LayerTreeHostProxy::purgeGLResources()
     623{
     624    TextureMapperNode* node = toTextureMapperNode(rootLayer());
     625
     626    node->purgeNodeTexturesRecursive();
     627    m_directlyCompositedImages.clear();
     628
     629    m_textureMapper.clear();
     630
     631    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
     632}
     633
    622634}
    623635#endif
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r102035 r102435  
    3434#include "DownloadProxy.h"
    3535#include "DrawingAreaProxyImpl.h"
     36#include "LayerTreeHostProxy.h"
    3637#include "qwkhistory.h"
    3738#include "qwkhistory_p.h"
     
    427428}
    428429
     430void QtWebPageProxy::purgeGLResources()
     431{
     432    DrawingAreaProxy* drawingArea = m_webPageProxy->drawingArea();
     433    if (drawingArea && drawingArea->layerTreeHostProxy())
     434        drawingArea->layerTreeHostProxy()->purgeGLResources();
     435}
     436
    429437void QtWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
    430438{
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r102035 r102435  
    138138    void setVisibleContentRectTrajectoryVector(const QPointF&);
    139139    void renderToCurrentGLContext(const WebCore::TransformationMatrix&, float);
     140    void purgeGLResources();
    140141
    141142    QWKHistory* history() const;
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp

    r102342 r102435  
    369369void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
    370370{
     371    recreateBackingStoreIfNeeded();
    371372    m_mainBackingStore->invalidate(IntRect(rect));
    372373    notifyChange();
     
    575576}
    576577
     578void WebGraphicsLayer::purgeBackingStores()
     579{
     580    for (size_t i = 0; i < children().size(); ++i) {
     581        WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
     582        layer->purgeBackingStores();
     583    }
     584
     585    if (m_mainBackingStore)
     586        m_mainBackingStore.clear();
     587
     588    if (!m_layerInfo.imageBackingStoreID)
     589        return;
     590
     591    layerTreeTileClient()->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
     592    m_layerInfo.imageBackingStoreID = 0;
     593}
     594
     595void WebGraphicsLayer::recreateBackingStoreIfNeeded()
     596{
     597    for (size_t i = 0; i < children().size(); ++i) {
     598        WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
     599        layer->recreateBackingStoreIfNeeded();
     600    }
     601
     602    if (!m_mainBackingStore) {
     603        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
     604        m_mainBackingStore->setContentsScale(m_contentsScale);
     605    }
     606
     607    if (m_image)
     608        setContentsNeedsDisplay();
     609}
    577610#endif
    578611
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h

    r97639 r102435  
    132132    void setContentsScale(float);
    133133    void updateContentBuffers();
     134    void purgeBackingStores();
     135    void recreateBackingStoreIfNeeded();
    134136#endif
    135137
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h

    r97639 r102435  
    8585    virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&) { }
    8686    virtual void renderNextFrame() { }
     87    virtual void purgeBackingStores() { }
    8788    virtual void didReceiveLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
    8889#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.messages.in

    r97639 r102435  
    2525    SetVisibleContentRectAndScale(WebCore::IntRect contentRect, float scale)
    2626    RenderNextFrame()
     27    PurgeBackingStores()
    2728}
    2829#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp

    r102156 r102435  
    6767    , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
    6868    , m_layerFlushSchedulingEnabled(true)
     69    , m_shouldRecreateBackingStore(false)
    6970{
    7071    // Create a root layer.
     
    213214bool LayerTreeHostQt::flushPendingLayerChanges()
    214215{
     216    recreateBackingStoreIfNeeded();
     217
    215218    bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
    216219    m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
     
    428431}
    429432
     433void LayerTreeHostQt::purgeBackingStores()
     434{
     435    m_shouldRecreateBackingStore = true;
     436    WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
     437    webRootLayer->purgeBackingStores();
     438
     439    ASSERT(!m_directlyCompositedImageRefCounts.size());
     440}
     441
     442void LayerTreeHostQt::recreateBackingStoreIfNeeded()
     443{
     444    if (!m_shouldRecreateBackingStore)
     445        return;
     446
     447    m_shouldRecreateBackingStore = false;
     448    WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
     449    webRootLayer->recreateBackingStoreIfNeeded();
     450}
    430451#endif
    431452
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h

    r97639 r102435  
    7272    virtual void setVisibleContentRectForLayer(int layerID, const WebCore::IntRect&);
    7373    virtual void renderNextFrame();
     74    virtual void purgeBackingStores();
    7475    virtual bool layerTreeTileUpdatesAllowed() const;
    7576    virtual void setVisibleContentRectAndScale(const IntRect&, float scale);
     
    9798    void performScheduledLayerFlush();
    9899    void sendLayersToUI();
     100    void recreateBackingStoreIfNeeded();
    99101
    100102    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
     
    120122    WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer;
    121123    bool m_layerFlushSchedulingEnabled;
     124    bool m_shouldRecreateBackingStore;
    122125};
    123126
Note: See TracChangeset for help on using the changeset viewer.