| 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/bitmap_platform_device_win.h" | 5 #include "skia/ext/bitmap_platform_device_win.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkMatrix.h" | 7 #include "third_party/skia/include/core/SkMatrix.h" |
| 8 #include "third_party/skia/include/core/SkRefCnt.h" | 8 #include "third_party/skia/include/core/SkRefCnt.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "third_party/skia/include/core/SkUtils.h" | 10 #include "third_party/skia/include/core/SkUtils.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 hdr.biXPelsPerMeter = 1; | 192 hdr.biXPelsPerMeter = 1; |
| 193 hdr.biYPelsPerMeter = 1; | 193 hdr.biYPelsPerMeter = 1; |
| 194 hdr.biClrUsed = 0; | 194 hdr.biClrUsed = 0; |
| 195 hdr.biClrImportant = 0; | 195 hdr.biClrImportant = 0; |
| 196 | 196 |
| 197 void* data = NULL; | 197 void* data = NULL; |
| 198 HBITMAP hbitmap = CreateDIBSection(screen_dc, | 198 HBITMAP hbitmap = CreateDIBSection(screen_dc, |
| 199 reinterpret_cast<BITMAPINFO*>(&hdr), 0, | 199 reinterpret_cast<BITMAPINFO*>(&hdr), 0, |
| 200 &data, | 200 &data, |
| 201 shared_section, 0); | 201 shared_section, 0); |
| 202 | |
| 203 // If we run out of GDI objects or some other error occurs, we won't get a | |
| 204 // bitmap here. This will cause us to crash later because the data pointer is | |
| 205 // NULL. To make sure that we can assign blame for those crashes to this code, | |
| 206 // we deliberately crash here, even in release mode. | |
| 207 if (!hbitmap) { | 202 if (!hbitmap) { |
| 208 DWORD error = GetLastError(); | |
| 209 return NULL; | 203 return NULL; |
| 210 } | 204 } |
| 211 | 205 |
| 212 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 206 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 213 bitmap.setPixels(data); | 207 bitmap.setPixels(data); |
| 214 bitmap.setIsOpaque(is_opaque); | 208 bitmap.setIsOpaque(is_opaque); |
| 215 | 209 |
| 216 if (is_opaque) { | 210 if (is_opaque) { |
| 217 #ifndef NDEBUG | 211 #ifndef NDEBUG |
| 218 // To aid in finding bugs, we set the background color to something | 212 // To aid in finding bugs, we set the background color to something |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 356 |
| 363 void BitmapPlatformDeviceWin::onAccessBitmap(SkBitmap* bitmap) { | 357 void BitmapPlatformDeviceWin::onAccessBitmap(SkBitmap* bitmap) { |
| 364 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI | 358 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI |
| 365 // operation has occurred on our DC. | 359 // operation has occurred on our DC. |
| 366 if (data_->IsBitmapDCCreated()) | 360 if (data_->IsBitmapDCCreated()) |
| 367 GdiFlush(); | 361 GdiFlush(); |
| 368 } | 362 } |
| 369 | 363 |
| 370 } // namespace skia | 364 } // namespace skia |
| 371 | 365 |
| OLD | NEW |