Bug 897452 - Part 1 - Implement the PTexture protocol - r=mattwoodrow

This commit is contained in:
Nicolas Silva 2013-12-11 13:05:09 -05:00
parent 171c6f13c2
commit 01cd073429
27 changed files with 339 additions and 272 deletions

View File

@ -369,14 +369,8 @@ ClientLayerManager::ForwardTransaction()
break;
}
case EditReply::TReplyTextureRemoved: {
// XXX - to manage reuse of gralloc buffers, we'll need to add some
// glue code here to find the TextureClient and invoke a callback to
// let the camera know that the gralloc buffer is not used anymore on
// the compositor side and that it can reuse it.
const ReplyTextureRemoved& rep = reply.get_ReplyTextureRemoved();
CompositableClient* compositable
= static_cast<CompositableChild*>(rep.compositableChild())->GetCompositableClient();
compositable->OnReplyTextureRemoved(rep.textureId());
// XXX - The logic to remove textures is implemented in the next patch
// of the same bug (897452). They will land together.
break;
}

View File

@ -36,23 +36,6 @@ CompositableClient::~CompositableClient()
{
MOZ_COUNT_DTOR(CompositableClient);
Destroy();
FlushTexturesToRemoveCallbacks();
MOZ_ASSERT(mTexturesToRemove.Length() == 0, "would leak textures pending for deletion");
}
void
CompositableClient::FlushTexturesToRemoveCallbacks()
{
std::map<uint64_t,TextureClientData*>::iterator it
= mTexturesToRemoveCallbacks.begin();
std::map<uint64_t,TextureClientData*>::iterator stop
= mTexturesToRemoveCallbacks.end();
for (; it != stop; ++it) {
it->second->DeallocateSharedData(GetForwarder());
delete it->second;
}
mTexturesToRemoveCallbacks.clear();
}
LayersBackend
@ -267,45 +250,20 @@ bool
CompositableClient::AddTextureClient(TextureClient* aClient)
{
aClient->SetID(NextTextureID());
return mForwarder->AddTexture(this, aClient);
return aClient->InitIPDLActor(mForwarder);
}
void
CompositableClient::RemoveTextureClient(TextureClient* aClient)
{
MOZ_ASSERT(aClient);
mTexturesToRemove.AppendElement(TextureIDAndFlags(aClient->GetID(),
aClient->GetFlags()));
if (aClient->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
TextureClientData* data = aClient->DropTextureData();
if (data) {
mTexturesToRemoveCallbacks[aClient->GetID()] = data;
}
}
aClient->ClearID();
mForwarder->RemoveTexture(aClient);
aClient->MarkInvalid();
}
void
CompositableClient::OnReplyTextureRemoved(uint64_t aTextureID)
{
std::map<uint64_t,TextureClientData*>::iterator it
= mTexturesToRemoveCallbacks.find(aTextureID);
if (it != mTexturesToRemoveCallbacks.end()) {
it->second->DeallocateSharedData(GetForwarder());
delete it->second;
mTexturesToRemoveCallbacks.erase(it);
}
}
void
CompositableClient::OnTransaction()
{
for (unsigned i = 0; i < mTexturesToRemove.Length(); ++i) {
const TextureIDAndFlags& texture = mTexturesToRemove[i];
mForwarder->RemoveTexture(this, texture.mID, texture.mFlags);
}
mTexturesToRemove.Clear();
}

View File

@ -148,26 +148,6 @@ public:
*/
virtual void OnDetach() {}
/**
* When texture deallocation must happen on the client side, we need to first
* ensure that the compositor has already let go of the data in order
* to safely deallocate it.
*
* This is implemented by registering a callback to postpone deallocation or
* recycling of the shared data.
*
* This hook is called when the compositor notifies the client that it is not
* holding any more references to the shared data so that this compositable
* can run the corresponding callback.
*/
void OnReplyTextureRemoved(uint64_t aTextureID);
/**
* Run all he registered callbacks (see the comment for OnReplyTextureRemoved).
* Only call this if you know what you are doing.
*/
void FlushTexturesToRemoveCallbacks();
/**
* Our IPDL actor is being destroyed, get rid of any shmem resources now.
*/
@ -177,15 +157,6 @@ protected:
// return the next texture ID
uint64_t NextTextureID();
struct TextureIDAndFlags {
TextureIDAndFlags(uint64_t aID, TextureFlags aFlags)
: mID(aID), mFlags(aFlags) {}
uint64_t mID;
TextureFlags mFlags;
};
// The textures to destroy in the next transaction;
nsTArray<TextureIDAndFlags> mTexturesToRemove;
std::map<uint64_t, TextureClientData*> mTexturesToRemoveCallbacks;
uint64_t mNextTextureID;
CompositableChild* mCompositableChild;
CompositableForwarder* mForwarder;

