Bug 897452 - Part 3 - Clean up some unused code after PTexture change - r=mattwoodrow

This commit is contained in:
Nicolas Silva 2013-12-11 13:05:13 -05:00
parent 5a8009c28f
commit 82e5ac3f48
18 changed files with 49 additions and 205 deletions

View File

@ -35,11 +35,10 @@ MacIOSurfaceTextureSourceBasic::GetFormat() const
}
MacIOSurfaceTextureHostBasic::MacIOSurfaceTextureHostBasic(
uint64_t aID,
TextureFlags aFlags,
const SurfaceDescriptorMacIOSurface& aDescriptor
)
: TextureHost(aID, aFlags)
: TextureHost(aFlags)
{
mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
aDescriptor.scaleFactor(),

View File

@ -56,9 +56,8 @@ protected:
class MacIOSurfaceTextureHostBasic : public TextureHost
{
public:
MacIOSurfaceTextureHostBasic(uint64_t aID,
TextureFlags aFlags,
const SurfaceDescriptorMacIOSurface& aDescriptor);
MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
const SurfaceDescriptorMacIOSurface& aDescriptor);
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;

View File

@ -13,8 +13,7 @@ namespace mozilla {
namespace layers {
TemporaryRef<TextureHost>
CreateTextureHostBasic(uint64_t aID,
const SurfaceDescriptor& aDesc,
CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
@ -24,12 +23,12 @@ CreateTextureHostBasic(uint64_t aID,
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
const SurfaceDescriptorMacIOSurface& desc =
aDesc.get_SurfaceDescriptorMacIOSurface();
result = new MacIOSurfaceTextureHostBasic(aID, aFlags, desc);
result = new MacIOSurfaceTextureHostBasic(aFlags, desc);
break;
}
#endif
default: {
result = CreateBackendIndependentTextureHost(aID, aDesc, aDeallocator, aFlags);
result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
break;
}
}

View File

@ -24,8 +24,7 @@ namespace mozilla {
namespace layers {
CompositableClient::CompositableClient(CompositableForwarder* aForwarder)
: mNextTextureID(1)
, mCompositableChild(nullptr)
: mCompositableChild(nullptr)
, mForwarder(aForwarder)
{
MOZ_COUNT_CTOR(CompositableClient);
@ -249,7 +248,6 @@ CompositableClient::NextTextureID()
bool
CompositableClient::AddTextureClient(TextureClient* aClient)
{
aClient->SetID(NextTextureID());
return aClient->InitIPDLActor(mForwarder);
}

View File

@ -151,7 +151,6 @@ protected:
// return the next texture ID
uint64_t NextTextureID();
uint64_t mNextTextureID;
CompositableChild* mCompositableChild;
CompositableForwarder* mForwarder;
};

View File

@ -217,7 +217,6 @@ ShmemTextureClient::DropTextureData()
TextureClient::TextureClient(TextureFlags aFlags)
: mRefCount(0)
, mActor(nullptr)
, mID(0)
, mFlags(aFlags)
, mShared(false)
, mValid(true)

View File

@ -204,30 +204,6 @@ public:
static PTextureChild* CreateIPDLActor();
static bool DestroyIPDLActor(PTextureChild* actor);
/**
* Sets this texture's ID.
*
* This ID is used to match a texture client with his corresponding TextureHost.
* Only the CompositableClient should be allowed to set or clear the ID.
* Zero is always an invalid ID.
* For a given compositableClient, there can never be more than one texture
* client with the same non-zero ID.
* Texture clients from different compositables may have the same ID.
*/
void SetID(uint64_t aID)
{
MOZ_ASSERT(mID == 0 && aID != 0);
mID = aID;
mShared = true;
}
void ClearID()
{
MOZ_ASSERT(mID != 0);
mID = 0;
}
uint64_t GetID() const { return mID; }
virtual bool IsAllocated() const = 0;
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aDescriptor) = 0;
@ -320,7 +296,6 @@ protected:
}
TextureChild* mActor;
uint64_t mID;
TextureFlags mFlags;
bool mShared;
bool mValid;

View File

@ -36,14 +36,6 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
CompositableHost::~CompositableHost()
{
MOZ_COUNT_DTOR(CompositableHost);
RefPtr<TextureHost> it = mFirstTexture;
while (it) {
if (!(it->GetFlags() & TEXTURE_DEALLOCATE_CLIENT)) {
it->DeallocateSharedData();
}
it = it->GetNextSibling();
}
}
void
@ -56,54 +48,6 @@ CompositableHost::UseTextureHost(TextureHost* aTexture)
aTexture->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
}
void
CompositableHost::AddTextureHost(TextureHost* aTexture)
{
MOZ_ASSERT(aTexture);
MOZ_ASSERT(GetTextureHost(aTexture->GetID()) == nullptr,
"A texture is already present with this ID");
RefPtr<TextureHost> second = mFirstTexture;
mFirstTexture = aTexture;
aTexture->SetNextSibling(second);
aTexture->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
}
void
CompositableHost::RemoveTextureHost(TextureHost* aTexture)
{
uint64_t textureID = aTexture->GetID();
if (mFirstTexture && mFirstTexture->GetID() == textureID) {
mFirstTexture = mFirstTexture->GetNextSibling();
aTexture->SetNextSibling(nullptr);
}
RefPtr<TextureHost> it = mFirstTexture;
while (it) {
if (it->GetNextSibling() &&
it->GetNextSibling()->GetID() == textureID) {
it->SetNextSibling(it->GetNextSibling()->GetNextSibling());
aTexture->SetNextSibling(nullptr);
}
it = it->GetNextSibling();
}
if (!mFirstTexture && mBackendData) {
mBackendData->ClearData();
}
}
TextureHost*
CompositableHost::GetTextureHost(uint64_t aTextureID)
{
RefPtr<TextureHost> it = mFirstTexture;
while (it) {
if (it->GetID() == aTextureID) {
return it;
}
it = it->GetNextSibling();
}
return nullptr;
}
void
CompositableHost::OnActorDestroy()
{
@ -118,11 +62,6 @@ void
CompositableHost::SetCompositor(Compositor* aCompositor)
{
mCompositor = aCompositor;
RefPtr<TextureHost> it = mFirstTexture;
while (!!it) {
it->SetCompositor(aCompositor);
it = it->GetNextSibling();
}
}
bool

View File

@ -294,16 +294,7 @@ public:
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
void AddTextureHost(TextureHost* aTexture);
virtual void UseTextureHost(TextureHost* aTexture);
// If a texture host is flagged for deferred removal, the compositable will
// get an option to run any cleanup code early, that is when it would have
// been run if the texture host was not marked deferred.
// If the compositable does not cleanup the texture host now, it is the
// compositable's responsibility to cleanup the texture host before the
// texture host dies.
virtual void RemoveTextureHost(TextureHost* aTexture);
TextureHost* GetTextureHost(uint64_t aTextureID);
protected:
TextureInfo mTextureInfo;

View File

@ -137,35 +137,32 @@ DeprecatedTextureHost::CreateDeprecatedTextureHost(SurfaceDescriptorType aDescri
}
// implemented in TextureHostOGL.cpp
TemporaryRef<TextureHost> CreateTextureHostOGL(uint64_t aID,
const SurfaceDescriptor& aDesc,
TemporaryRef<TextureHost> CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
// implemented in TextureHostBasic.cpp
TemporaryRef<TextureHost> CreateTextureHostBasic(uint64_t aID,
const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
TemporaryRef<TextureHost> CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
// static
TemporaryRef<TextureHost>
TextureHost::Create(uint64_t aID,
const SurfaceDescriptor& aDesc,
TextureHost::Create(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
switch (Compositor::GetBackend()) {
case LAYERS_OPENGL:
return CreateTextureHostOGL(aID, aDesc, aDeallocator, aFlags);
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
case LAYERS_BASIC:
return CreateTextureHostBasic(aID, aDesc, aDeallocator, aFlags);
return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
#ifdef MOZ_WIDGET_GONK
case LAYERS_NONE:
// Power on video reqests to allocate TextureHost,
// when Compositor is still not present. This is a very hacky workaround.
// See Bug 944420.
return CreateTextureHostOGL(aID, aDesc, aDeallocator, aFlags);
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
#endif
#ifdef XP_WIN
case LAYERS_D3D11:
@ -179,8 +176,7 @@ TextureHost::Create(uint64_t aID,
}
TemporaryRef<TextureHost>
CreateBackendIndependentTextureHost(uint64_t aID,
const SurfaceDescriptor& aDesc,
CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
@ -188,8 +184,7 @@ CreateBackendIndependentTextureHost(uint64_t aID,
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem: {
const SurfaceDescriptorShmem& descriptor = aDesc.get_SurfaceDescriptorShmem();
result = new ShmemTextureHost(aID,
descriptor.data(),
result = new ShmemTextureHost(descriptor.data(),
descriptor.format(),
aDeallocator,
aFlags);
@ -197,8 +192,7 @@ CreateBackendIndependentTextureHost(uint64_t aID,
}
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
const SurfaceDescriptorMemory& descriptor = aDesc.get_SurfaceDescriptorMemory();
result = new MemoryTextureHost(aID,
reinterpret_cast<uint8_t*>(descriptor.data()),
result = new MemoryTextureHost(reinterpret_cast<uint8_t*>(descriptor.data()),
descriptor.format(),
aFlags);
break;
@ -217,11 +211,8 @@ TextureHost::SetCompositableBackendSpecificData(CompositableBackendSpecificData*
}
TextureHost::TextureHost(uint64_t aID,
TextureFlags aFlags)
: mID(aID)
, mNextTexture(nullptr)
, mFlags(aFlags)
TextureHost::TextureHost(TextureFlags aFlags)
: mFlags(aFlags)
{}
TextureHost::~TextureHost()
@ -335,10 +326,9 @@ DeprecatedTextureHost::SetBuffer(SurfaceDescriptor* aBuffer, ISurfaceAllocator*
mDeAllocator = aAllocator;
}
BufferTextureHost::BufferTextureHost(uint64_t aID,
gfx::SurfaceFormat aFormat,
BufferTextureHost::BufferTextureHost(gfx::SurfaceFormat aFormat,
TextureFlags aFlags)
: TextureHost(aID, aFlags)
: TextureHost(aFlags)
, mCompositor(nullptr)
, mFormat(aFormat)
, mUpdateSerial(1)
@ -557,12 +547,11 @@ BufferTextureHost::GetAsSurface()
return result.forget();
}
ShmemTextureHost::ShmemTextureHost(uint64_t aID,
const ipc::Shmem& aShmem,
ShmemTextureHost::ShmemTextureHost(const ipc::Shmem& aShmem,
gfx::SurfaceFormat aFormat,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
: BufferTextureHost(aID, aFormat, aFlags)
: BufferTextureHost(aFormat, aFlags)
, mShmem(new ipc::Shmem(aShmem))
, mDeallocator(aDeallocator)
{
@ -609,11 +598,10 @@ uint8_t* ShmemTextureHost::GetBuffer()
return mShmem ? mShmem->get<uint8_t>() : nullptr;
}
MemoryTextureHost::MemoryTextureHost(uint64_t aID,
uint8_t* aBuffer,
MemoryTextureHost::MemoryTextureHost(uint8_t* aBuffer,
gfx::SurfaceFormat aFormat,
TextureFlags aFlags)
: BufferTextureHost(aID, aFormat, aFlags)
: BufferTextureHost(aFormat, aFlags)
, mBuffer(aBuffer)
{
MOZ_COUNT_CTOR(MemoryTextureHost);
@ -664,8 +652,7 @@ bool
TextureParent::RecvInit(const SurfaceDescriptor& aSharedData,
const TextureFlags& aFlags)
{
mTextureHost = TextureHost::Create(0, // XXX legacy texture id, see subsequent patch
aSharedData,
mTextureHost = TextureHost::Create(aSharedData,
mAllocator,
aFlags);
return !!mTextureHost;

View File

@ -261,16 +261,14 @@ private:
class TextureHost : public RefCounted<TextureHost>
{
public:
TextureHost(uint64_t aID,
TextureFlags aFlags);
TextureHost(TextureFlags aFlags);
virtual ~TextureHost();
/**
* Factory method.
*/
static TemporaryRef<TextureHost> Create(uint64_t aID,
const SurfaceDescriptor& aDesc,
static TemporaryRef<TextureHost> Create(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
@ -340,28 +338,8 @@ public:
*/
virtual void ForgetSharedData() {}
/**
* An ID to differentiate TextureHosts of a given CompositableHost.
*
* A TextureHost and its corresponding TextureClient always have the same ID.
* TextureHosts of a given CompositableHost always have different IDs.
* TextureHosts of different CompositableHosts, may have the same ID.
* Zero is always an invalid ID.
*/
uint64_t GetID() const { return mID; }
virtual gfx::IntSize GetSize() const = 0;
/**
* TextureHosts are kept as a linked list in their compositable
* XXX - This is just a poor man's PTexture. The purpose of this list is
* to keep TextureHost alive which should be independent from compositables.
* It will be removed when we add the PTetxure protocol (which will more
* gracefully handle the lifetime of textures). See bug 897452
*/
TextureHost* GetNextSibling() const { return mNextTexture; }
void SetNextSibling(TextureHost* aNext) { mNextTexture = aNext; }
/**
* Debug facility.
* XXX - cool kids use Moz2D. See bug 882113.
@ -422,8 +400,6 @@ public:
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
protected:
uint64_t mID;
RefPtr<TextureHost> mNextTexture;
TextureFlags mFlags;
RefPtr<CompositableBackendSpecificData> mCompositableBackendData;
};
@ -444,8 +420,7 @@ protected:
class BufferTextureHost : public TextureHost
{
public:
BufferTextureHost(uint64_t aID,
gfx::SurfaceFormat aFormat,
BufferTextureHost(gfx::SurfaceFormat aFormat,
TextureFlags aFlags);
~BufferTextureHost();
@ -500,8 +475,7 @@ protected:
class ShmemTextureHost : public BufferTextureHost
{
public:
ShmemTextureHost(uint64_t aID,
const mozilla::ipc::Shmem& aShmem,
ShmemTextureHost(const mozilla::ipc::Shmem& aShmem,
gfx::SurfaceFormat aFormat,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);
@ -532,8 +506,7 @@ protected:
class MemoryTextureHost : public BufferTextureHost
{
public:
MemoryTextureHost(uint64_t aID,
uint8_t* aBuffer,
MemoryTextureHost(uint8_t* aBuffer,
gfx::SurfaceFormat aFormat,
TextureFlags aFlags);
@ -848,8 +821,7 @@ private:
* Not all SurfaceDescriptor types are supported
*/
TemporaryRef<TextureHost>
CreateBackendIndependentTextureHost(uint64_t aID,
const SurfaceDescriptor& aDesc,
CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags);

View File

@ -220,10 +220,9 @@ GrallocTextureSourceOGL::DeallocateDeviceData()
}
}
GrallocTextureHostOGL::GrallocTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
const NewSurfaceDescriptorGralloc& aDescriptor)
: TextureHost(aID, aFlags)
: TextureHost(aFlags)
{
mGrallocActor =
static_cast<GrallocBufferActor*>(aDescriptor.bufferParent());

View File

@ -76,8 +76,7 @@ class GrallocTextureHostOGL : public TextureHost
{
friend class GrallocBufferActor;
public:
GrallocTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
GrallocTextureHostOGL(TextureFlags aFlags,
const NewSurfaceDescriptorGralloc& aDescriptor);
virtual ~GrallocTextureHostOGL();

View File

@ -34,10 +34,9 @@ MacIOSurfaceTextureSourceOGL::GetFormat() const
return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
}
MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
const SurfaceDescriptorMacIOSurface& aDescriptor)
: TextureHost(aID, aFlags)
: TextureHost(aFlags)
{
mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
aDescriptor.scaleFactor(),

View File

@ -65,8 +65,7 @@ protected:
class MacIOSurfaceTextureHostOGL : public TextureHost
{
public:
MacIOSurfaceTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
const SurfaceDescriptorMacIOSurface& aDescriptor);
// SharedTextureHostOGL doesn't own any GL texture

View File

@ -87,8 +87,7 @@ CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
TemporaryRef<TextureHost>
CreateTextureHostOGL(uint64_t aID,
const SurfaceDescriptor& aDesc,
CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
ISurfaceAllocator* aDeallocator,
TextureFlags aFlags)
{
@ -96,13 +95,13 @@ CreateTextureHostOGL(uint64_t aID,
switch (aDesc.type()) {
case SurfaceDescriptor::TSurfaceDescriptorShmem:
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
result = CreateBackendIndependentTextureHost(aID, aDesc,
result = CreateBackendIndependentTextureHost(aDesc,
aDeallocator, aFlags);
break;
}
case SurfaceDescriptor::TSharedTextureDescriptor: {
const SharedTextureDescriptor& desc = aDesc.get_SharedTextureDescriptor();
result = new SharedTextureHostOGL(aID, aFlags,
result = new SharedTextureHostOGL(aFlags,
desc.shareType(),
desc.handle(),
gfx::ToIntSize(desc.size()),
@ -113,7 +112,7 @@ CreateTextureHostOGL(uint64_t aID,
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
const SurfaceDescriptorMacIOSurface& desc =
aDesc.get_SurfaceDescriptorMacIOSurface();
result = new MacIOSurfaceTextureHostOGL(aID, aFlags, desc);
result = new MacIOSurfaceTextureHostOGL(aFlags, desc);
break;
}
#endif
@ -121,7 +120,7 @@ CreateTextureHostOGL(uint64_t aID,
case SurfaceDescriptor::TNewSurfaceDescriptorGralloc: {
const NewSurfaceDescriptorGralloc& desc =
aDesc.get_NewSurfaceDescriptorGralloc();
result = new GrallocTextureHostOGL(aID, aFlags, desc);
result = new GrallocTextureHostOGL(aFlags, desc);
break;
}
#endif
@ -376,13 +375,12 @@ SharedTextureSourceOGL::GetTextureTransform()
return handleDetails.mTextureTransform;
}
SharedTextureHostOGL::SharedTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
SharedTextureHostOGL::SharedTextureHostOGL(TextureFlags aFlags,
gl::SharedTextureShareType aShareType,
gl::SharedTextureHandle aSharedHandle,
gfx::IntSize aSize,
bool inverted)
: TextureHost(aID, aFlags)
: TextureHost(aFlags)
, mSize(aSize)
, mCompositor(nullptr)
, mSharedHandle(aSharedHandle)

View File

@ -298,8 +298,7 @@ protected:
class SharedTextureHostOGL : public TextureHost
{
public:
SharedTextureHostOGL(uint64_t aID,
TextureFlags aFlags,
SharedTextureHostOGL(TextureFlags aFlags,
gl::SharedTextureShareType aShareType,
gl::SharedTextureHandle aSharedhandle,
gfx::IntSize aSize,

View File

@ -119,20 +119,17 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface)
texture->Unlock();
// client serialization
texture->SetID(1);
SurfaceDescriptor descriptor;
ASSERT_TRUE(texture->ToSurfaceDescriptor(descriptor));
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
// host deserialization
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(texture->GetID(),
descriptor, nullptr,
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(descriptor, nullptr,
texture->GetFlags());
ASSERT_TRUE(host.get() != nullptr);
ASSERT_EQ(host->GetFlags(), texture->GetFlags());
ASSERT_EQ(host->GetID(), texture->GetID());
// host read
ASSERT_TRUE(host->Lock());
@ -168,22 +165,19 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
client->Unlock();
// client serialization
client->SetID(1);
SurfaceDescriptor descriptor;
ASSERT_TRUE(client->ToSurfaceDescriptor(descriptor));
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
// host deserialization
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(client->GetID(),
descriptor, nullptr,
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
client->GetFlags());
RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
ASSERT_TRUE(host.get() != nullptr);
ASSERT_EQ(host->GetFlags(), client->GetFlags());
ASSERT_EQ(host->GetID(), client->GetID());
// This will work iff the compositor is not BasicCompositor
ASSERT_EQ(host->GetFormat(), mozilla::gfx::FORMAT_YUV);