Bug 916118 - Simplify the deallocation flags in TextureClient/Host. r=nrc

This commit is contained in:
Nicolas Silva 2013-09-26 18:00:23 +02:00
parent f43d24af2c
commit bc11135ff0
16 changed files with 30 additions and 41 deletions

View File

@ -60,12 +60,11 @@ const TextureFlags TEXTURE_TILE = 1 << 15;
// from the previous texture.
const TextureFlags TEXTURE_COPY_PREVIOUS = 1 << 24;
// Who is responsible for deallocating the shared data.
// if none of the following two flags is set, the shared data will not be
// deallocated by the layers system. It is not necessarily a leak, it could
// be a choice from another part of gecko that wants to keep the data alive
// for some reason. The default behaviour is to deallocate on the host side.
// if TEXTURE_DEALLOCATE_CLIENT is set, the shared data is deallocated on the
// client side and requires some extra synchronizaion to ensure race-free
// deallocation.
// The default behaviour is to deallocate on the host side.
const TextureFlags TEXTURE_DEALLOCATE_CLIENT = 1 << 25;
const TextureFlags TEXTURE_DEALLOCATE_HOST = 1 << 26;
// After being shared ith the compositor side, an immutable texture is never
// modified, it can only be read. It is safe to not Lock/Unlock immutable
// textures.
@ -80,8 +79,7 @@ const TextureFlags TEXTURE_IMMEDIATE_UPLOAD = 1 << 28;
const TextureFlags TEXTURE_DOUBLE_BUFFERED = 1 << 29;
// the default flags
const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_DEALLOCATE_HOST
| TEXTURE_FRONT;
const TextureFlags TEXTURE_FLAGS_DEFAULT = TEXTURE_FRONT;
static inline bool
TextureRequiresLocking(TextureFlags aFlags)

View File

@ -290,8 +290,7 @@ GrallocImage::GetTextureClient()
return nullptr;
}
const SurfaceDescriptorGralloc& desc = sd.get_SurfaceDescriptorGralloc();
TextureFlags flags = desc.external() ? TEXTURE_DEALLOCATE_CLIENT
: TEXTURE_DEALLOCATE_HOST;
TextureFlags flags = desc.external() ? TEXTURE_DEALLOCATE_CLIENT : 0;
if (desc.isRBSwapped()) {
flags |= TEXTURE_RB_SWAPPED;
}

View File

@ -225,7 +225,6 @@ AppendToString(nsACString& s, TextureFlags flags,
AppendFlag(TEXTURE_DISALLOW_BIGIMAGE);
AppendFlag(TEXTURE_ALLOW_REPEAT);
AppendFlag(TEXTURE_NEW_TILE);
AppendFlag(TEXTURE_DEALLOCATE_HOST);
#undef AppendFlag
}

View File

@ -42,11 +42,11 @@ CanvasClient::CreateCanvasClient(CanvasClientType aType,
{
if (aType == CanvasClientGLContext &&
aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
aFlags &= ~TEXTURE_DEALLOCATE_HOST;
aFlags &= TEXTURE_DEALLOCATE_CLIENT;
return new DeprecatedCanvasClientSurfaceStream(aForwarder, aFlags);
}
if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
aFlags &= ~TEXTURE_DEALLOCATE_HOST;
aFlags &= TEXTURE_DEALLOCATE_CLIENT;
return new DeprecatedCanvasClient2D(aForwarder, aFlags);
}
return new CanvasClient2D(aForwarder, aFlags);

View File

@ -98,12 +98,12 @@ ClientCanvasLayer::RenderLayer()
}
if (!mGLContext) {
// GLContext's SurfaceStream handles ownership itself,
// and doesn't require layers to do any deallocation.
flags |= TEXTURE_DEALLOCATE_HOST;
// We don't support locking for buffer surfaces currently
flags |= TEXTURE_IMMEDIATE_UPLOAD;
} else {
// GLContext's SurfaceStream handles ownership itself,
// and doesn't require layers to do any deallocation.
flags |= TEXTURE_DEALLOCATE_CLIENT;
}
mCanvasClient = CanvasClient::CreateCanvasClient(GetCanvasClientType(),
ClientManager(), flags);

View File

