Index: include/core/SkPathEffect.h |
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h |
index a77b9467e42fda294329976e6fddf6f2ce436fe6..405a504774b227c0559c8c9673287dd29b48daa1 100644 |
--- a/include/core/SkPathEffect.h |
+++ b/include/core/SkPathEffect.h |
@@ -18,6 +18,10 @@ |
class SkPath; |
class SkStrokeRec; |
+#ifndef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
+ #define SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
+#endif |
+ |
/** \class SkPathEffect |
SkPathEffect is the base class for objects in the SkPaint that affect |
@@ -154,16 +158,14 @@ private: |
for managing the lifetimes of its two arguments. |
*/ |
class SkPairPathEffect : public SkPathEffect { |
-public: |
- virtual ~SkPairPathEffect(); |
- |
protected: |
- SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1); |
+ SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1); |
void flatten(SkWriteBuffer&) const override; |
// these are visible to our subclasses |
- SkPathEffect* fPE0, *fPE1; |
+ sk_sp<SkPathEffect> fPE0; |
+ sk_sp<SkPathEffect> fPE1; |
SK_TO_STRING_OVERRIDE() |
@@ -183,16 +185,22 @@ public: |
The reference counts for outer and inner are both incremented in the constructor, |
and decremented in the destructor. |
*/ |
- static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { |
+ static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) { |
if (!outer) { |
- return SkSafeRef(inner); |
+ return inner; |
} |
if (!inner) { |
- return SkSafeRef(outer); |
+ return outer; |
} |
- return new SkComposePathEffect(outer, inner); |
+ return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner)); |
} |
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
+ static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { |
+ return Make(sk_ref_sp(outer), sk_ref_sp(inner)).release(); |
+ } |
+#endif |
+ |
virtual bool filterPath(SkPath* dst, const SkPath& src, |
SkStrokeRec*, const SkRect*) const override; |
@@ -204,7 +212,8 @@ public: |
#endif |
protected: |
- SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(outer, inner) {} |
+ SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) |
+ : INHERITED(outer, inner) {} |
private: |
// illegal |
@@ -226,16 +235,21 @@ public: |
The reference counts for first and second are both incremented in the constructor, |
and decremented in the destructor. |
*/ |
- static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
+ static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) { |
if (!first) { |
- return SkSafeRef(second); |
+ return second; |
} |
if (!second) { |
- return SkSafeRef(first); |
+ return first; |
} |
- return new SkSumPathEffect(first, second); |
+ return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second)); |
} |
+#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
+ static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { |
+ return Make(sk_ref_sp(first), sk_ref_sp(second)).release(); |
+ } |
+#endif |
virtual bool filterPath(SkPath* dst, const SkPath& src, |
SkStrokeRec*, const SkRect*) const override; |
@@ -247,7 +261,8 @@ public: |
#endif |
protected: |
- SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first, second) {} |
+ SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) |
+ : INHERITED(first, second) {} |
private: |
// illegal |