Bug 592118 - Don't stack-allocate gfxContexts that are passed to other functions. r=roc a=blocking2.0:final

--HG--
extra : rebase_source : efcf3b58c953ea8ec8cad45f4b0ffa0b898a2397
This commit is contained in:
Markus Stange 2010-10-15 12:20:22 +02:00
parent 7dd0ac125f
commit 4c74ef0ee6
6 changed files with 38 additions and 29 deletions

View File

@ -5565,8 +5565,8 @@ nsSVGFEImageElement::Filter(nsSVGFilterInstance *instance,
gfxMatrix TM = viewBoxTM * xyTM;
gfxContext ctx(aTarget->mImage);
nsSVGUtils::CompositePatternMatrix(&ctx, thebesPattern, TM, nativeWidth, nativeHeight, 1.0);
nsRefPtr<gfxContext> ctx = new gfxContext(aTarget->mImage);
nsSVGUtils::CompositePatternMatrix(ctx, thebesPattern, TM, nativeWidth, nativeHeight, 1.0);
}
return NS_OK;

View File

@ -1042,11 +1042,12 @@ nsSVGPathList::Playback(gfxContext *aCtx)
already_AddRefed<gfxFlattenedPath>
nsSVGPathList::GetFlattenedPath(const gfxMatrix& aMatrix)
{
gfxContext ctx(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
nsRefPtr<gfxContext> ctx =
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
ctx.SetMatrix(aMatrix);
Playback(&ctx);
ctx.IdentityMatrix();
ctx->SetMatrix(aMatrix);
Playback(ctx);
ctx->IdentityMatrix();
return ctx.GetFlattenedPath();
return ctx->GetFlattenedPath();
}

View File

@ -270,9 +270,9 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable,
if (!temp || temp->CairoStatus())
return nsnull;
gfxContext tmpCtx(temp);
tmpCtx.SetOperator(OptimalFillOperator());
aDrawable->Draw(&tmpCtx, needed - needed.pos, PR_TRUE,
nsRefPtr<gfxContext> tmpCtx = new gfxContext(temp);
tmpCtx->SetOperator(OptimalFillOperator());
aDrawable->Draw(tmpCtx, needed - needed.pos, PR_TRUE,
gfxPattern::FILTER_FAST, gfxMatrix().Translate(needed.pos));
nsRefPtr<gfxPattern> resultPattern = new gfxPattern(temp);

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<title>Stack pointer free with -moz-element</title>
<div id="paintServer" style="width: 20px; height: 20px; background: red;"></div>
<div style="-moz-transform: scale(1.01); width: 100px; height: 100px; background: -moz-element(#paintServer) -5px -3px; background-size: 20px 32769px;"></div>

View File

@ -338,3 +338,4 @@ load 586973-1.html
load 589002-1.html
load 590404.html
load 591141.html
asserts(0-1) load 592118.html

View File

@ -170,23 +170,24 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
PRBool isHit = PR_FALSE;
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
nsRefPtr<gfxContext> context =
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
GeneratePath(&context);
GeneratePath(context);
gfxPoint userSpacePoint =
context.DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
PresContext()->AppUnitsToGfxUnits(aPoint.y)));
context->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
PresContext()->AppUnitsToGfxUnits(aPoint.y)));
if (fillRule == NS_STYLE_FILL_RULE_EVENODD)
context.SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
context->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
else
context.SetFillRule(gfxContext::FILL_RULE_WINDING);
context->SetFillRule(gfxContext::FILL_RULE_WINDING);
if (mask & HITTEST_MASK_FILL)
isHit = context.PointInFill(userSpacePoint);
isHit = context->PointInFill(userSpacePoint);
if (!isHit && (mask & HITTEST_MASK_STROKE)) {
SetupCairoStrokeHitGeometry(&context);
isHit = context.PointInStroke(userSpacePoint);
SetupCairoStrokeHitGeometry(context);
isHit = context->PointInStroke(userSpacePoint);
}
if (isHit && nsSVGUtils::HitTestClip(this, aPoint))
@ -250,12 +251,13 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
{
mRect.Empty();
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
nsRefPtr<gfxContext> context =
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
GeneratePath(&context);
context.IdentityMatrix();
GeneratePath(context);
context->IdentityMatrix();
gfxRect extent = context.GetUserPathExtent();
gfxRect extent = context->GetUserPathExtent();
// Be careful when replacing the following logic to get the fill and stroke
// extents independently (instead of computing the stroke extents from the
@ -270,12 +272,12 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
// stroke bounds that it will return will be empty.
if (HasStroke()) {
SetupCairoStrokeGeometry(&context);
SetupCairoStrokeGeometry(context);
if (extent.Width() <= 0 && extent.Height() <= 0) {
// If 'extent' is empty, its position will not be set. Although
// GetUserStrokeExtent gets the extents wrong we can still use it
// to get the device space position of zero length stroked paths.
extent = context.GetUserStrokeExtent();
extent = context->GetUserStrokeExtent();
extent.pos.x += extent.size.width / 2;
extent.pos.y += extent.size.height / 2;
extent.size.width = 0;
@ -362,10 +364,11 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
// XXX ReportToConsole
return gfxRect(0.0, 0.0, 0.0, 0.0);
}
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
GeneratePath(&context, &aToBBoxUserspace);
context.IdentityMatrix();
return context.GetUserPathExtent();
nsRefPtr<gfxContext> context =
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
GeneratePath(context, &aToBBoxUserspace);
context->IdentityMatrix();
return context->GetUserPathExtent();
}
//----------------------------------------------------------------------