OSDN Git Service

Improve tile painting prioritization to minimize stalled, blank tiles
authorChris Craik <ccraik@google.com>
Wed, 14 Sep 2011 23:06:57 +0000 (16:06 -0700)
committerChris Craik <ccraik@google.com>
Wed, 14 Sep 2011 23:13:50 +0000 (16:13 -0700)
bug:5320450

* Greedily deallocate textures from stolen tiles

* Force all prioritization values to be positive

* Create simply described prioritization ordering:
    * Draw count
    * Has front texture?
    * position (if base tile)

Change-Id: Icd5dab931f735c14c18feef5186c8245c5956cfd

Source/WebCore/platform/graphics/android/PaintTileOperation.cpp
Source/WebCore/platform/graphics/android/TiledPage.cpp

index 4366ad6..aa3f320 100644 (file)
@@ -76,27 +76,25 @@ int PaintTileOperation::priority()
     if (!m_tile)
         return -1;
 
-    int priority;
-    if (m_tile->isLayerTile())
-        priority = -2;
-    else {
+    // first, prioritize higher draw count
+    unsigned long long currentDraw = TilesManager::instance()->getDrawGLCount();
+    unsigned long long drawDelta = currentDraw - m_tile->drawCount();
+    int priority = 100000 * (int)std::min(drawDelta, (unsigned long long)1000);
+
+    // prioritize unpainted tiles, within the same drawCount
+    if (m_tile->frontTexture())
+        priority += 50000;
+
+    // for base tiles, prioritize based on position
+    if (!m_tile->isLayerTile()) {
         bool goingDown = m_tile->page()->scrollingDown();
         SkIRect *rect = m_tile->page()->expandedTileBounds();
-        int firstTileX = rect->fLeft;
-        int nbTilesWidth = rect->width();
-        priority = m_tile->x() - firstTileX;
+        priority += m_tile->x();
+
         if (goingDown)
-            priority += (rect->fBottom - m_tile->y()) * nbTilesWidth;
+            priority += 100000 - (1 + m_tile->y()) * 1000;
         else
-            priority += (m_tile->y() - rect->fTop) * nbTilesWidth;
-    }
-
-    if (m_tile->frontTexture()) {
-        // de-prioritize old tiles that have something visible
-        unsigned long long currentDraw = TilesManager::instance()->getDrawGLCount();
-        unsigned long long drawDelta = currentDraw - m_tile->drawCount();
-        int cappedDrawDelta = (int)std::max(drawDelta, (unsigned long long)1000);
-        priority += cappedDrawDelta * 100000;
+            priority += m_tile->y() * 1000;
     }
 
     return priority;
index 78140fa..ede7d1b 100644 (file)
@@ -172,6 +172,7 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y
         if (!currentTile && availableTile) {
             XLOG("STEALING tile %d, %d (draw count %llu) for tile %d, %d",
                   availableTile->x(), availableTile->y(), availableTile->drawCount(), x, y);
+            availableTile->discardTextures(); // don't wait for textures to be stolen
             currentTile = availableTile;
         }