Changeset 108501 in webkit


Ignore:
Timestamp:
Feb 22, 2012, 7:15:10 AM (14 years ago)
Author:
kenneth@webkit.org
Message:

[Qt] Disregard previous backing store as soon as possible https://bugs.webkit.org/show_bug.cgi?id=79232

Reviewed by Simon Hausmann and No'am Rosenthal.

Source/WebCore:

Make it possible to drop non-visible tiles and to test
if the current visible rect is fully covered.

  • platform/graphics/TiledBackingStore.cpp:

(WebCore::TiledBackingStore::visibleContentsRect):
(WebCore::TiledBackingStore::coverageRatio):
(WebCore::TiledBackingStore::visibleAreaIsCovered):
(WebCore):
(WebCore::TiledBackingStore::createTiles):
(WebCore::TiledBackingStore::removeAllNonVisibleTiles):

  • platform/graphics/TiledBackingStore.h:

(TiledBackingStore):

Source/WebKit2:

Between creating the new backing store and painting the content,
we do not want to drop the previous one as that might result in
briefly seeing flickering as the old tiles may be dropped before
something replaces them.

But we do need to drop it at some point and we need to make sure
to not spike the memory usage before of this.

What we now do, is to store the previous backing store as before,
but drop all tiles which are not visible and then drop it as soon
as the visible rect (which might change due if followed by a quick
panning) has been fully covered by tiles.

  • WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:

