OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPathEffect_DEFINED | 10 #ifndef SkPathEffect_DEFINED |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 This subclass of SkPathEffect composes its two arguments, to create | 176 This subclass of SkPathEffect composes its two arguments, to create |
177 a compound pathEffect. | 177 a compound pathEffect. |
178 */ | 178 */ |
179 class SkComposePathEffect : public SkPairPathEffect { | 179 class SkComposePathEffect : public SkPairPathEffect { |
180 public: | 180 public: |
181 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct | 181 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct |
182 and the the outer pathEffect (e.g. outer(inner(path))) | 182 and the the outer pathEffect (e.g. outer(inner(path))) |
183 The reference counts for outer and inner are both incremented in the con
structor, | 183 The reference counts for outer and inner are both incremented in the con
structor, |
184 and decremented in the destructor. | 184 and decremented in the destructor. |
185 */ | 185 */ |
186 static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { | 186 static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner)
{ |
187 if (!outer) { | |
188 return SkSafeRef(inner); | |
189 } | |
190 if (!inner) { | |
191 return SkSafeRef(outer); | |
192 } | |
193 return new SkComposePathEffect(outer, inner); | 187 return new SkComposePathEffect(outer, inner); |
194 } | 188 } |
195 | 189 |
196 virtual bool filterPath(SkPath* dst, const SkPath& src, | 190 virtual bool filterPath(SkPath* dst, const SkPath& src, |
197 SkStrokeRec*, const SkRect*) const override; | 191 SkStrokeRec*, const SkRect*) const override; |
198 | 192 |
199 SK_TO_STRING_OVERRIDE() | 193 SK_TO_STRING_OVERRIDE() |
200 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) | 194 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) |
201 | 195 |
202 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 196 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
(...skipping 16 matching lines...) Expand all Loading... |
219 This subclass of SkPathEffect applies two pathEffects, one after the other. | 213 This subclass of SkPathEffect applies two pathEffects, one after the other. |
220 Its filterPath() returns true if either of the effects succeeded. | 214 Its filterPath() returns true if either of the effects succeeded. |
221 */ | 215 */ |
222 class SkSumPathEffect : public SkPairPathEffect { | 216 class SkSumPathEffect : public SkPairPathEffect { |
223 public: | 217 public: |
224 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. | 218 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. |
225 (e.g. first(path) + second(path)) | 219 (e.g. first(path) + second(path)) |
226 The reference counts for first and second are both incremented in the co
nstructor, | 220 The reference counts for first and second are both incremented in the co
nstructor, |
227 and decremented in the destructor. | 221 and decremented in the destructor. |
228 */ | 222 */ |
229 static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { | 223 static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
230 if (!first) { | |
231 return SkSafeRef(second); | |
232 } | |
233 if (!second) { | |
234 return SkSafeRef(first); | |
235 } | |
236 return new SkSumPathEffect(first, second); | 224 return new SkSumPathEffect(first, second); |
237 } | 225 } |
238 | 226 |
239 virtual bool filterPath(SkPath* dst, const SkPath& src, | 227 virtual bool filterPath(SkPath* dst, const SkPath& src, |
240 SkStrokeRec*, const SkRect*) const override; | 228 SkStrokeRec*, const SkRect*) const override; |
241 | 229 |
242 SK_TO_STRING_OVERRIDE() | 230 SK_TO_STRING_OVERRIDE() |
243 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) | 231 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) |
244 | 232 |
245 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 233 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
246 bool exposedInAndroidJavaAPI() const override { return true; } | 234 bool exposedInAndroidJavaAPI() const override { return true; } |
247 #endif | 235 #endif |
248 | 236 |
249 protected: | 237 protected: |
250 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first
, second) {} | 238 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first
, second) {} |
251 | 239 |
252 private: | 240 private: |
253 // illegal | 241 // illegal |
254 SkSumPathEffect(const SkSumPathEffect&); | 242 SkSumPathEffect(const SkSumPathEffect&); |
255 SkSumPathEffect& operator=(const SkSumPathEffect&); | 243 SkSumPathEffect& operator=(const SkSumPathEffect&); |
256 | 244 |
257 typedef SkPairPathEffect INHERITED; | 245 typedef SkPairPathEffect INHERITED; |
258 }; | 246 }; |
259 | 247 |
260 #endif | 248 #endif |
OLD | NEW |