Chromium Code Reviews| Index: skia/ext/bitmap_platform_device_win.cc |
| diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc |
| index 203281d327128671574873225de435510fadd1fc..a4004e9622955a9ae29dfdbfb1c4c9aba7cacf0d 100644 |
| --- a/skia/ext/bitmap_platform_device_win.cc |
| +++ b/skia/ext/bitmap_platform_device_win.cc |
| @@ -57,6 +57,24 @@ HBITMAP CreateHBitmap(int width, int height, bool is_opaque, |
| HBITMAP hbitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr), |
| 0, data, shared_section, 0); |
| + |
| + if (!hbitmap) { |
| + // Attempt to create a smaller DIBSection to debug whether |
| + // the failure was due to memory exhaustion/fragmentation |
| + // or GDI resource exhaution. |
| + // See crbug.com/275046 |
| + hdr.biWidth = 5; |
| + hdr.biHeight = 5; |
| + void* small_data; |
| + HBITMAP small_bitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr), |
| + 0, &small_data, shared_section, 0); |
| + SkASSERT(small_bitmap); |
| + DeleteObject(small_bitmap); |
| + BITMAP bitmap_data; |
| + if (GetObject(small_bitmap, sizeof(BITMAP), &bitmap_data)) |
| + SkASSERT(DeleteObject(small_bitmap)); |
| + } |
| + |
| return hbitmap; |
| } |
| @@ -69,7 +87,7 @@ PlatformBitmapPixelRef::PlatformBitmapPixelRef(HBITMAP bitmap_handle, |
| PlatformBitmapPixelRef::~PlatformBitmapPixelRef() { |
| if (bitmap_handle_) |
| - DeleteObject(bitmap_handle_); |
| + SkASSERT(DeleteObject(bitmap_handle_)); |
|
reed1
2013/11/04 16:49:28
SkASSERT becomes a no-op in release builds, so I t
|
| } |
| void* PlatformBitmapPixelRef::onLockPixels(SkColorTable** color_table) { |
| @@ -106,7 +124,7 @@ BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() { |
| ReleaseBitmapDC(); |
| // this will free the bitmap data as well as the bitmap handle |
| - DeleteObject(bitmap_context_); |
| + SkASSERT(DeleteObject(bitmap_context_)); |
| } |
| HDC BitmapPlatformDevice::BitmapPlatformDeviceData::GetBitmapDC() { |
| @@ -117,7 +135,7 @@ HDC BitmapPlatformDevice::BitmapPlatformDeviceData::GetBitmapDC() { |
| // When the memory DC is created, its display surface is exactly one |
| // monochrome pixel wide and one monochrome pixel high. Since we select our |
| // own bitmap, we must delete the previous one. |
| - DeleteObject(old_bitmap); |
| + SkASSERT(DeleteObject(old_bitmap)); |
| } |
| LoadConfig(); |