Limit drawing operations to the width/height of the IOSurface. b=570347 r=josh

This commit is contained in:
Benoit Girard 2010-06-09 00:12:06 -04:00
parent df81c3c2b2
commit a3c64abed6

View File

@ -690,6 +690,13 @@ nsresult nsCARenderer::DrawSurfaceToCGContext(CGContextRef aContext,
return NS_ERROR_FAILURE;
}
// We get rendering glitches if we use a width/height that falls
// outside of the IOSurface.
if (aWidth > ioWidth - aX)
aWidth = ioWidth - aX;
if (aHeight > ioHeight - aY)
aHeight = ioHeight - aY;
CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
aColorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, NULL, true, kCGRenderingIntentDefault);
@ -706,10 +713,8 @@ nsresult nsCARenderer::DrawSurfaceToCGContext(CGContextRef aContext,
return NS_ERROR_FAILURE;
}
::CGContextTranslateCTM(aContext, 0.0f, float(aHeight));
::CGContextScaleCTM(aContext, 1.0f, -1.0f);
::CGContextTranslateCTM(aContext, aX, -aY);
CGContextDrawImage(aContext, CGRectMake(0, 0, aWidth, aHeight), subImage);
::CGContextDrawImage(aContext, CGRectMake(aX, -aY-aHeight, aWidth, aHeight), subImage);
::CGImageRelease(subImage);
::CGImageRelease(cgImage);