View File

@ -19,6 +19,7 @@
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
#include "mozilla/layers/YCbCrImageDataSerializer.h"
#include "mozilla/layers/PTextureChild.h"
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
@ -38,6 +39,47 @@ using namespace mozilla::gfx;
namespace mozilla {
namespace layers {
class TextureChild : public PTextureChild
{
public:
};
// static
PTextureChild*
TextureClient::CreateIPDLActor()
{
return new TextureChild();
}
// static
bool
TextureClient::DestroyIPDLActor(PTextureChild* actor)
{
delete actor;
return true;
}
bool
TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
{
MOZ_ASSERT(!mActor);
SurfaceDescriptor desc;
if (!ToSurfaceDescriptor(desc)) {
return false;
}
mActor = static_cast<TextureChild*>(aForwarder->CreateEmptyTextureChild());
mShared = true;
return mActor->SendInit(desc, GetFlags());
}
PTextureChild*
TextureClient::GetIPDLActor()
{
return mActor;
}
class ShmemTextureClientData : public TextureClientData
{
public:
@ -112,6 +154,7 @@ ShmemTextureClient::DropTextureData()
TextureClient::TextureClient(TextureFlags aFlags)
: mRefCount(0)
, mActor(nullptr)
, mID(0)
, mFlags(aFlags)
, mShared(false)

View File

@ -39,6 +39,8 @@ class CompositableClient;
class PlanarYCbCrImage;
class PlanarYCbCrData;
class Image;
class PTextureChild;
class TextureChild;
/**
* TextureClient is the abstraction that allows us to share data between the
@ -192,6 +194,17 @@ public:
*/
virtual bool ImplementsLocking() const { return false; }
/**
* Allocate and deallocate a TextureChild actor.
*
* TextureChild is an implementation detail of TextureHost that is not
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
* are for use with the maging IPDL protocols only (so that they can
* implement AllocPextureChild and DeallocPTextureChild).
*/
static PTextureChild* CreateIPDLActor();
static bool DestroyIPDLActor(PTextureChild* actor);
/**
* Sets this texture's ID.
*
@ -269,6 +282,21 @@ public:
// method to forget about the shmem _without_ releasing it.
virtual void OnActorDestroy() {}
/**
* Create and init the TextureChild/Parent IPDL actor pair.
*
* Should be called only once per TextureClient.
*/
bool InitIPDLActor(CompositableForwarder* aForwarder);
/**
* Return a pointer to the IPDLActor.
*
* This is to be used with IPDL messages only. Do not store the returned
* pointer.
*/
PTextureChild* GetIPDLActor();
private:
Atomic<int> mRefCount;
@ -290,6 +318,7 @@ protected:
mFlags |= aFlags;
}
TextureChild* mActor;
uint64_t mID;
TextureFlags mFlags;
bool mShared;

View File

@ -52,6 +52,7 @@ CompositableHost::UseTextureHost(TextureHost* aTexture)
if (!aTexture) {
return;
}
aTexture->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
aTexture->SetCompositor(GetCompositor());
}

View File

@ -18,12 +18,62 @@
#include "nsAString.h"
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsPrintfCString.h" // for nsPrintfCString
#include "mozilla/layers/PTextureParent.h"
struct nsIntPoint;
namespace mozilla {
namespace layers {
/**
* TextureParent is the host-side IPDL glue between TextureClient and TextureHost.
* It is an IPDL actor just like LayerParent, CompositableParent, etc.
*/
class TextureParent : public PTextureParent
{
public:
TextureParent(ISurfaceAllocator* aAllocator);
~TextureParent();
bool RecvInit(const SurfaceDescriptor& aSharedData,
const TextureFlags& aFlags) MOZ_OVERRIDE;
TextureHost* GetTextureHost() { return mTextureHost; }
ISurfaceAllocator* mAllocator;
RefPtr<TextureHost> mTextureHost;
};
// static
PTextureParent*
TextureHost::CreateIPDLActor(ISurfaceAllocator* aAllocator)
{
return new TextureParent(aAllocator);
}
// static
bool
TextureHost::DestroyIPDLActor(PTextureParent* actor)
{
delete actor;
return true;
}
// static
bool
TextureHost::SendDeleteIPDLActor(PTextureParent* actor)
{
return PTextureParent::Send__delete__(actor);
}
// static
TextureHost*
TextureHost::AsTextureHost(PTextureParent* actor)
{
return actor? static_cast<TextureParent*>(actor)->mTextureHost : nullptr;
}
// implemented in TextureOGL.cpp
TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
uint32_t aDeprecatedTextureHostFlags,
@ -576,5 +626,28 @@ uint8_t* MemoryTextureHost::GetBuffer()
return mBuffer;
}
TextureParent::TextureParent(ISurfaceAllocator* aAllocator)
: mAllocator(aAllocator)
{
MOZ_COUNT_CTOR(TextureParent);
}
TextureParent::~TextureParent()
{
MOZ_COUNT_DTOR(TextureParent);
mTextureHost = nullptr;
}
bool
TextureParent::RecvInit(const SurfaceDescriptor& aSharedData,
const TextureFlags& aFlags)
{
mTextureHost = TextureHost::Create(0, // XXX legacy texture id, see subsequent patch
aSharedData,
mAllocator,
aFlags);
return !!mTextureHost;
}
} // namespace
} // namespace

