Index: skia/ext/skia_utils_win.cc |
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc |
index 37bd21e3c898ac1cd0432d89f0c6d999983773c9..b0aff357adbbcfb1ae01bafc415d0bf987e15948 100644 |
--- a/skia/ext/skia_utils_win.cc |
+++ b/skia/ext/skia_utils_win.cc |
@@ -7,9 +7,9 @@ |
#include <stddef.h> |
#include <windows.h> |
+#include "base/debug/gdi_debug_util_win.h" |
#include "third_party/skia/include/core/SkRect.h" |
#include "third_party/skia/include/core/SkTypes.h" |
-#include "third_party/skia/include/effects/SkGradientShader.h" |
namespace { |
@@ -148,5 +148,40 @@ void CopyHDC(HDC source, HDC destination, int x, int y, bool is_opaque, |
LoadTransformToDC(source, transform); |
} |
+HBITMAP CreateHBitmap(int width, int height, bool is_opaque, |
+ HANDLE shared_section, void** data) { |
+ // CreateDIBSection appears to get unhappy if we create an empty bitmap, so |
+ // just create a minimal bitmap |
+ if ((width == 0) || (height == 0)) { |
+ width = 1; |
+ height = 1; |
+ } |
+ |
+ BITMAPINFOHEADER hdr = {0}; |
+ hdr.biSize = sizeof(BITMAPINFOHEADER); |
+ hdr.biWidth = width; |
+ hdr.biHeight = -height; // minus means top-down bitmap |
+ hdr.biPlanes = 1; |
+ hdr.biBitCount = 32; |
+ hdr.biCompression = BI_RGB; // no compression |
+ hdr.biSizeImage = 0; |
+ hdr.biXPelsPerMeter = 1; |
+ hdr.biYPelsPerMeter = 1; |
+ hdr.biClrUsed = 0; |
+ hdr.biClrImportant = 0; |
+ |
+ HBITMAP hbitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr), |
+ 0, data, shared_section, 0); |
+ |
+#if !defined(_WIN64) |
+ // If this call fails, we're gonna crash hard. Try to get some useful |
+ // information out before we crash for post-mortem analysis. |
+ if (!hbitmap) |
+ base::debug::GDIBitmapAllocFailure(&hdr, shared_section); |
+#endif |
+ |
+ return hbitmap; |
+} |
+ |
} // namespace skia |