| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "skia/ext/bitmap_platform_device_win.h" | 5 #include "skia/ext/bitmap_platform_device_win.h" |
| 6 | 6 |
| 7 #include "SkMatrix.h" | 7 #include "SkMatrix.h" |
| 8 #include "SkRefCnt.h" | 8 #include "SkRefCnt.h" |
| 9 #include "SkRegion.h" | 9 #include "SkRegion.h" |
| 10 #include "SkUtils.h" | 10 #include "SkUtils.h" |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 void BitmapPlatformDeviceWin::postProcessGDI(int x, int y, int width, | 395 void BitmapPlatformDeviceWin::postProcessGDI(int x, int y, int width, |
| 396 int height) { | 396 int height) { |
| 397 processPixels<PostProcessAlphaForGDI>(x, y, width, height); | 397 processPixels<PostProcessAlphaForGDI>(x, y, width, height); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void BitmapPlatformDeviceWin::makeOpaque(int x, int y, int width, int height) { | 400 void BitmapPlatformDeviceWin::makeOpaque(int x, int y, int width, int height) { |
| 401 processPixels<MakeOpaqueAlphaAdjuster>(x, y, width, height); | 401 processPixels<MakeOpaqueAlphaAdjuster>(x, y, width, height); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void BitmapPlatformDeviceWin::fixupAlphaBeforeCompositing() { | 404 // static |
| 405 const SkBitmap& bitmap = accessBitmap(true); | 405 void BitmapPlatformDeviceWin::fixupAlpha(SkBitmap& bitmap) { |
| 406 SkAutoLockPixels lock(bitmap); | 406 SkAutoLockPixels lock(bitmap); |
| 407 uint32_t* data = bitmap.getAddr32(0, 0); | 407 uint32_t* data = bitmap.getAddr32(0, 0); |
| 408 | 408 |
| 409 size_t words = bitmap.rowBytes() / sizeof(uint32_t) * bitmap.height(); | 409 size_t words = bitmap.rowBytes() / sizeof(uint32_t) * bitmap.height(); |
| 410 for (size_t i = 0; i < words; i++) { | 410 for (size_t i = 0; i < words; i++) { |
| 411 if (data[i] == kMagicTransparencyColor) | 411 if (data[i] == kMagicTransparencyColor) |
| 412 data[i] = 0; | 412 data[i] = 0; |
| 413 else | 413 else |
| 414 data[i] |= 0xFF000000; | 414 data[i] |= 0xFF000000; |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 void BitmapPlatformDeviceWin::fixupAlphaBeforeCompositing() { |
| 419 fixupAlpha(const_cast<SkBitmap&>(accessBitmap(true))); |
| 420 } |
| 421 |
| 418 // Returns the color value at the specified location. | 422 // Returns the color value at the specified location. |
| 419 SkColor BitmapPlatformDeviceWin::getColorAt(int x, int y) { | 423 SkColor BitmapPlatformDeviceWin::getColorAt(int x, int y) { |
| 420 const SkBitmap& bitmap = accessBitmap(false); | 424 const SkBitmap& bitmap = accessBitmap(false); |
| 421 SkAutoLockPixels lock(bitmap); | 425 SkAutoLockPixels lock(bitmap); |
| 422 uint32_t* data = bitmap.getAddr32(0, 0); | 426 uint32_t* data = bitmap.getAddr32(0, 0); |
| 423 return static_cast<SkColor>(data[x + y * width()]); | 427 return static_cast<SkColor>(data[x + y * width()]); |
| 424 } | 428 } |
| 425 | 429 |
| 426 void BitmapPlatformDeviceWin::onAccessBitmap(SkBitmap* bitmap) { | 430 void BitmapPlatformDeviceWin::onAccessBitmap(SkBitmap* bitmap) { |
| 427 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI | 431 // FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI |
| (...skipping 25 matching lines...) Expand all Loading... |
| 453 for (int j = 0; j < width; j++) { | 457 for (int j = 0; j < width; j++) { |
| 454 adjustor(data + j); | 458 adjustor(data + j); |
| 455 } | 459 } |
| 456 data += row_words; | 460 data += row_words; |
| 457 } | 461 } |
| 458 } | 462 } |
| 459 } | 463 } |
| 460 | 464 |
| 461 } // namespace skia | 465 } // namespace skia |
| 462 | 466 |
| OLD | NEW |