OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDropShadowImageFilter.h" | 8 #include "SkDropShadowImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (nullptr == device.get()) { | 72 if (nullptr == device.get()) { |
73 return false; | 73 return false; |
74 } | 74 } |
75 SkCanvas canvas(device.get()); | 75 SkCanvas canvas(device.get()); |
76 | 76 |
77 SkVector sigma = SkVector::Make(fSigmaX, fSigmaY); | 77 SkVector sigma = SkVector::Make(fSigmaX, fSigmaY); |
78 ctx.ctm().mapVectors(&sigma, 1); | 78 ctx.ctm().mapVectors(&sigma, 1); |
79 sigma.fX = SkMaxScalar(0, sigma.fX); | 79 sigma.fX = SkMaxScalar(0, sigma.fX); |
80 sigma.fY = SkMaxScalar(0, sigma.fY); | 80 sigma.fY = SkMaxScalar(0, sigma.fY); |
81 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, s
igma.fY)); | 81 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, s
igma.fY)); |
82 SkAutoTUnref<SkColorFilter> colorFilter( | |
83 SkColorFilter::CreateModeFilter(fColor, SkXfermode::kSrcIn_Mode)); | |
84 SkPaint paint; | 82 SkPaint paint; |
85 paint.setImageFilter(blurFilter.get()); | 83 paint.setImageFilter(blurFilter.get()); |
86 paint.setColorFilter(colorFilter.get()); | 84 paint.setColorFilter(SkColorFilter::MakeModeFilter(fColor, SkXfermode::kSrcI
n_Mode)); |
87 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 85 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
88 SkVector offsetVec = SkVector::Make(fDx, fDy); | 86 SkVector offsetVec = SkVector::Make(fDx, fDy); |
89 ctx.ctm().mapVectors(&offsetVec, 1); | 87 ctx.ctm().mapVectors(&offsetVec, 1); |
90 canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft), | 88 canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft), |
91 SkIntToScalar(srcOffset.fY - bounds.fTop)); | 89 SkIntToScalar(srcOffset.fY - bounds.fTop)); |
92 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); | 90 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); |
93 if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { | 91 if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { |
94 canvas.drawBitmap(src, 0, 0); | 92 canvas.drawBitmap(src, 0, 0); |
95 } | 93 } |
96 *result = device->accessBitmap(false); | 94 *result = device->accessBitmap(false); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 "kDrawShadowAndForeground", "kDrawShadowOnly" | 146 "kDrawShadowAndForeground", "kDrawShadowOnly" |
149 }; | 147 }; |
150 | 148 |
151 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); | 149 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); |
152 | 150 |
153 str->appendf(" mode: %s", gModeStrings[fShadowMode]); | 151 str->appendf(" mode: %s", gModeStrings[fShadowMode]); |
154 | 152 |
155 str->append(")"); | 153 str->append(")"); |
156 } | 154 } |
157 #endif | 155 #endif |
OLD | NEW |