OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "skia/ext/skia_utils_win.h" | 5 #include "skia/ext/skia_utils_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
| 10 #include "base/debug/gdi_debug_util_win.h" |
10 #include "third_party/skia/include/core/SkRect.h" | 11 #include "third_party/skia/include/core/SkRect.h" |
11 #include "third_party/skia/include/core/SkTypes.h" | 12 #include "third_party/skia/include/core/SkTypes.h" |
12 #include "third_party/skia/include/effects/SkGradientShader.h" | |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 static_assert(offsetof(RECT, left) == offsetof(SkIRect, fLeft), "o1"); | 16 static_assert(offsetof(RECT, left) == offsetof(SkIRect, fLeft), "o1"); |
17 static_assert(offsetof(RECT, top) == offsetof(SkIRect, fTop), "o2"); | 17 static_assert(offsetof(RECT, top) == offsetof(SkIRect, fTop), "o2"); |
18 static_assert(offsetof(RECT, right) == offsetof(SkIRect, fRight), "o3"); | 18 static_assert(offsetof(RECT, right) == offsetof(SkIRect, fRight), "o3"); |
19 static_assert(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), "o4"); | 19 static_assert(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), "o4"); |
20 static_assert(sizeof(RECT().left) == sizeof(SkIRect().fLeft), "o5"); | 20 static_assert(sizeof(RECT().left) == sizeof(SkIRect().fLeft), "o5"); |
21 static_assert(sizeof(RECT().top) == sizeof(SkIRect().fTop), "o6"); | 21 static_assert(sizeof(RECT().top) == sizeof(SkIRect().fTop), "o6"); |
22 static_assert(sizeof(RECT().right) == sizeof(SkIRect().fRight), "o7"); | 22 static_assert(sizeof(RECT().right) == sizeof(SkIRect().fRight), "o7"); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 source, | 141 source, |
142 src_rect.left, | 142 src_rect.left, |
143 src_rect.top, | 143 src_rect.top, |
144 copy_width, | 144 copy_width, |
145 copy_height, | 145 copy_height, |
146 blend_function); | 146 blend_function); |
147 } | 147 } |
148 LoadTransformToDC(source, transform); | 148 LoadTransformToDC(source, transform); |
149 } | 149 } |
150 | 150 |
| 151 HBITMAP CreateHBitmap(int width, int height, bool is_opaque, |
| 152 HANDLE shared_section, void** data) { |
| 153 // CreateDIBSection appears to get unhappy if we create an empty bitmap, so |
| 154 // just create a minimal bitmap |
| 155 if ((width == 0) || (height == 0)) { |
| 156 width = 1; |
| 157 height = 1; |
| 158 } |
| 159 |
| 160 BITMAPINFOHEADER hdr = {0}; |
| 161 hdr.biSize = sizeof(BITMAPINFOHEADER); |
| 162 hdr.biWidth = width; |
| 163 hdr.biHeight = -height; // minus means top-down bitmap |
| 164 hdr.biPlanes = 1; |
| 165 hdr.biBitCount = 32; |
| 166 hdr.biCompression = BI_RGB; // no compression |
| 167 hdr.biSizeImage = 0; |
| 168 hdr.biXPelsPerMeter = 1; |
| 169 hdr.biYPelsPerMeter = 1; |
| 170 hdr.biClrUsed = 0; |
| 171 hdr.biClrImportant = 0; |
| 172 |
| 173 HBITMAP hbitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr), |
| 174 0, data, shared_section, 0); |
| 175 |
| 176 #if !defined(_WIN64) |
| 177 // If this call fails, we're gonna crash hard. Try to get some useful |
| 178 // information out before we crash for post-mortem analysis. |
| 179 if (!hbitmap) |
| 180 base::debug::GDIBitmapAllocFailure(&hdr, shared_section); |
| 181 #endif |
| 182 |
| 183 return hbitmap; |
| 184 } |
| 185 |
151 } // namespace skia | 186 } // namespace skia |
152 | 187 |
OLD | NEW |