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 "base/debug/gdi_debug_util_win.h" | 8 #include "base/debug/gdi_debug_util_win.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "skia/ext/bitmap_platform_device_win.h" | 10 #include "skia/ext/bitmap_platform_device_win.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 base::debug::GDIBitmapAllocFailure(&hdr, shared_section); | 48 base::debug::GDIBitmapAllocFailure(&hdr, shared_section); |
49 #endif | 49 #endif |
50 | 50 |
51 return hbitmap; | 51 return hbitmap; |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 namespace skia { | 56 namespace skia { |
57 | 57 |
| 58 void DrawToNativeContext(SkCanvas* canvas, HDC hdc, int x, int y, |
| 59 const RECT* src_rect) { |
| 60 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
| 61 if (platform_device) |
| 62 platform_device->DrawToHDC(hdc, x, y, src_rect); |
| 63 } |
| 64 |
| 65 void PlatformDevice::DrawToHDC(HDC, int x, int y, const RECT* src_rect) {} |
| 66 |
58 HDC BitmapPlatformDevice::GetBitmapDC() { | 67 HDC BitmapPlatformDevice::GetBitmapDC() { |
59 if (!hdc_) { | 68 if (!hdc_) { |
60 hdc_ = CreateCompatibleDC(NULL); | 69 hdc_ = CreateCompatibleDC(NULL); |
61 InitializeDC(hdc_); | 70 InitializeDC(hdc_); |
62 old_hbitmap_ = static_cast<HBITMAP>(SelectObject(hdc_, hbitmap_)); | 71 old_hbitmap_ = static_cast<HBITMAP>(SelectObject(hdc_, hbitmap_)); |
63 } | 72 } |
64 | 73 |
65 LoadConfig(); | 74 LoadConfig(); |
66 return hdc_; | 75 return hdc_; |
67 } | 76 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 SkASSERT(begin_paint_count_--); | 204 SkASSERT(begin_paint_count_--); |
196 PlatformDevice::EndPlatformPaint(); | 205 PlatformDevice::EndPlatformPaint(); |
197 } | 206 } |
198 | 207 |
199 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 208 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
200 const SkRegion& region, | 209 const SkRegion& region, |
201 const SkClipStack&) { | 210 const SkClipStack&) { |
202 SetMatrixClip(transform, region); | 211 SetMatrixClip(transform, region); |
203 } | 212 } |
204 | 213 |
205 void BitmapPlatformDevice::DrawToNativeContext(HDC dc, int x, int y, | 214 void BitmapPlatformDevice::DrawToHDC(HDC dc, int x, int y, |
206 const RECT* src_rect) { | 215 const RECT* src_rect) { |
207 bool created_dc = !IsBitmapDCCreated(); | 216 bool created_dc = !IsBitmapDCCreated(); |
208 HDC source_dc = BeginPlatformPaint(); | 217 HDC source_dc = BeginPlatformPaint(); |
209 | 218 |
210 RECT temp_rect; | 219 RECT temp_rect; |
211 if (!src_rect) { | 220 if (!src_rect) { |
212 temp_rect.left = 0; | 221 temp_rect.left = 0; |
213 temp_rect.right = width(); | 222 temp_rect.right = width(); |
214 temp_rect.top = 0; | 223 temp_rect.top = 0; |
215 temp_rect.bottom = height(); | 224 temp_rect.bottom = height(); |
216 src_rect = &temp_rect; | 225 src_rect = &temp_rect; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 platform_extra_ = reinterpret_cast<intptr_t>(stock_bitmap); | 319 platform_extra_ = reinterpret_cast<intptr_t>(stock_bitmap); |
311 | 320 |
312 if (!InstallHBitmapPixels(&bitmap_, width, height, is_opaque, data, hbitmap)) | 321 if (!InstallHBitmapPixels(&bitmap_, width, height, is_opaque, data, hbitmap)) |
313 return false; | 322 return false; |
314 bitmap_.lockPixels(); | 323 bitmap_.lockPixels(); |
315 | 324 |
316 return true; | 325 return true; |
317 } | 326 } |
318 | 327 |
319 } // namespace skia | 328 } // namespace skia |
OLD | NEW |