Bug 1272600 - Part 8 - Simplify the textures ReadLock on the content side. r=sotaro
This commit is contained in:
@@ -452,13 +452,7 @@ TextureClient::UnlockActor() const
|
|||||||
bool
|
bool
|
||||||
TextureClient::IsReadLocked() const
|
TextureClient::IsReadLocked() const
|
||||||
{
|
{
|
||||||
// mPendingReadUnlock is true when the texture has been written into (and as
|
return mReadLock && mReadLock->GetReadCount() > 1;
|
||||||
// a result the read-count already incremented on the behalf of the compositor),
|
|
||||||
// but we haven't sent the notification for the compositor to use the texture,
|
|
||||||
// so it is still OK to access the texture data on this side.
|
|
||||||
// If we didn't take mPendingReadUnlock into account here, we would not be able
|
|
||||||
// to Lock and Unlock a texture twice before sending it.
|
|
||||||
return mReadLock && mReadLock->GetReadCount() > 1 && !mPendingReadUnlock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -535,12 +529,7 @@ TextureClient::Unlock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mOpenMode & OpenMode::OPEN_WRITE) {
|
if (mOpenMode & OpenMode::OPEN_WRITE) {
|
||||||
if (mReadLock && !mPendingReadUnlock) {
|
mUpdated = true;
|
||||||
// Take a read lock on behalf of the TextureHost. The latter will unlock
|
|
||||||
// after the shared data is available again for drawing.
|
|
||||||
mReadLock->ReadLock();
|
|
||||||
}
|
|
||||||
mPendingReadUnlock = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mData->Unlock();
|
mData->Unlock();
|
||||||
@@ -555,27 +544,18 @@ TextureClient::EnableReadLock()
|
|||||||
{
|
{
|
||||||
if (!mReadLock) {
|
if (!mReadLock) {
|
||||||
mReadLock = TextureReadLock::Create(mAllocator);
|
mReadLock = TextureReadLock::Create(mAllocator);
|
||||||
if (mPendingReadUnlock) {
|
|
||||||
// We would have done this during TextureClient::Unlock if the ReadLock
|
|
||||||
// had been there, need to account for this here.
|
|
||||||
mReadLock->ReadLock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
TextureClient::SetReadLock(TextureReadLock* aLock)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!mReadLock);
|
|
||||||
mReadLock = aLock;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextureClient::SerializeReadLock(ReadLockDescriptor& aDescriptor)
|
TextureClient::SerializeReadLock(ReadLockDescriptor& aDescriptor)
|
||||||
{
|
{
|
||||||
if (mReadLock && mPendingReadUnlock) {
|
if (mReadLock && mUpdated) {
|
||||||
|
// Take a read lock on behalf of the TextureHost. The latter will unlock
|
||||||
|
// after the shared data is available again for drawing.
|
||||||
|
mReadLock->ReadLock();
|
||||||
mReadLock->Serialize(aDescriptor);
|
mReadLock->Serialize(aDescriptor);
|
||||||
mPendingReadUnlock = false;
|
mUpdated = false;
|
||||||
} else {
|
} else {
|
||||||
aDescriptor = null_t();
|
aDescriptor = null_t();
|
||||||
}
|
}
|
||||||
@@ -583,10 +563,7 @@ TextureClient::SerializeReadLock(ReadLockDescriptor& aDescriptor)
|
|||||||
|
|
||||||
TextureClient::~TextureClient()
|
TextureClient::~TextureClient()
|
||||||
{
|
{
|
||||||
if (mPendingReadUnlock && mReadLock) {
|
mReadLock = nullptr;
|
||||||
mReadLock->ReadUnlock();
|
|
||||||
mReadLock = nullptr;
|
|
||||||
}
|
|
||||||
Destroy(false);
|
Destroy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,7 +1071,7 @@ TextureClient::TextureClient(TextureData* aData, TextureFlags aFlags, ClientIPCA
|
|||||||
, mExpectedDtRefs(0)
|
, mExpectedDtRefs(0)
|
||||||
#endif
|
#endif
|
||||||
, mIsLocked(false)
|
, mIsLocked(false)
|
||||||
, mPendingReadUnlock(false)
|
, mUpdated(false)
|
||||||
, mInUse(false)
|
, mInUse(false)
|
||||||
, mAddedToCompositableClient(false)
|
, mAddedToCompositableClient(false)
|
||||||
, mWorkaroundAnnoyingSharedSurfaceLifetimeIssues(false)
|
, mWorkaroundAnnoyingSharedSurfaceLifetimeIssues(false)
|
||||||
|
|||||||
@@ -653,8 +653,6 @@ public:
|
|||||||
|
|
||||||
void EnableReadLock();
|
void EnableReadLock();
|
||||||
|
|
||||||
void SetReadLock(TextureReadLock* aLock);
|
|
||||||
|
|
||||||
TextureReadLock* GetReadLock() { return mReadLock; }
|
TextureReadLock* GetReadLock() { return mReadLock; }
|
||||||
|
|
||||||
bool IsReadLocked() const;
|
bool IsReadLocked() const;
|
||||||
@@ -710,10 +708,10 @@ protected:
|
|||||||
uint32_t mExpectedDtRefs;
|
uint32_t mExpectedDtRefs;
|
||||||
#endif
|
#endif
|
||||||
bool mIsLocked;
|
bool mIsLocked;
|
||||||
// True when there has been a modification of the texture that hasn't been sent
|
// This member tracks that the texture was written into until the update
|
||||||
// to the compositor yet. We keep track of this to avoid sending the texture's
|
// is sent to the compositor. We need this remember to lock mReadLock on
|
||||||
// ReadLock twice after a single update.
|
// behalf of the compositor just before sending the notification.
|
||||||
bool mPendingReadUnlock;
|
bool mUpdated;
|
||||||
bool mInUse;
|
bool mInUse;
|
||||||
|
|
||||||
bool mAddedToCompositableClient;
|
bool mAddedToCompositableClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user