move intermediate patheffect classes inside src
authorMike Reed <reed@google.com>
Thu, 9 Mar 2017 12:51:09 +0000 (07:51 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 9 Mar 2017 14:46:11 +0000 (14:46 +0000)
BUG=skia:

Change-Id: I49d2079ff35c7d228839940a57ba29169cb5b310
Reviewed-on: https://skia-review.googlesource.com/9462
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>

include/core/SkPathEffect.h
src/core/SkPathEffect.cpp

index 62f8993..65adb33 100644 (file)
@@ -26,7 +26,21 @@ class SkStrokeRec;
 */
 class SK_API SkPathEffect : public SkFlattenable {
 public:
+    /**
+     *  Returns a patheffect that apples each effect (first and second) to the original path,
+     *  and returns a path with the sum of these.
+     *
+     *  result = first(path) + second(path)
+     *
+     */
     static sk_sp<SkPathEffect> MakeSum(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second);
+
+    /**
+     *  Returns a patheffect that applies the inner effect to the path, and then applies the
+     *  outer effect to the result of the inner's.
+     *
+     *  result = outer(inner(path))
+     */
     static sk_sp<SkPathEffect> MakeCompose(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner);
 
     /**
@@ -152,119 +166,4 @@ private:
     typedef SkFlattenable INHERITED;
 };
 
-#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_SUBCLASSES
-
-/** \class SkPairPathEffect
-
-    Common baseclass for Compose and Sum. This subclass manages two pathEffects,
-    including flattening them. It does nothing in filterPath, and is only useful
-    for managing the lifetimes of its two arguments.
-*/
-class SK_API SkPairPathEffect : public SkPathEffect {
-protected:
-    SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1);
-
-    void flatten(SkWriteBuffer&) const override;
-
-    // these are visible to our subclasses
-    sk_sp<SkPathEffect> fPE0;
-    sk_sp<SkPathEffect> fPE1;
-
-    SK_TO_STRING_OVERRIDE()
-
-private:
-    typedef SkPathEffect INHERITED;
-};
-
-/** \class SkComposePathEffect
-
-    This subclass of SkPathEffect composes its two arguments, to create
-    a compound pathEffect.
-*/
-class SK_API SkComposePathEffect : public SkPairPathEffect {
-public:
-    /** Construct a pathEffect whose effect is to apply first the inner pathEffect
-        and the the outer pathEffect (e.g. outer(inner(path)))
-        The reference counts for outer and inner are both incremented in the constructor,
-        and decremented in the destructor.
-    */
-    static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) {
-        if (!outer) {
-            return inner;
-        }
-        if (!inner) {
-            return outer;
-        }
-        return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner));
-    }
-
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
-    SK_TO_STRING_OVERRIDE()
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
-
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
-    bool exposedInAndroidJavaAPI() const override { return true; }
-#endif
-
-protected:
-    SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner)
-        : INHERITED(outer, inner) {}
-
-private:
-    // illegal
-    SkComposePathEffect(const SkComposePathEffect&);
-    SkComposePathEffect& operator=(const SkComposePathEffect&);
-    friend class SkPathEffect;
-
-    typedef SkPairPathEffect INHERITED;
-};
-
-/** \class SkSumPathEffect
-
-    This subclass of SkPathEffect applies two pathEffects, one after the other.
-    Its filterPath() returns true if either of the effects succeeded.
-*/
-class SK_API SkSumPathEffect : public SkPairPathEffect {
-public:
-    /** Construct a pathEffect whose effect is to apply two effects, in sequence.
-        (e.g. first(path) + second(path))
-        The reference counts for first and second are both incremented in the constructor,
-        and decremented in the destructor.
-    */
-    static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) {
-        if (!first) {
-            return second;
-        }
-        if (!second) {
-            return first;
-        }
-        return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second));
-    }
-
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
-    SK_TO_STRING_OVERRIDE()
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
-
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
-    bool exposedInAndroidJavaAPI() const override { return true; }
-#endif
-
-protected:
-    SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second)
-        : INHERITED(first, second) {}
-
-private:
-    // illegal
-    SkSumPathEffect(const SkSumPathEffect&);
-    SkSumPathEffect& operator=(const SkSumPathEffect&);
-    friend class SkPathEffect;
-
-    typedef SkPairPathEffect INHERITED;
-};
-#endif
-
 #endif
index 6f953c5..ec5ac3b 100644 (file)
@@ -27,8 +27,6 @@ SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-#ifndef SK_SUPPORT_LEGACY_PATHEFFECT_SUBCLASSES
-
 /** \class SkPairPathEffect
 
  Common baseclass for Compose and Sum. This subclass manages two pathEffects,
@@ -37,9 +35,17 @@ SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
  */
 class SK_API SkPairPathEffect : public SkPathEffect {
 protected:
-    SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1);
+    SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
+        : fPE0(std::move(pe0)), fPE1(std::move(pe1))
+    {
+        SkASSERT(fPE0.get());
+        SkASSERT(fPE1.get());
+    }
 