View File

@ -46,8 +46,9 @@ class TextureSourceOGL;
class TextureSourceD3D9;
class TextureSourceD3D11;
class TextureSourceBasic;
class TextureParent;
class DataTextureSource;
class PTextureParent;
class TextureParent;
/**
* A view on a TextureHost where the texture is internally represented as tiles
@ -371,6 +372,27 @@ public:
TextureFlags GetFlags() { return mFlags; }
/**
* Allocate and deallocate a TextureParent actor.
*
* TextureParent< is an implementation detail of TextureHost that is not
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
* are for use with the managing IPDL protocols only (so that they can
* implement AllocPTextureParent and DeallocPTextureParent).
*/
static PTextureParent* CreateIPDLActor(ISurfaceAllocator* aAllocator);
static bool DestroyIPDLActor(PTextureParent* actor);
/**
* Destroy the TextureChild/Parent pair.
*/
static bool SendDeleteIPDLActor(PTextureParent* actor);
/**
* Get the TextureHost corresponding to the actor passed in parameter.
*/
static TextureHost* AsTextureHost(PTextureParent* actor);
/**
* Specific to B2G's Composer2D
* XXX - more doc here

View File

@ -29,6 +29,8 @@ class ThebesBufferData;
class DeprecatedTextureClient;
class TextureClient;
class BasicTiledLayerBuffer;
class PTextureChild;
class TextureClientData;
/**
* A transaction is a set of changes that happenned on the content side, that
@ -93,6 +95,14 @@ public:
virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable,
const SurfaceDescriptorTiles& aTiledDescriptor) = 0;
/**
* Create an unitialized TextureChild.
*
* This does not trigger the the creation of a TextureHost on the compositor
* side (see PTexture::Init).
*/
virtual PTextureChild* CreateEmptyTextureChild() = 0;
/**
* Communicate to the compositor that the texture identified by aCompositable
* and aTextureId has been updated to aImage.
@ -150,25 +160,14 @@ public:
virtual void DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy) = 0;
/**
* Tell the compositor side to create a TextureHost that corresponds to
* aClient.
* Tell the compositor side to delete the TextureHost corresponding to the
* TextureClient passed in parameter.
*/
virtual bool AddTexture(CompositableClient* aCompositable,
TextureClient* aClient) = 0;
/**
* Tell the compositor side to delete the TextureHost corresponding to
* aTextureID.
* By default the shared Data is deallocated along with the TextureHost, but
* this behaviour can be overriden by the TextureFlags passed here.
* XXX - This is kind of bad, but for now we have to do this, because of some
* edge cases caused by the lifetime of the TextureHost being limited by the
* lifetime of the CompositableHost. We should be able to remove this flags
* parameter when we remove the lifetime constraint.
*/
virtual void RemoveTexture(CompositableClient* aCompositable,
uint64_t aTextureID,
TextureFlags aFlags) = 0;
virtual void RemoveTexture(TextureClient* aTexture)
{
// XXX - this part is incomplete. The removing textures is implemented
// in a subsequent patch of the same bug (897452).
}
/**
* Tell the CompositableHost on the compositor side what texture to use for

View File

@ -222,12 +222,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
}
case CompositableOperation::TOpUseTexture: {
const OpUseTexture& op = aEdit.get_OpUseTexture();
if (op.textureID() == 0) {
NS_WARNING("Invalid texture ID");
break;
}
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> tex = compositable->GetTextureHost(op.textureID());
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(tex.get());
compositable->UseTextureHost(tex);
@ -237,36 +233,10 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
}
break;
}
case CompositableOperation::TOpAddTexture: {
const OpAddTexture& op = aEdit.get_OpAddTexture();
if (op.textureID() == 0) {
NS_WARNING("Invalid texture ID");
break;
}
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> tex = TextureHost::Create(op.textureID(),
op.data(),
this,
op.textureFlags());
MOZ_ASSERT(tex.get());
tex->SetCompositor(compositable->GetCompositor());
// set CompositableBackendSpecificData
// on gonk, create EGLImage if possible.
// create EGLImage during buffer swap could reduce the graphic driver's task
// during rendering.
compositable->AddTextureHost(tex);
MOZ_ASSERT(compositable->GetTextureHost(op.textureID()) == tex.get());
break;
}
case CompositableOperation::TOpRemoveTexture: {
const OpRemoveTexture& op = aEdit.get_OpRemoveTexture();
if (op.textureID() == 0) {
NS_WARNING("Invalid texture ID");
break;
}
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> texture = compositable->GetTextureHost(op.textureID());
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(texture);
TextureFlags flags = texture->GetFlags();
@ -276,27 +246,22 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
texture->DeallocateSharedData();
}
compositable->RemoveTextureHost(texture);
// 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_CLIENT) {
replyv.push_back(ReplyTextureRemoved(op.compositableParent(), nullptr,
op.textureID()));
replyv.push_back(ReplyTextureRemoved(op.callbackID()));
}
TextureHost::SendDeleteIPDLActor(op.textureParent());
break;
}
case CompositableOperation::TOpUpdateTexture: {
const OpUpdateTexture& op = aEdit.get_OpUpdateTexture();
if (op.textureID() == 0) {
NS_WARNING("Invalid texture ID");
break;
}
CompositableHost* compositable = AsCompositable(op);
MOZ_ASSERT(compositable);
RefPtr<TextureHost> texture = compositable->GetTextureHost(op.textureID());
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(op.textureParent());
MOZ_ASSERT(texture);
texture->Updated(op.region().type() == MaybeRegion::TnsIntRegion

View File

@ -36,6 +36,7 @@
#include "nsThreadUtils.h" // for NS_IsMainThread
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
#include "mozilla/StaticPtr.h" // for StaticRefPtr
#include "mozilla/layers/TextureClient.h"
struct nsIntRect;
@ -103,46 +104,12 @@ struct AutoEndTransaction {
CompositableTransaction* mTxn;
};
bool
ImageBridgeChild::AddTexture(CompositableClient* aCompositable,
TextureClient* aTexture)
{
SurfaceDescriptor descriptor;
if (!aTexture->ToSurfaceDescriptor(descriptor)) {
NS_WARNING("ImageBridge: Failed to serialize a TextureClient");
return false;
}
mTxn->AddEdit(OpAddTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID(),
descriptor,
aTexture->GetFlags()));
return true;
}
void
ImageBridgeChild::RemoveTexture(CompositableClient* aCompositable,
uint64_t aTexture,
TextureFlags aFlags)
{
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
// if deallocation happens on the host side, we need the transaction
// to be synchronous.
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
} else {
mTxn->AddNoSwapEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
}
}
void
ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
TextureClient* aTexture)
{
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID()));
nullptr, aTexture->GetIPDLActor()));
}
void
@ -153,7 +120,7 @@ ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
: MaybeRegion(null_t());
mTxn->AddNoSwapEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID(),
nullptr, aTexture->GetIPDLActor(),
region));
}
@ -465,7 +432,6 @@ void ImageBridgeChild::FlushAllImagesNow(ImageClient* aClient, ImageContainer* a
aClient->FlushAllImages(aExceptFront);
aClient->OnTransaction();
sImageBridgeChildSingleton->EndTransaction();
aClient->FlushTexturesToRemoveCallbacks();
}
void
@ -524,15 +490,7 @@ ImageBridgeChild::EndTransaction()
break;
}
case EditReply::TReplyTextureRemoved: {
// We receive this reply when a Texture is removed and when it is not
// the responsibility of the compositor side to deallocate memory.
// This would be, for instance, the place to implement a mechanism to
// notify the B2G camera that the gralloc buffer is not used by the
// compositor anymore and that it can be recycled.
const ReplyTextureRemoved& rep = reply.get_ReplyTextureRemoved();
CompositableClient* compositable
= static_cast<CompositableChild*>(rep.compositableChild())->GetCompositableClient();
compositable->OnReplyTextureRemoved(rep.textureId());
// XXX - implemented in another patch of the same bug (897452).
break;
}
default:
@ -940,5 +898,23 @@ ImageBridgeChild::AllocGrallocBuffer(const gfxIntSize& aSize,
#endif
}
PTextureChild*
ImageBridgeChild::AllocPTextureChild()
{
return TextureClient::CreateIPDLActor();
}
bool
ImageBridgeChild::DeallocPTextureChild(PTextureChild* actor)
{
return TextureClient::DestroyIPDLActor(actor);
}
PTextureChild*
ImageBridgeChild::CreateEmptyTextureChild()
{
return SendPTextureConstructor();
}
} // layers
} // mozilla

View File

@ -195,6 +195,12 @@ public:
virtual bool
DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
virtual PTextureChild*
AllocPTextureChild() MOZ_OVERRIDE;
virtual bool
DeallocPTextureChild(PTextureChild* actor) MOZ_OVERRIDE;
/**
* Allocate a gralloc SurfaceDescriptor remotely.
*/
@ -254,19 +260,6 @@ public:
virtual void Connect(CompositableClient* aCompositable) MOZ_OVERRIDE;
/**
* See CompositableForwarder::AddTexture
*/
virtual bool AddTexture(CompositableClient* aCompositable,
TextureClient* aClient) MOZ_OVERRIDE;
/**
* See CompositableForwarder::RemoveTexture
*/
virtual void RemoveTexture(CompositableClient* aCompositable,
uint64_t aTextureID,
TextureFlags aFlags) MOZ_OVERRIDE;
/**
* See CompositableForwarder::UpdatedTexture
*/
@ -378,6 +371,8 @@ public:
*/
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem);
virtual PTextureChild* CreateEmptyTextureChild() MOZ_OVERRIDE;
protected:
ImageBridgeChild();
bool DispatchAllocShmemInternal(size_t aSize,

View File

@ -30,6 +30,7 @@
#include "nsTArray.h" // for nsTArray, nsTArray_Impl
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
#include "mozilla/layers/TextureHost.h"
using namespace base;
using namespace mozilla::ipc;
@ -178,6 +179,18 @@ bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
return true;
}
PTextureParent*
ImageBridgeParent::AllocPTextureParent()
{
return TextureHost::CreateIPDLActor(this);
}
bool
ImageBridgeParent::DeallocPTextureParent(PTextureParent* actor)
{
return TextureHost::DestroyIPDLActor(actor);
}
MessageLoop * ImageBridgeParent::GetMessageLoop() {
return mMessageLoop;
}