(WebCore::WebGraphicsLayer::setContentsScale):
(WebCore::WebGraphicsLayer::updateContentBuffers):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108498 r108501  
     12012-02-22  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        [Qt] Disregard previous backing store as soon as possible
     4        https://bugs.webkit.org/show_bug.cgi?id=79232
     5
     6        Reviewed by Simon Hausmann and No'am Rosenthal.
     7
     8        Make it possible to drop non-visible tiles and to test
     9        if the current visible rect is fully covered.
     10
     11        * platform/graphics/TiledBackingStore.cpp:
     12        (WebCore::TiledBackingStore::visibleContentsRect):
     13        (WebCore::TiledBackingStore::coverageRatio):
     14        (WebCore::TiledBackingStore::visibleAreaIsCovered):
     15        (WebCore):
     16        (WebCore::TiledBackingStore::createTiles):
     17        (WebCore::TiledBackingStore::removeAllNonVisibleTiles):
     18        * platform/graphics/TiledBackingStore.h:
     19        (TiledBackingStore):
     20
    1212012-02-22  Simon Hausmann  <simon.hausmann@nokia.com>
    222
  • trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp

    r108491 r108501  
    165165}
    166166
    167 IntRect TiledBackingStore::visibleContentsRect()
     167IntRect TiledBackingStore::visibleContentsRect() const
    168168{
    169169    return mapFromContents(intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect()));
     
    204204
    205205// Returns a ratio between 0.0f and 1.0f of the surface of contentsRect covered by rendered tiles.
    206 float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect)
     206float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) const
    207207{
    208208    IntRect dirtyRect = mapFromContents(contentsRect);
     
    226226}
    227227
     228bool TiledBackingStore::visibleAreaIsCovered() const
     229{
     230    return coverageRatio(visibleContentsRect()) == 1.0f;
     231}
     232
    228233void TiledBackingStore::createTiles()
    229234{
     
    260265                continue;
    261266            ++requiredTileCount;
    262             // Distance is 0 for all currently visible tiles.
     267            // Distance is 0 for all tiles inside the visibleRect.
    263268            double distance = tileDistance(visibleRect, currentCoordinate);
    264269            if (distance > shortestDistance)
     
    403408}
    404409
     410void TiledBackingStore::removeAllNonVisibleTiles()
     411{
     412    dropTilesOutsideRect(visibleContentsRect());
     413}
     414
    405415PassRefPtr<Tile> TiledBackingStore::tileAt(const Tile::Coordinate& coordinate) const
    406416{
  • trunk/Source/WebCore/platform/graphics/TiledBackingStore.h

    r108491 r108501  
    5454    bool contentsFrozen() const { return m_contentsFrozen; }
    5555    void setContentsFrozen(bool);
     56
    5657    void updateTileBuffers();
    5758
     
    7172    Tile::Coordinate tileCoordinateForPoint(const IntPoint&) const;
    7273    double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const;
    73     float coverageRatio(const WebCore::IntRect& contentsRect);
     74
     75    bool visibleAreaIsCovered() const;
     76    void removeAllNonVisibleTiles();
    7477
    7578    void setSupportsAlpha(bool);
     
    7982    void startTileBufferUpdateTimer();
    8083    void startTileCreationTimer();
    81    
     84
    8285    typedef Timer<TiledBackingStore> TileTimer;
    8386
    8487    void tileBufferUpdateTimerFired(TileTimer*);
    8588    void tileCreationTimerFired(TileTimer*);
    86    
     89
    8790    void createTiles();
    8891    void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
    89    
     92
    9093    void commitScaleChange();
    9194
    9295    bool resizeEdgeTiles();
    9396    void dropTilesOutsideRect(const IntRect&);
    94    
     97
    9598    PassRefPtr<Tile> tileAt(const Tile::Coordinate&) const;
    9699    void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
    97100    void removeTile(const Tile::Coordinate& coordinate);
    98101
     102    IntRect contentsRect() const;
     103    IntRect visibleContentsRect() const;
     104
     105    float coverageRatio(const IntRect&) const;
    99106    void adjustForContentsRect(IntRect&) const;
    100     IntRect contentsRect() const;
    101    
     107
    102108    void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
    103     IntRect visibleContentsRect();
    104109
    105110private:
  • trunk/Source/WebKit2/ChangeLog

    r108499 r108501  
     12012-02-22  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        [Qt] Disregard previous backing store as soon as possible
     4        https://bugs.webkit.org/show_bug.cgi?id=79232
     5
     6        Reviewed by Simon Hausmann and No'am Rosenthal.
     7
     8        Between creating the new backing store and painting the content,
     9        we do not want to drop the previous one as that might result in
     10        briefly seeing flickering as the old tiles may be dropped before
     11        something replaces them.
     12
     13        But we do need to drop it at some point and we need to make sure
     14        to not spike the memory usage before of this.
     15
     16        What we now do, is to store the previous backing store as before,
     17        but drop all tiles which are not visible and then drop it as soon
     18        as the visible rect (which might change due if followed by a quick
     19        panning) has been fully covered by tiles.
     20
     21        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
     22        (WebCore::WebGraphicsLayer::setContentsScale):
     23        (WebCore::WebGraphicsLayer::updateContentBuffers):
     24
    1252012-02-22  Michael Brüning  <michael.bruning@nokia.com>
    226
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp

    r108491 r108501  
    489489{
    490490    m_contentsScale = scale;
    491     if (m_mainBackingStore && m_mainBackingStore->contentsScale() != scale) {
    492         m_previousBackingStore = m_mainBackingStore.release();
    493         createBackingStore();
    494     }
     491
     492    if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == scale)
     493        return;
     494
     495    // Between creating the new backing store and painting the content,
     496    // we do not want to drop the previous one as that might result in
     497    // briefly seeing flickering as the old tiles may be dropped before
     498    // something replaces them.
     499    m_previousBackingStore = m_mainBackingStore.release();
     500
     501    // No reason to save the previous backing store for non-visible areas.
     502    m_previousBackingStore->removeAllNonVisibleTiles();
     503
     504    createBackingStore();
    495505}
    496506
     
    583593
    584594    m_inUpdateMode = true;
    585     // This is the only place we (re)create the main tiled backing store,
    586     // once we have a remote client and we are ready to send our data to the UI process.
     595    // This is the only place we (re)create the main tiled backing store, once we
     596    // have a remote client and we are ready to send our data to the UI process.
    587597    if (!m_mainBackingStore)
    588598        createBackingStore();
    589599    m_mainBackingStore->updateTileBuffers();
    590600    m_inUpdateMode = false;
     601
     602    // The previous backing store is kept around to avoid flickering between
     603    // removing the existing tiles and painting the new ones. The first time
     604    // the visibleRect is full painted we remove the previous backing store.
     605    if (m_mainBackingStore->visibleAreaIsCovered())
     606        m_previousBackingStore.clear();
    591607}
    592608
Note: See TracChangeset for help on using the changeset viewer.