aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkPathEffect.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-18 10:00:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 10:00:32 -0700
commit9fbee18f691a0afed1e38a851048ce06063505ed (patch)
treecd647dad4bae251bbbadea7fdd85b8a4b22cecc7 /include/core/SkPathEffect.h
parent1195260e22fc2e9c92b435491d4d19108a20df5c (diff)
switch patheffects over to sk_sp
Diffstat (limited to 'include/core/SkPathEffect.h')
-rw-r--r--include/core/SkPathEffect.h45
1 files changed, 30 insertions, 15 deletions
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index a77b9467e4..405a504774 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