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 |
11 #define SkPathEffect_DEFINED | 11 #define SkPathEffect_DEFINED |
12 | 12 |
13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
14 #include "SkPath.h" | 14 #include "SkPath.h" |
15 #include "SkPoint.h" | 15 #include "SkPoint.h" |
16 #include "SkRect.h" | 16 #include "SkRect.h" |
17 | 17 |
18 class SkPath; | 18 class SkPath; |
19 class SkStrokeRec; | 19 class SkStrokeRec; |
20 | 20 |
21 #ifndef SK_SUPPORT_LEGACY_PATHEFFECT_PTR | |
22 #define SK_SUPPORT_LEGACY_PATHEFFECT_PTR | |
23 #endif | |
24 | |
25 /** \class SkPathEffect | 21 /** \class SkPathEffect |
26 | 22 |
27 SkPathEffect is the base class for objects in the SkPaint that affect | 23 SkPathEffect is the base class for objects in the SkPaint that affect |
28 the geometry of a drawing primitive before it is transformed by the | 24 the geometry of a drawing primitive before it is transformed by the |
29 canvas' matrix and drawn. | 25 canvas' matrix and drawn. |
30 | 26 |
31 Dashing is implemented as a subclass of SkPathEffect. | 27 Dashing is implemented as a subclass of SkPathEffect. |
32 */ | 28 */ |
33 class SK_API SkPathEffect : public SkFlattenable { | 29 class SK_API SkPathEffect : public SkFlattenable { |
34 public: | 30 public: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 typedef SkFlattenable INHERITED; | 147 typedef SkFlattenable INHERITED; |
152 }; | 148 }; |
153 | 149 |
154 /** \class SkPairPathEffect | 150 /** \class SkPairPathEffect |
155 | 151 |
156 Common baseclass for Compose and Sum. This subclass manages two pathEffects, | 152 Common baseclass for Compose and Sum. This subclass manages two pathEffects, |
157 including flattening them. It does nothing in filterPath, and is only useful | 153 including flattening them. It does nothing in filterPath, and is only useful |
158 for managing the lifetimes of its two arguments. | 154 for managing the lifetimes of its two arguments. |
159 */ | 155 */ |
160 class SkPairPathEffect : public SkPathEffect { | 156 class SkPairPathEffect : public SkPathEffect { |
| 157 public: |
| 158 virtual ~SkPairPathEffect(); |
| 159 |
161 protected: | 160 protected: |
162 SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1); | 161 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); |
163 | 162 |
164 void flatten(SkWriteBuffer&) const override; | 163 void flatten(SkWriteBuffer&) const override; |
165 | 164 |
166 // these are visible to our subclasses | 165 // these are visible to our subclasses |
167 sk_sp<SkPathEffect> fPE0; | 166 SkPathEffect* fPE0, *fPE1; |
168 sk_sp<SkPathEffect> fPE1; | |
169 | 167 |
170 SK_TO_STRING_OVERRIDE() | 168 SK_TO_STRING_OVERRIDE() |
171 | 169 |
172 private: | 170 private: |
173 typedef SkPathEffect INHERITED; | 171 typedef SkPathEffect INHERITED; |
174 }; | 172 }; |
175 | 173 |
176 /** \class SkComposePathEffect | 174 /** \class SkComposePathEffect |
177 | 175 |
178 This subclass of SkPathEffect composes its two arguments, to create | 176 This subclass of SkPathEffect composes its two arguments, to create |
179 a compound pathEffect. | 177 a compound pathEffect. |
180 */ | 178 */ |
181 class SkComposePathEffect : public SkPairPathEffect { | 179 class SkComposePathEffect : public SkPairPathEffect { |
182 public: | 180 public: |
183 /** 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 |
184 and the the outer pathEffect (e.g. outer(inner(path))) | 182 and the the outer pathEffect (e.g. outer(inner(path))) |
185 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, |
186 and decremented in the destructor. | 184 and decremented in the destructor. |
187 */ | 185 */ |
188 static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffec
t> inner) { | 186 static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { |
189 if (!outer) { | 187 if (!outer) { |
190 return inner; | 188 return SkSafeRef(inner); |
191 } | 189 } |
192 if (!inner) { | 190 if (!inner) { |
193 return outer; | 191 return SkSafeRef(outer); |
194 } | 192 } |
195 return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner)); | 193 return new SkComposePathEffect(outer, inner); |
196 } | 194 } |
197 | 195 |
198 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR | |
199 static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { | |
200 return Make(sk_ref_sp(outer), sk_ref_sp(inner)).release(); | |
201 } | |
202 #endif | |
203 | |
204 virtual bool filterPath(SkPath* dst, const SkPath& src, | 196 virtual bool filterPath(SkPath* dst, const SkPath& src, |
205 SkStrokeRec*, const SkRect*) const override; | 197 SkStrokeRec*, const SkRect*) const override; |
206 | 198 |
207 SK_TO_STRING_OVERRIDE() | 199 SK_TO_STRING_OVERRIDE() |
208 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) | 200 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) |
209 | 201 |
210 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 202 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
211 bool exposedInAndroidJavaAPI() const override { return true; } | 203 bool exposedInAndroidJavaAPI() const override { return true; } |
212 #endif | 204 #endif |
213 | 205 |
214 protected: | 206 protected: |
215 SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) | 207 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(ou
ter, inner) {} |
216 : INHERITED(outer, inner) {} | |
217 | 208 |
218 private: | 209 private: |
219 // illegal | 210 // illegal |
220 SkComposePathEffect(const SkComposePathEffect&); | 211 SkComposePathEffect(const SkComposePathEffect&); |
221 SkComposePathEffect& operator=(const SkComposePathEffect&); | 212 SkComposePathEffect& operator=(const SkComposePathEffect&); |
222 | 213 |
223 typedef SkPairPathEffect INHERITED; | 214 typedef SkPairPathEffect INHERITED; |
224 }; | 215 }; |
225 | 216 |
226 /** \class SkSumPathEffect | 217 /** \class SkSumPathEffect |
227 | 218 |
228 This subclass of SkPathEffect applies two pathEffects, one after the other. | 219 This subclass of SkPathEffect applies two pathEffects, one after the other. |
229 Its filterPath() returns true if either of the effects succeeded. | 220 Its filterPath() returns true if either of the effects succeeded. |
230 */ | 221 */ |
231 class SkSumPathEffect : public SkPairPathEffect { | 222 class SkSumPathEffect : public SkPairPathEffect { |
232 public: | 223 public: |
233 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. | 224 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. |
234 (e.g. first(path) + second(path)) | 225 (e.g. first(path) + second(path)) |
235 The reference counts for first and second are both incremented in the co
nstructor, | 226 The reference counts for first and second are both incremented in the co
nstructor, |
236 and decremented in the destructor. | 227 and decremented in the destructor. |
237 */ | 228 */ |
238 static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffec
t> second) { | 229 static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
239 if (!first) { | 230 if (!first) { |
240 return second; | 231 return SkSafeRef(second); |
241 } | 232 } |
242 if (!second) { | 233 if (!second) { |
243 return first; | 234 return SkSafeRef(first); |
244 } | 235 } |
245 return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second)); | 236 return new SkSumPathEffect(first, second); |
246 } | 237 } |
247 | 238 |
248 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR | |
249 static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { | |
250 return Make(sk_ref_sp(first), sk_ref_sp(second)).release(); | |
251 } | |
252 #endif | |
253 virtual bool filterPath(SkPath* dst, const SkPath& src, | 239 virtual bool filterPath(SkPath* dst, const SkPath& src, |
254 SkStrokeRec*, const SkRect*) const override; | 240 SkStrokeRec*, const SkRect*) const override; |
255 | 241 |
256 SK_TO_STRING_OVERRIDE() | 242 SK_TO_STRING_OVERRIDE() |
257 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) | 243 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) |
258 | 244 |
259 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 245 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
260 bool exposedInAndroidJavaAPI() const override { return true; } | 246 bool exposedInAndroidJavaAPI() const override { return true; } |
261 #endif | 247 #endif |
262 | 248 |
263 protected: | 249 protected: |
264 SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) | 250 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first
, second) {} |
265 : INHERITED(first, second) {} | |
266 | 251 |
267 private: | 252 private: |
268 // illegal | 253 // illegal |
269 SkSumPathEffect(const SkSumPathEffect&); | 254 SkSumPathEffect(const SkSumPathEffect&); |
270 SkSumPathEffect& operator=(const SkSumPathEffect&); | 255 SkSumPathEffect& operator=(const SkSumPathEffect&); |
271 | 256 |
272 typedef SkPairPathEffect INHERITED; | 257 typedef SkPairPathEffect INHERITED; |
273 }; | 258 }; |
274 | 259 |
275 #endif | 260 #endif |
OLD | NEW |