View File

@ -65,6 +65,9 @@ public:
uint64_t*) MOZ_OVERRIDE;
bool DeallocPCompositableParent(PCompositableParent* aActor) MOZ_OVERRIDE;
virtual PTextureParent* AllocPTextureParent() MOZ_OVERRIDE;
virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
bool RecvStop() MOZ_OVERRIDE;
MessageLoop * GetMessageLoop();

View File

@ -13,6 +13,7 @@
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsDebug.h" // for NS_RUNTIMEABORT, etc
#include "nsTArray.h" // for nsTArray
#include "mozilla/layers/TextureClient.h"
namespace mozilla {
namespace layers {
@ -96,5 +97,17 @@ LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
#endif
}
PTextureChild*
LayerTransactionChild::AllocPTextureChild()
{
return TextureClient::CreateIPDLActor();
}
bool
LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor)
{
return TextureClient::DestroyIPDLActor(actor);
}
} // namespace layers
} // namespace mozilla

View File

@ -58,6 +58,10 @@ protected:
virtual PCompositableChild* AllocPCompositableChild(const TextureInfo& aInfo) MOZ_OVERRIDE;
virtual bool DeallocPCompositableChild(PCompositableChild* actor) MOZ_OVERRIDE;
virtual PTextureChild* AllocPTextureChild() MOZ_OVERRIDE;
virtual bool DeallocPTextureChild(PTextureChild* actor) MOZ_OVERRIDE;
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
void AddIPDLReference() {

View File

@ -39,6 +39,7 @@
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "GeckoProfiler.h"
#include "mozilla/layers/TextureHost.h"
typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
@ -600,5 +601,17 @@ LayerTransactionParent::DeallocPCompositableParent(PCompositableParent* actor)
return true;
}
PTextureParent*
LayerTransactionParent::AllocPTextureParent()
{
return TextureHost::CreateIPDLActor(this);
}
bool
LayerTransactionParent::DeallocPTextureParent(PTextureParent* actor)
{
return TextureHost::DestroyIPDLActor(actor);
}
} // namespace layers
} // namespace mozilla

