Bug 907792 - Refactor texture flags so that we set the deallocate flags based on the texture type. r=nical

This commit is contained in:
Matt Woodrow 2013-08-28 08:16:03 +12:00
parent 77a0dc925c
commit 64e549b0dc
7 changed files with 37 additions and 10 deletions

View File

@ -138,7 +138,7 @@ ClientImageLayer::RenderLayer()
if (type == BUFFER_UNKNOWN) {
return;
}
TextureFlags flags = TEXTURE_FLAGS_DEFAULT;
TextureFlags flags = TEXTURE_FRONT;
if (mDisallowBigImage) {
flags |= TEXTURE_DISALLOW_BIGIMAGE;
}

View File

@ -197,7 +197,7 @@ CompositableClient::RemoveTextureClient(TextureClient* aClient)
{
MOZ_ASSERT(aClient);
mTexturesToRemove.AppendElement(aClient->GetID());
aClient->SetID(0);
aClient->ClearID();
}
void

View File

@ -80,7 +80,7 @@ public:
TemporaryRef<DeprecatedTextureClient>
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
TemporaryRef<BufferTextureClient>
virtual TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
virtual TemporaryRef<BufferTextureClient>

View File

@ -136,7 +136,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
bool bufferCreated = false;
if (!mFrontBuffer) {
mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV);
mFrontBuffer = CreateBufferTextureClient(gfx::FORMAT_YUV, TEXTURE_DEALLOCATE_HOST);
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)) {
@ -180,7 +180,8 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
if (!mFrontBuffer) {
gfxASurface::gfxImageFormat format
= gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
TEXTURE_DEALLOCATE_HOST);
MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);
@ -229,6 +230,12 @@ ImageClientSingle::AddTextureClient(TextureClient* aTexture)
CompositableClient::AddTextureClient(aTexture);
}
TemporaryRef<BufferTextureClient>
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
{
return CompositableClient::CreateBufferTextureClient(aFormat, mTextureFlags | aFlags);
}
TemporaryRef<BufferTextureClient>
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
{

View File

@ -86,6 +86,9 @@ public:
virtual void AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE;
virtual TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags) MOZ_OVERRIDE;
virtual TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;

View File

@ -38,6 +38,7 @@ namespace layers {
TextureClient::TextureClient(TextureFlags aFlags)
: mID(0)
, mFlags(aFlags)
, mShared(false)
{}
TextureClient::~TextureClient()
@ -46,9 +47,18 @@ TextureClient::~TextureClient()
bool
TextureClient::ShouldDeallocateInDestructor() const
{
return IsAllocated() &&
!IsSharedWithCompositor() &&
!(GetFlags() & (TEXTURE_DEALLOCATE_HOST | TEXTURE_DEALLOCATE_CLIENT));
if (!IsAllocated()) {
return false;
}
if (GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
return true;
}
// If we're meant to be deallocated by the host,
// but we haven't been shared yet, then we should
// deallocate on the client instead.
return (GetFlags() & TEXTURE_DEALLOCATE_HOST) &&
!IsSharedWithCompositor();
}
bool

View File

@ -123,8 +123,14 @@ public:
void SetID(uint64_t aID)
{
MOZ_ASSERT(mID == 0 || aID == 0);
MOZ_ASSERT(mID == 0 && aID != 0);
mID = aID;
mShared = true;
}
void ClearID()
{
MOZ_ASSERT(mID != 0);
mID = 0;
}
uint64_t GetID() const
@ -149,7 +155,7 @@ public:
void MarkImmutable() { AddFlags(TEXTURE_IMMUTABLE); }
bool IsSharedWithCompositor() const { return GetID() != 0; }
bool IsSharedWithCompositor() const { return mShared; }
bool ShouldDeallocateInDestructor() const;
protected:
@ -168,6 +174,7 @@ protected:
uint64_t mID;
TextureFlags mFlags;
bool mShared;
};
/**