summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h1
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp16
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp14
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp13
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.h2
-rw-r--r--Source/WebKit/android/nav/WebView.cpp2
9 files changed, 47 insertions, 25 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 827c858..a8c4d7a 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -57,8 +57,8 @@
// TODO: dynamically determine based on DPI
#define PREFETCH_SCALE_MODIFIER 0.3
#define PREFETCH_OPACITY 1
-#define PREFETCH_X_DIST 1
-#define PREFETCH_Y_DIST 2
+#define PREFETCH_X_DIST 0
+#define PREFETCH_Y_DIST 1
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index 350001a..05b3a3d 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -504,6 +504,14 @@ void BaseTile::discardTextures() {
m_state = Unpainted;
}
+void BaseTile::discardBackTexture() {
+ android::AutoMutex lock(m_atomicSync);
+ if (m_backTexture) {
+ m_backTexture->release(this);
+ m_backTexture = 0;
+ }
+}
+
bool BaseTile::swapTexturesIfNeeded() {
android::AutoMutex lock(m_atomicSync);
if (m_state == ReadyToSwap) {
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index cabf5f1..685ca43 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -127,6 +127,7 @@ public:
// only used for prioritization - the higher, the more relevant the tile is
unsigned long long drawCount() { return m_drawCount; }
void discardTextures();
+ void discardBackTexture();
bool swapTexturesIfNeeded();
void backTextureTransfer();
void backTextureTransferFail();
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index 5b7acdb..caaf116 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -91,7 +91,11 @@ void BaseTileTexture::discardGLTexture()
if (m_ownTextureId)
GLUtils::deleteTexture(&m_ownTextureId);
- releaseAndRemoveFromTile();
+ if (m_owner) {
+ // clear both Tile->Texture and Texture->Tile links
+ m_owner->removeTexture(this);
+ release(m_owner);
+ }
}
void BaseTileTexture::destroyTextures(SharedTexture** textures)
@@ -209,16 +213,6 @@ bool BaseTileTexture::release(TextureOwner* owner)
return true;
}
-void BaseTileTexture::releaseAndRemoveFromTile()
-{
- // NOTE: only call on UI thread, so m_owner won't be changing
- if (m_owner) {
- // clear both Tile->Texture and Texture->Tile links
- m_owner->removeTexture(this);
- release(m_owner);
- }
-}
-
void BaseTileTexture::setTile(TextureInfo* info, int x, int y,
float scale, TilePainter* painter,
unsigned int pictureCount)
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
index d48c116..c5ed38c 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
@@ -51,6 +51,10 @@
#endif // DEBUG
+// Allows layers using less than MAX_UNCLIPPED_AREA tiles to
+// schedule all of them instead of clipping the area with the visible rect.
+#define MAX_UNCLIPPED_AREA 16
+
namespace WebCore {
PaintedSurface::PaintedSurface(LayerAndroid* layer)
@@ -208,6 +212,14 @@ void PaintedSurface::computeVisibleArea() {
IntRect layerRect = (*m_layer->drawTransform()).mapRect(m_area);
IntRect clippedRect = TilesManager::instance()->shader()->clippedRectWithViewport(layerRect);
m_visibleArea = (*m_layer->drawTransform()).inverse().mapRect(clippedRect);
+ if (!m_visibleArea.isEmpty()) {
+ float tileWidth = TilesManager::instance()->layerTileWidth();
+ float tileHeight = TilesManager::instance()->layerTileHeight();
+ int w = ceilf(m_area.width() / tileWidth);
+ int h = ceilf(m_area.height() / tileHeight);
+ if (w * h < MAX_UNCLIPPED_AREA)
+ m_visibleArea = m_area;
+ }
}
bool PaintedSurface::owns(BaseTileTexture* texture)
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
index 34f0d4e..b3b4daf 100644
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp
@@ -142,9 +142,6 @@ void TiledPage::invalidateRect(const IntRect& inval, const unsigned int pictureC
void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds)
{
- if (y < 0)
- return;
-
for (int i = 0; i < tilesInRow; i++) {
int x = firstTileX;
@@ -156,9 +153,6 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y
else
x += i;
- if (x < 0)
- continue;
-
BaseTile* currentTile = 0;
BaseTile* availableTile = 0;
for (int j = 0; j < m_baseTileSize; j++) {
@@ -269,6 +263,14 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
nbTilesHeight += expandY * 2;
}
+ // crop the prepared region to the contents of the base layer
+ float maxWidthTiles = m_glWebViewState->baseContentWidth() * m_scale / TilesManager::tileWidth();
+ float maxHeightTiles = m_glWebViewState->baseContentHeight() * m_scale / TilesManager::tileHeight();
+ firstTileX = std::max(0, firstTileX);
+ firstTileY = std::max(0, firstTileY);
+ lastTileX = std::min(lastTileX, static_cast<int>(ceilf(maxWidthTiles)) - 1);
+ lastTileY = std::min(lastTileY, static_cast<int>(ceilf(maxHeightTiles)) - 1);
+
m_expandedTileBounds.fLeft = firstTileX;
m_expandedTileBounds.fTop = firstTileY;
m_expandedTileBounds.fRight = lastTileX;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index 3fc1b93..4e29870 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -440,6 +440,7 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
XLOG("ERROR update a tile which is dirty already @ index %d", index);
}
+ m_transferQueue[index].savedBaseTileTexturePtr = renderInfo->baseTile->backTexture();
m_transferQueue[index].savedBaseTilePtr = renderInfo->baseTile;
m_transferQueue[index].status = pendingBlit;
m_transferQueue[index].uploadType = type;
@@ -493,14 +494,16 @@ void TransferQueue::cleanupTransportQueue()
// since tiles in the queue may be from another webview, remove
// their textures so that they will be repainted / retransferred
BaseTile* tile = m_transferQueue[index].savedBaseTilePtr;
- if (tile) {
- BaseTileTexture* texture = tile->backTexture();
- if (texture)
- texture->releaseAndRemoveFromTile();
+ BaseTileTexture* texture = m_transferQueue[index].savedBaseTileTexturePtr;
+ if (tile && texture && texture->owner() == tile) {
+ // since tile destruction removes textures on the UI thread, the
+ // texture->owner ptr guarantees the tile is valid
+ tile->discardBackTexture();
+ XLOG("transfer queue discarded tile %p, removed texture", tile);
}
- XLOG("transfer queue discarded tile %p, removed texture", tile);
m_transferQueue[index].savedBaseTilePtr = 0;
+ m_transferQueue[index].savedBaseTileTexturePtr = 0;
m_transferQueue[index].status = emptyItem;
}
index = (index + 1) % ST_BUFFER_NUMBER;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h
index bddc85d..63455de 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.h
@@ -70,6 +70,7 @@ public:
TileTransferData()
: status(emptyItem)
, savedBaseTilePtr(0)
+ , savedBaseTileTexturePtr(0)
, uploadType(DEFAULT_UPLOAD_TYPE)
, bitmap(0)
, m_syncKHR(EGL_NO_SYNC_KHR)
@@ -84,6 +85,7 @@ public:
TransferItemStatus status;
BaseTile* savedBaseTilePtr;
+ BaseTileTexture* savedBaseTileTexturePtr;
TextureTileInfo tileInfo;
TextureUploadType uploadType;
// This is only useful in Cpu upload code path, so it will be dynamically
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 0876db6..493d4b3 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -420,7 +420,7 @@ void scrollRectOnScreen(const IntRect& rect)
{
if (rect.isEmpty())
return;
- SkRect visible;
+ SkRect visible = SkRect::MakeEmpty();
calcOurContentVisibleRect(&visible);
int dx = 0;
int left = rect.x();