Bug 966528 - Use a specific IPDL message for component alpha. r=mattwoodrow

This commit is contained in:
Nicolas Silva 2014-02-06 12:28:29 +01:00
parent 10cf13f470
commit 84a35dc66a
13 changed files with 82 additions and 9 deletions

View File

@ -293,9 +293,11 @@ ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
aDidSelfCopy);
MOZ_ASSERT(mTextureClient);
mForwarder->UseTexture(this, mTextureClient);
if (mTextureClientOnWhite) {
mForwarder->UseTexture(this, mTextureClientOnWhite);
mForwarder->UseComponentAlphaTextures(this, mTextureClient,
mTextureClientOnWhite);
} else {
mForwarder->UseTexture(this, mTextureClient);
}
mForwarder->UpdateTextureRegion(this,
ThebesBufferData(BufferRect(),

View File

@ -109,6 +109,7 @@ public:
// call before and after painting into this content client
virtual void BeginPaint() {}
virtual void EndPaint() {}
};
/**

View File

@ -48,6 +48,17 @@ CompositableHost::UseTextureHost(TextureHost* aTexture)
aTexture->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
}
void
CompositableHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
TextureHost* aTextureOnWhite)
{
MOZ_ASSERT(aTextureOnBlack && aTextureOnWhite);
aTextureOnBlack->SetCompositor(GetCompositor());
aTextureOnBlack->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
aTextureOnWhite->SetCompositor(GetCompositor());
aTextureOnWhite->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
}
void
CompositableHost::SetCompositor(Compositor* aCompositor)
{

View File

@ -288,6 +288,8 @@ public:
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
virtual void UseTextureHost(TextureHost* aTexture);
virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
TextureHost* aTextureOnWhite);
protected:
TextureInfo mTextureInfo;

View File

@ -220,13 +220,18 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
void
ContentHostBase::UseTextureHost(TextureHost* aTexture)
{
if (aTexture->GetFlags() & TEXTURE_ON_WHITE) {
mTextureHostOnWhite = aTexture;
mTextureHostOnWhite->SetCompositor(GetCompositor());
} else {
mTextureHost = aTexture;
mTextureHost->SetCompositor(GetCompositor());
}
mTextureHost = aTexture;
mTextureHostOnWhite = nullptr;
mTextureHost->SetCompositor(GetCompositor());
}
void
ContentHostBase::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
TextureHost* aTextureOnWhite)
{
CompositableHost::UseComponentAlphaTextures(aTextureOnBlack, aTextureOnWhite);
mTextureHost = aTextureOnBlack;
mTextureHostOnWhite = aTextureOnWhite;
}
void

View File

@ -116,6 +116,8 @@ public:
virtual TextureHost* GetAsTextureHost() MOZ_OVERRIDE;
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
TextureHost* aTextureOnWhite) MOZ_OVERRIDE;
virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }

View File

@ -190,6 +190,9 @@ public:
*/
virtual void UseTexture(CompositableClient* aCompositable,
TextureClient* aClient) = 0;
virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aClientOnBlack,
TextureClient* aClientOnWhite) = 0;
/**
* Tell the compositor side that the shared data has been modified so that

View File

@ -233,6 +233,20 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
}
break;
}
case CompositableOperation::TOpUseComponentAlphaTextures: {
const OpUseComponentAlphaTextures& op = aEdit.get_OpUseComponentAlphaTextures();
CompositableHost* compositable = AsCompositable(op);
RefPtr<TextureHost> texOnBlack = TextureHost::AsTextureHost(op.textureOnBlackParent());
RefPtr<TextureHost> texOnWhite = TextureHost::AsTextureHost(op.textureOnWhiteParent());
MOZ_ASSERT(texOnBlack && texOnWhite);
compositable->UseComponentAlphaTextures(texOnBlack, texOnWhite);
if (IsAsync()) {
ScheduleComposition(op);
}
break;
}
case CompositableOperation::TOpUpdateTexture: {
const OpUpdateTexture& op = aEdit.get_OpUpdateTexture();
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(op.textureParent());

View File

@ -114,6 +114,16 @@ ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
nullptr, aTexture->GetIPDLActor()));
}
void
ImageBridgeChild::UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aTextureOnBlack,
TextureClient* aTextureOnWhite)
{
mTxn->AddNoSwapEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTextureOnBlack->GetIPDLActor(),
nullptr, aTextureOnWhite->GetIPDLActor()));
}
void
ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
TextureClient* aTexture,

View File

@ -271,6 +271,9 @@ public:
*/
virtual void UseTexture(CompositableClient* aCompositable,
TextureClient* aClient) MOZ_OVERRIDE;
virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aClientOnBlack,
TextureClient* aClientOnWhite) MOZ_OVERRIDE;
virtual void RemoveTexture(TextureClient* aTexture) MOZ_OVERRIDE;

View File

@ -312,6 +312,12 @@ struct OpUseTexture {
PTexture texture;
};
struct OpUseComponentAlphaTextures {
PCompositable compositable;
PTexture textureOnBlack;
PTexture textureOnWhite;
};
union MaybeRegion {
nsIntRegion;
null_t;
@ -338,6 +344,7 @@ union CompositableOperation {
OpUpdateTexture;
OpUseTexture;
OpUseComponentAlphaTextures;
};
// A unit of a changeset; a set of these comprise a changeset

View File

@ -435,6 +435,16 @@ ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
nullptr, aTexture->GetIPDLActor()));
}
void
ShadowLayerForwarder::UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aTextureOnBlack,
TextureClient* aTextureOnWhite)
{
mTxn->AddEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTextureOnBlack->GetIPDLActor(),
nullptr, aTextureOnWhite->GetIPDLActor()));
}
void
ShadowLayerForwarder::RemoveTexture(TextureClient* aTexture)
{

View File

@ -321,6 +321,9 @@ public:
*/
virtual void UseTexture(CompositableClient* aCompositable,
TextureClient* aClient) MOZ_OVERRIDE;
virtual void UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aClientOnBlack,
TextureClient* aClientOnWhite) MOZ_OVERRIDE;
/**
* End the current transaction and forward it to LayerManagerComposite.