Bug 383166 - "stack-allocate gfxContext where possible" [p=alfredkayser@nl.ibm.com (Alfred Kayser) r+a1.9=stuart]

This commit is contained in:
reed@reedloden.com 2007-12-31 20:42:49 -08:00
Родитель 3cc6dae42a
Коммит ea9e5ead9e
4 изменённых файлов: 40 добавлений и 48 удалений

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

@ -340,17 +340,13 @@ nsThebesImage::LockImagePixels(PRBool aMaskPixels)
gfxImageSurface::ImageFormatARGB32);
if (!mImageSurface || mImageSurface->CairoStatus())
return NS_ERROR_OUT_OF_MEMORY;
nsRefPtr<gfxContext> context = new gfxContext(mImageSurface);
if (!context) {
mImageSurface = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
context->SetOperator(gfxContext::OPERATOR_SOURCE);
gfxContext context(mImageSurface);
context.SetOperator(gfxContext::OPERATOR_SOURCE);
if (mSinglePixel)
context->SetColor(mSinglePixelColor);
context.SetColor(mSinglePixelColor);
else
context->SetSource(mOptSurface);
context->Paint();
context.SetSource(mOptSurface);
context.Paint();
}
return NS_OK;
}
@ -361,10 +357,10 @@ nsThebesImage::UnlockImagePixels(PRBool aMaskPixels)
if (aMaskPixels)
return NS_ERROR_NOT_IMPLEMENTED;
if (mImageSurface && mOptSurface) {
nsRefPtr<gfxContext> context = new gfxContext(mOptSurface);
context->SetOperator(gfxContext::OPERATOR_SOURCE);
context->SetSource(mImageSurface);
context->Paint();
gfxContext context(mOptSurface);
context.SetOperator(gfxContext::OPERATOR_SOURCE);
context.SetSource(mImageSurface);
context.Paint();
// Don't need the pixel data anymore
mImageSurface = nsnull;
}
@ -444,19 +440,19 @@ nsThebesImage::Draw(nsIRenderingContext &aContext,
NS_lroundf(destRect.size.height));
nsRefPtr<gfxASurface> temp =
gfxPlatform::GetPlatform()->CreateOffscreenSurface (dim, mFormat);
nsRefPtr<gfxContext> tempctx = new gfxContext(temp);
gfxContext tempctx(temp);
nsRefPtr<gfxPattern> srcpat = new gfxPattern(ThebesSurface());
gfxPattern srcpat(ThebesSurface());
gfxMatrix mat;
mat.Translate(srcRect.pos);
mat.Scale(1.0 / xscale, 1.0 / yscale);
srcpat->SetMatrix(mat);
srcpat.SetMatrix(mat);
tempctx->SetPattern(srcpat);
tempctx->SetOperator(gfxContext::OPERATOR_SOURCE);
tempctx->NewPath();
tempctx->Rectangle(gfxRect(0.0, 0.0, dim.width, dim.height));
tempctx->Fill();
tempctx.SetPattern(&srcpat);
tempctx.SetOperator(gfxContext::OPERATOR_SOURCE);
tempctx.NewPath();
tempctx.Rectangle(gfxRect(0.0, 0.0, dim.width, dim.height));
tempctx.Fill();
pat = new gfxPattern(temp);
@ -524,9 +520,6 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
if (mSinglePixel && mSinglePixelColor.a == 0.0)
return NS_OK;
// so we can hold on to this for a bit longer; might not be needed
nsRefPtr<gfxPattern> pat;
PRBool doSnap = !(thebesContext->CurrentMatrix().HasNonTranslation());
PRBool hasPadding = ((xPadding != 0) || (yPadding != 0));
@ -556,15 +549,15 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
tmpSurfaceGrip = surface;
nsRefPtr<gfxContext> tmpContext = new gfxContext(surface);
gfxContext tmpContext(surface);
if (mSinglePixel) {
tmpContext->SetColor(mSinglePixelColor);
tmpContext.SetColor(mSinglePixelColor);
} else {
tmpContext->SetSource(ThebesSurface());
tmpContext.SetSource(ThebesSurface());
}
tmpContext->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpContext->Rectangle(gfxRect(0, 0, mWidth, mHeight));
tmpContext->Fill();
tmpContext.SetOperator(gfxContext::OPERATOR_SOURCE);
tmpContext.Rectangle(gfxRect(0, 0, mWidth, mHeight));
tmpContext.Fill();
} else {
width = mWidth;
height = mHeight;
@ -584,19 +577,19 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
patMat.Scale(scale, scale);
patMat.Translate(p0);
pat = new gfxPattern(surface);
pat->SetExtend(gfxPattern::EXTEND_REPEAT);
pat->SetMatrix(patMat);
gfxPattern pat(surface);
pat.SetExtend(gfxPattern::EXTEND_REPEAT);
pat.SetMatrix(patMat);
#ifndef XP_MACOSX
if (scale < 1.0) {
// See bug 324698. This is a workaround. See comments
// by the earlier SetFilter call.
pat->SetFilter(0);
pat.SetFilter(0);
}
#endif
thebesContext->SetPattern(pat);
thebesContext->SetPattern(&pat);
}
thebesContext->NewPath();

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

@ -67,11 +67,10 @@ gfxAlphaRecovery::RecoverAlpha (gfxImageSurface *blackSurf,
resultSurf = new gfxImageSurface(dimensions, gfxASurface::ImageFormatARGB32);
// copy blackSurf into resultSurf
nsRefPtr<gfxContext> ctx = new gfxContext(resultSurf);
ctx->SetSource(blackSurf);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->Paint();
ctx = nsnull;
gfxContext ctx(resultSurf);
ctx.SetSource(blackSurf);
ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
ctx.Paint();
gfxAlphaRecoveryResult result;
_compute_alpha_values ((unsigned int*) resultSurf->Data(),

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

@ -204,10 +204,10 @@ gfxPlatform::OptimizeImage(gfxImageSurface *aSurface,
if (!optSurface || optSurface->CairoStatus() != 0)
return nsnull;
nsRefPtr<gfxContext> tmpCtx(new gfxContext(optSurface));
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx->SetSource(aSurface);
tmpCtx->Paint();
gfxContext tmpCtx(optSurface);
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx.SetSource(aSurface);
tmpCtx.Paint();
gfxASurface *ret = optSurface;
NS_ADDREF(ret);

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

@ -151,10 +151,10 @@ gfxWindowsSurface::OptimizeToDDB(HDC dc, const gfxIntSize& size, gfxImageFormat
if (wsurf->CairoStatus() != 0)
return nsnull;
nsRefPtr<gfxContext> tmpCtx = new gfxContext(wsurf);
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx->SetSource(this);
tmpCtx->Paint();
gfxContext tmpCtx(wsurf);
tmpCtx.SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx.SetSource(this);
tmpCtx.Paint();
gfxWindowsSurface *raw = (gfxWindowsSurface*) (wsurf.get());
NS_ADDREF(raw);