Bug 870211 - Add new IPC messages to LayersTransaction for doing incremental updates to textures. r=Bas

This commit is contained in:
Matt Woodrow 2013-05-16 15:45:43 +12:00
parent a1675f0918
commit 43219a3a35
6 changed files with 128 additions and 2 deletions

View File

@ -37,6 +37,8 @@ class CompositableForwarder : public ISurfaceAllocator
friend class AutoOpenSurface;
friend class TextureClientShmem;
public:
typedef gfxASurface::gfxContentType gfxContentType;
CompositableForwarder()
: mMaxTextureSize(0)
, mCompositorBackend(layers::LAYERS_NONE)
@ -70,6 +72,14 @@ public:
const SurfaceDescriptor* aFrontDescriptorOnWhite = nullptr,
const SurfaceDescriptor* aBackDescriptorOnWhite = nullptr) = 0;
/**
* Notify the CompositableHost that it should create host-side-only
* texture(s), that we will update incrementally using UpdateTextureIncremental.
*/
virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
const TextureInfo& aTextureInfo,
const nsIntRect& aBufferRect) = 0;
/**
* Tell the compositor that a Compositable is killing its buffer(s),
* that is TextureClient/Hosts.
@ -102,6 +112,23 @@ public:
const ThebesBufferData& aThebesBufferData,
const nsIntRegion& aUpdatedRegion) = 0;
/**
* Notify the compositor to update aTextureId using aDescriptor, and take
* ownership of aDescriptor.
*
* aDescriptor only contains the pixels for aUpdatedRegion, and is relative
* to aUpdatedRegion.TopLeft().
*
* aBufferRect/aBufferRotation define the new valid region contained
* within the texture after the update has been applied.
*/
virtual void UpdateTextureIncremental(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor& aDescriptor,
const nsIntRegion& aUpdatedRegion,
const nsIntRect& aBufferRect,
const nsIntPoint& aBufferRotation) = 0;
/**
* Communicate the picture rect of a YUV image in aLayer to the compositor
*/

View File

