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 16 matching lines...) Expand all Loading... |
27 SkASSERT(fBlurFlags <= kAll_BlurFlag); | 27 SkASSERT(fBlurFlags <= kAll_BlurFlag); |
28 if (fSigma > 0) { | 28 if (fSigma > 0) { |
29 uint32_t flags = fBlurFlags & kIgnoreTransform_BlurFlag ? | 29 uint32_t flags = fBlurFlags & kIgnoreTransform_BlurFlag ? |
30 SkBlurMaskFilter::kIgnoreTransform_BlurFlag : | 30 SkBlurMaskFilter::kIgnoreTransform_BlurFlag : |
31 SkBlurMaskFilter::kNone_BlurFlag; | 31 SkBlurMaskFilter::kNone_BlurFlag; |
32 | 32 |
33 flags |= fBlurFlags & kHighQuality_BlurFlag ? | 33 flags |= fBlurFlags & kHighQuality_BlurFlag ? |
34 SkBlurMaskFilter::kHighQuality_BlurFlag : | 34 SkBlurMaskFilter::kHighQuality_BlurFlag : |
35 SkBlurMaskFilter::kNone_BlurFlag; | 35 SkBlurMaskFilter::kNone_BlurFlag; |
36 | 36 |
37 fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fSigma, flags); | 37 fBlur = SkBlurMaskFilter::Make(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::MakeModeFilter(opaqueColor, SkXfermode::kS
rcIn_Mode); |
(...skipping 23 matching lines...) Expand all Loading... |
71 } | 71 } |
72 | 72 |
73 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { | 73 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { |
74 buffer.writeColor(fBlurColor); | 74 buffer.writeColor(fBlurColor); |
75 buffer.writeScalar(fSigma); | 75 buffer.writeScalar(fSigma); |
76 buffer.writeScalar(fDx); | 76 buffer.writeScalar(fDx); |
77 buffer.writeScalar(fDy); | 77 buffer.writeScalar(fDy); |
78 buffer.write32(fBlurFlags); | 78 buffer.write32(fBlurFlags); |
79 } | 79 } |
80 | 80 |
81 SkBlurDrawLooper::~SkBlurDrawLooper() { | |
82 SkSafeUnref(fBlur); | |
83 } | |
84 | |
85 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { | 81 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { |
86 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { | 82 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { |
87 return false; | 83 return false; |
88 } | 84 } |
89 | 85 |
90 if (rec) { | 86 if (rec) { |
91 rec->fSigma = fSigma; | 87 rec->fSigma = fSigma; |
92 rec->fColor = fBlurColor; | 88 rec->fColor = fBlurColor; |
93 rec->fOffset.set(fDx, fDy); | 89 rec->fOffset.set(fDx, fDy); |
94 rec->fStyle = kNormal_SkBlurStyle; | 90 rec->fStyle = kNormal_SkBlurStyle; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 &needsSeparator); | 169 &needsSeparator); |
174 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi
ghQuality", | 170 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi
ghQuality", |
175 &needsSeparator); | 171 &needsSeparator); |
176 } | 172 } |
177 str->append(")"); | 173 str->append(")"); |
178 | 174 |
179 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr
ing is added | 175 // 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 | 176 // alternatively we could cache the radius in SkBlurDrawLooper and just add
it here |
181 } | 177 } |
182 #endif | 178 #endif |
OLD | NEW |