| 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 "ui/gfx/skbitmap_operations.h" | 5 #include "ui/gfx/skbitmap_operations.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 SkBitmap SkBitmapOperations::CreateColorMask(const SkBitmap& bitmap, | 697 SkBitmap SkBitmapOperations::CreateColorMask(const SkBitmap& bitmap, |
| 698 SkColor c) { | 698 SkColor c) { |
| 699 DCHECK(bitmap.colorType() == kN32_SkColorType); | 699 DCHECK(bitmap.colorType() == kN32_SkColorType); |
| 700 | 700 |
| 701 SkBitmap color_mask; | 701 SkBitmap color_mask; |
| 702 color_mask.allocN32Pixels(bitmap.width(), bitmap.height()); | 702 color_mask.allocN32Pixels(bitmap.width(), bitmap.height()); |
| 703 color_mask.eraseARGB(0, 0, 0, 0); | 703 color_mask.eraseARGB(0, 0, 0, 0); |
| 704 | 704 |
| 705 SkCanvas canvas(color_mask); | 705 SkCanvas canvas(color_mask); |
| 706 | 706 |
| 707 skia::RefPtr<SkColorFilter> color_filter = skia::AdoptRef( | |
| 708 SkColorFilter::CreateModeFilter(c, SkXfermode::kSrcIn_Mode)); | |
| 709 SkPaint paint; | 707 SkPaint paint; |
| 710 paint.setColorFilter(color_filter.get()); | 708 paint.setColorFilter( |
| 709 SkColorFilter::MakeModeFilter(c, SkXfermode::kSrcIn_Mode)); |
| 711 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); | 710 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0), &paint); |
| 712 return color_mask; | 711 return color_mask; |
| 713 } | 712 } |
| 714 | 713 |
| 715 // static | 714 // static |
| 716 SkBitmap SkBitmapOperations::CreateDropShadow( | 715 SkBitmap SkBitmapOperations::CreateDropShadow( |
| 717 const SkBitmap& bitmap, | 716 const SkBitmap& bitmap, |
| 718 const gfx::ShadowValues& shadows) { | 717 const gfx::ShadowValues& shadows) { |
| 719 DCHECK(bitmap.colorType() == kN32_SkColorType); | 718 DCHECK(bitmap.colorType() == kN32_SkColorType); |
| 720 | 719 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 canvas.translate(SkFloatToScalar(result.width() * 0.5f), | 785 canvas.translate(SkFloatToScalar(result.width() * 0.5f), |
| 787 SkFloatToScalar(result.height() * 0.5f)); | 786 SkFloatToScalar(result.height() * 0.5f)); |
| 788 canvas.rotate(angle); | 787 canvas.rotate(angle); |
| 789 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), | 788 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), |
| 790 -SkFloatToScalar(source.height() * 0.5f)); | 789 -SkFloatToScalar(source.height() * 0.5f)); |
| 791 canvas.drawBitmap(source, 0, 0); | 790 canvas.drawBitmap(source, 0, 0); |
| 792 canvas.flush(); | 791 canvas.flush(); |
| 793 | 792 |
| 794 return result; | 793 return result; |
| 795 } | 794 } |
| OLD | NEW |