OSDN Git Service

If unlock base layer marks tiles dirty, repaint
authorChris Craik <ccraik@google.com>
Thu, 8 Sep 2011 23:54:13 +0000 (16:54 -0700)
committerChris Craik <ccraik@google.com>
Fri, 9 Sep 2011 01:14:43 +0000 (18:14 -0700)
bug:5278818
Change-Id: I03206bdc5e95743054c361f235e2d94b835a95d1

Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
Source/WebCore/platform/graphics/android/BaseTile.cpp
Source/WebCore/platform/graphics/android/TiledPage.cpp
Source/WebCore/platform/graphics/android/TiledPage.h

index 573ad6b..54290cc 100644 (file)
@@ -141,7 +141,10 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale,
         nextTiledPage->setScale(scale);
         m_glWebViewState->setFutureViewport(viewportTileBounds);
         m_glWebViewState->lockBaseLayerUpdate();
-        nextTiledPage->updateTileState(viewportTileBounds);
+
+        // ignore dirtiness return value since while zooming we repaint regardless
+        nextTiledPage->updateTileDirtiness(viewportTileBounds);
+
         nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds,
                                TiledPage::VisibleBounds);
         // Cancel pending paints for the foreground page
@@ -212,24 +215,27 @@ bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale,
             *buffersSwappedPtr = true;
     }
 
-    // If stuff is happening such that we need a redraw, lock updates to the
-    // base layer, and only then start painting.
+
     bool needsRedraw = scrolling || zooming || !buffersSwapped;
-    if (needsRedraw)
-        m_glWebViewState->lockBaseLayerUpdate();
-    else
+
+    // if we don't expect to redraw, unlock the invals
+    if (!needsRedraw)
         m_glWebViewState->unlockBaseLayerUpdate();
 
-    XLOG("scrolling %d, zooming %d, buffersSwapped %d, needsRedraw %d",
-         scrolling, zooming, buffersSwapped, needsRedraw);
+    // if applied invals mark tiles dirty, need to redraw
+    needsRedraw |= tiledPage->updateTileDirtiness(preZoomBounds);
 
-    tiledPage->updateTileState(preZoomBounds);
+    if (needsRedraw) {
+        // lock and paint what's needed unless we're zooming, since the new
+        // tiles won't be relevant soon anyway
+        m_glWebViewState->lockBaseLayerUpdate();
+        if (!zooming)
+            tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
+                               TiledPage::ExpandedBounds);
+    }
 
-    // Only paint new textures if the base layer has been locked, but not if
-    // we're zooming since the new tiles won't be relevant soon anyway
-    if (needsRedraw && !zooming)
-        tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
-                           TiledPage::ExpandedBounds);
+    XLOG("scrolling %d, zooming %d, buffersSwapped %d, needsRedraw %d",
+         scrolling, zooming, buffersSwapped, needsRedraw);
 
     tiledPage->draw(transparency, preZoomBounds);
 
index 0a87ffe..8a4c2d5 100644 (file)
 
 #include <cutils/atomic.h>
 
-#ifdef DEBUG
-
 #include <cutils/log.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/text/CString.h>
 
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "BaseTile", __VA_ARGS__)
+
+#ifdef DEBUG
+
 #undef XLOG
 #define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "BaseTile", __VA_ARGS__)
 
@@ -432,6 +435,8 @@ void BaseTile::paintBitmap()
         if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
             m_dirty = true;
 
+        XLOG("painted tile %p (%d, %d), dirty=%d", this, x, y, m_dirty);
+
         if (!m_dirty)
             m_isSwapNeeded = true;
     }
index b6a0c47..78140fa 100644 (file)
@@ -202,27 +202,32 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y
     }
 }
 
-void TiledPage::updateTileState(const SkIRect& tileBounds)
+bool TiledPage::updateTileDirtiness(const SkIRect& tileBounds)
 {
     if (!m_glWebViewState || tileBounds.isEmpty()) {
         m_invalRegion.setEmpty();
         m_invalTilesRegion.setEmpty();
-        return;
+        return false;
     }
 
+    bool visibleTileIsDirty = false;
     for (int x = 0; x < m_baseTileSize; x++) {
 
         BaseTile& tile = m_baseTiles[x];
 
         // if the tile is in the dirty region then we must invalidate it
-        if (m_invalRegion.contains(tile.x(), tile.y()))
+        if (m_invalRegion.contains(tile.x(), tile.y())) {
             tile.markAsDirty(m_latestPictureInval, m_invalTilesRegion);
+            if (tileBounds.contains(tile.x(), tile.y()))
+                visibleTileIsDirty = true;
+        }
     }
 
     // clear the invalidated region as all tiles within that region have now
     // been marked as dirty.
     m_invalRegion.setEmpty();
     m_invalTilesRegion.setEmpty();
+    return visibleTileIsDirty;
 }
 
 void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds)
@@ -231,8 +236,6 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
         return;
 
     TilesManager::instance()->gatherTextures();
-    // update the tiles distance from the viewport
-    updateTileState(tileBounds);
     m_scrollingDown = goingDown;
 
     int firstTileX = tileBounds.fLeft;
index 14306eb..946421c 100644 (file)
@@ -68,7 +68,10 @@ public:
 
     // prepare the page for display on the screen
     void prepare(bool goingDown, bool goingLeft, const SkIRect& tileBounds, PrepareBounds bounds);
-    void updateTileState(const SkIRect& tileBounds);
+
+    // update tiles with inval information, return true if visible ones are
+    // dirty (and thus repaint needed)
+    bool updateTileDirtiness(const SkIRect& tileBounds);
 
     // check to see if the page is ready for display