Bug 1447880. Allow PaintMaskAndClipPath to support different ways of painting its children. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D6223
This commit is contained in:
Jeff Muizelaar 2018-09-12 15:14:20 -04:00
parent e6183a10a0
commit f2485f9b16
3 changed files with 32 additions and 11 deletions

View File

@ -856,8 +856,8 @@ Grouper::PaintContainerItem(DIGroup* aGroup, nsDisplayItem* aItem, const IntRect
Matrix4x4Flagged trans = transformItem->GetTransform();
Matrix trans2d;
if (!trans.Is2D(&trans2d)) {
// We don't currently support doing invalidation inside 3d transforms
// for now just paint it as a single item
// We don't currently support doing invalidation inside 3d transforms.
// For now just paint it as a single item.
BlobItemData* data = GetBlobItemDataForGroup(aItem, aGroup);
if (data->mLayerManager->GetRoot()) {
data->mLayerManager->BeginTransaction();

View File

@ -862,10 +862,10 @@ nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
return true;
}
void
nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
template<class T>
void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, const T& aPaintChild)
{
MOZ_ASSERT(UsingMaskOrClipPathForFrame(aParams.frame),
MOZ_ASSERT(nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(aParams.frame),
"Should not use this method when no mask or clipPath effect"
"on this frame");
@ -1016,12 +1016,7 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
/* Paint the child */
context.SetMatrix(matrixAutoSaveRestore.Matrix());
BasicLayerManager* basic = aParams.layerManager->AsBasicLayerManager();
RefPtr<gfxContext> oldCtx = basic->GetTarget();
basic->SetTarget(&context);
aParams.layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
aParams.builder);
basic->SetTarget(oldCtx);
aPaintChild();
if (gfxPrefs::DrawMaskLayer()) {
gfxContextAutoSaveRestore saver(&context);
@ -1058,6 +1053,27 @@ nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
}
void
nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
{
PaintMaskAndClipPathInternal(aParams, [&] {
gfxContext& context = aParams.ctx;
BasicLayerManager* basic = aParams.layerManager->AsBasicLayerManager();
RefPtr<gfxContext> oldCtx = basic->GetTarget();
basic->SetTarget(&context);
aParams.layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
aParams.builder);
basic->SetTarget(oldCtx);
});
}
void
nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams, const std::function<void()>& aPaintChild)
{
PaintMaskAndClipPathInternal(aParams, aPaintChild);
}
void
nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
{

View File

@ -166,6 +166,11 @@ public:
static void
PaintMaskAndClipPath(const PaintFramesParams& aParams);
// This should use FunctionRef instead of std::function because we don't need
// to take ownership of the function. See bug 1490781.
static void
PaintMaskAndClipPath(const PaintFramesParams& aParams, const std::function<void()>& aPaintChild);
/**
* Paint mask of non-SVG frame onto a given context, aParams.ctx.
* aParams.ctx must contain an A8 surface. Returns false if the mask