remove unused and untested SkPath::subdivide()

git-svn-id: http://skia.googlecode.com/svn/trunk@1732 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-06-28 11:57:12 +00:00
parent 3aaf6a0c87
commit 33114e0e59
2 changed files with 0 additions and 88 deletions

View File

@ -639,12 +639,6 @@ public:
void flatten(SkWriter32&) const;
void unflatten(SkReader32&);
/** Subdivide the path so that no segment is longer that dist.
If bendLines is true, then turn all line segments into curves.
If dst == null, then the original path itself is modified (not const!)
*/
void subdivide(SkScalar dist, bool bendLines, SkPath* dst = NULL) const;
#ifdef ANDROID
uint32_t getGenerationID() const;
#endif

View File

@ -1194,88 +1194,6 @@ SkPath::Verb SkPath::Iter::next(SkPoint pts[4]) {
///////////////////////////////////////////////////////////////////////////////
static bool exceeds_dist(const SkScalar p[], const SkScalar q[], SkScalar dist,
int count) {
SkASSERT(dist > 0);
for (int i = 0; i < count; i++) {
if (SkScalarAbs(p[i] - q[i]) > dist) {
return true;
}
}
return false;
}
static void subdivide_quad(SkPath* dst, const SkPoint pts[3], SkScalar dist,
int subLevel = 4) {
if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 4)) {
SkPoint tmp[5];
SkChopQuadAtHalf(pts, tmp);
subdivide_quad(dst, &tmp[0], dist, subLevel);
subdivide_quad(dst, &tmp[2], dist, subLevel);
} else {
dst->quadTo(pts[1], pts[2]);
}
}
static void subdivide_cubic(SkPath* dst, const SkPoint pts[4], SkScalar dist,
int subLevel = 4) {
if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 6)) {
SkPoint tmp[7];
SkChopCubicAtHalf(pts, tmp);
subdivide_cubic(dst, &tmp[0], dist, subLevel);
subdivide_cubic(dst, &tmp[3], dist, subLevel);
} else {
dst->cubicTo(pts[1], pts[2], pts[3]);
}
}
void SkPath::subdivide(SkScalar dist, bool bendLines, SkPath* dst) const {
SkPath tmpPath;
if (NULL == dst || this == dst) {
dst = &tmpPath;
}
SkPath::Iter iter(*this, false);
SkPoint pts[4];
for (;;) {
switch (iter.next(pts)) {
case SkPath::kMove_Verb:
dst->moveTo(pts[0]);
break;
case SkPath::kLine_Verb:
if (!bendLines) {
dst->lineTo(pts[1]);
break;
}
// construct a quad from the line
pts[2] = pts[1];
pts[1].set(SkScalarAve(pts[0].fX, pts[2].fX),
SkScalarAve(pts[0].fY, pts[2].fY));
// fall through to the quad case
case SkPath::kQuad_Verb:
subdivide_quad(dst, pts, dist);
break;
case SkPath::kCubic_Verb:
subdivide_cubic(dst, pts, dist);
break;
case SkPath::kClose_Verb:
dst->close();
break;
case SkPath::kDone_Verb:
goto DONE;
}
}
DONE:
if (&tmpPath == dst) { // i.e. the dst should be us
dst->swap(*(SkPath*)this);
}
}
///////////////////////////////////////////////////////////////////////
/*
Format in flattened buffer: [ptCount, verbCount, pts[], verbs[]]
*/