mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 13:55:43 +00:00
Bug 1234485 - Part 3. Implement nsSVGIntegrationUtils::PaintMask. r=mstange
Unlike nsSVGIntegrationUtils::PaintMaskAndClipPath, which paints masked content onto aParam.ctx, nsSVGIntegrationUtils::PaintMask paints only mask, no content, onto aParams.ctx. MozReview-Commit-ID: BaRbtHpoHzj --HG-- extra : rebase_source : 4a258b7332ba7a7edbffdc13c7f4b065fbe5eaa4
This commit is contained in:
parent
999ca66251
commit
4d9495cf77
@ -749,6 +749,60 @@ nsSVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame)
|
||||
return true;
|
||||
}
|
||||
|
||||
DrawResult
|
||||
nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams)
|
||||
{
|
||||
MaskUsage maskUsage;
|
||||
DetermineMaskUsage(aParams.frame, aParams.handleOpacity, maskUsage);
|
||||
MOZ_ASSERT(maskUsage.shouldGenerateMaskLayer);
|
||||
|
||||
nsIFrame* frame = aParams.frame;
|
||||
DrawResult result = DrawResult::SUCCESS;
|
||||
if (!ValidateSVGFrame(frame)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (maskUsage.opacity == 0.0f) {
|
||||
return DrawResult::SUCCESS;
|
||||
}
|
||||
|
||||
gfxContext& ctx = aParams.ctx;
|
||||
|
||||
Matrix maskTransform;
|
||||
RefPtr<SourceSurface> maskSurface;
|
||||
|
||||
gfxContextMatrixAutoSaveRestore matSR(&ctx);
|
||||
|
||||
nsIFrame* firstFrame =
|
||||
nsLayoutUtils::FirstContinuationOrIBSplitSibling(frame);
|
||||
nsSVGEffects::EffectProperties effectProperties =
|
||||
nsSVGEffects::GetEffectProperties(firstFrame);
|
||||
nsTArray<nsSVGMaskFrame *> maskFrames = effectProperties.GetMaskFrames();
|
||||
bool opacityApplied = false;
|
||||
|
||||
nsPoint offsetToBoundingBox;
|
||||
nsPoint offsetToUserSpace;
|
||||
SetupContextMatrix(frame, aParams, offsetToBoundingBox,
|
||||
offsetToUserSpace, false);
|
||||
result = GenerateMaskSurface(aParams, maskUsage.opacity,
|
||||
firstFrame->StyleContext(),
|
||||
maskFrames, offsetToUserSpace,
|
||||
maskTransform, maskSurface, opacityApplied);
|
||||
if (!maskSurface) {
|
||||
// Entire surface is clipped out.
|
||||
return result;
|
||||
}
|
||||
|
||||
ctx.Multiply(ThebesMatrix(maskTransform));
|
||||
|
||||
DrawTarget* target = ctx.GetDrawTarget();
|
||||
MOZ_ASSERT(target->GetFormat() == SurfaceFormat::A8);
|
||||
Rect drawingRect(Point(0, 0), Size(target->GetSize()));
|
||||
target->DrawSurface(maskSurface, drawingRect, drawingRect);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DrawResult
|
||||
nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
|
||||
{
|
||||
|
@ -160,6 +160,13 @@ public:
|
||||
static DrawResult
|
||||
PaintMaskAndClipPath(const PaintFramesParams& aParams);
|
||||
|
||||
/**
|
||||
* Paint mask of non-SVG frame onto a given context, aParams.ctx.
|
||||
* aParams.ctx must contain an A8 surface.
|
||||
*/
|
||||
static DrawResult
|
||||
PaintMask(const PaintFramesParams& aParams);
|
||||
|
||||
struct MaskUsage {
|
||||
bool shouldGenerateMaskLayer;
|
||||
bool shouldGenerateClipMaskLayer;
|
||||
|
Loading…
Reference in New Issue
Block a user