зеркало из https://github.com/mozilla/gecko-dev.git
Bug 950312 - Part 2: Add Effect for BlendModes. r=nical
This commit is contained in:
Родитель
2f69378b9b
Коммит
23232a9040
|
@ -140,6 +140,7 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DiagnosticFlags)
|
|||
*/
|
||||
MOZ_BEGIN_ENUM_CLASS(EffectTypes, uint8_t)
|
||||
MASK,
|
||||
BLEND_MODE,
|
||||
MAX_SECONDARY, // sentinel for the count of secondary effect types
|
||||
RGB,
|
||||
YCBCR,
|
||||
|
|
|
@ -54,3 +54,10 @@ EffectSolidColor::PrintInfo(nsACString& aTo, const char* aPrefix)
|
|||
aTo += nsPrintfCString("EffectSolidColor (0x%p) [color=%x]", this, mColor.ToABGR());
|
||||
}
|
||||
|
||||
void
|
||||
EffectBlendMode::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
aTo += aPrefix;
|
||||
aTo += nsPrintfCString("EffectBlendMode (0x%p) [blendmode=%i]", this, (int)mBlendMode);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,19 @@ struct EffectMask : public Effect
|
|||
gfx::Matrix4x4 mMaskTransform;
|
||||
};
|
||||
|
||||
struct EffectBlendMode : public Effect
|
||||
{
|
||||
EffectBlendMode(gfx::CompositionOp aBlendMode)
|
||||
: Effect(EffectTypes::BLEND_MODE)
|
||||
, mBlendMode(aBlendMode)
|
||||
{ }
|
||||
|
||||
virtual const char* Name() { return "EffectBlendMode"; }
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
gfx::CompositionOp mBlendMode;
|
||||
};
|
||||
|
||||
// Render to a render target rather than the screen.
|
||||
struct EffectRenderTarget : public TexturedEffect
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ CanvasLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
|||
#endif
|
||||
|
||||
EffectChain effectChain(this);
|
||||
AddBlendModeEffect(effectChain);
|
||||
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
|
|
|
@ -41,6 +41,8 @@ ColorLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
|||
|
||||
float opacity = GetEffectiveOpacity();
|
||||
|
||||
AddBlendModeEffect(effects);
|
||||
|
||||
const gfx::Matrix4x4& transform = GetEffectiveTransform();
|
||||
mCompositor->DrawQuad(rect, clipRect, effects, opacity, transform);
|
||||
mCompositor->DrawDiagnostics(DiagnosticFlags::COLOR,
|
||||
|
|
|
@ -400,6 +400,7 @@ ContainerRender(ContainerT* aContainer,
|
|||
effectChain,
|
||||
!aContainer->GetTransform().CanDraw2D());
|
||||
|
||||
aContainer->AddBlendModeEffect(effectChain);
|
||||
effectChain.mPrimaryEffect = new EffectRenderTarget(surface);
|
||||
|
||||
gfx::Rect rect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height);
|
||||
|
|
|
@ -100,6 +100,7 @@ ImageLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
|||
|
||||
EffectChain effectChain(this);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
|
||||
AddBlendModeEffect(effectChain);
|
||||
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
mImageHost->SetCompositor(mCompositor);
|
||||
|
|
|
@ -914,6 +914,18 @@ LayerComposite::Destroy()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
LayerComposite::AddBlendModeEffect(EffectChain& aEffectChain)
|
||||
{
|
||||
gfx::CompositionOp blendMode = GetLayer()->GetEffectiveMixBlendMode();
|
||||
if (blendMode == gfx::CompositionOp::OP_OVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
aEffectChain.mSecondaryEffects[EffectTypes::BLEND_MODE] = new EffectBlendMode(blendMode);
|
||||
return;
|
||||
}
|
||||
|
||||
bool
|
||||
LayerManagerComposite::CanUseCanvasLayerForSize(const IntSize &aSize)
|
||||
{
|
||||
|
|
|
@ -338,6 +338,8 @@ public:
|
|||
|
||||
virtual void DestroyFrontBuffer() { }
|
||||
|
||||
void AddBlendModeEffect(EffectChain& aEffectChain);
|
||||
|
||||
/**
|
||||
* The following methods are
|
||||
*
|
||||
|
|
|
@ -130,6 +130,7 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
|
|||
|
||||
EffectChain effectChain(this);
|
||||
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
|
||||
AddBlendModeEffect(effectChain);
|
||||
|
||||
nsIntRegion visibleRegion = GetEffectiveVisibleRegion();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче