summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android/BaseTile.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-11-04 16:22:28 -0400
committerDerek Sollenberger <djsollen@google.com>2010-11-04 16:22:28 -0400
commit144ccd9c8dba05ffaa0ae598f9b70032050fc20e (patch)
treee63cbbd7d1297d293f0952904618b9ff63a981f1 /WebCore/platform/graphics/android/BaseTile.cpp
parentf337498167288e7a10576e418b97d8d9afa223c8 (diff)
downloadexternal_webkit-144ccd9c8dba05ffaa0ae598f9b70032050fc20e.zip
external_webkit-144ccd9c8dba05ffaa0ae598f9b70032050fc20e.tar.gz
external_webkit-144ccd9c8dba05ffaa0ae598f9b70032050fc20e.tar.bz2
Revert "Support partial invalidation of tiles based on webkit's inval rect."
This reverts commit fc92ca2409a95b539274985812d88016b6b84b7e.
Diffstat (limited to 'WebCore/platform/graphics/android/BaseTile.cpp')
-rw-r--r--WebCore/platform/graphics/android/BaseTile.cpp103
1 files changed, 40 insertions, 63 deletions
diff --git a/WebCore/platform/graphics/android/BaseTile.cpp b/WebCore/platform/graphics/android/BaseTile.cpp
index 1c81634..5ab801e 100644
--- a/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/WebCore/platform/graphics/android/BaseTile.cpp
@@ -72,9 +72,6 @@ BaseTile::BaseTile(TiledPage* page, int x, int y)
, m_y(y)
, m_texture(0)
, m_scale(1)
- , m_dirty(true)
- , m_lastDirtyPicture(0)
- , m_lastPaintedPicture(0)
{
#ifdef DEBUG_COUNT
gBaseTileCount++;
@@ -83,7 +80,6 @@ BaseTile::BaseTile(TiledPage* page, int x, int y)
BaseTile::~BaseTile()
{
- setUsedLevel(-1);
#ifdef DEBUG_COUNT
gBaseTileCount--;
#endif
@@ -94,43 +90,26 @@ BaseTile::~BaseTile()
void BaseTile::reserveTexture()
{
BackedDoubleBufferedTexture* texture = TilesManager::instance()->getAvailableTexture(this);
-
- android::AutoMutex lock(m_atomicSync);
- if (m_texture != texture) {
- m_lastPaintedPicture = 0;
- m_dirty = true;
- }
- m_texture = texture;
+ // We update atomically, so paintBitmap() can see the correct value
+ android_atomic_acquire_store((int32_t)texture, (int32_t*)&m_texture);
+ XLOG("%x (%d, %d) reserveTexture res: %x...", this, x(), y(), m_texture);
}
void BaseTile::removeTexture()
{
XLOG("%x removeTexture res: %x...", this, m_texture);
// We update atomically, so paintBitmap() can see the correct value
- android::AutoMutex lock(m_atomicSync);
- m_texture = 0;
+ android_atomic_acquire_store(0, (int32_t*)&m_texture);
}
void BaseTile::setScale(float scale)
{
- android::AutoMutex lock(m_atomicSync);
- if (m_scale != scale)
- m_dirty = true;
m_scale = scale;
-}
-
-void BaseTile::markAsDirty(int pictureCount)
-{
- android::AutoMutex lock(m_atomicSync);
- m_lastDirtyPicture = pictureCount;
- if (m_lastPaintedPicture < m_lastDirtyPicture)
- m_dirty = true;
-}
-
-bool BaseTile::isDirty()
-{
- android::AutoMutex lock(m_atomicSync);
- return m_dirty;
+ // FIXME: the following two lines force a memory barrier which causes
+ // m_scale to be observable on other cores. We should replace this
+ // with a dedicated system function if/when available.
+ int32_t tempValue = 0;
+ android_atomic_acquire_load(&tempValue);
}
void BaseTile::setUsedLevel(int usedLevel)
@@ -141,13 +120,13 @@ void BaseTile::setUsedLevel(int usedLevel)
void BaseTile::draw(float transparency, SkRect& rect)
{
- // No need to mutex protect reads of m_texture as it is only written to by
- // the consumer thread.
if (!m_texture) {
XLOG("%x (%d, %d) trying to draw, but no m_texture!", this, x(), y());
return;
}
+ PaintingInfo info(m_x, m_y, m_page->glWebViewState());
+
TextureInfo* textureInfo = m_texture->consumerLock();
if (!textureInfo) {
XLOG("%x (%d, %d) trying to draw, but no textureInfo!", this, x(), y());
@@ -155,57 +134,61 @@ void BaseTile::draw(float transparency, SkRect& rect)
return;
}
- m_atomicSync.lock();
- bool isTexturePainted = m_lastPaintedPicture;
- m_atomicSync.unlock();
-
- if (isTexturePainted)
+ if (m_texture->consumerTextureSimilar(info)) {
TilesManager::instance()->shader()->drawQuad(rect, textureInfo->m_textureId,
transparency);
+ }
m_texture->consumerRelease();
}
-bool BaseTile::isTileReady()
+bool BaseTile::isBitmapReady()
{
if (!m_texture)
return false;
if (m_texture->owner() != this)
return false;
-
- android::AutoMutex lock(m_atomicSync);
- return !m_dirty;
+ PaintingInfo info(m_x, m_y, m_page->glWebViewState());
+ return m_texture->consumerTextureUpToDate(info);
}
// This is called from the texture generation thread
void BaseTile::paintBitmap()
{
+ const int x = m_x;
+ const int y = m_y;
+ TiledPage* tiledPage = m_page;
+
+ // We acquire the texture atomically. Once we have it, we
+ // can continue with it, and m_texture can be updated without
+ // consequences.
+ BackedDoubleBufferedTexture* texture = reinterpret_cast<BackedDoubleBufferedTexture*>(
+ android_atomic_release_load((int32_t*)&m_texture));
- // We acquire the values below atomically. This ensures that we are reading
- // values correctly across cores. Further, once we have these values they
- // can be updated by other threads without consequence.
- m_atomicSync.lock();
- bool dirty = m_dirty;
- BackedDoubleBufferedTexture* texture = m_texture;
+ // The loading of m_texture forces the execution of a memory barrier,
+ // which ensures that we are observing the most recent value of m_scale
+ // written by another core.
float scale = m_scale;
- m_atomicSync.unlock();
- if(!dirty || !texture)
+ if (!texture)
return;
- const int x = m_x;
- const int y = m_y;
- TiledPage* tiledPage = m_page;
-
TextureInfo* textureInfo = texture->producerLock();
- // at this point we can safely check the ownership (if the texture got
- // transferred to another BaseTile under us)
+ // at this point we can safely check the ownership
+ // (if the texture got transferred to another BaseTile
+ // under us)
if (texture->owner() != this || texture->usedLevel() > 1) {
texture->producerRelease();
return;
}
+ PaintingInfo info(x, y, tiledPage->glWebViewState());
+ if (texture->consumerTextureUpToDate(info)) {
+ texture->producerRelease();
+ return;
+ }
+
float tileWidth = textureInfo->m_width;
float tileHeight = textureInfo->m_height;
@@ -220,7 +203,7 @@ void BaseTile::paintBitmap()
canvas->scale(scale, scale);
canvas->translate(-x * w, -y * h);
- int pictureCount = tiledPage->paintBaseLayerContent(canvas);
+ tiledPage->paintBaseLayerContent(canvas);
canvas->restore();
@@ -236,13 +219,7 @@ void BaseTile::paintBitmap()
canvas->drawLine(tileWidth, 0, tileWidth, tileHeight, paint);
#endif
- texture->producerUpdate(textureInfo);
-
- m_atomicSync.lock();
- m_lastPaintedPicture = pictureCount;
- if (m_lastPaintedPicture >= m_lastDirtyPicture)
- m_dirty = false;
- m_atomicSync.unlock();
+ texture->producerUpdate(this, textureInfo, info);
}
} // namespace WebCore