Bug 1276811 - Enable TextureClient to be used without CompositableForwarder,r=nical

- Refactoring to make TextureClient use the higher-level
  TextureForwarder interface.

MozReview-Commit-ID: EMpsT2exGMf

--HG--
extra : rebase_source : 09d9110ad3fdffabe9e54eed13ef827893e568f4
This commit is contained in:
Kearwood (Kip) Gilbert 2016-05-27 13:49:30 -07:00
Родитель 4a3ae90945
Коммит c1ee67da2e
2 изменённых файлов: 59 добавлений и 4 удалений

Просмотреть файл

@ -121,9 +121,9 @@ public:
bool IPCOpen() const { return mIPCOpen; }
void Lock() const { if (mCompositableForwarder->UsesImageBridge()) { mLock.Enter(); } }
void Lock() const { if (mCompositableForwarder && mCompositableForwarder->UsesImageBridge()) { mLock.Enter(); } }
void Unlock() const { if (mCompositableForwarder->UsesImageBridge()) { mLock.Leave(); } }
void Unlock() const { if (mCompositableForwarder && mCompositableForwarder->UsesImageBridge()) { mLock.Leave(); } }
private:
@ -905,6 +905,51 @@ TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
return mActor->IPCOpen();
}
bool
TextureClient::InitIPDLActor(TextureForwarder* aForwarder, LayersBackend aBackend)
{
MOZ_ASSERT(aForwarder && aForwarder->GetMessageLoop() == mAllocator->AsClientAllocator()->GetMessageLoop());
if (mActor && !mActor->mDestroyed) {
CompositableForwarder* currentFwd = mActor->mCompositableForwarder;
TextureForwarder* currentTexFwd = mActor->mTextureForwarder;
if (currentFwd) {
gfxCriticalError() << "Attempt to remove a texture from a CompositableForwarder.";
return false;
}
if (currentTexFwd && currentTexFwd != aForwarder) {
gfxCriticalError() << "Attempt to move a texture to a different channel.";
return false;
}
mActor->mTextureForwarder = aForwarder;
return true;
}
MOZ_ASSERT(!mActor || mActor->mDestroyed, "Cannot use a texture on several IPC channels.");
SurfaceDescriptor desc;
if (!ToSurfaceDescriptor(desc)) {
return false;
}
mActor = static_cast<TextureChild*>(aForwarder->CreateTexture(desc,
aBackend,
GetFlags(),
mSerial));
MOZ_ASSERT(mActor);
mActor->mTextureForwarder = aForwarder;
mActor->mTextureClient = this;
mActor->mMainThreadOnly = !!(mFlags & TextureFlags::DEALLOCATE_MAIN_THREAD);
// If the TextureClient is already locked, we have to lock TextureChild's mutex
// since it will be unlocked in TextureClient::Unlock.
if (mIsLocked) {
LockActor();
}
return mActor->IPCOpen();
}
PTextureChild*
TextureClient::GetIPDLActor()
{

Просмотреть файл

@ -550,12 +550,22 @@ public:
bool IsAddedToCompositableClient() const { return mAddedToCompositableClient; }
/**
* Create and init the TextureChild/Parent IPDL actor pair.
* Create and init the TextureChild/Parent IPDL actor pair
* with a CompositableForwarder.
*
* Should be called only once per TextureClient.
* The TextureClient must not be locked when calling this method.
*/
bool InitIPDLActor(CompositableForwarder* aForwarder);
/**
* Create and init the TextureChild/Parent IPDL actor pair
* with a TextureForwarder.
*
* Should be called only once per TextureClient.
* The TextureClient must not be locked when calling this method.
*/
bool InitIPDLActor(CompositableForwarder* aForwarder);
bool InitIPDLActor(TextureForwarder* aForwarder, LayersBackend aBackendType);
/**
* Return a pointer to the IPDLActor.