Title: [134048] trunk/Source/WebCore
Revision
134048
Author
commit-qu...@webkit.org
Date
2012-11-09 04:13:25 -0800 (Fri, 09 Nov 2012)

Log Message

Coordinated Graphics: Remove a backing store of GraphicsLayer when the layer is far from the viewport.
https://bugs.webkit.org/show_bug.cgi?id=101656

Patch by Huang Dongsung <luxte...@company100.net> on 2012-11-09
Reviewed by Kenneth Rohde Christiansen.

TiledBackingStore computes cover and keep rects to create, keep or remove tiles
smartly, but currently TiledBackingStore expects a contents rect is big enough
to cover the visibleRect. However, when CoordinatedGraphicsLayer uses TBS, it
is usually wrong expectation.

We must compute cover and keep rects using the visibleRect, instead of
the rect intersecting the visibleRect with m_rect, because TBS can be
used as a backing store of GraphicsLayer and the visible rect usually
does not intersect with m_rect.
In the below case, the intersecting rect is an empty.

 +---------------+
 |               |
 |   m_rect      |
 |       +-------|-----------------------+
 |       | HERE  |  cover or keep        |
 +---------------+      rect             |
         |         +---------+           |
         |         | visible |           |
         |         |  rect   |           |
         |         +---------+           |
         |                               |
         |                               |
         +-------------------------------+

We must create or keep the tiles in the HERE region. Currently in the
case, we do not create or keep tiles on the HERE region. Moreover, in
the case, we early return, which means we don't remove any tiles. It
causes to waste heap and video memory.

This patch changes TiledBackingStore to manage tiles smartly for
Coordinated Graphics.

Changing cache policy is not testable in layout tests.

* platform/graphics/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::visibleRect):
(WebCore::TiledBackingStore::visibleAreaIsCovered):
(WebCore::TiledBackingStore::createTiles):
(WebCore::TiledBackingStore::adjustForContentsRect):
(WebCore::TiledBackingStore::removeAllNonVisibleTiles):
* platform/graphics/TiledBackingStore.h:
(TiledBackingStore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134047 => 134048)


--- trunk/Source/WebCore/ChangeLog	2012-11-09 12:08:06 UTC (rev 134047)
+++ trunk/Source/WebCore/ChangeLog	2012-11-09 12:13:25 UTC (rev 134048)
@@ -1,3 +1,54 @@
+2012-11-09  Huang Dongsung  <luxte...@company100.net>
+
+        Coordinated Graphics: Remove a backing store of GraphicsLayer when the layer is far from the viewport.
+        https://bugs.webkit.org/show_bug.cgi?id=101656
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        TiledBackingStore computes cover and keep rects to create, keep or remove tiles
+        smartly, but currently TiledBackingStore expects a contents rect is big enough
+        to cover the visibleRect. However, when CoordinatedGraphicsLayer uses TBS, it
+        is usually wrong expectation.
+
+        We must compute cover and keep rects using the visibleRect, instead of
+        the rect intersecting the visibleRect with m_rect, because TBS can be
+        used as a backing store of GraphicsLayer and the visible rect usually
+        does not intersect with m_rect.
+        In the below case, the intersecting rect is an empty.
+
+         +---------------+
+         |               |
+         |   m_rect      |
+         |       +-------|-----------------------+
+         |       | HERE  |  cover or keep        |
+         +---------------+      rect             |
+                 |         +---------+           |
+                 |         | visible |           |
+                 |         |  rect   |           |
+                 |         +---------+           |
+                 |                               |
+                 |                               |
+                 +-------------------------------+
+
+        We must create or keep the tiles in the HERE region. Currently in the
+        case, we do not create or keep tiles on the HERE region. Moreover, in
+        the case, we early return, which means we don't remove any tiles. It
+        causes to waste heap and video memory.
+
+        This patch changes TiledBackingStore to manage tiles smartly for
+        Coordinated Graphics.
+
+        Changing cache policy is not testable in layout tests.
+
+        * platform/graphics/TiledBackingStore.cpp:
+        (WebCore::TiledBackingStore::visibleRect):
+        (WebCore::TiledBackingStore::visibleAreaIsCovered):
+        (WebCore::TiledBackingStore::createTiles):
+        (WebCore::TiledBackingStore::adjustForContentsRect):
+        (WebCore::TiledBackingStore::removeAllNonVisibleTiles):
+        * platform/graphics/TiledBackingStore.h:
+        (TiledBackingStore):
+
 2012-11-09  Keishi Hattori  <kei...@webkit.org>
 
         Fix undefined variable in Week constructor for calendar picker

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp (134047 => 134048)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-11-09 12:08:06 UTC (rev 134047)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.cpp	2012-11-09 12:13:25 UTC (rev 134048)
@@ -170,14 +170,9 @@
     context->restore();
 }
 
