OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBlurDrawLooper.h" | 8 #include "SkBlurDrawLooper.h" |
9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma | 9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fSigma, flags); | 37 fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fSigma, flags); |
38 } else { | 38 } else { |
39 fBlur = nullptr; | 39 fBlur = nullptr; |
40 } | 40 } |
41 | 41 |
42 if (fBlurFlags & kOverrideColor_BlurFlag) { | 42 if (fBlurFlags & kOverrideColor_BlurFlag) { |
43 // Set alpha to 1 for the override since transparency will already | 43 // Set alpha to 1 for the override since transparency will already |
44 // be baked into the blurred mask. | 44 // be baked into the blurred mask. |
45 SkColor opaqueColor = SkColorSetA(fBlurColor, 255); | 45 SkColor opaqueColor = SkColorSetA(fBlurColor, 255); |
46 //The SrcIn xfer mode will multiply 'color' by the incoming alpha | 46 //The SrcIn xfer mode will multiply 'color' by the incoming alpha |
47 fColorFilter = SkColorFilter::MakeModeFilter(opaqueColor, SkXfermode::kS
rcIn_Mode); | 47 fColorFilter = SkColorFilter::CreateModeFilter(opaqueColor, |
| 48 SkXfermode::kSrcIn_Mode); |
48 } else { | 49 } else { |
49 fColorFilter = nullptr; | 50 fColorFilter = nullptr; |
50 } | 51 } |
51 } | 52 } |
52 | 53 |
53 void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, | 54 void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, |
54 SkColor color, uint32_t flags) { | 55 SkColor color, uint32_t flags) { |
55 fSigma = sigma; | 56 fSigma = sigma; |
56 fDx = dx; | 57 fDx = dx; |
57 fDy = dy; | 58 fDy = dy; |
(...skipping 15 matching lines...) Expand all Loading... |
73 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { | 74 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { |
74 buffer.writeColor(fBlurColor); | 75 buffer.writeColor(fBlurColor); |
75 buffer.writeScalar(fSigma); | 76 buffer.writeScalar(fSigma); |
76 buffer.writeScalar(fDx); | 77 buffer.writeScalar(fDx); |
77 buffer.writeScalar(fDy); | 78 buffer.writeScalar(fDy); |
78 buffer.write32(fBlurFlags); | 79 buffer.write32(fBlurFlags); |
79 } | 80 } |
80 | 81 |
81 SkBlurDrawLooper::~SkBlurDrawLooper() { | 82 SkBlurDrawLooper::~SkBlurDrawLooper() { |
82 SkSafeUnref(fBlur); | 83 SkSafeUnref(fBlur); |
| 84 SkSafeUnref(fColorFilter); |
83 } | 85 } |
84 | 86 |
85 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { | 87 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { |
86 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { | 88 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { |
87 return false; | 89 return false; |
88 } | 90 } |
89 | 91 |
90 if (rec) { | 92 if (rec) { |
91 rec->fSigma = fSigma; | 93 rec->fSigma = fSigma; |
92 rec->fColor = fBlurColor; | 94 rec->fColor = fBlurColor; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 &needsSeparator); | 175 &needsSeparator); |
174 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi
ghQuality", | 176 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi
ghQuality", |
175 &needsSeparator); | 177 &needsSeparator); |
176 } | 178 } |
177 str->append(")"); | 179 str->append(")"); |
178 | 180 |
179 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr
ing is added | 181 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr
ing is added |
180 // alternatively we could cache the radius in SkBlurDrawLooper and just add
it here | 182 // alternatively we could cache the radius in SkBlurDrawLooper and just add
it here |
181 } | 183 } |
182 #endif | 184 #endif |
OLD | NEW |