move all details for dashing into impl
authorMike Reed <reed@google.com>
Wed, 24 May 2017 03:00:14 +0000 (23:00 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 24 May 2017 03:22:23 +0000 (03:22 +0000)
Bug: skia:
Change-Id: I035603ad75158d9984cce7807bef6a668d9eb014
Reviewed-on: https://skia-review.googlesource.com/17793
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
include/effects/SkDashPathEffect.h
src/effects/SkDashImpl.h [new file with mode: 0644]
src/effects/SkDashPathEffect.cpp
src/ports/SkGlobalInitialization_default.cpp

index 13cbb4d..f742956 100644 (file)
 
 #include "SkPathEffect.h"
 
-/** \class SkDashPathEffect
-
-    SkDashPathEffect is a subclass of SkPathEffect that implements dashing
-*/
-class SK_API SkDashPathEffect : public SkPathEffect {
+class SK_API SkDashPathEffect {
 public:
     /** intervals: array containing an even number of entries (>=2), with
          the even indices specifying the length of "on" intervals, and the odd
@@ -37,39 +33,6 @@ public:
         Note: only affects stroked paths.
     */
     static sk_sp<SkPathEffect> Make(const SkScalar intervals[], int count, SkScalar phase);
-
-    virtual bool filterPath(SkPath* dst, const SkPath& src,
-                            SkStrokeRec*, const SkRect*) const override;
-
-    virtual bool asPoints(PointData* results, const SkPath& src,
-                          const SkStrokeRec&, const SkMatrix&,
-                          const SkRect*) const override;
-
-    DashType asADash(DashInfo* info) const override;
-
-    SK_TO_STRING_OVERRIDE()
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDashPathEffect)
-
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
-    bool exposedInAndroidJavaAPI() const override { return true; }
-#endif
-
-protected:
-    ~SkDashPathEffect() override;
-    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase);
-    void flatten(SkWriteBuffer&) const override;
-
-private:
-    SkScalar*   fIntervals;
-    int32_t     fCount;
-    SkScalar    fPhase;
-    // computed from phase
-
-    SkScalar    fInitialDashLength;
-    int32_t     fInitialDashIndex;
-    SkScalar    fIntervalLength;
-
-    typedef SkPathEffect INHERITED;
 };
 
 #endif
diff --git a/src/effects/SkDashImpl.h b/src/effects/SkDashImpl.h
new file mode 100644 (file)
index 0000000..cf74529
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDashImpl_DEFINED
+#define SkDashImpl_DEFINED
+
+#include "SkPathEffect.h"
+
+class SK_API SkDashImpl : public SkPathEffect {
+public:
+    SkDashImpl(const SkScalar intervals[], int count, SkScalar phase);
+
+    bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
+
+    bool asPoints(PointData* results, const SkPath& src, const SkStrokeRec&, const SkMatrix&,
+                  const SkRect*) const override;
+
+    DashType asADash(DashInfo* info) const override;
+
+    SK_TO_STRING_OVERRIDE()
+    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDashImpl)
+
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+    bool exposedInAndroidJavaAPI() const override { return true; }
+#endif
+
+protected:
+    ~SkDashImpl() override;
+    void flatten(SkWriteBuffer&) const override;
+
+private:
+    SkScalar*   fIntervals;
+    int32_t     fCount;
+    SkScalar    fPhase;
+    // computed from phase
+
+    SkScalar    fInitialDashLength;
+    int32_t     fInitialDashIndex;
+    SkScalar    fIntervalLength;
+
+    typedef SkPathEffect INHERITED;
+};
+
+#endif
index b1029e1..04f9e9e 100644 (file)
@@ -6,13 +6,13 @@
  */
 
 #include "SkDashPathEffect.h"
-
+#include "SkDashImpl.h"
 #include "SkDashPathPriv.h"
 #include "SkReadBuffer.h"
 #include "SkWriteBuffer.h"
 #include "SkStrokeRec.h"
 
-SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase)
+SkDashImpl::SkDashImpl(const SkScalar intervals[], int count, SkScalar phase)
         : fPhase(0)
         , fInitialDashLength(-1)
         , fInitialDashIndex(0)
