diff options
author | reed <reed@google.com> | 2016-03-18 11:22:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 11:22:57 -0700 |
commit | a439334b6e758d38501e225e2e5d0ab73e2fb6eb (patch) | |
tree | 8f2919ed2f6dcae5c4d5dbaaf608b5c6d248f2fc /include | |
parent | 0be9e806af72b3e029e691eef5c891c90d3fd320 (diff) |
Reland of "switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.org/1813553005/ )"
This reverts commit f28ad894272018fd2855e3f77ea1236ea0cce1c0.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1813123003
TBR=
Review URL: https://codereview.chromium.org/1813123003
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkPaint.h | 4 | ||||
-rw-r--r-- | include/core/SkPathEffect.h | 41 | ||||
-rw-r--r-- | include/core/SkTypes.h | 4 | ||||
-rw-r--r-- | include/effects/Sk1DPathEffect.h | 8 | ||||
-rw-r--r-- | include/effects/Sk2DPathEffect.h | 8 | ||||
-rw-r--r-- | include/effects/SkArcToPathEffect.h | 4 | ||||
-rw-r--r-- | include/effects/SkCornerPathEffect.h | 10 | ||||
-rw-r--r-- | include/effects/SkDashPathEffect.h | 8 | ||||
-rw-r--r-- | include/effects/SkDiscretePathEffect.h | 6 |
9 files changed, 67 insertions, 26 deletions
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 39ee1e0de1..8266eaaddc 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -561,8 +561,10 @@ public: paint @return effect */ - SkPathEffect* setPathEffect(SkPathEffect* effect); void setPathEffect(sk_sp<SkPathEffect>); +#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR + SkPathEffect* setPathEffect(SkPathEffect* effect); +#endif /** Get the paint's maskfilter object. <p /> diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index a77b9467e4..fd5957378a 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -154,16 +154,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 +181,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 +208,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 +231,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 +257,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 diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index d7a791163b..796180febd 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -15,6 +15,10 @@ #include <stddef.h> #include <stdint.h> +#ifndef SK_SUPPORT_LEGACY_PATHEFFECT_PTR + #define SK_SUPPORT_LEGACY_PATHEFFECT_PTR +#endif + #if defined(SK_ARM_HAS_NEON) #include <arm_neon.h> #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h index 03c6966943..d5315a8735 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -56,7 +56,13 @@ public: @param style how to transform path at each point (based on the current position and tangent) */ - static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style); + static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style); + +#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR + static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style s) { + return Make(path, advance, phase, s).release(); + } +#endif virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override; diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h index 73da83c4b9..823a6ad9d8 100644 --- a/include/effects/Sk2DPathEffect.h +++ b/include/effects/Sk2DPathEffect.h @@ -55,8 +55,8 @@ private: class SK_API SkLine2DPathEffect : public Sk2DPathEffect { public: - static SkPathEffect* Create(SkScalar width, const SkMatrix& matrix) { - return new SkLine2DPathEffect(width, matrix); + static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) { + return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix)); } virtual bool filterPath(SkPath* dst, const SkPath& src, @@ -84,8 +84,8 @@ public: * Stamp the specified path to fill the shape, using the matrix to define * the latice. */ - static SkPathEffect* Create(const SkMatrix& matrix, const SkPath& path) { - return new SkPath2DPathEffect(matrix, path); + static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path) { + return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path)); } SK_TO_STRING_OVERRIDE() diff --git a/include/effects/SkArcToPathEffect.h b/include/effects/SkArcToPathEffect.h index 4716ea125d..fcf4a3a5dc 100644 --- a/include/effects/SkArcToPathEffect.h +++ b/include/effects/SkArcToPathEffect.h @@ -15,11 +15,11 @@ public: /** radius must be > 0 to have an effect. It specifies the distance from each corner that should be "rounded". */ - static SkPathEffect* Create(SkScalar radius) { + static sk_sp<SkPathEffect> Make(SkScalar radius) { if (radius <= 0) { return NULL; } - return new SkArcToPathEffect(radius); + return sk_sp<SkPathEffect>(new SkArcToPathEffect(radius)); } bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h index 13095f0e6c..cf03463530 100644 --- a/include/effects/SkCornerPathEffect.h +++ b/include/effects/SkCornerPathEffect.h @@ -20,7 +20,15 @@ public: /** radius must be > 0 to have an effect. It specifies the distance from each corner that should be "rounded". */ - static SkPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); } + static sk_sp<SkPathEffect> Make(SkScalar radius) { + return sk_sp<SkPathEffect>(new SkCornerPathEffect(radius)); + } + +#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR + static SkPathEffect* Create(SkScalar radius) { + return Make(radius).release(); + } +#endif virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h index 08b0a4693f..ccb1a4e440 100644 --- a/include/effects/SkDashPathEffect.h +++ b/include/effects/SkDashPathEffect.h @@ -36,7 +36,13 @@ public: Note: only affects stroked paths. */ - static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase); + static sk_sp<SkPathEffect> Make(const SkScalar intervals[], int count, SkScalar phase); + +#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR + static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase) { + return Make(intervals, count, phase).release(); + } +#endif virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h index a49e2d89a7..78d4516ee6 100644 --- a/include/effects/SkDiscretePathEffect.h +++ b/include/effects/SkDiscretePathEffect.h @@ -29,9 +29,13 @@ public: they can pass in a different seedAssist to get a different set of path segments. */ + static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0); + +#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR static SkPathEffect* Create(SkScalar segLength, SkScalar deviation, uint32_t seedAssist = 0) { - return new SkDiscretePathEffect(segLength, deviation, seedAssist); + return Make(segLength, deviation, seedAssist).release(); } +#endif virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; |