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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 data_->unref(); | 194 data_->unref(); |
195 } | 195 } |
196 | 196 |
197 BitmapPlatformDevice& BitmapPlatformDevice::operator=( | 197 BitmapPlatformDevice& BitmapPlatformDevice::operator=( |
198 const BitmapPlatformDevice& other) { | 198 const BitmapPlatformDevice& other) { |
199 data_ = other.data_; | 199 data_ = other.data_; |
200 data_->ref(); | 200 data_->ref(); |
201 return *this; | 201 return *this; |
202 } | 202 } |
203 | 203 |
204 HDC BitmapPlatformDevice::beginPlatformPaint() { | 204 HDC BitmapPlatformDevice::BeginPlatformPaint() { |
205 return data_->GetBitmapDC(); | 205 return data_->GetBitmapDC(); |
206 } | 206 } |
207 | 207 |
208 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, | 208 void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform, |
209 const SkRegion& region, | 209 const SkRegion& region, |
210 const SkClipStack&) { | 210 const SkClipStack&) { |
211 data_->SetMatrixClip(transform, region); | 211 data_->SetMatrixClip(transform, region); |
212 } | 212 } |
213 | 213 |
214 void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y, | 214 void BitmapPlatformDevice::drawToHDC(HDC dc, int x, int y, |
215 const RECT* src_rect) { | 215 const RECT* src_rect) { |
216 bool created_dc = !data_->IsBitmapDCCreated(); | 216 bool created_dc = !data_->IsBitmapDCCreated(); |
217 HDC source_dc = beginPlatformPaint(); | 217 HDC source_dc = BeginPlatformPaint(); |
218 | 218 |
219 RECT temp_rect; | 219 RECT temp_rect; |
220 if (!src_rect) { | 220 if (!src_rect) { |
221 temp_rect.left = 0; | 221 temp_rect.left = 0; |
222 temp_rect.right = width(); | 222 temp_rect.right = width(); |
223 temp_rect.top = 0; | 223 temp_rect.top = 0; |
224 temp_rect.bottom = height(); | 224 temp_rect.bottom = height(); |
225 src_rect = &temp_rect; | 225 src_rect = &temp_rect; |
226 } | 226 } |
227 | 227 |
(...skipping 26 matching lines...) Expand all Loading... |
254 copy_height, | 254 copy_height, |
255 source_dc, | 255 source_dc, |
256 src_rect->left, | 256 src_rect->left, |
257 src_rect->top, | 257 src_rect->top, |
258 copy_width, | 258 copy_width, |
259 copy_height, | 259 copy_height, |
260 blend_function); | 260 blend_function); |
261 } | 261 } |
262 LoadTransformToDC(source_dc, data_->transform()); | 262 LoadTransformToDC(source_dc, data_->transform()); |
263 | 263 |
264 endPlatformPaint(); | 264 EndPlatformPaint(); |
265 if (created_dc) | 265 if (created_dc) |
266 data_->ReleaseBitmapDC(); | 266 data_->ReleaseBitmapDC(); |
267 } | 267 } |
268 | 268 |
269 // Returns the color value at the specified location. | 269 // Returns the color value at the specified location. |
270 SkColor BitmapPlatformDevice::getColorAt(int x, int y) { | 270 SkColor BitmapPlatformDevice::getColorAt(int x, int y) { |
271 const SkBitmap& bitmap = accessBitmap(false); | 271 const SkBitmap& bitmap = accessBitmap(false); |
272 SkAutoLockPixels lock(bitmap); | 272 SkAutoLockPixels lock(bitmap); |
273 uint32_t* data = bitmap.getAddr32(0, 0); | 273 uint32_t* data = bitmap.getAddr32(0, 0); |
274 return static_cast<SkColor>(data[x + y * width()]); | 274 return static_cast<SkColor>(data[x + y * width()]); |
275 } | 275 } |
276 | 276 |
277 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { | 277 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { |
278 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI | 278 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI |
279 // operation has occurred on our DC. | 279 // operation has occurred on our DC. |
280 if (data_->IsBitmapDCCreated()) | 280 if (data_->IsBitmapDCCreated()) |
281 GdiFlush(); | 281 GdiFlush(); |
282 } | 282 } |
283 | 283 |
284 } // namespace skia | 284 } // namespace skia |
285 | 285 |
OLD | NEW |