Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: skia/ext/bitmap_platform_device_win.cc

Issue 57053002: Aggressively assert on BITMAP object deletions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unecessary new include Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698