Bug 342726 - Reduce nsSVGPatternFrame and nsSVGMaskFrame memory usage. r=tor,sr=roc

This commit is contained in:
longsonr%gmail.com 2006-06-28 12:32:26 +00:00
Родитель 0448688f03
Коммит ef48bcf0fc
3 изменённых файлов: 45 добавлений и 26 удалений

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

@ -83,8 +83,8 @@ class nsSVGMaskFrame : public nsSVGMaskFrameBase,
#endif
private:
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMaskUnits;
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> mMaskContentUnits;
PRUint16 GetMaskUnits();
PRUint16 GetMaskContentUnits();
nsISVGChildFrame *mMaskParent;
nsCOMPtr<nsIDOMSVGMatrix> mMaskParentMatrix;
@ -150,10 +150,6 @@ nsSVGMaskFrame::InitSVG()
nsCOMPtr<nsIDOMSVGMaskElement> mask = do_QueryInterface(mContent);
NS_ASSERTION(mask, "wrong content element");
mask->GetMaskUnits(getter_AddRefs(mMaskUnits));
mask->GetMaskContentUnits(getter_AddRefs(mMaskContentUnits));
return NS_OK;
}
@ -213,8 +209,7 @@ nsSVGMaskFrame::MaskPaint(nsISVGRendererCanvas* aCanvas,
float x, y, width, height;
PRUint16 units;
mMaskUnits->GetAnimVal(&units);
PRUint16 units = GetMaskUnits();
nsSVGMaskElement *mask = NS_STATIC_CAST(nsSVGMaskElement*, mContent);
nsSVGLength2 *tmpX, *tmpY, *tmpWidth, *tmpHeight;
@ -330,11 +325,7 @@ nsSVGMaskFrame::GetCanvasTM()
nsCOMPtr<nsIDOMSVGMatrix> canvasTM = mMaskParentMatrix;
/* object bounding box? */
PRUint16 units;
nsCOMPtr<nsIDOMSVGMaskElement> path = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> aEnum;
path->GetMaskContentUnits(getter_AddRefs(aEnum));
aEnum->GetAnimVal(&units);
PRUint16 units = GetMaskContentUnits();
if (mMaskParent &&
units == nsIDOMSVGMaskElement::SVG_MUNITS_OBJECTBOUNDINGBOX) {
@ -359,3 +350,32 @@ nsSVGMaskFrame::GetCanvasTM()
NS_IF_ADDREF(retval);
return retval;
}
// -------------------------------------------------------------------------
// Helper functions
// -------------------------------------------------------------------------
PRUint16
nsSVGMaskFrame::GetMaskUnits()
{
PRUint16 rv;
nsSVGMaskElement *maskElement = NS_STATIC_CAST(nsSVGMaskElement*, mContent);
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> units;
maskElement->GetMaskUnits(getter_AddRefs(units));
units->GetAnimVal(&rv);
return rv;
}
PRUint16
nsSVGMaskFrame::GetMaskContentUnits()
{
PRUint16 rv;
nsSVGMaskElement *maskElement = NS_STATIC_CAST(nsSVGMaskElement*, mContent);
nsCOMPtr<nsIDOMSVGAnimatedEnumeration> units;
maskElement->GetMaskContentUnits(getter_AddRefs(units));
units->GetAnimVal(&rv);
return rv;
}

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

@ -256,25 +256,26 @@ nsSVGPatternFrame::PaintPattern(nsISVGRendererCanvas* canvas,
// Get the bounding box of the pattern. This will be used to determine
// the size of the surface, and will also be used to define the bounding
// box for the pattern tile.
if (NS_FAILED(GetPatternRect(getter_AddRefs(mBBox), callerBBox,
nsCOMPtr<nsIDOMSVGRect> bbox;
if (NS_FAILED(GetPatternRect(getter_AddRefs(bbox), callerBBox,
callerContent)))
return NS_ERROR_FAILURE;
// Get the transformation matrix that we will hand to the renderer's pattern
// routine.
if (NS_FAILED(GetPatternMatrix(patternMatrix, mBBox, callerCTM)))
if (NS_FAILED(GetPatternMatrix(patternMatrix, bbox, callerCTM)))
return NS_ERROR_FAILURE;
#ifdef DEBUG_scooter
printRect("Bounding Rect: ",mBBox);
printRect("Bounding Rect: ",bbox);
printCTM("Pattern TM ",*patternMatrix);
printCTM("Child TM ",mCTM);
#endif
// Now that we have all of the necessary geometries, we can
// create our surface. Note that this uses mBBox for the size
// create our surface.
nsCOMPtr<nsISVGRendererSurface> patternSurface;
if (NS_FAILED(CreateSurface(getter_AddRefs(patternSurface))))
if (NS_FAILED(CreateSurface(getter_AddRefs(patternSurface), bbox)))
return NS_ERROR_FAILURE;
// Push the surface
@ -760,7 +761,8 @@ nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
}
nsresult
nsSVGPatternFrame::CreateSurface(nsISVGRendererSurface **aSurface)
nsSVGPatternFrame::CreateSurface(nsISVGRendererSurface **aSurface,
nsIDOMSVGRect *bbox)
{
*aSurface = nsnull;
@ -770,8 +772,8 @@ nsSVGPatternFrame::CreateSurface(nsISVGRendererSurface **aSurface)
}
float width, height;
mBBox->GetWidth(&width);
mBBox->GetHeight(&height);
bbox->GetWidth(&width);
bbox->GetHeight(&height);
nsCOMPtr<nsISVGRenderer> renderer;
outerSVGFrame->GetRenderer(getter_AddRefs(renderer));

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

@ -138,17 +138,14 @@ protected:
nsIDOMSVGRect *bbox,
nsIDOMSVGMatrix *callerCTM);
nsresult ConstructCTM(nsIDOMSVGMatrix **ctm, nsIDOMSVGRect *callerBBox);
nsresult CreateSurface(nsISVGRendererSurface **aSurface);
nsresult CreateSurface(nsISVGRendererSurface **aSurface,
nsIDOMSVGRect *bbox);
nsresult GetCallerGeometry(nsIDOMSVGMatrix **aCTM,
nsIDOMSVGRect **aBBox,
nsSVGElement **aContent,
nsSVGGeometryFrame *aSource);
//
private:
nsCOMPtr<nsIDOMSVGRect> mBBox;
// this is a *temporary* reference to the frame of the element currently
// referencing our pattern. This must be termporary because different
// referencing frames will all reference this one fram