aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/effects/SkDashPathEffect.h39
-rw-r--r--src/effects/SkDashImpl.h48
-rw-r--r--src/effects/SkDashPathEffect.cpp29
-rw-r--r--src/ports/SkGlobalInitialization_default.cpp4
4 files changed, 64 insertions, 56 deletions
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index 13cbb4def0..f7429563ad 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -10,11 +10,7 @@
#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
index 0000000000..cf74529934
--- /dev/null
+++ b/src/effects/SkDashImpl.h
@@ -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
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index b1029e1eef..04f9e9e85f 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -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));
}
diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp
index a06a47ee2c..8052417ca8 100644
--- a/src/ports/SkGlobalInitialization_default.cpp
+++ b/src/ports/SkGlobalInitialization_default.cpp
@@ -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)