Iter::next takes a bool (defaults to true for now) if we want to consume degenerates.
path-filling and stroking pass false, as they already are written to handle small segments (and it makes next() run 2x faster if you pass false). Review URL: https://codereview.appspot.com/6214049 git-svn-id: http://skia.googlecode.com/svn/trunk@3974 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
292aff6aca
commit
4a3b714d73
@ -684,9 +684,16 @@ public:
|
||||
segments have been visited, return kDone_Verb.
|
||||
|
||||
@param pts The points representing the current verb and/or segment
|
||||
@param doConsumeDegerates If true, first scan for segments that are
|
||||
deemed degenerate (too short) and skip those.
|
||||
@return The verb for the current segment
|
||||
*/
|
||||
Verb next(SkPoint pts[4]);
|
||||
Verb next(SkPoint pts[4], bool doConsumeDegerates = true) {
|
||||
if (doConsumeDegerates) {
|
||||
this->consumeDegenerateSegments();
|
||||
}
|
||||
return this->doNext(pts);
|
||||
}
|
||||
|
||||
/** If next() returns kLine_Verb, then this query returns true if the
|
||||
line was the result of a close() command (i.e. the end point is the
|
||||
@ -717,6 +724,7 @@ public:
|
||||
inline const SkPoint& cons_moveTo();
|
||||
Verb autoClose(SkPoint pts[2]);
|
||||
void consumeDegenerateSegments();
|
||||
Verb doNext(SkPoint pts[4]);
|
||||
};
|
||||
|
||||
/** Iterate through the verbs in the path, providing the associated points.
|
||||
|
@ -92,7 +92,7 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
|
||||
setShiftedClip(&clip, *iclip, shiftUp);
|
||||
SkEdgeClipper clipper;
|
||||
|
||||
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
|
||||
switch (verb) {
|
||||
case SkPath::kMove_Verb:
|
||||
case SkPath::kClose_Verb:
|
||||
@ -123,7 +123,7 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
|
||||
switch (verb) {
|
||||
case SkPath::kMove_Verb:
|
||||
case SkPath::kClose_Verb:
|
||||
|
@ -1265,7 +1265,7 @@ void SkPath::transform(const SkMatrix& matrix, SkPath* dst) const {
|
||||
SkPoint pts[4];
|
||||
SkPath::Verb verb;
|
||||
|
||||
while ((verb = iter.next(pts)) != kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != kDone_Verb) {
|
||||
switch (verb) {
|
||||
case kMove_Verb:
|
||||
tmp.moveTo(pts[0]);
|
||||
@ -1498,9 +1498,8 @@ void SkPath::Iter::consumeDegenerateSegments() {
|
||||
}
|
||||
}
|
||||
|
||||
SkPath::Verb SkPath::Iter::next(SkPoint ptsParam[4]) {
|
||||
SkPath::Verb SkPath::Iter::doNext(SkPoint ptsParam[4]) {
|
||||
SkASSERT(ptsParam);
|
||||
this->consumeDegenerateSegments();
|
||||
|
||||
if (fVerbs == fVerbStop) {
|
||||
// Close the curve if requested and if there is some curve to close
|
||||
@ -1689,7 +1688,7 @@ void SkPath::dump(bool forceClose, const char title[]) const {
|
||||
SkDebugf("path: forceClose=%s %s\n", forceClose ? "true" : "false",
|
||||
title ? title : "");
|
||||
|
||||
while ((verb = iter.next(pts)) != kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != kDone_Verb) {
|
||||
switch (verb) {
|
||||
case kMove_Verb:
|
||||
#ifdef SK_CAN_USE_FLOAT
|
||||
|
@ -243,7 +243,7 @@ static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot) {
|
||||
SkScalar top = SkIntToScalar(SK_MaxS16);
|
||||
SkScalar bot = SkIntToScalar(SK_MinS16);
|
||||
|
||||
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
|
||||
maxEdges += gPathVerbToMaxEdges[verb];
|
||||
|
||||
int lastIndex = gPathVerbToInitialLastIndex[verb];
|
||||
|
@ -303,7 +303,7 @@ static void hair_path(const SkPath& path, const SkRasterClip& rclip, SkBlitter*
|
||||
SkPoint pts[4];
|
||||
SkPath::Verb verb;
|
||||
|
||||
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
|
||||
switch (verb) {
|
||||
case SkPath::kLine_Verb:
|
||||
lineproc(pts[0], pts[1], clip, blitter);
|
||||
|
@ -591,7 +591,7 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const {
|
||||
SkPoint pts[4];
|
||||
SkPath::Verb verb, lastSegment = SkPath::kMove_Verb;
|
||||
|
||||
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
||||
while ((verb = iter.next(pts, false)) != SkPath::kDone_Verb) {
|
||||
switch (verb) {
|
||||
case SkPath::kMove_Verb:
|
||||
APPLY_PROC(proc, &pts[0], 1);
|
||||
|
@ -56,7 +56,7 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
|
||||
lastCorner.set(0, 0);
|
||||
|
||||
for (;;) {
|
||||
switch (verb = iter.next(pts)) {
|
||||
switch (verb = iter.next(pts, false)) {
|
||||
case SkPath::kMove_Verb:
|
||||
// close out the previous (open) contour
|
||||
if (SkPath::kLine_Verb == prevVerb) {
|
||||
|
@ -33,7 +33,7 @@ static void dumpVerbs(const SkPath& path, SkString* str) {
|
||||
SkPath::Iter iter(path, false);
|
||||
SkPoint pts[4];
|
||||
for (;;) {
|
||||
switch (iter.next(pts)) {
|
||||
switch (iter.next(pts, false)) {
|
||||
case SkPath::kMove_Verb:
|
||||
str->appendf(" M%g,%g", pts[0].fX, pts[0].fY);
|
||||
break;
|
||||
|
@ -220,7 +220,7 @@ void SkParsePath::ToSVGString(const SkPath& path, SkString* str) {
|
||||
SkPoint pts[4];
|
||||
|
||||
for (;;) {
|
||||
switch (iter.next(pts)) {
|
||||
switch (iter.next(pts, false)) {
|
||||
case SkPath::kMove_Verb:
|
||||
append_scalars(&stream, 'M', &pts[0].fX, 2);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user