Bug 900133 - Support MaskLayers that are backed by a NewTextureHost. r=nical

This commit is contained in:
Matt Woodrow 2013-08-01 21:12:16 -04:00
parent d96bf88ffc
commit 77b9490231
9 changed files with 53 additions and 1 deletions

View File

@ -93,6 +93,8 @@ CanvasLayerComposite::RenderLayer(const nsIntPoint& aOffset,
gfx::Point(aOffset.x, aOffset.y),
gfx::ToFilter(filter),
clipRect);
LayerManagerComposite::RemoveMaskEffect(mMaskLayer);
}
CompositableHost*

View File

@ -40,6 +40,7 @@ ColorLayerComposite::RenderLayer(const nsIntPoint& aOffset,
rect, clipRect,
transform, gfx::Point(aOffset.x, aOffset.y));
LayerManagerComposite::RemoveMaskEffect(GetMaskLayer());
}
} /* layers */

View File

@ -104,7 +104,18 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
const gfx::Matrix4x4& aTransform,
bool aIs3D)
{
RefPtr<TextureSource> source = GetDeprecatedTextureHost();
RefPtr<TextureSource> source;
RefPtr<DeprecatedTextureHost> oldHost = GetDeprecatedTextureHost();
if (oldHost) {
oldHost->Lock();
source = oldHost;
} else {
RefPtr<TextureHost> host = GetTextureHost();
if (host) {
host->Lock();
source = host->GetTextureSources();
}
}
if (!source) {
NS_WARNING("Using compositable with no texture host as mask layer");
@ -119,6 +130,20 @@ CompositableHost::AddMaskEffect(EffectChain& aEffects,
return true;
}
void
CompositableHost::RemoveMaskEffect()
{
RefPtr<DeprecatedTextureHost> oldHost = GetDeprecatedTextureHost();
if (oldHost) {
oldHost->Unlock();
} else {
RefPtr<TextureHost> host = GetTextureHost();
if (host) {
host->Unlock();
}
}
}
/* static */ TemporaryRef<CompositableHost>
CompositableHost::Create(const TextureInfo& aTextureInfo)
{

View File

@ -172,6 +172,8 @@ public:
const gfx::Matrix4x4& aTransform,
bool aIs3D = false);
void RemoveMaskEffect();
Compositor* GetCompositor() const
{
return mCompositor;

View File

@ -163,6 +163,8 @@ ContainerRender(ContainerT* aContainer,
rect, clipRect,
transform, gfx::Point(aOffset.x, aOffset.y));
}
LayerManagerComposite::RemoveMaskEffect(aContainer->GetMaskLayer());
}
ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager)

View File

@ -96,6 +96,8 @@ ImageLayerComposite::RenderLayer(const nsIntPoint& aOffset,
gfx::Point(aOffset.x, aOffset.y),
gfx::ToFilter(mFilter),
clipRect);
LayerManagerComposite::RemoveMaskEffect(mMaskLayer);
}
void

View File

@ -661,6 +661,21 @@ LayerManagerComposite::AddMaskEffect(Layer* aMaskLayer, EffectChain& aEffects, b
return maskLayerComposite->GetCompositableHost()->AddMaskEffect(aEffects, transform, aIs3D);
}
/* static */ void
LayerManagerComposite::RemoveMaskEffect(Layer* aMaskLayer)
{
if (!aMaskLayer) {
return;
}
LayerComposite* maskLayerComposite = static_cast<LayerComposite*>(aMaskLayer->ImplData());
if (!maskLayerComposite->GetCompositableHost()) {
NS_WARNING("Mask layer with no compositable host");
return;
}
maskLayerComposite->GetCompositableHost()->RemoveMaskEffect();
}
TemporaryRef<DrawTarget>
LayerManagerComposite::CreateDrawTarget(const IntSize &aSize,
SurfaceFormat aFormat)

View File

@ -165,6 +165,8 @@ public:
EffectChain& aEffect,
bool aIs3D = false);
static void RemoveMaskEffect(Layer* aMaskLayer);
/**
* Creates a DrawTarget which is optimized for inter-operating with this
* layermanager.

View File

@ -140,6 +140,7 @@ ThebesLayerComposite::RenderLayer(const nsIntPoint& aOffset,
mValidRegion = tiledLayerProps.mValidRegion;
}
LayerManagerComposite::RemoveMaskEffect(mMaskLayer);
mCompositeManager->GetCompositor()->MakeCurrent();
}