@ -231,7 +231,7 @@ CompositableClient::RemoveTextureClient(TextureClient* aClient)
MOZ_ASSERT(aClient);
mTexturesToRemove.AppendElement(TextureIDAndFlags(aClient->GetID(),
aClient->GetFlags()));
if (!(aClient->GetFlags() & TEXTURE_DEALLOCATE_HOST)) {
if (aClient->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
TextureClientData* data = aClient->DropTextureData();
if (data) {
mTexturesToRemoveCallbacks[aClient->GetID()] = data;

View File

@ -201,7 +201,7 @@ ContentClientRemoteBuffer::BuildDeprecatedTextureClients(ContentType aType,
mContentType = aType;
mSize = gfx::IntSize(aRect.width, aRect.height);
mTextureInfo.mTextureFlags = aFlags | TEXTURE_DEALLOCATE_HOST;
mTextureInfo.mTextureFlags = aFlags & ~TEXTURE_DEALLOCATE_CLIENT;
if (!CreateAndAllocateDeprecatedTextureClient(mDeprecatedTextureClient)) {
return;

View File

@ -404,7 +404,7 @@ private:
void NotifyBufferCreated(ContentType aType, uint32_t aFlags)
{
mTextureInfo.mTextureFlags = aFlags | TEXTURE_DEALLOCATE_HOST;
mTextureInfo.mTextureFlags = aFlags & ~TEXTURE_DEALLOCATE_CLIENT;
mContentType = aType;
mForwarder->CreatedIncrementalBuffer(this,

View File

@ -165,7 +165,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
bool bufferCreated = false;
if (!mFrontBuffer) {
mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_DEALLOCATE_HOST);
mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_FLAGS_DEFAULT);
gfx::IntSize ySize(data->mYSize.width, data->mYSize.height);
gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
@ -226,7 +226,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
gfxImageFormat format
= gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
TEXTURE_DEALLOCATE_HOST);
TEXTURE_FLAGS_DEFAULT);
MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);

View File

@ -398,7 +398,7 @@ DeprecatedTextureClientShmem::ReleaseResources()
ShadowLayerForwarder::CloseDescriptor(mDescriptor);
}
if (mTextureInfo.mTextureFlags & TEXTURE_DEALLOCATE_HOST) {
if (!(mTextureInfo.mTextureFlags & TEXTURE_DEALLOCATE_CLIENT)) {
mDescriptor = SurfaceDescriptor();
return;
}

View File

@ -195,13 +195,6 @@ protected:
void AddFlags(TextureFlags aFlags)
{
MOZ_ASSERT(!IsSharedWithCompositor());
// make sure we don't deallocate on both client and host;
MOZ_ASSERT(!(aFlags & TEXTURE_DEALLOCATE_CLIENT && aFlags & TEXTURE_DEALLOCATE_HOST));
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
mFlags &= ~TEXTURE_DEALLOCATE_HOST;
} else if (aFlags & TEXTURE_DEALLOCATE_HOST) {
mFlags &= ~TEXTURE_DEALLOCATE_CLIENT;
}
mFlags |= aFlags;
}

View File

@ -39,7 +39,7 @@ CompositableHost::~CompositableHost()
RefPtr<TextureHost> it = mFirstTexture;
while (it) {
if (it->GetFlags() & TEXTURE_DEALLOCATE_HOST) {
if (!(it->GetFlags() & TEXTURE_DEALLOCATE_CLIENT)) {
it->DeallocateSharedData();
}
it = it->GetNextSibling();

View File

@ -260,7 +260,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
TextureFlags flags = texture->GetFlags();
if (flags & TEXTURE_DEALLOCATE_HOST) {
if (!(flags & TEXTURE_DEALLOCATE_CLIENT)) {
texture->DeallocateSharedData();
}
@ -269,7 +269,7 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
// if it is not the host that deallocates the shared data, then we need
// to notfy the client side to tell when it is safe to deallocate or
// reuse it.
if (!(flags & TEXTURE_DEALLOCATE_HOST)) {
if (flags & TEXTURE_DEALLOCATE_CLIENT) {
replyv.push_back(ReplyTextureRemoved(op.compositableParent(), nullptr,
op.textureID()));
}

View File

@ -122,14 +122,14 @@ ImageBridgeChild::RemoveTexture(CompositableClient* aCompositable,
uint64_t aTexture,
TextureFlags aFlags)
{
if (aFlags & TEXTURE_DEALLOCATE_HOST) {
// if deallocation happens on the host side, we don't need the transaction
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
// if deallocation happens on the host side, we need the transaction
// to be synchronous.
mTxn->AddNoSwapEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
} else {
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
mTxn->AddNoSwapEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
}

View File

@ -411,7 +411,7 @@ ShadowLayerForwarder::RemoveTexture(CompositableClient* aCompositable,
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
if (!(aFlags & TEXTURE_DEALLOCATE_HOST)) {
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
mTxn->MarkSyncTransaction();
}
}

View File

@ -21,8 +21,8 @@ SharedTextureClientOGL::SharedTextureClientOGL(TextureFlags aFlags)
, mHandle(0)
, mInverted(false)
{
MOZ_ASSERT(!(aFlags & (TEXTURE_DEALLOCATE_CLIENT|TEXTURE_DEALLOCATE_HOST)),
"SharedTextureClientOGL doesn't know how to release textures!");
MOZ_ASSERT(aFlags & TEXTURE_DEALLOCATE_CLIENT,
"SharedTextureClientOGL is always owned externally");
}
SharedTextureClientOGL::~SharedTextureClientOGL()