Bug 764813 - Avoid using gfxContext::SetMatrix in SVG code where possible. r=Bas.

This commit is contained in:
Jonathan Watt 2012-06-15 04:02:27 +01:00
parent 675334cbbb
commit 87661488ec
3 changed files with 11 additions and 18 deletions

View File

@ -317,8 +317,7 @@ nsSVGGlyphFrame::PaintSVG(nsRenderingContext *aContext,
}
if (renderMode != SVGAutoRenderState::NORMAL) {
gfxMatrix matrix = gfx->CurrentMatrix();
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(gfx);
SetupGlobalTransform(gfx);
CharacterIterator iter(this, true);
@ -336,7 +335,6 @@ nsSVGGlyphFrame::PaintSVG(nsRenderingContext *aContext,
DrawCharacters(&iter, gfx, gfxFont::GLYPH_PATH);
}
gfx->SetMatrix(matrix);
return NS_OK;
}

View File

@ -250,7 +250,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
}
gfxContext* gfx = aCtx->ThebesContext();
gfxMatrix savedCTM = gfx->CurrentMatrix();
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(gfx);
//SVGAutoRenderState autoRenderState(aCtx, SVGAutoRenderState::NORMAL);
@ -286,7 +286,7 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
nsIntRect r = (aDirtyRect - userSpaceRect.TopLeft()).ToOutsidePixels(appUnitsPerDevPixel);
filterFrame->FilterPaint(aCtx, aEffectsFrame, &paint, &r);
} else {
gfx->SetMatrix(savedCTM);
gfx->SetMatrix(matrixAutoSaveRestore.Matrix());
aInnerList->PaintForFrame(aBuilder, aCtx, aEffectsFrame,
nsDisplayList::PAINT_DEFAULT);
aCtx->Translate(userSpaceRect.TopLeft());
@ -298,7 +298,6 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
/* No more effects, we're done. */
if (!complexEffects) {
gfx->SetMatrix(savedCTM);
return;
}
@ -334,7 +333,6 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
}
gfx->Restore();
gfx->SetMatrix(savedCTM);
}
gfxMatrix
@ -420,7 +418,6 @@ PaintFrameCallback::operator()(gfxContext* aContext,
aContext->NewPath();
aContext->Rectangle(aFillRect);
aContext->Clip();
gfxMatrix savedMatrix(aContext->CurrentMatrix());
aContext->Multiply(gfxMatrix(aTransform).Invert());
@ -450,7 +447,6 @@ PaintFrameCallback::operator()(gfxContext* aContext,
nsLayoutUtils::PAINT_IN_TRANSFORM |
nsLayoutUtils::PAINT_ALL_CONTINUATIONS);
aContext->SetMatrix(savedMatrix);
aContext->Restore();
mFrame->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);

View File

@ -1407,15 +1407,15 @@ nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
float aRX, float aRY, float aRWidth, float aRHeight,
float aX, float aY)
{
if (aMatrix.IsSingular()) {
gfxRect rect(aRX, aRY, aRWidth, aRHeight);
if (rect.IsEmpty() || aMatrix.IsSingular()) {
return false;
}
gfxContext ctx(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
ctx.SetMatrix(aMatrix);
ctx.NewPath();
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
ctx.IdentityMatrix();
return ctx.PointInFill(gfxPoint(aX, aY));
gfxMatrix toRectSpace = aMatrix;
toRectSpace.Invert();
gfxPoint p = toRectSpace.Transform(gfxPoint(aX, aY));
return rect.x <= p.x && p.x <= rect.XMost() &&
rect.y <= p.y && p.y <= rect.YMost();
}
gfxRect
@ -1518,10 +1518,9 @@ nsSVGUtils::SetClipRect(gfxContext *aContext,
if (aCTM.IsSingular())
return;
gfxMatrix oldMatrix = aContext->CurrentMatrix();
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(aContext);
aContext->Multiply(aCTM);
aContext->Clip(aRect);
aContext->SetMatrix(oldMatrix);
}
void