diff options
author | John Reck <jreck@google.com> | 2011-04-05 18:08:35 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-04-05 18:08:35 -0700 |
commit | 7404fb69c0389c04c5d20d9d2dff7a4aba1db63a (patch) | |
tree | f1093cc3c0232d7d9d12d84dc68c9b0f1c5ec6e1 | |
parent | bd064363b650efb80cde0685b2260a854311a3bb (diff) | |
parent | 61d841295b182b0d6c9eab04af1c55b9218eaefb (diff) | |
download | external_webkit-7404fb69c0389c04c5d20d9d2dff7a4aba1db63a.zip external_webkit-7404fb69c0389c04c5d20d9d2dff7a4aba1db63a.tar.gz external_webkit-7404fb69c0389c04c5d20d9d2dff7a4aba1db63a.tar.bz2 |
Merge "Race condition fix" into honeycomb-mr1
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); |