@@ -31,12 +31,12 @@ SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScal
             &fInitialDashLength, &fInitialDashIndex, &fIntervalLength, &fPhase);
 }
 
-SkDashPathEffect::~SkDashPathEffect() {
+SkDashImpl::~SkDashImpl() {
     sk_free(fIntervals);
 }
 
-bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
-                              SkStrokeRec* rec, const SkRect* cullRect) const {
+bool SkDashImpl::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
+                            const SkRect* cullRect) const {
     return SkDashPath::InternalFilter(dst, src, rec, cullRect, fIntervals, fCount,
                                       fInitialDashLength, fInitialDashIndex, fIntervalLength);
 }
@@ -155,11 +155,8 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
 // we need to:
 //      allow kRound_Cap capping (could allow rotations in the matrix with this)
 //      allow paths to be returned
-bool SkDashPathEffect::asPoints(PointData* results,
-                                const SkPath& src,
-                                const SkStrokeRec& rec,
-                                const SkMatrix& matrix,
-                                const SkRect* cullRect) const {
+bool SkDashImpl::asPoints(PointData* results, const SkPath& src, const SkStrokeRec& rec,
+                          const SkMatrix& matrix, const SkRect* cullRect) const {
     // width < 0 -> fill && width == 0 -> hairline so requiring width > 0 rules both out
     if (0 >= rec.getWidth()) {
         return false;
@@ -351,7 +348,7 @@ bool SkDashPathEffect::asPoints(PointData* results,
     return true;
 }
 
-SkPathEffect::DashType SkDashPathEffect::asADash(DashInfo* info) const {
+SkPathEffect::DashType SkDashImpl::asADash(DashInfo* info) const {
     if (info) {
         if (info->fCount >= fCount && info->fIntervals) {
             memcpy(info->fIntervals, fIntervals, fCount * sizeof(SkScalar));
@@ -362,23 +359,23 @@ SkPathEffect::DashType SkDashPathEffect::asADash(DashInfo* info) const {
     return kDash_DashType;
 }
 
-void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const {
+void SkDashImpl::flatten(SkWriteBuffer& buffer) const {
     buffer.writeScalar(fPhase);
     buffer.writeScalarArray(fIntervals, fCount);
 }
 
-sk_sp<SkFlattenable> SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
+sk_sp<SkFlattenable> SkDashImpl::CreateProc(SkReadBuffer& buffer) {
     const SkScalar phase = buffer.readScalar();
     uint32_t count = buffer.getArrayCount();
     SkAutoSTArray<32, SkScalar> intervals(count);
     if (buffer.readScalarArray(intervals.get(), count)) {
-        return Make(intervals.get(), SkToInt(count), phase);
+        return SkDashPathEffect::Make(intervals.get(), SkToInt(count), phase);
     }
     return nullptr;
 }
 
 #ifndef SK_IGNORE_TO_STRING
-void SkDashPathEffect::toString(SkString* str) const {
+void SkDashImpl::toString(SkString* str) const {
     str->appendf("SkDashPathEffect: (");
     str->appendf("count: %d phase %.2f intervals: (", fCount, fPhase);
     for (int i = 0; i < fCount; ++i) {
@@ -397,5 +394,5 @@ sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count
     if (!SkDashPath::ValidDashPath(phase, intervals, count)) {
         return nullptr;
     }
-    return sk_sp<SkPathEffect>(new SkDashPathEffect(intervals, count, phase));
+    return sk_sp<SkPathEffect>(new SkDashImpl(intervals, count, phase));
 }
index a06a47e..8052417 100644 (file)
@@ -17,7 +17,7 @@
 #include "SkColorMatrixFilterRowMajor255.h"
 #include "SkComposeImageFilter.h"
 #include "SkCornerPathEffect.h"
-#include "SkDashPathEffect.h"
+#include "../../src/effects/SkDashImpl.h"
 #include "SkDiscretePathEffect.h"
 #include "SkDisplacementMapEffect.h"
 #include "SkDropShadowImageFilter.h"
@@ -97,7 +97,7 @@ void SkFlattenable::PrivateInitializer::InitEffects() {
     // PathEffect
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArcToPathEffect)
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect)
-    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect)
+    SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashImpl)
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect)
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect)
     SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLine2DPathEffect)