diff options
author | reed <reed@google.com> | 2016-03-18 10:00:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 10:00:32 -0700 |
commit | 9fbee18f691a0afed1e38a851048ce06063505ed (patch) | |
tree | cd647dad4bae251bbbadea7fdd85b8a4b22cecc7 /include/core/SkPathEffect.h | |
parent | 1195260e22fc2e9c92b435491d4d19108a20df5c (diff) |
switch patheffects over to sk_sp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1813553005
Review URL: https://codereview.chromium.org/1813553005
Diffstat (limited to 'include/core/SkPathEffect.h')
-rw-r--r-- | include/core/SkPathEffect.h | 45 |
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 |