Bug 386083 - SVG code should check gfxASurface::CairoStatus() when it creates new surfaces. r=jwatt,sr=tor

This commit is contained in:
longsonr@gmail.com 2007-07-17 02:24:27 -07:00
parent 37b0493711
commit 0336304911
5 changed files with 14 additions and 13 deletions

View File

@ -4114,8 +4114,8 @@ nsSVGFEConvolveMatrixElement::Filter(nsSVGFilterInstance *instance)
gfxASurface::ImageFormatARGB32); gfxASurface::ImageFormatARGB32);
scaledTarget = new gfxImageSurface(scaledSize, scaledTarget = new gfxImageSurface(scaledSize,
gfxASurface::ImageFormatARGB32); gfxASurface::ImageFormatARGB32);
if (!scaledSource || !scaledSource->Data() || if (!scaledSource || scaledSource->CairoStatus() ||
!scaledTarget || !scaledTarget->Data()) !scaledTarget || scaledTarget->CairoStatus())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
gfxContext ctx(scaledSource); gfxContext ctx(scaledSource);

View File

@ -227,7 +227,7 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
// paint the target geometry // paint the target geometry
nsRefPtr<gfxImageSurface> tmpSurface = nsRefPtr<gfxImageSurface> tmpSurface =
new gfxImageSurface(filterRes, gfxASurface::ImageFormatARGB32); new gfxImageSurface(filterRes, gfxASurface::ImageFormatARGB32);
if (!tmpSurface || !tmpSurface->Data()) { if (!tmpSurface || tmpSurface->CairoStatus()) {
FilterFailCleanup(aContext, aTarget); FilterFailCleanup(aContext, aTarget);
return NS_OK; return NS_OK;
} }
@ -255,7 +255,7 @@ nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
nsRefPtr<gfxImageSurface> alpha = nsRefPtr<gfxImageSurface> alpha =
new gfxImageSurface(filterRes, gfxASurface::ImageFormatARGB32); new gfxImageSurface(filterRes, gfxASurface::ImageFormatARGB32);
if (!alpha || !alpha->Data()) { if (!alpha || alpha->CairoStatus()) {
FilterFailCleanup(aContext, aTarget); FilterFailCleanup(aContext, aTarget);
return NS_OK; return NS_OK;
} }
@ -518,7 +518,7 @@ nsSVGFilterInstance::GetImage()
new gfxImageSurface(gfxIntSize(mFilterResX, mFilterResY), new gfxImageSurface(gfxIntSize(mFilterResX, mFilterResY),
gfxASurface::ImageFormatARGB32); gfxASurface::ImageFormatARGB32);
if (!(surface && surface->Data())) { if (!surface || surface->CairoStatus()) {
return nsnull; return nsnull;
} }

View File

@ -203,7 +203,7 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
nsRefPtr<gfxImageSurface> image = nsRefPtr<gfxImageSurface> image =
new gfxImageSurface(surfaceSize, gfxASurface::ImageFormatARGB32); new gfxImageSurface(surfaceSize, gfxASurface::ImageFormatARGB32);
if (!image || !image->Data()) if (!image || image->CairoStatus())
return nsnull; return nsnull;
gfxContext transferCtx(image); gfxContext transferCtx(image);
@ -211,17 +211,15 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
transferCtx.SetSource(surface, -clipExtents.pos); transferCtx.SetSource(surface, -clipExtents.pos);
transferCtx.Paint(); transferCtx.Paint();
PRUint32 width = surfaceSize.width;
PRUint32 height = surfaceSize.height;
PRUint8 *data = image->Data(); PRUint8 *data = image->Data();
PRInt32 stride = image->Stride(); PRInt32 stride = image->Stride();
nsRect rect(0, 0, width, height); nsRect rect(0, 0, surfaceSize.width, surfaceSize.height);
nsSVGUtils::UnPremultiplyImageDataAlpha(data, stride, rect); nsSVGUtils::UnPremultiplyImageDataAlpha(data, stride, rect);
nsSVGUtils::ConvertImageDataToLinearRGB(data, stride, rect); nsSVGUtils::ConvertImageDataToLinearRGB(data, stride, rect);
for (PRUint32 y = 0; y < height; y++) for (PRUint32 y = 0; y < surfaceSize.height; y++)
for (PRUint32 x = 0; x < width; x++) { for (PRUint32 x = 0; x < surfaceSize.width; x++) {
PRUint8 *pixel = data + stride * y + 4 * x; PRUint8 *pixel = data + stride * y + 4 * x;
/* linearRGB -> intensity */ /* linearRGB -> intensity */

View File

@ -183,7 +183,8 @@ nsSVGPatternFrame::GetType() const
// matrix, which depends on our units parameters // matrix, which depends on our units parameters
// and X, Y, Width, and Height // and X, Y, Width, and Height
already_AddRefed<nsIDOMSVGMatrix> already_AddRefed<nsIDOMSVGMatrix>
nsSVGPatternFrame::GetCanvasTM() { nsSVGPatternFrame::GetCanvasTM()
{
nsIDOMSVGMatrix *rCTM; nsIDOMSVGMatrix *rCTM;
if (mCTM) { if (mCTM) {
@ -316,7 +317,7 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
nsRefPtr<gfxASurface> tmpSurface = nsRefPtr<gfxASurface> tmpSurface =
gfxPlatform::GetPlatform()->CreateOffscreenSurface(surfaceSize, gfxPlatform::GetPlatform()->CreateOffscreenSurface(surfaceSize,
gfxASurface::ImageFormatARGB32); gfxASurface::ImageFormatARGB32);
if (!tmpSurface) if (!tmpSurface || tmpSurface->CairoStatus())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
gfxContext tmpContext(tmpSurface); gfxContext tmpContext(tmpSurface);

View File

@ -1385,6 +1385,8 @@ nsSVGUtils::GetThebesComputationalSurface()
nsRefPtr<gfxASurface> surface = nsRefPtr<gfxASurface> surface =
gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1), gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1),
gfxASurface::ImageFormatARGB32); gfxASurface::ImageFormatARGB32);
NS_ASSERTION(surface && !surface->CairoStatus(),
"Could not create offscreen surface");
mThebesComputationalSurface = surface; mThebesComputationalSurface = surface;
// we want to keep this surface around // we want to keep this surface around
NS_IF_ADDREF(mThebesComputationalSurface); NS_IF_ADDREF(mThebesComputationalSurface);