@ -38,6 +38,19 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
break;
}
case CompositableOperation::TOpCreatedIncrementalTexture: {
MOZ_LAYERS_LOG(("[ParentSide] Created texture"));
const OpCreatedIncrementalTexture& op = aEdit.get_OpCreatedIncrementalTexture();
CompositableParent* compositableParent =
static_cast<CompositableParent*>(op.compositableParent());
CompositableHost* compositable = compositableParent->GetCompositableHost();
compositable->EnsureTextureHost(compositableParent->GetCompositableManager(),
op.textureInfo(),
op.bufferRect());
break;
}
case CompositableOperation::TOpDestroyThebesBuffer: {
MOZ_LAYERS_LOG(("[ParentSide] Created double buffer"));
const OpDestroyThebesBuffer& op = aEdit.get_OpDestroyThebesBuffer();
@ -128,6 +141,24 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
RenderTraceInvalidateEnd(thebes, "FF00FF");
break;
}
case CompositableOperation::TOpPaintTextureIncremental: {
MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer"));
const OpPaintTextureIncremental& op = aEdit.get_OpPaintTextureIncremental();
CompositableParent* compositableParent = static_cast<CompositableParent*>(op.compositableParent());
CompositableHost* compositable =
compositableParent->GetCompositableHost();
SurfaceDescriptor desc = op.image();
compositable->UpdateIncremental(op.textureId(),
desc,
op.updatedRegion(),
op.bufferRect(),
op.bufferRotation());
break;
}
case CompositableOperation::TOpUpdatePictureRect: {
const OpUpdatePictureRect& op = aEdit.get_OpUpdatePictureRect();
CompositableHost* compositable

View File

@ -247,6 +247,15 @@ public:
virtual void UpdateTextureNoSwap(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
virtual void UpdateTextureIncremental(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor& aDescriptor,
const nsIntRegion& aUpdatedRegion,
const nsIntRect& aBufferRect,
const nsIntPoint& aBufferRotation) MOZ_OVERRIDE
{
NS_RUNTIMEABORT("should not be called");
}
/**
* Communicate the picture rect of a YUV image in aLayer to the compositor
@ -263,6 +272,12 @@ public:
const SurfaceDescriptor* aDescriptorOnWhite = nullptr) MOZ_OVERRIDE {
NS_RUNTIMEABORT("should not be called");
}
virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
const TextureInfo& aTextureInfo,
const nsIntRect& aBufferRect) MOZ_OVERRIDE
{
NS_RUNTIMEABORT("should not be called");
}
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,

View File

@ -251,6 +251,12 @@ struct OpCreatedTexture {
TextureInfo textureInfo;
};
struct OpCreatedIncrementalTexture {
PCompositable compositable;
TextureInfo textureInfo;
nsIntRect bufferRect;
};
struct OpDestroyThebesBuffer {
PCompositable compositable;
};
@ -267,6 +273,15 @@ struct OpPaintTextureRegion {
nsIntRegion updatedRegion;
};
struct OpPaintTextureIncremental {
PCompositable compositable;
uint32_t textureId;
SurfaceDescriptor image;
nsIntRegion updatedRegion;
nsIntRect bufferRect;
nsIntPoint bufferRotation;
};
struct OpUpdatePictureRect {
PCompositable compositable;
nsIntRect picture;
@ -276,10 +291,12 @@ union CompositableOperation {
OpUpdatePictureRect;
OpCreatedTexture;
OpCreatedIncrementalTexture;
OpDestroyThebesBuffer;
OpPaintTexture;
OpPaintTextureRegion;
OpPaintTextureIncremental;
OpPaintTiledLayerBuffer;
};

View File

@ -348,6 +348,25 @@ ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable,
aUpdatedRegion));
}
void
ShadowLayerForwarder::UpdateTextureIncremental(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor& aDescriptor,
const nsIntRegion& aUpdatedRegion,
const nsIntRect& aBufferRect,
const nsIntPoint& aBufferRotation)
{
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->GetIPDLActor());
mTxn->AddPaint(OpPaintTextureIncremental(nullptr, aCompositable->GetIPDLActor(),
aTextureId,
aDescriptor,
aUpdatedRegion,
aBufferRect,
aBufferRotation));
}
void
ShadowLayerForwarder::UpdatePictureRect(CompositableClient* aCompositable,
const nsIntRect& aRect)
@ -706,6 +725,15 @@ ShadowLayerForwarder::CreatedSingleBuffer(CompositableClient* aCompositable,
}
}
void
ShadowLayerForwarder::CreatedIncrementalBuffer(CompositableClient* aCompositable,
const TextureInfo& aTextureInfo,
const nsIntRect& aBufferRect)
{
mTxn->AddPaint(OpCreatedIncrementalTexture(nullptr, aCompositable->GetIPDLActor(),
aTextureInfo, aBufferRect));
}
void
ShadowLayerForwarder::CreatedDoubleBuffer(CompositableClient* aCompositable,
const SurfaceDescriptor& aFrontDescriptor,

View File

@ -138,8 +138,6 @@ class ShadowLayerForwarder : public CompositableForwarder
friend class TextureClientShmem;
public:
typedef gfxASurface::gfxContentType gfxContentType;
virtual ~ShadowLayerForwarder();
/**
@ -152,6 +150,9 @@ public:
const SurfaceDescriptor& aDescriptor,
const TextureInfo& aTextureInfo,
const SurfaceDescriptor* aDescriptorOnWhite = nullptr) MOZ_OVERRIDE;
virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
const TextureInfo& aTextureInfo,
const nsIntRect& aBufferRect) MOZ_OVERRIDE;
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
const SurfaceDescriptor& aFrontDescriptor,
const SurfaceDescriptor& aBackDescriptor,
@ -288,6 +289,13 @@ public:
const ThebesBufferData& aThebesBufferData,
const nsIntRegion& aUpdatedRegion) MOZ_OVERRIDE;
virtual void UpdateTextureIncremental(CompositableClient* aCompositable,
TextureIdentifier aTextureId,
SurfaceDescriptor& aDescriptor,
const nsIntRegion& aUpdatedRegion,
const nsIntRect& aBufferRect,
const nsIntPoint& aBufferRotation) MOZ_OVERRIDE;
/**
* Communicate the picture rect of an image to the compositor
*/