m_delayedRelease = false;
m_delayedReleaseOwner = 0;
}
+ m_busyCond.signal();
}
bool BackedDoubleBufferedTexture::busy()
producerReleaseAndSwap();
}
-bool BackedDoubleBufferedTexture::acquire(TextureOwner* owner)
+bool BackedDoubleBufferedTexture::acquire(TextureOwner* owner, bool force)
{
if (m_owner == owner) {
if (m_delayedRelease) {
return true;
}
- return setOwner(owner);
+ return setOwner(owner, force);
}
bool BackedDoubleBufferedTexture::tryAcquire(TextureOwner* owner, TiledPage* currentPage, TiledPage* nextPage)
return false;
}
-bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner)
+bool BackedDoubleBufferedTexture::setOwner(TextureOwner* owner, bool force)
{
// if the writable texture is busy (i.e. currently being written to) then we
// can't change the owner out from underneath that texture
m_busyLock.lock();
+ while (m_busy && force)
+ m_busyCond.wait(m_busyLock);
bool busy = m_busy;
m_busyLock.unlock();
+
if (!busy) {
// if we are not busy we can try to remove the texture from the layer;
// LayerAndroid::removeTexture() is protected by the same lock as
// allows consumer thread to assign ownership of the texture to the tile. It
// returns false if ownership cannot be transferred because the tile is busy
- bool acquire(TextureOwner* owner);
+ bool acquire(TextureOwner* owner, bool force = false);
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);
+ bool setOwner(TextureOwner* owner, bool force = false);
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
// We mutex protect the reads/writes of m_busy to ensure that we are reading
// the most up-to-date value even across processors in an SMP system.
android::Mutex m_busyLock;
+ // We use this condition variable to signal that the texture
+ // is not busy anymore
+ android::Condition m_busyCond;
};
} // namespace WebCore
layer->uniqueId(), layer);
}
- if (best && best->acquire(layer))
+ if (best && best->acquire(layer, any))
return best;
return 0;
}