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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 typedef SkFlattenable INHERITED; | 147 typedef SkFlattenable INHERITED; |
148 }; | 148 }; |
149 | 149 |
150 /** \class SkPairPathEffect | 150 /** \class SkPairPathEffect |
151 | 151 |
152 Common baseclass for Compose and Sum. This subclass manages two pathEffects, | 152 Common baseclass for Compose and Sum. This subclass manages two pathEffects, |
153 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 |
154 for managing the lifetimes of its two arguments. | 154 for managing the lifetimes of its two arguments. |
155 */ | 155 */ |
156 class SkPairPathEffect : public SkPathEffect { | 156 class SkPairPathEffect : public SkPathEffect { |
157 public: | |
158 virtual ~SkPairPathEffect(); | |
159 | |
160 protected: | 157 protected: |
161 SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); | 158 SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1); |
162 | 159 |
163 void flatten(SkWriteBuffer&) const override; | 160 void flatten(SkWriteBuffer&) const override; |
164 | 161 |
165 // these are visible to our subclasses | 162 // these are visible to our subclasses |
166 SkPathEffect* fPE0, *fPE1; | 163 sk_sp<SkPathEffect> fPE0; |
| 164 sk_sp<SkPathEffect> fPE1; |
167 | 165 |
168 SK_TO_STRING_OVERRIDE() | 166 SK_TO_STRING_OVERRIDE() |
169 | 167 |
170 private: | 168 private: |
171 typedef SkPathEffect INHERITED; | 169 typedef SkPathEffect INHERITED; |
172 }; | 170 }; |
173 | 171 |
174 /** \class SkComposePathEffect | 172 /** \class SkComposePathEffect |
175 | 173 |
176 This subclass of SkPathEffect composes its two arguments, to create | 174 This subclass of SkPathEffect composes its two arguments, to create |
177 a compound pathEffect. | 175 a compound pathEffect. |
178 */ | 176 */ |
179 class SkComposePathEffect : public SkPairPathEffect { | 177 class SkComposePathEffect : public SkPairPathEffect { |
180 public: | 178 public: |
181 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct | 179 /** Construct a pathEffect whose effect is to apply first the inner pathEffe
ct |
182 and the the outer pathEffect (e.g. outer(inner(path))) | 180 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, | 181 The reference counts for outer and inner are both incremented in the con
structor, |
184 and decremented in the destructor. | 182 and decremented in the destructor. |
185 */ | 183 */ |
186 static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { | 184 static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffec
t> inner) { |
187 if (!outer) { | 185 if (!outer) { |
188 return SkSafeRef(inner); | 186 return inner; |
189 } | 187 } |
190 if (!inner) { | 188 if (!inner) { |
191 return SkSafeRef(outer); | 189 return outer; |
192 } | 190 } |
193 return new SkComposePathEffect(outer, inner); | 191 return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner)); |
194 } | 192 } |
195 | 193 |
| 194 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
| 195 static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { |
| 196 return Make(sk_ref_sp(outer), sk_ref_sp(inner)).release(); |
| 197 } |
| 198 #endif |
| 199 |
196 virtual bool filterPath(SkPath* dst, const SkPath& src, | 200 virtual bool filterPath(SkPath* dst, const SkPath& src, |
197 SkStrokeRec*, const SkRect*) const override; | 201 SkStrokeRec*, const SkRect*) const override; |
198 | 202 |
199 SK_TO_STRING_OVERRIDE() | 203 SK_TO_STRING_OVERRIDE() |
200 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) | 204 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect) |
201 | 205 |
202 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 206 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
203 bool exposedInAndroidJavaAPI() const override { return true; } | 207 bool exposedInAndroidJavaAPI() const override { return true; } |
204 #endif | 208 #endif |
205 | 209 |
206 protected: | 210 protected: |
207 SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(ou
ter, inner) {} | 211 SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) |
| 212 : INHERITED(outer, inner) {} |
208 | 213 |
209 private: | 214 private: |
210 // illegal | 215 // illegal |
211 SkComposePathEffect(const SkComposePathEffect&); | 216 SkComposePathEffect(const SkComposePathEffect&); |
212 SkComposePathEffect& operator=(const SkComposePathEffect&); | 217 SkComposePathEffect& operator=(const SkComposePathEffect&); |
213 | 218 |
214 typedef SkPairPathEffect INHERITED; | 219 typedef SkPairPathEffect INHERITED; |
215 }; | 220 }; |
216 | 221 |
217 /** \class SkSumPathEffect | 222 /** \class SkSumPathEffect |
218 | 223 |
219 This subclass of SkPathEffect applies two pathEffects, one after the other. | 224 This subclass of SkPathEffect applies two pathEffects, one after the other. |
220 Its filterPath() returns true if either of the effects succeeded. | 225 Its filterPath() returns true if either of the effects succeeded. |
221 */ | 226 */ |
222 class SkSumPathEffect : public SkPairPathEffect { | 227 class SkSumPathEffect : public SkPairPathEffect { |
223 public: | 228 public: |
224 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. | 229 /** Construct a pathEffect whose effect is to apply two effects, in sequence
. |
225 (e.g. first(path) + second(path)) | 230 (e.g. first(path) + second(path)) |
226 The reference counts for first and second are both incremented in the co
nstructor, | 231 The reference counts for first and second are both incremented in the co
nstructor, |
227 and decremented in the destructor. | 232 and decremented in the destructor. |
228 */ | 233 */ |
229 static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { | 234 static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffec
t> second) { |
230 if (!first) { | 235 if (!first) { |
231 return SkSafeRef(second); | 236 return second; |
232 } | 237 } |
233 if (!second) { | 238 if (!second) { |
234 return SkSafeRef(first); | 239 return first; |
235 } | 240 } |
236 return new SkSumPathEffect(first, second); | 241 return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second)); |
237 } | 242 } |
238 | 243 |
| 244 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
| 245 static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
| 246 return Make(sk_ref_sp(first), sk_ref_sp(second)).release(); |
| 247 } |
| 248 #endif |
239 virtual bool filterPath(SkPath* dst, const SkPath& src, | 249 virtual bool filterPath(SkPath* dst, const SkPath& src, |
240 SkStrokeRec*, const SkRect*) const override; | 250 SkStrokeRec*, const SkRect*) const override; |
241 | 251 |
242 SK_TO_STRING_OVERRIDE() | 252 SK_TO_STRING_OVERRIDE() |
243 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) | 253 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect) |
244 | 254 |
245 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 255 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
246 bool exposedInAndroidJavaAPI() const override { return true; } | 256 bool exposedInAndroidJavaAPI() const override { return true; } |
247 #endif | 257 #endif |
248 | 258 |
249 protected: | 259 protected: |
250 SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first
, second) {} | 260 SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) |
| 261 : INHERITED(first, second) {} |
251 | 262 |
252 private: | 263 private: |
253 // illegal | 264 // illegal |
254 SkSumPathEffect(const SkSumPathEffect&); | 265 SkSumPathEffect(const SkSumPathEffect&); |
255 SkSumPathEffect& operator=(const SkSumPathEffect&); | 266 SkSumPathEffect& operator=(const SkSumPathEffect&); |
256 | 267 |
257 typedef SkPairPathEffect INHERITED; | 268 typedef SkPairPathEffect INHERITED; |
258 }; | 269 }; |
259 | 270 |
260 #endif | 271 #endif |
OLD | NEW |