mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1540737 - Implement PushLayerWithBlend for DrawTargetCairo. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D114671
This commit is contained in:
parent
6543cd468c
commit
7487e05b57
@ -1540,6 +1540,16 @@ void DrawTargetCairo::PushLayer(bool aOpaque, Float aOpacity,
|
||||
SourceSurface* aMask,
|
||||
const Matrix& aMaskTransform,
|
||||
const IntRect& aBounds, bool aCopyBackground) {
|
||||
PushLayerWithBlend(aOpaque, aOpacity, aMask, aMaskTransform, aBounds,
|
||||
aCopyBackground, CompositionOp::OP_OVER);
|
||||
}
|
||||
|
||||
void DrawTargetCairo::PushLayerWithBlend(bool aOpaque, Float aOpacity,
|
||||
SourceSurface* aMask,
|
||||
const Matrix& aMaskTransform,
|
||||
const IntRect& aBounds,
|
||||
bool aCopyBackground,
|
||||
CompositionOp aCompositionOp) {
|
||||
cairo_content_t content = CAIRO_CONTENT_COLOR_ALPHA;
|
||||
|
||||
if (mFormat == SurfaceFormat::A8) {
|
||||
@ -1561,7 +1571,7 @@ void DrawTargetCairo::PushLayer(bool aOpaque, Float aOpacity,
|
||||
cairo_push_group_with_content(mContext, content);
|
||||
}
|
||||
|
||||
PushedLayer layer(aOpacity, mPermitSubpixelAA);
|
||||
PushedLayer layer(aOpacity, aCompositionOp, mPermitSubpixelAA);
|
||||
|
||||
if (aMask) {
|
||||
cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aMask);
|
||||
@ -1595,6 +1605,7 @@ void DrawTargetCairo::PopLayer() {
|
||||
mPushedLayers.pop_back();
|
||||
|
||||
if (!layer.mMaskPattern) {
|
||||
cairo_set_operator(mContext, GfxOpToCairoOp(layer.mCompositionOp));
|
||||
cairo_paint_with_alpha(mContext, layer.mOpacity);
|
||||
} else {
|
||||
if (layer.mOpacity != Float(1.0)) {
|
||||
@ -1605,6 +1616,7 @@ void DrawTargetCairo::PopLayer() {
|
||||
|
||||
cairo_pop_group_to_source(mContext);
|
||||
}
|
||||
cairo_set_operator(mContext, GfxOpToCairoOp(layer.mCompositionOp));
|
||||
cairo_mask(mContext, layer.mMaskPattern);
|
||||
}
|
||||
|
||||
@ -1612,6 +1624,8 @@ void DrawTargetCairo::PopLayer() {
|
||||
GfxMatrixToCairoMatrix(mTransform, mat);
|
||||
cairo_set_matrix(mContext, &mat);
|
||||
|
||||
cairo_set_operator(mContext, CAIRO_OPERATOR_OVER);
|
||||
|
||||
cairo_pattern_destroy(layer.mMaskPattern);
|
||||
SetPermitSubpixelAA(layer.mWasPermittingSubpixelAA);
|
||||
}
|
||||
|
@ -131,6 +131,11 @@ class DrawTargetCairo final : public DrawTarget {
|
||||
const Matrix& aMaskTransform,
|
||||
const IntRect& aBounds = IntRect(),
|
||||
bool aCopyBackground = false) override;
|
||||
virtual void PushLayerWithBlend(
|
||||
bool aOpaque, Float aOpacity, SourceSurface* aMask,
|
||||
const Matrix& aMaskTransform, const IntRect& aBounds = IntRect(),
|
||||
bool aCopyBackground = false,
|
||||
CompositionOp = CompositionOp::OP_OVER) override;
|
||||
virtual void PopLayer() override;
|
||||
|
||||
virtual already_AddRefed<PathBuilder> CreatePathBuilder(
|
||||
@ -220,11 +225,14 @@ class DrawTargetCairo final : public DrawTarget {
|
||||
cairo_font_options_t* mFontOptions;
|
||||
|
||||
struct PushedLayer {
|
||||
PushedLayer(Float aOpacity, bool aWasPermittingSubpixelAA)
|
||||
PushedLayer(Float aOpacity, CompositionOp aCompositionOp,
|
||||
bool aWasPermittingSubpixelAA)
|
||||
: mOpacity(aOpacity),
|
||||
mCompositionOp(aCompositionOp),
|
||||
mMaskPattern(nullptr),
|
||||
mWasPermittingSubpixelAA(aWasPermittingSubpixelAA) {}
|
||||
Float mOpacity;
|
||||
CompositionOp mCompositionOp;
|
||||
cairo_pattern_t* mMaskPattern;
|
||||
bool mWasPermittingSubpixelAA;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user