summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-04-05 15:39:47 -0700
committerJohn Reck <jreck@google.com>2011-04-05 17:20:52 -0700
commit61d841295b182b0d6c9eab04af1c55b9218eaefb (patch)
tree4a310f38ddba9061b6c82352f8eb628c91297a9a /WebCore/platform
parenta33d490302a04453e2c671114d30a4ee93cb08f1 (diff)
downloadexternal_webkit-61d841295b182b0d6c9eab04af1c55b9218eaefb.zip
external_webkit-61d841295b182b0d6c9eab04af1c55b9218eaefb.tar.gz
external_webkit-61d841295b182b0d6c9eab04af1c55b9218eaefb.tar.bz2
Race condition fix
Bug: 4232693 Change-Id: I273671aea3dc379858f11546e6459fd9e1443d4f
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp14
-rw-r--r--WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h1
-rw-r--r--WebCore/platform/graphics/android/TilesManager.cpp5
3 files changed, 16 insertions, 4 deletions
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
index 63c9806..dc0962c 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.cpp
@@ -202,6 +202,20 @@ bool BackedDoubleBufferedTexture::acquire(TextureOwner* owner)
return setOwner(owner);
}
+bool BackedDoubleBufferedTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage)
+{
+ m_busyLock.lock();
+ if (!m_busy
+ && m_owner
+ && m_owner->page() != currentPage
+ && m_owner->page() != nextPage) {
+ m_busyLock.unlock();
+ return this->acquire(owner);
+ }
+ m_busyLock.unlock();
+ return false;
+}
+
bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner)
{
// if the writable texture is busy (i.e. currently being written to) then we
diff --git a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
index f612114..8bfae59 100644
--- a/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
+++ b/WebCore/platform/graphics/android/BackedDoubleBufferedTexture.h
@@ -90,6 +90,7 @@ public:
// returns false if ownership cannot be transferred because the tile is busy
bool acquire(TextureOwner* owner);
bool release(TextureOwner* owner);
+ bool tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage);
// set the texture owner if not busy. Return false if busy, true otherwise.
bool setOwner(TextureOwner* owner);
diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp
index bff1551..34d0546 100644
--- a/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/WebCore/platform/graphics/android/TilesManager.cpp
@@ -201,10 +201,7 @@ BackedDoubleBufferedTexture* TilesManager::getAvailableTexture(BaseTile* owner)
TiledPage* nextPage = currentPage->sibling();
for (unsigned int i = 0; i < max; i++) {
BackedDoubleBufferedTexture* texture = m_textures[i];
- if (texture->owner()
- && texture->owner()->page() != currentPage
- && texture->owner()->page() != nextPage
- && texture->acquire(owner)) {
+ if (texture->tryAcquire(owner, currentPage, nextPage)) {
XLOG("grab a texture that wasn't ours, (%x != %x) at %d => texture %x",
owner->page(), texture->owner()->page(), i, texture);
texture->setUsedLevel(0);