Bug 1091321, part 2 - Convert nsSVGIntegrationUtils::PaintFramesWithEffects and related code from nsRenderingContext to gfxContext. r=longsonr

This commit is contained in:
Jonathan Watt 2014-10-31 20:08:53 +00:00
parent 0f53ed4ee5
commit eed0ff092f
8 changed files with 35 additions and 34 deletions

View File

@ -290,7 +290,7 @@ nsSVGDisplayContainerFrame::PaintSVG(nsRenderingContext* aContext,
continue;
}
}
nsSVGUtils::PaintFrameWithEffects(kid, aContext, m, aDirtyRect);
nsSVGUtils::PaintFrameWithEffects(kid, *aContext->ThebesContext(), m, aDirtyRect);
}
return NS_OK;

View File

@ -157,7 +157,7 @@ nsSVGMarkerFrame::PaintMark(nsRenderingContext *aContext,
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
// The CTM of each frame referencing us may be different.
SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM);
nsSVGUtils::PaintFrameWithEffects(kid, *gfx, markTM);
if (StyleDisplay()->IsScrollableOverflow())
gfx->Restore();

View File

@ -243,7 +243,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
m = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(m);
}
nsSVGUtils::PaintFrameWithEffects(kid, &tmpCtx, mMatrixForChildren);
nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx.ThebesContext(), mMatrixForChildren);
}
RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot();

View File

@ -614,7 +614,7 @@ nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder,
// units (i.e. CSS px) in the matrix that we pass to our children):
gfxMatrix tm = nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(mFrame) *
gfxMatrix::Translation(devPixelOffset);
nsSVGUtils::PaintFrameWithEffects(mFrame, aContext, tm, &contentAreaDirtyRect);
nsSVGUtils::PaintFrameWithEffects(mFrame, *aContext->ThebesContext(), tm, &contentAreaDirtyRect);
aContext->ThebesContext()->Restore();
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)

View File

@ -416,7 +416,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
tm = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(tm, nsSVGElement::eUserSpaceToParent);
}
nsSVGUtils::PaintFrameWithEffects(kid, &context, tm);
nsSVGUtils::PaintFrameWithEffects(kid, *gfx, tm);
}
patternWithChildren->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
}

View File

@ -126,7 +126,7 @@ nsSVGSwitchFrame::PaintSVG(nsRenderingContext* aContext,
tm = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(tm, nsSVGElement::eUserSpaceToParent);
}
nsSVGUtils::PaintFrameWithEffects(kid, aContext, tm, aDirtyRect);
nsSVGUtils::PaintFrameWithEffects(kid, *aContext->ThebesContext(), tm, aDirtyRect);
}
return NS_OK;
}

View File

