Bug 725903 - PathExtentsToMaxStrokeExtents needs to take a transform argument. r=longsonr.

This commit is contained in:
Jonathan Watt 2012-02-10 12:33:39 +00:00
parent 989bcc0208
commit d36fb51f1e
4 changed files with 22 additions and 14 deletions

View File

@ -487,7 +487,7 @@ nsSVGGlyphFrame::UpdateCoveredRegion()
// calls to record and then reset the stroke width.
gfxRect extent = tmpCtx->GetUserPathExtent();
if (hasStroke) {
extent = nsSVGUtils::PathExtentsToMaxStrokeExtents(extent, this);
extent = nsSVGUtils::PathExtentsToMaxStrokeExtents(extent, this, matrix);
}
if (!extent.IsEmpty()) {
@ -621,7 +621,9 @@ nsSVGGlyphFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
if ((aFlags & nsSVGUtils::eBBoxIncludeStroke) != 0 &&
((aFlags & nsSVGUtils::eBBoxIgnoreStrokeIfNone) == 0 || HasStroke())) {
bbox =
bbox.Union(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents, this));
bbox.Union(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents,
this,
aToBBoxUserspace));
}
return bbox;

View File

@ -308,7 +308,9 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace,
pathExtents.SizeTo(0, 0);
}
bbox =
bbox.Union(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents, this));
bbox.Union(nsSVGUtils::PathExtentsToMaxStrokeExtents(pathExtents,
this,
aToBBoxUserspace));
}
// Account for markers:

View File

@ -1477,15 +1477,14 @@ nsSVGUtils::WritePPM(const char *fname, gfxImageSurface *aSurface)
static gfxRect
PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGGeometryFrame* aFrame,
double styleExpansionFactor)
double styleExpansionFactor,
const gfxMatrix& aMatrix)
{
double style_expansion =
styleExpansionFactor * aFrame->GetStrokeWidth();
gfxMatrix ctm = aFrame->GetCanvasTM();
double dx = style_expansion * (fabs(ctm.xx) + fabs(ctm.xy));
double dy = style_expansion * (fabs(ctm.yy) + fabs(ctm.yx));
double dx = style_expansion * (fabs(aMatrix.xx) + fabs(aMatrix.xy));
double dy = style_expansion * (fabs(aMatrix.yy) + fabs(aMatrix.yx));
gfxRect strokeExtents = aPathExtents;
strokeExtents.Inflate(dx, dy);
@ -1494,14 +1493,16 @@ PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
/*static*/ gfxRect
nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGGeometryFrame* aFrame)
nsSVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix)
{
return ::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, 0.5);
return ::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, 0.5, aMatrix);
}
/*static*/ gfxRect
nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGPathGeometryFrame* aFrame)
nsSVGPathGeometryFrame* aFrame,
const gfxMatrix& aMatrix)
{
double styleExpansionFactor = 0.5;
@ -1521,7 +1522,8 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
return ::PathExtentsToMaxStrokeExtents(aPathExtents,
aFrame,
styleExpansionFactor);
styleExpansionFactor,
aMatrix);
}
// ----------------------------------------------------------------------

View File

@ -572,9 +572,11 @@ public:
* This should die once bug 478152 is fixed.
*/
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGGeometryFrame* aFrame);
nsSVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix);
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsSVGPathGeometryFrame* aFrame);
nsSVGPathGeometryFrame* aFrame,
const gfxMatrix& aMatrix);
/**
* Convert a floating-point value to a 32-bit integer value, clamping to