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);
scaledTarget = new gfxImageSurface(scaledSize,
gfxASurface::ImageFormatARGB32);
if (!scaledSource || !scaledSource->Data() ||
!scaledTarget || !scaledTarget->Data())
if (!scaledSource || scaledSource->CairoStatus() ||
!scaledTarget || scaledTarget->CairoStatus())
return NS_ERROR_FAILURE;
gfxContext ctx(scaledSource);

View File

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

View File

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

View File

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

View File

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