| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <psapi.h> | 6 #include <psapi.h> |
| 7 | 7 |
| 8 #include "skia/ext/bitmap_platform_device_win.h" | 8 #include "skia/ext/bitmap_platform_device_win.h" |
| 9 | 9 |
| 10 #include "skia/ext/bitmap_platform_device_data.h" | 10 #include "skia/ext/bitmap_platform_device_data.h" |
| 11 #include "third_party/skia/include/core/SkMatrix.h" | 11 #include "third_party/skia/include/core/SkMatrix.h" |
| 12 #include "third_party/skia/include/core/SkRefCnt.h" | 12 #include "third_party/skia/include/core/SkRefCnt.h" |
| 13 #include "third_party/skia/include/core/SkRegion.h" | 13 #include "third_party/skia/include/core/SkRegion.h" |
| 14 #include "third_party/skia/include/core/SkUtils.h" | 14 #include "third_party/skia/include/core/SkUtils.h" |
| 15 | 15 |
| 16 namespace skia { | 16 namespace skia { |
| 17 | 17 |
| 18 SkDevice* BitmapPlatformDeviceFactory::newDevice(SkCanvas* ignored, | |
| 19 SkBitmap::Config config, | |
| 20 int width, int height, | |
| 21 bool isOpaque, | |
| 22 bool isForLayer) { | |
| 23 SkASSERT(config == SkBitmap::kARGB_8888_Config); | |
| 24 return BitmapPlatformDevice::create(width, height, isOpaque, NULL); | |
| 25 } | |
| 26 | |
| 27 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( | 18 BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData( |
| 28 HBITMAP hbitmap) | 19 HBITMAP hbitmap) |
| 29 : bitmap_context_(hbitmap), | 20 : bitmap_context_(hbitmap), |
| 30 hdc_(NULL), | 21 hdc_(NULL), |
| 31 config_dirty_(true) { // Want to load the config next time. | 22 config_dirty_(true) { // Want to load the config next time. |
| 32 // Initialize the clip region to the entire bitmap. | 23 // Initialize the clip region to the entire bitmap. |
| 33 BITMAP bitmap_data; | 24 BITMAP bitmap_data; |
| 34 if (GetObject(bitmap_context_, sizeof(BITMAP), &bitmap_data)) { | 25 if (GetObject(bitmap_context_, sizeof(BITMAP), &bitmap_data)) { |
| 35 SkIRect rect; | 26 SkIRect rect; |
| 36 rect.set(0, 0, bitmap_data.bmWidth, bitmap_data.bmHeight); | 27 rect.set(0, 0, bitmap_data.bmWidth, bitmap_data.bmHeight); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 data_->ReleaseBitmapDC(); | 247 data_->ReleaseBitmapDC(); |
| 257 } | 248 } |
| 258 | 249 |
| 259 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { | 250 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { |
| 260 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI | 251 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI |
| 261 // operation has occurred on our DC. | 252 // operation has occurred on our DC. |
| 262 if (data_->IsBitmapDCCreated()) | 253 if (data_->IsBitmapDCCreated()) |
| 263 GdiFlush(); | 254 GdiFlush(); |
| 264 } | 255 } |
| 265 | 256 |
| 266 SkDeviceFactory* BitmapPlatformDevice::onNewDeviceFactory() { | 257 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 267 return SkNEW(BitmapPlatformDeviceFactory); | 258 SkBitmap::Config config, int width, int height, bool isOpaque, |
| 259 Usage /*usage*/) { |
| 260 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 261 return BitmapPlatformDevice::create(width, height, isOpaque, NULL); |
| 268 } | 262 } |
| 269 | 263 |
| 270 } // namespace skia | 264 } // namespace skia |
| 271 | 265 |
| OLD | NEW |