@ -472,7 +472,7 @@ public:
void
nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
nsRenderingContext *aContext,
gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect *aDirtyRect)
{
@ -557,8 +557,7 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
if (opacity != 1.0f && CanOptimizeOpacity(aFrame))
opacity = 1.0f;
DrawTarget* drawTarget = aContext->GetDrawTarget();
gfxContext *gfx = aContext->ThebesContext();
DrawTarget* drawTarget = aContext.GetDrawTarget();
bool complexEffects = false;
nsSVGClipPathFrame *clipPathFrame = effectProperties.GetClipPathFrame(&isOK);
@ -576,12 +575,12 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
if (opacity != 1.0f || maskFrame || (clipPathFrame && !isTrivialClip)
|| aFrame->StyleDisplay()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {
complexEffects = true;
gfx->Save();
aContext.Save();
if (!(aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
// aFrame has a valid visual overflow rect, so clip to it before calling
// PushGroup() to minimize the size of the surfaces we'll composite:
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(gfx);
gfx->Multiply(aTransform);
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(&aContext);
aContext.Multiply(aTransform);
nsRect overflowRect = aFrame->GetVisualOverflowRectRelativeToSelf();
if (aFrame->IsFrameOfType(nsIFrame::eSVGGeometry) ||
aFrame->IsSVGText()) {
@ -589,21 +588,23 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
// GetCanvasTM().
overflowRect = overflowRect + aFrame->GetPosition();
}
gfx->Clip(NSRectToSnappedRect(overflowRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
aContext.Clip(NSRectToSnappedRect(overflowRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
}
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
aContext.PushGroup(gfxContentType::COLOR_ALPHA);
}
/* If this frame has only a trivial clipPath, set up cairo's clipping now so
* we can just do normal painting and get it clipped appropriately.
*/
if (clipPathFrame && isTrivialClip) {
gfx->Save();
clipPathFrame->ApplyClipOrPaintClipMask(*gfx, aFrame, aTransform);
aContext.Save();
clipPathFrame->ApplyClipOrPaintClipMask(aContext, aFrame, aTransform);
}
nsRenderingContext rendCtx(&aContext);
/* Paint the child */
if (effectProperties.HasValidFilter()) {
nsRegion* dirtyRegion = nullptr;
@ -627,55 +628,55 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
dirtyRegion = &tmpDirtyRegion;
}
SVGPaintCallback paintCallback;
nsFilterInstance::PaintFilteredFrame(aFrame, aContext, aTransform,
nsFilterInstance::PaintFilteredFrame(aFrame, &rendCtx, aTransform,
&paintCallback, dirtyRegion);
} else {
svgChildFrame->PaintSVG(aContext, aTransform, aDirtyRect);
svgChildFrame->PaintSVG(&rendCtx, aTransform, aDirtyRect);
}
if (clipPathFrame && isTrivialClip) {
gfx->Restore();
aContext.Restore();
}
/* No more effects, we're done. */
if (!complexEffects)
return;
gfx->PopGroupToSource();
aContext.PopGroupToSource();
Matrix maskTransform;
RefPtr<SourceSurface> maskSurface =
maskFrame ? maskFrame->GetMaskForMaskedFrame(aContext->ThebesContext(),
maskFrame ? maskFrame->GetMaskForMaskedFrame(&aContext,
aFrame, aTransform, opacity, &maskTransform)
: nullptr;
if (clipPathFrame && !isTrivialClip) {
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
aContext.PushGroup(gfxContentType::COLOR_ALPHA);
nsresult rv = clipPathFrame->ApplyClipOrPaintClipMask(*gfx, aFrame, aTransform);
nsresult rv = clipPathFrame->ApplyClipOrPaintClipMask(aContext, aFrame, aTransform);
Matrix clippedMaskTransform;
RefPtr<SourceSurface> clipMaskSurface = gfx->PopGroupToSurface(&clippedMaskTransform);
RefPtr<SourceSurface> clipMaskSurface = aContext.PopGroupToSurface(&clippedMaskTransform);
if (NS_SUCCEEDED(rv) && clipMaskSurface) {
// Still more set after clipping, so clip to another surface
if (maskSurface || opacity != 1.0f) {
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
gfx->Mask(clipMaskSurface, clippedMaskTransform);
gfx->PopGroupToSource();
aContext.PushGroup(gfxContentType::COLOR_ALPHA);
aContext.Mask(clipMaskSurface, clippedMaskTransform);
aContext.PopGroupToSource();
} else {
gfx->Mask(clipMaskSurface, clippedMaskTransform);
aContext.Mask(clipMaskSurface, clippedMaskTransform);
}
}
}
if (maskSurface) {
gfx->Mask(maskSurface, maskTransform);
aContext.Mask(maskSurface, maskTransform);
} else if (opacity != 1.0f ||
aFrame->StyleDisplay()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {
gfx->Paint(opacity);
aContext.Paint(opacity);
}
gfx->Restore();
aContext.Restore();
}
bool

View File

@ -279,7 +279,7 @@ public:
* redrawn, in device pixel coordinates relative to the outer svg */
static void
PaintFrameWithEffects(nsIFrame *aFrame,
nsRenderingContext *aContext,
gfxContext& aContext,
const gfxMatrix& aTransform,
const nsIntRect *aDirtyRect = nullptr);