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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 | 261 |
262 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( | 262 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( |
263 SkBitmap::Config config, int width, int height, bool isOpaque, | 263 SkBitmap::Config config, int width, int height, bool isOpaque, |
264 Usage /*usage*/) { | 264 Usage /*usage*/) { |
265 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 265 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
266 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height, | 266 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height, |
267 isOpaque); | 267 isOpaque); |
268 return bitmap_device; | 268 return bitmap_device; |
269 } | 269 } |
270 | 270 |
271 // PlatformCanvas impl | |
272 | |
273 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque, | |
274 HANDLE shared_section, OnFailureType failureType) { | |
sky
2012/11/05 14:43:10
nit: indentation. Also, when you wrap each param s
reed1
2012/11/05 19:14:13
Done.
| |
275 SkDevice* dev = BitmapPlatformDevice::Create(width, height, is_opaque, | |
276 shared_section); | |
277 return CreateCanvas(dev, failureType); | |
278 } | |
279 | |
271 // Port of PlatformBitmap to win | 280 // Port of PlatformBitmap to win |
272 | 281 |
273 PlatformBitmap::~PlatformBitmap() { | 282 PlatformBitmap::~PlatformBitmap() { |
274 if (surface_) | 283 if (surface_) |
275 DeleteDC(surface_); | 284 DeleteDC(surface_); |
276 } | 285 } |
277 | 286 |
278 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { | 287 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { |
279 HBITMAP hbitmap = CreateHBitmap(width, height, is_opaque, 0, &bitmap_); | 288 HBITMAP hbitmap = CreateHBitmap(width, height, is_opaque, 0, &bitmap_); |
280 if (!hbitmap) | 289 if (!hbitmap) |
281 return false; | 290 return false; |
282 | 291 |
283 surface_ = CreateCompatibleDC(NULL); | 292 surface_ = CreateCompatibleDC(NULL); |
284 InitializeDC(surface_); | 293 InitializeDC(surface_); |
285 HGDIOBJ old_bitmap = SelectObject(surface_, hbitmap); | 294 HGDIOBJ old_bitmap = SelectObject(surface_, hbitmap); |
286 // When the memory DC is created, its display surface is exactly one | 295 // When the memory DC is created, its display surface is exactly one |
287 // monochrome pixel wide and one monochrome pixel high. Since we select our | 296 // monochrome pixel wide and one monochrome pixel high. Since we select our |
288 // own bitmap, we must delete the previous one. | 297 // own bitmap, we must delete the previous one. |
289 DeleteObject(old_bitmap); | 298 DeleteObject(old_bitmap); |
290 return true; | 299 return true; |
291 } | 300 } |
292 | 301 |
293 } // namespace skia | 302 } // namespace skia |
OLD | NEW |