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 <string.h> | 7 #include <string.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 SkCanvas canvas(image_with_shadow); | 734 SkCanvas canvas(image_with_shadow); |
735 canvas.translate(SkIntToScalar(shadow_margin.left()), | 735 canvas.translate(SkIntToScalar(shadow_margin.left()), |
736 SkIntToScalar(shadow_margin.top())); | 736 SkIntToScalar(shadow_margin.top())); |
737 | 737 |
738 SkPaint paint; | 738 SkPaint paint; |
739 for (size_t i = 0; i < shadows.size(); ++i) { | 739 for (size_t i = 0; i < shadows.size(); ++i) { |
740 const gfx::ShadowValue& shadow = shadows[i]; | 740 const gfx::ShadowValue& shadow = shadows[i]; |
741 SkBitmap shadow_image = SkBitmapOperations::CreateColorMask(bitmap, | 741 SkBitmap shadow_image = SkBitmapOperations::CreateColorMask(bitmap, |
742 shadow.color()); | 742 shadow.color()); |
743 | 743 |
744 skia::RefPtr<SkBlurImageFilter> filter = | 744 skia::RefPtr<SkBlurImageFilter> filter = skia::AdoptRef( |
745 skia::AdoptRef(SkBlurImageFilter::Create( | 745 SkBlurImageFilter::Create(SkDoubleToScalar(shadow.blur() / 2), |
Alexei Svitkine (slow)
2015/05/19 15:12:04
It's not clear to me how this ensures that the sha
calamity
2015/05/20 04:26:51
Sorry, I should have explained better. At the begi
Alexei Svitkine (slow)
2015/05/20 20:47:42
Thanks for the explanation, that makes sense. Plea
calamity
2015/05/21 06:54:30
Done.
| |
746 SkDoubleToScalar(shadow.blur()), SkDoubleToScalar(shadow.blur()))); | 746 SkDoubleToScalar(shadow.blur() / 2))); |
Alexei Svitkine (slow)
2015/05/20 20:47:42
Nit: Since you use SkDoubleToScalar(shadow.blur()
calamity
2015/05/21 06:54:30
Done.
| |
747 paint.setImageFilter(filter.get()); | 747 paint.setImageFilter(filter.get()); |
748 | 748 |
749 canvas.saveLayer(0, &paint); | 749 canvas.saveLayer(0, &paint); |
750 canvas.drawBitmap(shadow_image, | 750 canvas.drawBitmap(shadow_image, |
751 SkIntToScalar(shadow.x()), | 751 SkIntToScalar(shadow.x()), |
752 SkIntToScalar(shadow.y())); | 752 SkIntToScalar(shadow.y())); |
753 canvas.restore(); | 753 canvas.restore(); |
754 } | 754 } |
755 | 755 |
756 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0)); | 756 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0)); |
(...skipping 27 matching lines...) Expand all Loading... | |
784 canvas.translate(SkFloatToScalar(result.width() * 0.5f), | 784 canvas.translate(SkFloatToScalar(result.width() * 0.5f), |
785 SkFloatToScalar(result.height() * 0.5f)); | 785 SkFloatToScalar(result.height() * 0.5f)); |
786 canvas.rotate(angle); | 786 canvas.rotate(angle); |
787 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), | 787 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), |
788 -SkFloatToScalar(source.height() * 0.5f)); | 788 -SkFloatToScalar(source.height() * 0.5f)); |
789 canvas.drawBitmap(source, 0, 0); | 789 canvas.drawBitmap(source, 0, 0); |
790 canvas.flush(); | 790 canvas.flush(); |
791 | 791 |
792 return result; | 792 return result; |
793 } | 793 } |
OLD | NEW |