-IntRect TiledBackingStore::visibleContentsRect() const
-{
-    return intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect());
-}
-
 IntRect TiledBackingStore::visibleRect() const
 {
-    return mapFromContents(visibleContentsRect());
+    return mapFromContents(m_client->tiledBackingStoreVisibleRect());
 }
 
 void TiledBackingStore::setContentsScale(float scale)
@@ -236,7 +231,8 @@
 
 bool TiledBackingStore::visibleAreaIsCovered() const
 {
-    return coverageRatio(visibleContentsRect()) == 1.0f;
+    IntRect boundedVisibleContentsRect = intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect());
+    return coverageRatio(boundedVisibleContentsRect) == 1.0f;
 }
 
 void TiledBackingStore::createTiles()
@@ -249,12 +245,36 @@
     const IntRect previousRect = m_rect;
     m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
 
+    if (m_rect.isEmpty()) {
+        setCoverRect(IntRect());
+        setKeepRect(IntRect());
+        return;
+    }
+
+    /* We must compute cover and keep rects using the visibleRect, instead of the rect intersecting the visibleRect with m_rect,
+     * because TBS can be used as a backing store of GraphicsLayer and the visible rect usually does not intersect with m_rect.
+     * In the below case, the intersecting rect is an empty.
+     *
+     *  +---------------+
+     *  |               |
+     *  |   m_rect      |
+     *  |       +-------|-----------------------+
+     *  |       | HERE  |  cover or keep        |
+     *  +---------------+      rect             |
+     *          |         +---------+           |
+     *          |         | visible |           |
+     *          |         |  rect   |           |
+     *          |         +---------+           |
+     *          |                               |
+     *          |                               |
+     *          +-------------------------------+
+     *
+     * We must create or keep the tiles in the HERE region.
+     */
+
     const IntRect visibleRect = this->visibleRect();
     m_visibleRect = visibleRect;
 
-    if (visibleRect.isEmpty())
-        return;
-
     IntRect coverRect;
     IntRect keepRect;
     computeCoverAndKeepRect(visibleRect, coverRect, keepRect);
@@ -262,6 +282,9 @@
     setCoverRect(coverRect);
     setKeepRect(keepRect);
 
+    if (coverRect.isEmpty())
+        return;
+
     // Resize tiles at the edge in case the contents size has changed, but only do so
     // after having dropped tiles outside the keep rect.
     bool didResizeTiles = false;
@@ -318,6 +341,12 @@
     IntRect bounds = m_rect;
     IntSize candidateSize = rect.size();
 
+    // If candidateSize is bigger than bounds (i.e. TBS is used as a backing store of GraphicsLayer), we skip the below adjusting logic which expects bounds to cover the given rect.
+    if (candidateSize.width() > bounds.width() && candidateSize.height() > bounds.height()) {
+        rect.intersect(bounds);
+        return;
+    }
+
     // We will try to keep the cover and keep rect the same size at all time, which
     // might not be the case when at the content edges.
 
@@ -441,7 +470,8 @@
 
 void TiledBackingStore::removeAllNonVisibleTiles()
 {
-    setKeepRect(visibleRect());
+    IntRect boundedVisibleRect = mapFromContents(intersection(m_client->tiledBackingStoreVisibleRect(), m_client->tiledBackingStoreContentsRect()));
+    setKeepRect(boundedVisibleRect);
 }
 
 PassRefPtr<Tile> TiledBackingStore::tileAt(const Tile::Coordinate& coordinate) const

Modified: trunk/Source/WebCore/platform/graphics/TiledBackingStore.h (134047 => 134048)


--- trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-11-09 12:08:06 UTC (rev 134047)
+++ trunk/Source/WebCore/platform/graphics/TiledBackingStore.h	2012-11-09 12:13:25 UTC (rev 134048)
@@ -102,7 +102,6 @@
     void setTile(const Tile::Coordinate& coordinate, PassRefPtr<Tile> tile);
     void removeTile(const Tile::Coordinate& coordinate);
 
-    IntRect visibleContentsRect() const;
     IntRect visibleRect() const;
 
     float coverageRatio(const IntRect&) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to