Title: [108501] trunk/Source
Revision
108501
Author
[email protected]
Date
2012-02-22 07:15:10 -0800 (Wed, 22 Feb 2012)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108500 => 108501)


--- trunk/Source/WebCore/ChangeLog	2012-02-22 15:12:10 UTC (rev 108500)
+++ trunk/Source/WebCore/ChangeLog	2012-02-22 15:15:10 UTC (rev 108501)
@@ -1,3 +1,23 @@
+2012-02-22  Kenneth Rohde Christiansen  <[email protected]>
+
+        [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.
+
+        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):
+
 2012-02-22  Simon Hausmann  <[email protected]>
 
         [Qt] Move QMenu dependant scrollbar context menu handling out of WebCore

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp (108500 => 108501)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-02-22 15:12:10 UTC (rev 108500)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-02-22 15:15:10 UTC (rev 108501)
@@ -164,7 +164,7 @@
     context->restore();
 }
 
-IntRect TiledBackingStore::visibleContentsRect()
+IntRect TiledBackingStore::visibleContentsRect() const
 {
     return mapFromContents(intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect()));
 }
@@ -203,7 +203,7 @@
 }
 
 // Returns a ratio between 0.0f and 1.0f of the surface of contentsRect covered by rendered tiles.
-float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect)
+float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) const
 {
     IntRect dirtyRect = mapFromContents(contentsRect);
     float rectArea = dirtyRect.width() * dirtyRect.height();
@@ -225,6 +225,11 @@
     return coverArea / rectArea;
 }
 
+bool TiledBackingStore::visibleAreaIsCovered() const
+{
+    return coverageRatio(visibleContentsRect()) == 1.0f;
+}
+
 void TiledBackingStore::createTiles()
 {
     if (m_contentsFrozen)
@@ -259,7 +264,7 @@
             if (tileAt(currentCoordinate))
                 continue;
             ++requiredTileCount;
-            // Distance is 0 for all currently visible tiles.
+            // Distance is 0 for all tiles inside the visibleRect.
             double distance = tileDistance(visibleRect, currentCoordinate);
             if (distance > shortestDistance)
                 continue;
@@ -402,6 +407,11 @@
         removeTile(toRemove[n]);
 }
 
+void TiledBackingStore::removeAllNonVisibleTiles()
+{
+    dropTilesOutsideRect(visibleContentsRect());
+}
+
 PassRefPtr<Tile> TiledBackingStore::tileAt(const Tile::Coordinate& coordinate) const
 {
     return m_tiles.get(coordinate);

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.h (108500 => 108501)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-02-22 15:12:10 UTC (rev 108500)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-02-22 15:15:10 UTC (rev 108501)
@@ -53,6 +53,7 @@
 
     bool contentsFrozen() const { return m_contentsFrozen; }
     void setContentsFrozen(bool);
+
     void updateTileBuffers();
 
     void invalidate(const IntRect& dirtyRect);
@@ -70,37 +71,41 @@
     IntRect tileRectForCoordinate(const Tile::Coordinate&) const;
     Tile::Coordinate tileCoordinateForPoint(const IntPoint&) const;
     double tileDistance(const IntRect& viewport, const Tile::Coordinate&) const;
-    float coverageRatio(const WebCore::IntRect& contentsRect);
 
+    bool visibleAreaIsCovered() const;
+    void removeAllNonVisibleTiles();
+
     void setSupportsAlpha(bool);
     bool supportsAlpha() const { return m_supportsAlpha; }
 
 private:
     void startTileBufferUpdateTimer();
     void startTileCreationTimer();
-    
+
     typedef Timer<TiledBackingStore> TileTimer;
 
     void tileBufferUpdateTimerFired(TileTimer*);
     void tileCreationTimerFired(TileTimer*);
-    
+
     void createTiles();
     void computeCoverAndKeepRect(const IntRect& visibleRect, IntRect& coverRect, IntRect& keepRect) const;
-    
+
     void commitScaleChange();
 
     bool resizeEdgeTiles();
     void dropTilesOutsideRect(const IntRect&);
-    
+
     PassRefPtr<Tile> tileAt(const Tile::Coordinate&) const;
     void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
     void removeTile(const Tile::Coordinate& coordinate);
 
+    IntRect contentsRect() const;
+    IntRect visibleContentsRect() const;
+
+    float coverageRatio(const IntRect&) const;
     void adjustForContentsRect(IntRect&) const;
-    IntRect contentsRect() const;
-    
+
     void paintCheckerPattern(GraphicsContext*, const IntRect&, const Tile::Coordinate&);
-    IntRect visibleContentsRect();
 
 private:
     TiledBackingStoreClient* m_client;

Modified: trunk/Source/WebKit2/ChangeLog (108500 => 108501)


--- trunk/Source/WebKit2/ChangeLog	2012-02-22 15:12:10 UTC (rev 108500)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-22 15:15:10 UTC (rev 108501)
@@ -1,3 +1,27 @@
+2012-02-22  Kenneth Rohde Christiansen  <[email protected]>
+
+        [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.
+
+        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):
+
 2012-02-22  Michael BrĂ¼ning  <[email protected]>
 
         [Qt][WK2] Implement proxy authentication handling.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (108500 => 108501)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-02-22 15:12:10 UTC (rev 108500)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-02-22 15:15:10 UTC (rev 108501)
@@ -488,10 +488,20 @@
 void WebGraphicsLayer::setContentsScale(float scale)
 {
     m_contentsScale = scale;
-    if (m_mainBackingStore && m_mainBackingStore->contentsScale() != scale) {
-        m_previousBackingStore = m_mainBackingStore.release();
-        createBackingStore();
-    }
+
+    if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == scale)
+        return;
+
+    // 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.
+    m_previousBackingStore = m_mainBackingStore.release();
+
+    // No reason to save the previous backing store for non-visible areas.
+    m_previousBackingStore->removeAllNonVisibleTiles();
+
+    createBackingStore();
 }
 
 void WebGraphicsLayer::createBackingStore()
@@ -582,12 +592,18 @@
     }
 
     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.
+    // 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)
         createBackingStore();
     m_mainBackingStore->updateTileBuffers();
     m_inUpdateMode = false;
+
+    // The previous backing store is kept around to avoid flickering between
+    // removing the existing tiles and painting the new ones. The first time
+    // the visibleRect is full painted we remove the previous backing store.
+    if (m_mainBackingStore->visibleAreaIsCovered())
+        m_previousBackingStore.clear();
 }
 
 void WebGraphicsLayer::purgeBackingStores()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to