-    void flatten(SkWriteBuffer&) const override;
+    void flatten(SkWriteBuffer& buffer) const override {
+        buffer.writeFlattenable(fPE0.get());
+        buffer.writeFlattenable(fPE1.get());
+    }
 
     // these are visible to our subclasses
     sk_sp<SkPathEffect> fPE0;
@@ -51,6 +57,21 @@ private:
     typedef SkPathEffect INHERITED;
 };
 
+#ifndef SK_IGNORE_TO_STRING
+void SkPairPathEffect::toString(SkString* str) const {
+    str->appendf("first: ");
+    if (fPE0) {
+        fPE0->toString(str);
+    }
+    str->appendf(" second: ");
+    if (fPE1) {
+        fPE1->toString(str);
+    }
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
 /** \class SkComposePathEffect
 
  This subclass of SkPathEffect composes its two arguments, to create
@@ -73,8 +94,17 @@ public:
         return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner));
     }
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
+    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                    const SkRect* cullRect) const override {
+        SkPath          tmp;
+        const SkPath*   ptr = &src;
+
+        if (fPE1->filterPath(&tmp, src, rec, cullRect)) {
+            ptr = &tmp;
+        }
+        return fPE0->filterPath(dst, *ptr, rec, cullRect);
+    }
+    
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposePathEffect)
@@ -85,7 +115,7 @@ public:
 
 protected:
     SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner)
-    : INHERITED(outer, inner) {}
+        : INHERITED(outer, inner) {}
 
 private:
     // illegal
@@ -96,6 +126,22 @@ private:
     typedef SkPairPathEffect INHERITED;
 };
 
+sk_sp<SkFlattenable> SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
+    sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
+    sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
+    return SkComposePathEffect::Make(std::move(pe0), std::move(pe1));
+}
+
+#ifndef SK_IGNORE_TO_STRING
+void SkComposePathEffect::toString(SkString* str) const {
+    str->appendf("SkComposePathEffect: (");
+    this->INHERITED::toString(str);
+    str->appendf(")");
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
 /** \class SkSumPathEffect
 
  This subclass of SkPathEffect applies two pathEffects, one after the other.
@@ -118,8 +164,13 @@ public:
         return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second));
     }
 
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
+    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                    const SkRect* cullRect) const override {
+        // use bit-or so that we always call both, even if the first one succeeds
+        return fPE0->filterPath(dst, src, rec, cullRect) |
+               fPE1->filterPath(dst, src, rec, cullRect);
+    }
+    
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSumPathEffect)
@@ -140,65 +191,6 @@ private:
 
     typedef SkPairPathEffect INHERITED;
 };
-#endif
-
-SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
-    : fPE0(std::move(pe0)), fPE1(std::move(pe1))
-{
-    SkASSERT(fPE0.get());
-    SkASSERT(fPE1.get());
-}
-
-/*
-    Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
-*/
-void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
-    buffer.writeFlattenable(fPE0.get());
-    buffer.writeFlattenable(fPE1.get());
-}
-
-#ifndef SK_IGNORE_TO_STRING
-void SkPairPathEffect::toString(SkString* str) const {
-    str->appendf("first: ");
-    if (fPE0) {
-        fPE0->toString(str);
-    }
-    str->appendf(" second: ");
-    if (fPE1) {
-        fPE1->toString(str);
-    }
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-
-sk_sp<SkFlattenable> SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
-    sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
-    sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
-    return SkComposePathEffect::Make(std::move(pe0), std::move(pe1));
-}
-
-bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
-                             SkStrokeRec* rec, const SkRect* cullRect) const {
-    SkPath          tmp;
-    const SkPath*   ptr = &src;
-
-    if (fPE1->filterPath(&tmp, src, rec, cullRect)) {
-        ptr = &tmp;
-    }
-    return fPE0->filterPath(dst, *ptr, rec, cullRect);
-}
-
-
-#ifndef SK_IGNORE_TO_STRING
-void SkComposePathEffect::toString(SkString* str) const {
-    str->appendf("SkComposePathEffect: (");
-    this->INHERITED::toString(str);
-    str->appendf(")");
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
 
 sk_sp<SkFlattenable> SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
     sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
@@ -206,14 +198,6 @@ sk_sp<SkFlattenable> SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
     return SkSumPathEffect::Make(pe0, pe1);
 }
 
-bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                             SkStrokeRec* rec, const SkRect* cullRect) const {
-    // use bit-or so that we always call both, even if the first one succeeds
-    return fPE0->filterPath(dst, src, rec, cullRect) |
-           fPE1->filterPath(dst, src, rec, cullRect);
-}
-
-
 #ifndef SK_IGNORE_TO_STRING
 void SkSumPathEffect::toString(SkString* str) const {
     str->appendf("SkSumPathEffect: (");