Changeset 131805 in webkit


Ignore:
Timestamp:
Oct 18, 2012, 2:28:02 PM (13 years ago)
Author:
reed@google.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131804 r131805  
     12012-10-18  Mike Reed  <reed@google.com>
     2
     3        Handle if we fail to allocate nonPlatformCanvas in ImageBuffer constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=99752
     5
     6        Reviewed by Stephen White.
     7
     8        Current code does not check if we were able to allocate the pixels, but still returns the canvas.
     9        However, the caller explicitly is checking for null on failure, so it will continue (and possibly
     10        crash later on).
     11        This change brings the nonPlatformCanvas behavior inline with createAcceleratedCanvas and
     12        TryCreateBitmapCanvas, both of which are also called by ImageBuffer's constructor.
     13
     14        No new tests. Existing tests exercise ImageBuffer constructor.
     15
     16        * platform/graphics/skia/ImageBufferSkia.cpp:
     17        (WebCore::createNonPlatformCanvas):
     18
    1192012-10-18  Beth Dakin  <bdakin@apple.com>
    220
  • trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

    r131017 r131805  
    105105static SkCanvas* createNonPlatformCanvas(const IntSize& size)
    106106{
    107     SkCanvas* canvas = new SkCanvas();
    108     canvas->setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()))->unref();
    109     return canvas;
     107    SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()));
     108    SkPixelRef* pixelRef = device->accessBitmap(false).pixelRef();
     109    return pixelRef ? new SkCanvas(device) : 0;
    110110}
    111111
Note: See TracChangeset for help on using the changeset viewer.