OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "skia/ext/bitmap_platform_device_data.h" | 9 #include "skia/ext/bitmap_platform_device_data.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 const SkBitmap& bitmap) | 170 const SkBitmap& bitmap) |
171 : SkDevice(bitmap), | 171 : SkDevice(bitmap), |
172 data_(data) { | 172 data_(data) { |
173 // The data object is already ref'ed for us by create(). | 173 // The data object is already ref'ed for us by create(). |
174 SkDEBUGCODE(begin_paint_count_ = 0); | 174 SkDEBUGCODE(begin_paint_count_ = 0); |
175 SetPlatformDevice(this, this); | 175 SetPlatformDevice(this, this); |
176 } | 176 } |
177 | 177 |
178 BitmapPlatformDevice::~BitmapPlatformDevice() { | 178 BitmapPlatformDevice::~BitmapPlatformDevice() { |
179 SkASSERT(begin_paint_count_ == 0); | 179 SkASSERT(begin_paint_count_ == 0); |
180 data_->unref(); | |
181 } | 180 } |
182 | 181 |
183 HDC BitmapPlatformDevice::BeginPlatformPaint() { | 182 HDC BitmapPlatformDevice::BeginPlatformPaint() { |
184 SkDEBUGCODE(begin_paint_count_++); | 183 SkDEBUGCODE(begin_paint_count_++); |
185 return data_->GetBitmapDC(); | 184 return data_->GetBitmapDC(); |
186 } | 185 } |
187 | 186 |
188 void BitmapPlatformDevice::EndPlatformPaint() { | 187 void BitmapPlatformDevice::EndPlatformPaint() { |
189 SkASSERT(begin_paint_count_--); | 188 SkASSERT(begin_paint_count_--); |
190 PlatformDevice::EndPlatformPaint(); | 189 PlatformDevice::EndPlatformPaint(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return BitmapPlatformDevice::CreateAndClear(width, height, isOpaque); | 264 return BitmapPlatformDevice::CreateAndClear(width, height, isOpaque); |
266 } | 265 } |
267 | 266 |
268 // PlatformCanvas impl | 267 // PlatformCanvas impl |
269 | 268 |
270 SkCanvas* CreatePlatformCanvas(int width, | 269 SkCanvas* CreatePlatformCanvas(int width, |
271 int height, | 270 int height, |
272 bool is_opaque, | 271 bool is_opaque, |
273 HANDLE shared_section, | 272 HANDLE shared_section, |
274 OnFailureType failureType) { | 273 OnFailureType failureType) { |
275 SkDevice* dev = BitmapPlatformDevice::Create(width, | 274 skia::RefPtr<SkDevice> dev = BitmapPlatformDevice::Create(width, |
276 height, | 275 height, |
277 is_opaque, | 276 is_opaque, |
278 shared_section); | 277 shared_section); |
279 return CreateCanvas(dev, failureType); | 278 return CreateCanvas(dev, failureType); |
280 } | 279 } |
281 | 280 |
282 // Port of PlatformBitmap to win | 281 // Port of PlatformBitmap to win |
283 | 282 |
284 PlatformBitmap::~PlatformBitmap() { | 283 PlatformBitmap::~PlatformBitmap() { |
285 if (surface_) | 284 if (surface_) |
286 DeleteDC(surface_); | 285 DeleteDC(surface_); |
287 | 286 |
288 HBITMAP hbitmap = (HBITMAP)platform_extra_; | 287 HBITMAP hbitmap = (HBITMAP)platform_extra_; |
(...skipping 12 matching lines...) Expand all Loading... |
301 // When the memory DC is created, its display surface is exactly one | 300 // When the memory DC is created, its display surface is exactly one |
302 // monochrome pixel wide and one monochrome pixel high. Since we select our | 301 // monochrome pixel wide and one monochrome pixel high. Since we select our |
303 // own bitmap, we must delete the previous one. | 302 // own bitmap, we must delete the previous one. |
304 DeleteObject(old_bitmap); | 303 DeleteObject(old_bitmap); |
305 // remember the hbitmap, so we can free it in our destructor | 304 // remember the hbitmap, so we can free it in our destructor |
306 platform_extra_ = (intptr_t)hbitmap; | 305 platform_extra_ = (intptr_t)hbitmap; |
307 return true; | 306 return true; |
308 } | 307 } |
309 | 308 |
310 } // namespace skia | 309 } // namespace skia |
OLD | NEW |