mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 907792 - Refactor texture flags so that we set the deallocate flags based on the texture type. r=nical
This commit is contained in:
parent
77a0dc925c
commit
64e549b0dc
@ -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;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ CompositableClient::RemoveTextureClient(TextureClient* aClient)
|
||||
{
|
||||
MOZ_ASSERT(aClient);
|
||||
mTexturesToRemove.AppendElement(aClient->GetID());
|
||||
aClient->SetID(0);
|
||||
aClient->ClearID();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
TemporaryRef<DeprecatedTextureClient>
|
||||
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
virtual TemporaryRef<BufferTextureClient>
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||
|
||||
virtual TemporaryRef<BufferTextureClient>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user