Changeset 107236 in webkit


Ignore:
Timestamp:
Feb 9, 2012 6:38:44 AM (12 years ago)
Author:
jocelyn.turcotte@nokia.com
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):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r107234 r107236  
     12012-02-09  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        [Qt] Control the lifetime of TiledBackingStores in WebGraphicsLayer.
     4        https://bugs.webkit.org/show_bug.cgi?id=78005
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This makes sure that no empty tiles are generated for layers without contents and that
     9        no interaction is made with the TiledBackingStore until we got a WebGraphicsLayerClient.
     10
     11        - Create the main TiledBackingStore only when the layer has drawsContent and has no
     12          directly composited image
     13        - Removed recreateBackingStoreIfNeeded and do the (re)creation of the backing stores
     14          in updateContentBuffers
     15        - Call purgeBackingStores on registered layers instead of passing it down the layer tree
     16
     17        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
     18        (WebCore::WebGraphicsLayer::WebGraphicsLayer):
     19        (WebCore::WebGraphicsLayer::~WebGraphicsLayer):
     20        (WebCore::WebGraphicsLayer::setDrawsContent):
     21        (WebCore::WebGraphicsLayer::setNeedsDisplayInRect):
     22        (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
     23        (WebCore::WebGraphicsLayer::setVisibleContentRectTrajectoryVector):
     24        (WebCore::WebGraphicsLayer::tiledBackingStoreContentsRect):
     25        (WebCore::WebGraphicsLayer::updateContentBuffers):
     26        (WebCore::WebGraphicsLayer::purgeBackingStores):
     27        (WebCore::WebGraphicsLayer::setWebGraphicsLayerClient):
     28        (WebCore::WebGraphicsLayer::computeTransformedVisibleRect):
     29        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
     30        (WebGraphicsLayer):
     31        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
     32        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
     33        (WebKit::LayerTreeHostQt::flushPendingLayerChanges):
     34        (WebKit):
     35        (WebKit::LayerTreeHostQt::purgeBackingStores):
     36        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
     37        (LayerTreeHostQt):
     38
    1392012-02-08  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    240
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp

    r107234 r107236  
    8989#if USE(TILED_BACKING_STORE)
    9090    , m_webGraphicsLayerClient(0)
    91     , m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))))
    9291    , m_contentsScale(1.f)
    9392#endif
    9493{
    95     m_mainBackingStore->setContentsScale(1.0);
    9694    static WebLayerID nextLayerID = 1;
    9795    m_layerInfo.id = nextLayerID++;
     
    103101    layerByIDMap().remove(id());
    104102
    105     // This would tell the UI process to release the backing store.
    106     setContentsToImage(0);
    107 
    108     if (m_webGraphicsLayerClient)
     103    if (m_webGraphicsLayerClient) {
     104        purgeBackingStores();
    109105        m_webGraphicsLayerClient->detachLayer(this);
     106    }
    110107}
    111108
     
    248245    GraphicsLayer::setDrawsContent(b);
    249246
    250     if (b)
    251         setNeedsDisplay();
    252247    notifyChange();
    253248}
     
    404399void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
    405400{
    406     recreateBackingStoreIfNeeded();
    407     m_mainBackingStore->invalidate(IntRect(rect));
     401    if (m_mainBackingStore)
     402        m_mainBackingStore->invalidate(IntRect(rect));
    408403    notifyChange();
    409404}
     
    463458        m_layerInfo.children.append(toWebLayerID(children()[i]));
    464459
    465     ASSERT(m_webGraphicsLayerClient);
    466     if (m_layerInfo.imageIsUpdated && m_image && !m_layerInfo.imageBackingStoreID)
    467         m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
    468 
    469460    m_webGraphicsLayerClient->didSyncCompositingStateForLayer(m_layerInfo);
    470461    m_modified = false;
     
    489480void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
    490481{
    491     m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector);
     482    if (m_mainBackingStore)
     483        m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector);
    492484}
    493485
     
    529521IntRect WebGraphicsLayer::tiledBackingStoreContentsRect()
    530522{
    531     if (!drawsContent())
    532         return IntRect();
    533523    return IntRect(0, 0, size().width(), size().height());
    534524}
     
    576566void WebGraphicsLayer::updateContentBuffers()
    577567{
    578     // Backing-stores for directly composited images is handled in LayerTreeHost.
    579     if (m_image)
    580         return;
    581 
    582     if (!drawsContent())
    583         return;
     568    // The remote image might have been released by purgeBackingStores.
     569    if (m_image) {
     570        if (!m_layerInfo.imageBackingStoreID) {
     571            m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
     572            m_layerInfo.imageIsUpdated = true;
     573        }
     574    }
     575
     576    if (!drawsContent()) {
     577        m_mainBackingStore.clear();
     578        m_previousBackingStore.clear();
     579        return;
     580    }
    584581
    585582    m_inUpdateMode = true;
    586     m_mainBackingStore->updateTileBuffers();
    587     m_inUpdateMode = false;
    588 }
    589 
    590 void WebGraphicsLayer::purgeBackingStores()
    591 {
    592     for (size_t i = 0; i < children().size(); ++i) {
    593         WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
    594         layer->purgeBackingStores();
    595     }
    596 
    597     if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer()))
    598         mask->purgeBackingStores();
    599 
    600     if (m_mainBackingStore)
    601         m_mainBackingStore.clear();
    602 
    603     if (!m_layerInfo.imageBackingStoreID)
    604         return;
    605 
    606     m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
    607     m_layerInfo.imageBackingStoreID = 0;
    608 }
    609 
    610 void WebGraphicsLayer::recreateBackingStoreIfNeeded()
    611 {
    612     for (size_t i = 0; i < children().size(); ++i) {
    613         WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]);
    614         layer->recreateBackingStoreIfNeeded();
    615     }
    616     if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer()))
    617         mask->recreateBackingStoreIfNeeded();
    618 
     583    // This is the only place we (re)create the main tiled backing store,
     584    // once we have a remote client and we are ready to send our data to the UI process.
    619585    if (!m_mainBackingStore) {
    620586        m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)));
    621587        m_mainBackingStore->setContentsScale(m_contentsScale);
    622588    }
    623 
    624     if (m_image)
    625         setContentsNeedsDisplay();
     589    m_mainBackingStore->updateTileBuffers();
     590    m_inUpdateMode = false;
     591}
     592
     593void WebGraphicsLayer::purgeBackingStores()
     594{
     595    m_mainBackingStore.clear();
     596    m_previousBackingStore.clear();
     597
     598    if (m_layerInfo.imageBackingStoreID) {
     599        m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID);
     600        m_layerInfo.imageBackingStoreID = 0;
     601    }
    626602}
    627603
     
    640616    }
    641617
    642     // Have to force detach from remote layer here if layer tile client changes.
    643     if (m_webGraphicsLayerClient)
     618    // We have to release resources on the UI process here if the remote client has changed or is removed.
     619    if (m_webGraphicsLayerClient) {
     620        purgeBackingStores();
    644621        m_webGraphicsLayerClient->detachLayer(this);
     622    }
    645623    m_webGraphicsLayerClient = client;
    646624    if (client)
     
    659637    m_layerTransform.combineTransforms(parent() ? toWebGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix());
    660638    // The combined transform will be used in tiledBackingStoreVisibleRect.
    661     m_mainBackingStore->adjustVisibleRect();
     639    if (m_mainBackingStore)
     640        m_mainBackingStore->adjustVisibleRect();
    662641}
    663642#endif
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h

    r107234 r107236  
    141141    void updateContentBuffers();
    142142    void purgeBackingStores();
    143     void recreateBackingStoreIfNeeded();
    144143#endif
    145144
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp

    r107233 r107236  
    7575    , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
    7676    , m_layerFlushSchedulingEnabled(true)
    77     , m_shouldRecreateBackingStore(false)
    7877{
    7978    // Create a root layer.
     
    222221bool LayerTreeHostQt::flushPendingLayerChanges()
    223222{
    224     recreateBackingStoreIfNeeded();
    225 
    226223    bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
    227224    m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
     
    412409    m_webPage->send(Messages::LayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, updateInfo));
    413410}
     411
    414412void LayerTreeHostQt::removeTile(WebLayerID layerID, int tileID)
    415413{
     
    448446void LayerTreeHostQt::purgeBackingStores()
    449447{
    450     m_shouldRecreateBackingStore = true;
    451     WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
    452     webRootLayer->purgeBackingStores();
     448    HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end();
     449    for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it)
     450        (*it)->purgeBackingStores();
    453451
    454452    ASSERT(!m_directlyCompositedImageRefCounts.size());
    455 }
    456 
    457 void LayerTreeHostQt::recreateBackingStoreIfNeeded()
    458 {
    459     if (!m_shouldRecreateBackingStore)
    460         return;
    461 
    462     m_shouldRecreateBackingStore = false;
    463     WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());
    464     webRootLayer->recreateBackingStoreIfNeeded();
    465453}
    466454#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h

    r107233 r107236  
    9898    void performScheduledLayerFlush();
    9999    void sendLayersToUI();
    100     void recreateBackingStoreIfNeeded();
    101100
    102101    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
     
    125124    WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer;
    126125    bool m_layerFlushSchedulingEnabled;
    127     bool m_shouldRecreateBackingStore;
    128126};
    129127
Note: See TracChangeset for help on using the changeset viewer.