Bug 1053237 - Stop unnecessarily calling nsSVGUtils::AdjustMatrixForUnits() over and over in nsSVGMaskFrame. r=longsonr

This commit is contained in:
Jonathan Watt 2014-08-18 10:35:26 +01:00
Родитель 38a80fab30
Коммит e2bfc1e9ea
2 изменённых файлов: 21 добавлений и 16 удалений

Просмотреть файл

@ -229,12 +229,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
tmpCtx->Init(this->PresContext()->DeviceContext(), maskDT);
tmpCtx->ThebesContext()->SetMatrix(maskSurfaceMatrix);
mMaskParent = aMaskedFrame;
if (mMaskParentMatrix) {
*mMaskParentMatrix = aMatrix;
} else {
mMaskParentMatrix = new gfxMatrix(aMatrix);
}
mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix;
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
@ -319,13 +314,17 @@ nsSVGMaskFrame::GetType() const
gfxMatrix
nsSVGMaskFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
{
NS_ASSERTION(mMaskParentMatrix, "null parent matrix");
SVGMaskElement *mask = static_cast<SVGMaskElement*>(mContent);
return nsSVGUtils::AdjustMatrixForUnits(
mMaskParentMatrix ? *mMaskParentMatrix : gfxMatrix(),
&mask->mEnumAttributes[SVGMaskElement::MASKCONTENTUNITS],
mMaskParent);
return mMatrixForChildren;
}
gfxMatrix
nsSVGMaskFrame::GetMaskTransform(nsIFrame* aMaskedFrame)
{
SVGMaskElement *content = static_cast<SVGMaskElement*>(mContent);
nsSVGEnum* maskContentUnits =
&content->mEnumAttributes[SVGMaskElement::MASKCONTENTUNITS];
return nsSVGUtils::AdjustMatrixForUnits(gfxMatrix(), maskContentUnits,
aMaskedFrame);
}

Просмотреть файл

@ -67,6 +67,13 @@ public:
#endif
private:
/**
* If the mask element transforms its children due to
* maskContentUnits="objectBoundingBox" being set on it, this function
* returns the resulting transform.
*/
gfxMatrix GetMaskTransform(nsIFrame* aMaskedFrame);
// A helper class to allow us to paint masks safely. The helper
// automatically sets and clears the mInUse flag on the mask frame
// (to prevent nasty reference loops). It's easy to mess this up
@ -89,8 +96,7 @@ private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
nsIFrame *mMaskParent;
nsAutoPtr<gfxMatrix> mMaskParentMatrix;
gfxMatrix mMatrixForChildren;
// recursion prevention flag
bool mInUse;