mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1091321, part 2 - Convert nsSVGIntegrationUtils::PaintFramesWithEffects and related code from nsRenderingContext to gfxContext. r=longsonr
This commit is contained in:
parent
0f53ed4ee5
commit
eed0ff092f
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user