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

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: Fixed 80 char limit 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..4ae8b504376ff1438f67474cf87e484bfdf79d1f 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -57,6 +57,26 @@ 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);
+ if (!small_bitmap)
+ SK_CRASH();
+ BITMAP bitmap_data;
+ if (GetObject(small_bitmap, sizeof(BITMAP), &bitmap_data))
+ if (!DeleteObject(small_bitmap))
+ SK_CRASH();
+ }
+
return hbitmap;
}
@@ -69,7 +89,8 @@ PlatformBitmapPixelRef::PlatformBitmapPixelRef(HBITMAP bitmap_handle,
PlatformBitmapPixelRef::~PlatformBitmapPixelRef() {
if (bitmap_handle_)
- DeleteObject(bitmap_handle_);
+ if (!DeleteObject(bitmap_handle_))
+ SK_CRASH();
}
void* PlatformBitmapPixelRef::onLockPixels(SkColorTable** color_table) {
@@ -106,7 +127,8 @@ BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() {
ReleaseBitmapDC();
// this will free the bitmap data as well as the bitmap handle
- DeleteObject(bitmap_context_);
+ if (!DeleteObject(bitmap_context_))
+ SK_CRASH();
}
HDC BitmapPlatformDevice::BitmapPlatformDeviceData::GetBitmapDC() {
@@ -117,7 +139,8 @@ 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);
+ if (!DeleteObject(old_bitmap))
+ SK_CRASH();
}
LoadConfig();
@@ -126,7 +149,8 @@ HDC BitmapPlatformDevice::BitmapPlatformDeviceData::GetBitmapDC() {
void BitmapPlatformDevice::BitmapPlatformDeviceData::ReleaseBitmapDC() {
SkASSERT(hdc_);
- DeleteDC(hdc_);
+ if (!DeleteDC(hdc_))
+ SK_CRASH();
hdc_ = NULL;
}
@@ -325,7 +349,8 @@ PlatformBitmap::~PlatformBitmap() {
if (surface_) {
if (platform_extra_)
SelectObject(surface_, reinterpret_cast<HGDIOBJ>(platform_extra_));
- DeleteDC(surface_);
+ if (!DeleteDC(surface_))
+ SK_CRASH();
}
}
« 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