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();
#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;
SkScalar fInitialDashLength;
int32_t fInitialDashIndex;
SkScalar fIntervalLength;
- bool fScaleToFit;
typedef SkPathEffect INHERITED;
};
}
SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count,
- SkScalar phase, bool scaleToFit)
- : fScaleToFit(scaleToFit) {
+ SkScalar phase) {
SkASSERT(intervals);
SkASSERT(count > 1 && SkAlign2(count) == count);
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,
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);
}
// 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());
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)) {
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);
}
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;