| OLD | NEW |
| 1 // Copyright (c) 2010 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" |
| 11 #include "third_party/skia/include/core/SkMatrix.h" | 11 #include "third_party/skia/include/core/SkMatrix.h" |
| (...skipping 182 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::getBitmapDC() { | 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 = getBitmapDC(); | 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 if (created_dc) | 265 if (created_dc) |
| 265 data_->ReleaseBitmapDC(); | 266 data_->ReleaseBitmapDC(); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // Returns the color value at the specified location. | 269 // Returns the color value at the specified location. |
| 269 SkColor BitmapPlatformDevice::getColorAt(int x, int y) { | 270 SkColor BitmapPlatformDevice::getColorAt(int x, int y) { |
| 270 const SkBitmap& bitmap = accessBitmap(false); | 271 const SkBitmap& bitmap = accessBitmap(false); |
| 271 SkAutoLockPixels lock(bitmap); | 272 SkAutoLockPixels lock(bitmap); |
| 272 uint32_t* data = bitmap.getAddr32(0, 0); | 273 uint32_t* data = bitmap.getAddr32(0, 0); |
| 273 return static_cast<SkColor>(data[x + y * width()]); | 274 return static_cast<SkColor>(data[x + y * width()]); |
| 274 } | 275 } |
| 275 | 276 |
| 276 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { | 277 void BitmapPlatformDevice::onAccessBitmap(SkBitmap* bitmap) { |
| 277 // 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 |
| 278 // operation has occurred on our DC. | 279 // operation has occurred on our DC. |
| 279 if (data_->IsBitmapDCCreated()) | 280 if (data_->IsBitmapDCCreated()) |
| 280 GdiFlush(); | 281 GdiFlush(); |
| 281 } | 282 } |
| 282 | 283 |
| 283 } // namespace skia | 284 } // namespace skia |
| 284 | 285 |
| OLD | NEW |