Change patheffect to take a (new) StrokeRec object, which encapsulates the fill
or stroke parameters for a path.
Today, the patheffect only sees if the caller was going to stroke or fill, and
if stroke, it just sees the width. With this change, the effect can see all of the
related parameters (e.g. cap/join/miter). No other change is intended at this
time.
After this change, I hope to use this additional data to allow SkDashPathEffect
to, at times, apply the stroke as part of its effect, which may be much more
efficient than first dashing, and then reading that and stroking it.
Most of these files changed just because of the new parameter to filterPath. The
key changes are in SkPathEffect.[h,cpp], SkPaint.cpp and SkScalerContext.cpp
Review URL: https://codereview.appspot.com/6250051
git-svn-id: http://skia.googlecode.com/svn/trunk@4048 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/Sk1DPathEffect.cpp b/src/effects/Sk1DPathEffect.cpp
index 09e8d13..10a9a84 100644
--- a/src/effects/Sk1DPathEffect.cpp
+++ b/src/effects/Sk1DPathEffect.cpp
@@ -10,7 +10,7 @@
#include "Sk1DPathEffect.h"
#include "SkPathMeasure.h"
-bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) {
+bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) {
SkPathMeasure meas(src, false);
do {
SkScalar length = meas.getLength();
@@ -67,10 +67,10 @@
}
bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src,
- SkScalar* width) {
+ SkStrokeRec* rec) {
if (fAdvance > 0) {
- *width = -1;
- return this->INHERITED::filterPath(dst, src, width);
+ rec->setFillStyle();
+ return this->INHERITED::filterPath(dst, src, rec);
}
return false;
}
diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp
index 8693157..3f8c998 100644
--- a/src/effects/Sk2DPathEffect.cpp
+++ b/src/effects/Sk2DPathEffect.cpp
@@ -31,7 +31,7 @@
fMatrixIsInvertible = mat.invert(&fInverse);
}
-bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width) {
+bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) {
if (!fMatrixIsInvertible) {
return false;
}
diff --git a/src/effects/SkCornerPathEffect.cpp b/src/effects/SkCornerPathEffect.cpp
index 4746231..749384d 100644
--- a/src/effects/SkCornerPathEffect.cpp
+++ b/src/effects/SkCornerPathEffect.cpp
@@ -36,7 +36,7 @@
}
bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
- SkScalar* width) {
+ SkStrokeRec*) {
if (fRadius == 0) {
return false;
}
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 0cc97b6..13c19af 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -81,9 +81,9 @@
}
bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
- SkScalar* width) {
+ SkStrokeRec* rec) {
// we do nothing if the src wants to be filled, or if our dashlength is 0
- if (*width < 0 || fInitialDashLength < 0) {
+ if (rec->isFillStyle() || fInitialDashLength < 0) {
return false;
}
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index 06b9d19..0536e56 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -26,8 +26,8 @@
}
bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
- SkScalar* width) {
- bool doFill = *width < 0;
+ SkStrokeRec* rec) {
+ bool doFill = rec->isFillStyle();
SkPathMeasure meas(src, doFill);
uint32_t seed = SkScalarRound(meas.getLength());