Chromium Code Reviews| 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" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return new BitmapPlatformDevice(new BitmapPlatformDeviceData(hbitmap), | 147 return new BitmapPlatformDevice(new BitmapPlatformDeviceData(hbitmap), |
| 148 bitmap); | 148 bitmap); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 BitmapPlatformDevice* BitmapPlatformDevice::create(int width, | 152 BitmapPlatformDevice* BitmapPlatformDevice::create(int width, |
| 153 int height, | 153 int height, |
| 154 bool is_opaque, | 154 bool is_opaque, |
| 155 HANDLE shared_section) { | 155 HANDLE shared_section) { |
| 156 HDC screen_dc = GetDC(NULL); | 156 HDC screen_dc = GetDC(NULL); |
| 157 BitmapPlatformDevice* device = BitmapPlatformDevice::create( | 157 BitmapPlatformDevice* device = BitmapPlatformDevice::create(screen_dc, width, height, |
|
alokp
2011/08/24 17:03:02
nit: formatting
Jeff Timanus
2011/08/24 22:09:58
Done.
| |
| 158 screen_dc, width, height, is_opaque, shared_section); | 158 is_opaque, shared_section); |
| 159 ReleaseDC(NULL, screen_dc); | 159 ReleaseDC(NULL, screen_dc); |
| 160 return device; | 160 return device; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // The device will own the HBITMAP, which corresponds to also owning the pixel | 163 // The device will own the HBITMAP, which corresponds to also owning the pixel |
| 164 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. | 164 // data. Therefore, we do not transfer ownership to the SkDevice's bitmap. |
| 165 BitmapPlatformDevice::BitmapPlatformDevice( | 165 BitmapPlatformDevice::BitmapPlatformDevice( |
| 166 BitmapPlatformDeviceData* data, | 166 BitmapPlatformDeviceData* data, |
| 167 const SkBitmap& bitmap) | 167 const SkBitmap& bitmap) |
| 168 : PlatformDevice(bitmap), | 168 : SkDevice(bitmap), |
| 169 data_(data) { | 169 data_(data) { |
| 170 // The data object is already ref'ed for us by create(). | 170 // The data object is already ref'ed for us by create(). |
| 171 SkDEBUGCODE(begin_paint_count_ = 0); | 171 SkDEBUGCODE(begin_paint_count_ = 0); |
| 172 SetPlatformDevice(this, this); | |
| 172 } | 173 } |
| 173 | 174 |
| 174 BitmapPlatformDevice::~BitmapPlatformDevice() { | 175 BitmapPlatformDevice::~BitmapPlatformDevice() { |
| 175 SkASSERT(begin_paint_count_ == 0); | 176 SkASSERT(begin_paint_count_ == 0); |
| 176 data_->unref(); | 177 data_->unref(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 HDC BitmapPlatformDevice::BeginPlatformPaint() { | 180 HDC BitmapPlatformDevice::BeginPlatformPaint() { |
| 180 SkDEBUGCODE(begin_paint_count_++); | 181 SkDEBUGCODE(begin_paint_count_++); |
| 181 return data_->GetBitmapDC(); | 182 return data_->GetBitmapDC(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 } | 256 } |
| 256 | 257 |
| 257 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 258 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
| 258 SkBitmap::Config config, int width, int height, bool isOpaque, | 259 SkBitmap::Config config, int width, int height, bool isOpaque, |
| 259 Usage /*usage*/) { | 260 Usage /*usage*/) { |
| 260 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 261 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 261 return BitmapPlatformDevice::create(width, height, isOpaque, NULL); | 262 return BitmapPlatformDevice::create(width, height, isOpaque, NULL); |
| 262 } | 263 } |
| 263 | 264 |
| 264 } // namespace skia | 265 } // namespace skia |
| 265 | |
| OLD | NEW |