Support all blend modes in the basic compositor. (bug 1203829 part 1, r=mattwoodrow)

This commit is contained in:
David Anderson 2015-09-15 13:07:05 -07:00
Родитель c5685d0363
Коммит ea934017d9
2 изменённых файлов: 29 добавлений и 12 удалений

Просмотреть файл

@ -109,6 +109,20 @@ void BasicCompositor::Destroy()
mWidget = nullptr;
}
TextureFactoryIdentifier
BasicCompositor::GetTextureFactoryIdentifier()
{
TextureFactoryIdentifier ident(LayersBackend::LAYERS_BASIC,
XRE_GetProcessType(),
GetMaxTextureSize());
// All composition ops are supported in software.
for (uint8_t op = 0; op < uint8_t(CompositionOp::OP_COUNT); op++) {
ident.mSupportedBlendModes += CompositionOp(op);
}
return ident;
}
already_AddRefed<CompositingRenderTarget>
BasicCompositor::CreateRenderTarget(const IntRect& aRect, SurfaceInitMode aInit)
{
@ -157,7 +171,7 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest,
SourceSurface *aSource,
const gfx::Rect& aTextureCoords,
gfx::Filter aFilter,
float aOpacity,
const DrawOptions& aOptions,
SourceSurface *aMask,
const Matrix* aMaskTransform)
{
@ -182,7 +196,7 @@ DrawSurfaceWithTextureCoords(DrawTarget *aDest,
gfx::Rect unitRect(0, 0, 1, 1);
ExtendMode mode = unitRect.Contains(aTextureCoords) ? ExtendMode::CLAMP : ExtendMode::REPEAT;
FillRectWithMask(aDest, aDestRect, aSource, aFilter, DrawOptions(aOpacity),
FillRectWithMask(aDest, aDestRect, aSource, aFilter, aOptions,
mode, aMask, aMaskTransform, &matrix);
}
@ -383,13 +397,18 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
maskTransform.PreTranslate(-offset.x, -offset.y);
}
CompositionOp blendMode = CompositionOp::OP_OVER;
if (Effect* effect = aEffectChain.mSecondaryEffects[EffectTypes::BLEND_MODE].get()) {
blendMode = static_cast<EffectBlendMode*>(effect)->mBlendMode;
}
switch (aEffectChain.mPrimaryEffect->mType) {
case EffectTypes::SOLID_COLOR: {
EffectSolidColor* effectSolidColor =
static_cast<EffectSolidColor*>(aEffectChain.mPrimaryEffect.get());
FillRectWithMask(dest, aRect, effectSolidColor->mColor,
DrawOptions(aOpacity), sourceMask, &maskTransform);
DrawOptions(aOpacity, blendMode), sourceMask, &maskTransform);
break;
}
case EffectTypes::RGB: {
@ -402,7 +421,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
source->GetSurface(dest),
texturedEffect->mTextureCoords,
texturedEffect->mFilter,
aOpacity, sourceMask, &maskTransform);
DrawOptions(aOpacity, blendMode),
sourceMask, &maskTransform);
} else {
RefPtr<DataSourceSurface> srcData = source->GetSurface(dest)->GetDataSurface();
@ -414,7 +434,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
premultData,
texturedEffect->mTextureCoords,
texturedEffect->mFilter,
aOpacity, sourceMask, &maskTransform);
DrawOptions(aOpacity, blendMode),
sourceMask, &maskTransform);
}
break;
}
@ -433,7 +454,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
sourceSurf,
effectRenderTarget->mTextureCoords,
effectRenderTarget->mFilter,
aOpacity, sourceMask, &maskTransform);
DrawOptions(aOpacity, blendMode),
sourceMask, &maskTransform);
break;
}
case EffectTypes::COMPONENT_ALPHA: {

Просмотреть файл

@ -50,12 +50,7 @@ public:
virtual void Destroy() override;
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() override
{
return TextureFactoryIdentifier(LayersBackend::LAYERS_BASIC,
XRE_GetProcessType(),
GetMaxTextureSize());
}
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() override;
virtual already_AddRefed<CompositingRenderTarget>
CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) override;