diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 7a351f25154c..b8b4d9f2e978 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -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 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(effect)->mBlendMode; + } + switch (aEffectChain.mPrimaryEffect->mType) { case EffectTypes::SOLID_COLOR: { EffectSolidColor* effectSolidColor = static_cast(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 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: { diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h index dab18a651674..5421a675762d 100644 --- a/gfx/layers/basic/BasicCompositor.h +++ b/gfx/layers/basic/BasicCompositor.h @@ -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 CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) override;