View File

@ -106,6 +106,9 @@ protected:
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
virtual PTextureParent* AllocPTextureParent() MOZ_OVERRIDE;
virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
void Attach(ShadowLayerParent* aLayerParent,
CompositableParent* aCompositable,
bool aIsAsyncVideo);

View File

@ -11,6 +11,7 @@ include protocol PCompositor;
include protocol PGrallocBuffer;
include protocol PLayer;
include protocol PRenderFrame;
include protocol PTexture;
include "gfxipc/ShadowLayerUtils.h";
include "mozilla/GfxMessageUtils.h";
@ -300,25 +301,13 @@ struct OpUpdatePictureRect {
nsIntRect picture;
};
/**
* Provides the compositor side with enough information to create a
* TextureHost.
*/
struct OpAddTexture {
PCompositable compositable;
uint64_t textureID;
SurfaceDescriptor data;
uint32_t textureFlags;
};
/**
* Tells the compositor-side to remove the corresponding TextureHost and
* deallocate its data.
*/
struct OpRemoveTexture {
PCompositable compositable;
uint64_t textureID;
uint32_t flags;
PTexture texture;
uint64_t callbackID;
};
/**
@ -327,7 +316,7 @@ struct OpRemoveTexture {
*/
struct OpUseTexture {
PCompositable compositable;
uint64_t textureID;
PTexture texture;
};
union MaybeRegion {
@ -337,7 +326,7 @@ union MaybeRegion {
struct OpUpdateTexture {
PCompositable compositable;
uint64_t textureID;
PTexture texture;
MaybeRegion region;
};
@ -354,7 +343,6 @@ union CompositableOperation {
OpPaintTiledLayerBuffer;
OpAddTexture;
OpRemoveTexture;
OpUpdateTexture;
OpUseTexture;
@ -400,8 +388,7 @@ struct OpTextureSwap {
};
struct ReplyTextureRemoved {
PCompositable compositable;
uint64_t textureId;
uint64_t callbackID;
};
// Unit of a "changeset reply". This is a weird abstraction, probably

View File

@ -7,6 +7,7 @@ include LayersSurfaces;
include LayersMessages;
include protocol PGrallocBuffer;
include protocol PCompositable;
include protocol PTexture;
include ProtocolTypes;
include "mozilla/GfxMessageUtils.h";
@ -25,6 +26,7 @@ intr protocol PImageBridge
{
manages PCompositable;
manages PGrallocBuffer;
manages PTexture;
parent:
@ -49,6 +51,7 @@ parent:
sync Stop();
sync PCompositable(TextureInfo aInfo) returns (uint64_t id);
async PTexture();
};

View File

@ -12,6 +12,7 @@ include protocol PCompositor;
include protocol PGrallocBuffer;
include protocol PLayer;
include protocol PRenderFrame;
include protocol PTexture;
include "mozilla/GfxMessageUtils.h";
@ -33,6 +34,7 @@ sync protocol PLayerTransaction {
manages PLayer;
manages PCompositable;
manages PGrallocBuffer;
manages PTexture;
parent:
/**
@ -66,6 +68,7 @@ parent:
returns (MaybeMagicGrallocBufferHandle handle);
async PLayer();
async PCompositable(TextureInfo aTextureInfo);
async PTexture();
// The isFirstPaint flag can be used to indicate that this is the first update
// for a particular document.

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include LayersSurfaces;
include protocol PLayerTransaction;
include protocol PImageBridge;
include protocol PGrallocBuffer;
include "mozilla/GfxMessageUtils.h";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
namespace mozilla {
namespace layers {
/**
* PTexture is the IPDL glue between a TextureClient and a TextureHost.
*/
sync protocol PTexture {
manager PImageBridge or PLayerTransaction;
child:
async __delete__();
parent:
/**
* Set the shared data and create the TextureHost on the parent side.
*/
async Init(SurfaceDescriptor aSharedData, uint32_t aTextureFlags);
};
} // layers
} // mozilla

View File

@ -13,6 +13,7 @@
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/unused.h"
#include "nsXULAppAPI.h"

View File

@ -15,10 +15,6 @@
#include "mozilla/layers/PGrallocBufferChild.h"
#include "mozilla/layers/PGrallocBufferParent.h"
// used only for hacky fix in gecko 23 for bug 862324
// see bug 865908 about fixing this.
#include "TextureHost.h"
#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
#define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
@ -29,6 +25,8 @@ namespace layers {
class MaybeMagicGrallocBufferHandle;
class SurfaceDescriptorGralloc;
class TextureHost;
class DeprecatedTextureHost;
/**
* This class exists to share the underlying GraphicBuffer resources

View File

@ -407,39 +407,6 @@ ShadowLayerForwarder::UpdatePictureRect(CompositableClient* aCompositable,
mTxn->AddNoSwapPaint(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
}
bool
ShadowLayerForwarder::AddTexture(CompositableClient* aCompositable,
TextureClient* aTexture)
{
SurfaceDescriptor descriptor;
if (!aTexture->ToSurfaceDescriptor(descriptor)) {
NS_WARNING("Failed to serialize a TextureClient");
return false;
}
CheckSurfaceDescriptor(&descriptor);
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->GetIPDLActor());
MOZ_ASSERT(aTexture->GetFlags() != 0);
mTxn->AddEdit(OpAddTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID(),
descriptor,
aTexture->GetFlags()));
return true;
}
void
ShadowLayerForwarder::RemoveTexture(CompositableClient* aCompositable,
uint64_t aTexture,
TextureFlags aFlags)
{
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture,
aFlags));
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
mTxn->MarkSyncTransaction();
}
}
void
ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
TextureClient* aTexture,
@ -449,11 +416,11 @@ ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
: MaybeRegion(null_t());
if (aTexture->GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
mTxn->AddPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID(),
nullptr, aTexture->GetIPDLActor(),
region));
} else {
mTxn->AddNoSwapPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID(),
nullptr, aTexture->GetIPDLActor(),
region));
}
}
@ -463,7 +430,7 @@ ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
TextureClient* aTexture)
{
mTxn->AddEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
aTexture->GetID()));
nullptr, aTexture->GetIPDLActor()));
}
bool
@ -989,6 +956,13 @@ void ShadowLayerForwarder::AttachAsyncCompositable(uint64_t aCompositableID,
aCompositableID));
}
PTextureChild*
ShadowLayerForwarder::CreateEmptyTextureChild()
{
return mShadowManager->SendPTextureConstructor();
}
void ShadowLayerForwarder::SetShadowManager(PLayerTransactionChild* aShadowManager)
{
mShadowManager = static_cast<LayerTransactionChild*>(aShadowManager);

View File

@ -149,6 +149,8 @@ public:
*/
void Connect(CompositableClient* aCompositable);
virtual PTextureChild* CreateEmptyTextureChild() MOZ_OVERRIDE;
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo,
@ -305,19 +307,6 @@ public:
void UpdatePictureRect(CompositableClient* aCompositable,
const nsIntRect& aRect);
/**
* See CompositableForwarder::AddTexture
*/
virtual bool AddTexture(CompositableClient* aCompositable,
TextureClient* aClient) MOZ_OVERRIDE;
/**
* See CompositableForwarder::RemoveTexture
*/
virtual void RemoveTexture(CompositableClient* aCompositable,
uint64_t aTextureID,
TextureFlags aFlags) MOZ_OVERRIDE;
/**
* See CompositableForwarder::UpdatedTexture
*/

View File

@ -290,6 +290,7 @@ IPDL_SOURCES = [
'ipc/PImageBridge.ipdl',
'ipc/PLayer.ipdl',
'ipc/PLayerTransaction.ipdl',
'ipc/PTexture.ipdl',
]
MSVC_ENABLE_PGO = True