diff options
author | Nicolas Roard <nicolas@android.com> | 2011-01-31 16:02:42 -0800 |
---|---|---|
committer | Nicolas Roard <nicolas@android.com> | 2011-01-31 23:16:39 -0800 |
commit | 7e3773d591be20a4ddb1ef7df2709fd7655b7917 (patch) | |
tree | a95c6e0074c7d24749a8ad5a853a885b20180b46 /WebCore/platform/graphics/android/BaseTile.cpp | |
parent | 968791c5f1c465f0633c618fda279246ba213fdf (diff) | |
download | external_webkit-7e3773d591be20a4ddb1ef7df2709fd7655b7917.zip external_webkit-7e3773d591be20a4ddb1ef7df2709fd7655b7917.tar.gz external_webkit-7e3773d591be20a4ddb1ef7df2709fd7655b7917.tar.bz2 |
Implement dynamic allocation of base tiles.
This way, a webview will only consume as much GPU memory
as needed, depending on its size, to a maximum of 256
tiles per TiledPage.
bug:3376517
Change-Id: Icc1e47623297cf1c01d40aa9e123c1a05373e7e5
Diffstat (limited to 'WebCore/platform/graphics/android/BaseTile.cpp')
-rw-r--r-- | WebCore/platform/graphics/android/BaseTile.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp index 2753fb2..960d073 100644 --- a/WebCore/platform/graphics/android/BaseTile.cpp +++ b/WebCore/platform/graphics/android/BaseTile.cpp @@ -174,6 +174,9 @@ void BaseTile::draw(float transparency, SkRect& rect) return; } + if (m_texture->x() != m_x || m_texture->y() != m_y) + return; + TextureInfo* textureInfo = m_texture->consumerLock(); if (!textureInfo) { XLOG("%x (%d, %d) trying to draw, but no textureInfo!", this, x(), y()); @@ -198,6 +201,20 @@ bool BaseTile::isTileReady() return !m_dirty; } +void BaseTile::drawTileInfo(SkCanvas* canvas, + BackedDoubleBufferedTexture* texture, + int x, int y, float scale) +{ + SkPaint paint; + char str[256]; + snprintf(str, 256, "(%d,%d) %.2f, tile %x, texture: %x", + x, y, scale, this, texture); + paint.setARGB(255, 0, 0, 0); + canvas->drawText(str, strlen(str), 50, 100, paint); + paint.setARGB(255, 255, 0, 0); + canvas->drawText(str, strlen(str), 51, 101, paint); +} + // This is called from the texture generation thread void BaseTile::paintBitmap() { @@ -218,6 +235,7 @@ void BaseTile::paintBitmap() const int y = m_y; TiledPage* tiledPage = m_page; + texture->producerAcquireContext(); TextureInfo* textureInfo = texture->producerLock(); // at this point we can safely check the ownership (if the texture got @@ -227,8 +245,9 @@ void BaseTile::paintBitmap() return; } - float tileWidth = textureInfo->m_width; - float tileHeight = textureInfo->m_height; + SkSize size = texture->getSize(); + float tileWidth = size.width(); + float tileHeight = size.height(); const float invScale = 1 / scale; float w = tileWidth * invScale; @@ -255,8 +274,10 @@ void BaseTile::paintBitmap() paint.setARGB(128, 0, 0, 255); canvas->drawLine(0, 0, tileWidth, 0, paint); canvas->drawLine(tileWidth, 0, tileWidth, tileHeight, paint); + drawTileInfo(canvas, texture, x, y, scale); #endif + texture->setTile(x, y); texture->producerUpdate(textureInfo); m_atomicSync.lock(); |