Bug 1210560 - Part 1: Add an API specifically intended for users that just Push and Pop-Mask/Pop-Paint. r=jrmuizel

This commit is contained in:
Bas Schouten 2015-11-11 16:15:39 +01:00
Родитель 3cbe348cdd
Коммит 752a87fbd2
2 изменённых файлов: 48 добавлений и 0 удалений

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

@ -881,6 +881,16 @@ gfxContext::PushGroup(gfxContentType content)
mDT->SetTransform(GetDTTransform());
}
void
gfxContext::PushGroupForBlendBack(gfxContentType content, Float aOpacity, SourceSurface* aMask, const Matrix& aMaskTransform)
{
PushGroup(content);
CurrentState().mBlendOpacity = aOpacity;
CurrentState().mBlendMask = aMask;
CurrentState().mWasPushedForBlendBack = true;
CurrentState().mBlendMaskTransform = aMaskTransform;
}
static gfxRect
GetRoundOutDeviceClipExtents(gfxContext* aCtx)
{
@ -1004,6 +1014,33 @@ gfxContext::PopGroupToSource()
CurrentState().surfTransform = mat;
}
void
gfxContext::PopGroupAndBlend()
{
MOZ_ASSERT(CurrentState().mWasPushedForBlendBack);
Float opacity = CurrentState().mBlendOpacity;
RefPtr<SourceSurface> mask = CurrentState().mBlendMask;
Matrix maskTransform = CurrentState().mBlendMaskTransform;
PopGroupToSource();
CompositionOp oldOp = GetOp();
SetOp(CompositionOp::OP_OVER);
if (mask) {
if (!maskTransform.HasNonTranslation()) {
Mask(mask, opacity, Point(maskTransform._31, maskTransform._32));
} else {
MOZ_ASSERT(opacity == 1.0f);
Mask(mask, maskTransform);
}
} else {
Paint(opacity);
}
SetOp(oldOp);
}
#ifdef MOZ_DUMP_PAINTING
void
gfxContext::WriteAsPNG(const char* aFile)

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

@ -431,6 +431,11 @@ public:
* Groups
*/
void PushGroup(gfxContentType content = gfxContentType::COLOR);
void PushGroupForBlendBack(gfxContentType content, mozilla::gfx::Float aOpacity = 1.0f,
mozilla::gfx::SourceSurface* aMask = nullptr,
const mozilla::gfx::Matrix& aMaskTransform = mozilla::gfx::Matrix());
/**
* Like PushGroup, but if the current surface is gfxContentType::COLOR and
* content is gfxContentType::COLOR_ALPHA, makes the pushed surface gfxContentType::COLOR
@ -445,6 +450,7 @@ public:
void PushGroupAndCopyBackground(gfxContentType content = gfxContentType::COLOR);
already_AddRefed<gfxPattern> PopGroup();
void PopGroupToSource();
void PopGroupAndBlend();
already_AddRefed<mozilla::gfx::SourceSurface>
PopGroupToSurface(mozilla::gfx::Matrix* aMatrix);
@ -527,6 +533,11 @@ private:
Color fontSmoothingBackgroundColor;
// This is used solely for using minimal intermediate surface size.
mozilla::gfx::Point deviceOffset;
// Support groups
mozilla::gfx::Float mBlendOpacity;
RefPtr<SourceSurface> mBlendMask;
Matrix mBlendMaskTransform;
mozilla::DebugOnly<bool> mWasPushedForBlendBack;
};
// This ensures mPath contains a valid path (in user space!)