Title: [131805] trunk/Source/WebCore
Revision
131805
Author
r...@google.com
Date
2012-10-18 14:28:02 -0700 (Thu, 18 Oct 2012)

Log Message

Handle if we fail to allocate nonPlatformCanvas in ImageBuffer constructor
https://bugs.webkit.org/show_bug.cgi?id=99752

Reviewed by Stephen White.

Current code does not check if we were able to allocate the pixels, but still returns the canvas.
However, the caller explicitly is checking for null on failure, so it will continue (and possibly
crash later on).
This change brings the nonPlatformCanvas behavior inline with createAcceleratedCanvas and
TryCreateBitmapCanvas, both of which are also called by ImageBuffer's constructor.

No new tests. Existing tests exercise ImageBuffer constructor.

* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::createNonPlatformCanvas):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131804 => 131805)


--- trunk/Source/WebCore/ChangeLog	2012-10-18 21:25:35 UTC (rev 131804)
+++ trunk/Source/WebCore/ChangeLog	2012-10-18 21:28:02 UTC (rev 131805)
@@ -1,3 +1,21 @@
+2012-10-18  Mike Reed  <r...@google.com>
+
+        Handle if we fail to allocate nonPlatformCanvas in ImageBuffer constructor
+        https://bugs.webkit.org/show_bug.cgi?id=99752
+
+        Reviewed by Stephen White.
+
+        Current code does not check if we were able to allocate the pixels, but still returns the canvas.
+        However, the caller explicitly is checking for null on failure, so it will continue (and possibly
+        crash later on).
+        This change brings the nonPlatformCanvas behavior inline with createAcceleratedCanvas and
+        TryCreateBitmapCanvas, both of which are also called by ImageBuffer's constructor.
+
+        No new tests. Existing tests exercise ImageBuffer constructor.
+
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::createNonPlatformCanvas):
+
 2012-10-18  Beth Dakin  <bda...@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=99668

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp (131804 => 131805)


--- trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-10-18 21:25:35 UTC (rev 131804)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp	2012-10-18 21:28:02 UTC (rev 131805)
@@ -104,9 +104,9 @@
 
 static SkCanvas* createNonPlatformCanvas(const IntSize& size)
 {
-    SkCanvas* canvas = new SkCanvas();
-    canvas->setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()))->unref();
-    return canvas;
+    SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()));
+    SkPixelRef* pixelRef = device->accessBitmap(false).pixelRef();
+    return pixelRef ? new SkCanvas(device) : 0;
 }
 
 ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, DeferralMode deferralMode, bool& success)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to