aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-31 18:52:51 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-31 18:52:51 +0000
commit35c03fbf101306e8e82141853de4c664cbafedbb (patch)
treeda6595ecf0d47244602f0198bed1ad982add6c63
parent07421a52d40083cdefc7ab5df6a90495a1d8e785 (diff)
Remove scaleToFit from DashPathEffect
BUG=skia: R=reed@google.com, bsalomon@google.com, scroggo@google.com Author: egdaniel@google.com Review URL: https://codereview.chromium.org/216493005 git-svn-id: http://skia.googlecode.com/svn/trunk@13999 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/DashBench.cpp2
-rw-r--r--gm/dashing.cpp2
-rw-r--r--include/effects/SkDashPathEffect.h8
-rw-r--r--src/effects/SkDashPathEffect.cpp32
-rw-r--r--tests/DrawPathTest.cpp2
5 files changed, 13 insertions, 33 deletions
diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp
index 365eee9841..d041828ba3 100644
--- a/bench/DashBench.cpp
+++ b/bench/DashBench.cpp
@@ -263,7 +263,7 @@ public:
fDoAA = doAA;
SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
- fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1, false));
+ fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1));
}
protected:
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index f690852fbd..595de5227a 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -202,7 +202,7 @@ protected:
SkScalar intervals[2] = { dashLength, dashLength };
- p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase, false))->unref();
+ p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
SkPoint pts[2];
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index a1c5482653..41f8f5a43e 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -37,8 +37,8 @@ public:
Note: only affects stroked paths.
*/
static SkDashPathEffect* Create(const SkScalar intervals[], int count,
- SkScalar phase, bool scaleToFit = false) {
- return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase, scaleToFit));
+ SkScalar phase) {
+ return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase));
}
virtual ~SkDashPathEffect();
@@ -60,8 +60,7 @@ protected:
#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
public:
#endif
- SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
- bool scaleToFit = false);
+ SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase);
private:
SkScalar* fIntervals;
@@ -70,7 +69,6 @@ private:
SkScalar fInitialDashLength;
int32_t fInitialDashIndex;
SkScalar fIntervalLength;
- bool fScaleToFit;
typedef SkPathEffect INHERITED;
};
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 58706c5b78..15276b684c 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -35,8 +35,7 @@ static SkScalar FindFirstInterval(const SkScalar intervals[], SkScalar phase,
}
SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count,
- SkScalar phase, bool scaleToFit)
- : fScaleToFit(scaleToFit) {
+ SkScalar phase) {
SkASSERT(intervals);
SkASSERT(count > 1 && SkAlign2(count) == count);
@@ -256,7 +255,6 @@ bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
bool addedSegment = false;
SkScalar length = meas.getLength();
int index = fInitialDashIndex;
- SkScalar scale = SK_Scalar1;
// Since the path length / dash length ratio may be arbitrarily large, we can exert
// significant memory pressure while attempting to build the filtered path. To avoid this,
@@ -273,20 +271,10 @@ bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
return false;
}
- if (fScaleToFit) {
- if (fIntervalLength >= length) {
- scale = SkScalarDiv(length, fIntervalLength);
- } else {
- SkScalar div = SkScalarDiv(length, fIntervalLength);
- int n = SkScalarFloorToInt(div);
- scale = SkScalarDiv(length, n * fIntervalLength);
- }
- }
-
// Using double precision to avoid looping indefinitely due to single precision rounding
// (for extreme path_length/dash_length ratios). See test_infinite_dash() unittest.
double distance = 0;
- double dlen = SkScalarMul(fInitialDashLength, scale);
+ double dlen = fInitialDashLength;
while (distance < length) {
SkASSERT(dlen >= 0);
@@ -318,13 +306,13 @@ bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
}
// fetch our next dlen
- dlen = SkScalarMul(intervals[index], scale);
+ dlen = intervals[index];
}
// extend if we ended on a segment and we need to join up with the (skipped) initial segment
if (meas.isClosed() && is_even(fInitialDashIndex) &&
fInitialDashLength > 0) {
- meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !addedSegment);
+ meas.getSegment(0, fInitialDashLength, dst, !addedSegment);
++segCount;
}
} while (meas.nextContour());
@@ -362,13 +350,6 @@ bool SkDashPathEffect::asPoints(PointData* results,
return false;
}
- // TODO: this next test could be eased up. The rescaling should not impact
- // the equality of the ons & offs. However, we would need to remove the
- // integer intervals restriction first
- if (fScaleToFit) {
- return false;
- }
-
SkPoint pts[2];
if (!src.isLine(pts)) {
@@ -538,7 +519,8 @@ void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeInt(fInitialDashIndex);
buffer.writeScalar(fInitialDashLength);
buffer.writeScalar(fIntervalLength);
- buffer.writeBool(fScaleToFit);
+ // Dummy write to stay compatible with old skps. Write will be removed in follow up patch.
+ buffer.writeBool(false);
buffer.writeScalarArray(fIntervals, fCount);
}
@@ -550,7 +532,7 @@ SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {
fInitialDashIndex = buffer.readInt();
fInitialDashLength = buffer.readScalar();
fIntervalLength = buffer.readScalar();
- fScaleToFit = buffer.readBool();
+ buffer.readBool(); // dummy read to stay compatible with old skps
fCount = buffer.getArrayCount();
size_t allocSize = sizeof(SkScalar) * fCount;
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index fafef02a52..dbafa40be2 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -204,7 +204,7 @@ static void test_crbug_124652() {
large values can "swamp" small ones.
*/
SkScalar intervals[2] = {837099584, 33450};
- SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10, false));
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10));
}
static void test_bigcubic() {