Index: skia/ext/skia_utils_win.cc |
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc |
index a78d0772619ff3cdea2477f7b0ff54c4689529e8..ca62a7cf83ff8116eb95f7c6ce34c68d300c4ead 100644 |
--- a/skia/ext/skia_utils_win.cc |
+++ b/skia/ext/skia_utils_win.cc |
@@ -195,28 +195,29 @@ SkBitmap MapPlatformBitmap(HDC context) { |
return bitmap; |
} |
-HDC CreateOffscreenSurface(int width, int height) { |
- HBITMAP bitmap = nullptr; |
- |
+HDC CreateOffscreenSurface(base::win::ScopedBitmap* bitmap, |
+ int width, |
+ int height) { |
+ DCHECK(bitmap); |
Peter Kasting
2016/09/23 18:45:00
Nit: Blank line below this
Rafał Chłodnicki
2016/09/26 10:12:09
Done.
|
// If this process doesn't have access to GDI, we'll have to use a shared |
// memory segment instead. |
if (!base::win::IsUser32AndGdi32Available()) |
return nullptr; |
- bitmap = CreateHBitmap(width, height, false, nullptr, nullptr); |
- if (!bitmap) |
- return nullptr; |
- |
base::win::ScopedCreateDC scoped_hdc(CreateCompatibleDC(nullptr)); |
if (!scoped_hdc.IsValid()) |
return nullptr; |
+ |
InitializeDC(scoped_hdc.Get()); |
HRGN clip = CreateRectRgn(0, 0, width, height); |
- if ((SelectClipRgn(scoped_hdc.Get(), clip) == ERROR) || |
- (!DeleteObject(clip))) |
+ if (SelectClipRgn(scoped_hdc.Get(), clip) == ERROR || !DeleteObject(clip)) |
Peter Kasting
2016/09/23 18:45:00
Nit: Removing the second set of parnes was good, I
Rafał Chłodnicki
2016/09/26 10:12:09
Done.
|
+ return nullptr; |
+ |
+ bitmap->reset(CreateHBitmap(width, height, false, nullptr, nullptr)); |
+ if (!bitmap->is_valid()) |
return nullptr; |
- SelectObject(scoped_hdc.Get(), bitmap); |
+ SelectObject(scoped_hdc.Get(), bitmap->get()); |
// The caller must call DeleteDC(hdc) on this object once done with it. |
return scoped_hdc.Take(); |