Bug 907792 - Refactor texture flags so that we set the deallocate flags based on the texture type. r=nical
This commit is contained in:
@@ -138,7 +138,7 @@ ClientImageLayer::RenderLayer()
|
|||||||
if (type == BUFFER_UNKNOWN) {
|
if (type == BUFFER_UNKNOWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TextureFlags flags = TEXTURE_FLAGS_DEFAULT;
|
TextureFlags flags = TEXTURE_FRONT;
|
||||||
if (mDisallowBigImage) {
|
if (mDisallowBigImage) {
|
||||||
flags |= TEXTURE_DISALLOW_BIGIMAGE;
|
flags |= TEXTURE_DISALLOW_BIGIMAGE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ CompositableClient::RemoveTextureClient(TextureClient* aClient)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(aClient);
|
MOZ_ASSERT(aClient);
|
||||||
mTexturesToRemove.AppendElement(aClient->GetID());
|
mTexturesToRemove.AppendElement(aClient->GetID());
|
||||||
aClient->SetID(0);
|
aClient->ClearID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
TemporaryRef<DeprecatedTextureClient>
|
TemporaryRef<DeprecatedTextureClient>
|
||||||
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
|
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
|
||||||
|
|
||||||
TemporaryRef<BufferTextureClient>
|
virtual TemporaryRef<BufferTextureClient>
|
||||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
|
||||||
|
|
||||||
virtual TemporaryRef<BufferTextureClient>
|
virtual TemporaryRef<BufferTextureClient>
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
|||||||
|
|
||||||
bool bufferCreated = false;
|
bool bufferCreated = false;
|
||||||
if (!mFrontBuffer) {
|
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 ySize(data->mYSize.width, data->mYSize.height);
|
||||||
gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
|
gfx::IntSize cbCrSize(data->mCbCrSize.width, data->mCbCrSize.height);
|
||||||
if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
|
if (!mFrontBuffer->AsTextureClientYCbCr()->AllocateForYCbCr(ySize, cbCrSize, data->mStereoMode)) {
|
||||||
@@ -180,7 +180,8 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
|||||||
if (!mFrontBuffer) {
|
if (!mFrontBuffer) {
|
||||||
gfxASurface::gfxImageFormat format
|
gfxASurface::gfxImageFormat format
|
||||||
= gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
|
= gfxPlatform::GetPlatform()->OptimalFormatForContent(surface->GetContentType());
|
||||||
mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
|
mFrontBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
|
||||||
|
TEXTURE_DEALLOCATE_HOST);
|
||||||
MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
|
MOZ_ASSERT(mFrontBuffer->AsTextureClientSurface());
|
||||||
mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);
|
mFrontBuffer->AsTextureClientSurface()->AllocateForSurface(size);
|
||||||
|
|
||||||
@@ -229,6 +230,12 @@ ImageClientSingle::AddTextureClient(TextureClient* aTexture)
|
|||||||
CompositableClient::AddTextureClient(aTexture);
|
CompositableClient::AddTextureClient(aTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TemporaryRef<BufferTextureClient>
|
||||||
|
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
||||||
|
{
|
||||||
|
return CompositableClient::CreateBufferTextureClient(aFormat, mTextureFlags | aFlags);
|
||||||
|
}
|
||||||
|
|
||||||
TemporaryRef<BufferTextureClient>
|
TemporaryRef<BufferTextureClient>
|
||||||
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
|
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ public:
|
|||||||
|
|
||||||
virtual void AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE;
|
virtual void AddTextureClient(TextureClient* aTexture) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
virtual TemporaryRef<BufferTextureClient>
|
||||||
|
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags) MOZ_OVERRIDE;
|
||||||
|
|
||||||
virtual TemporaryRef<BufferTextureClient>
|
virtual TemporaryRef<BufferTextureClient>
|
||||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;
|
CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace layers {
|
|||||||
TextureClient::TextureClient(TextureFlags aFlags)
|
TextureClient::TextureClient(TextureFlags aFlags)
|
||||||
: mID(0)
|
: mID(0)
|
||||||
, mFlags(aFlags)
|
, mFlags(aFlags)
|
||||||
|
, mShared(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TextureClient::~TextureClient()
|
TextureClient::~TextureClient()
|
||||||
@@ -46,9 +47,18 @@ TextureClient::~TextureClient()
|
|||||||
bool
|
bool
|
||||||
TextureClient::ShouldDeallocateInDestructor() const
|
TextureClient::ShouldDeallocateInDestructor() const
|
||||||
{
|
{
|
||||||
return IsAllocated() &&
|
if (!IsAllocated()) {
|
||||||
!IsSharedWithCompositor() &&
|
return false;
|
||||||
!(GetFlags() & (TEXTURE_DEALLOCATE_HOST | TEXTURE_DEALLOCATE_CLIENT));
|
}
|
||||||
|
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
|
bool
|
||||||
|
|||||||
@@ -123,8 +123,14 @@ public:
|
|||||||
|
|
||||||
void SetID(uint64_t aID)
|
void SetID(uint64_t aID)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mID == 0 || aID == 0);
|
MOZ_ASSERT(mID == 0 && aID != 0);
|
||||||
mID = aID;
|
mID = aID;
|
||||||
|
mShared = true;
|
||||||
|
}
|
||||||
|
void ClearID()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mID != 0);
|
||||||
|
mID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetID() const
|
uint64_t GetID() const
|
||||||
@@ -149,7 +155,7 @@ public:
|
|||||||
|
|
||||||
void MarkImmutable() { AddFlags(TEXTURE_IMMUTABLE); }
|
void MarkImmutable() { AddFlags(TEXTURE_IMMUTABLE); }
|
||||||
|
|
||||||
bool IsSharedWithCompositor() const { return GetID() != 0; }
|
bool IsSharedWithCompositor() const { return mShared; }
|
||||||
|
|
||||||
bool ShouldDeallocateInDestructor() const;
|
bool ShouldDeallocateInDestructor() const;
|
||||||
protected:
|
protected:
|
||||||
@@ -168,6 +174,7 @@ protected:
|
|||||||
|
|
||||||
uint64_t mID;
|
uint64_t mID;
|
||||||
TextureFlags mFlags;
|
TextureFlags mFlags;
|
||||||
|
bool mShared;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user