Protecting changes to the SkPath iteration with an ifdef for Chromium.

Something is broken, and this will protect us while we sort it out.

Unreviewed.

git-svn-id: http://skia.googlecode.com/svn/trunk@2922 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
schenney@chromium.org 2011-12-21 20:43:13 +00:00
parent 21e0bc2045
commit b0af6dad94
2 changed files with 38 additions and 9 deletions

View File

@ -38,7 +38,7 @@ public:
~SkPath();
SkPath& operator=(const SkPath&);
friend bool operator==(const SkPath&, const SkPath&);
friend bool operator!=(const SkPath& a, const SkPath& b) {
return !(a == b);
@ -70,7 +70,7 @@ public:
/** Set the path's fill type. This is used to define how "inside" is
computed. The default value is kWinding_FillType.
@param ft The new fill type for this path
*/
void setFillType(FillType ft) {
@ -633,7 +633,7 @@ public:
/** Return the next verb in this iteration of the path. When all
segments have been visited, return kDone_Verb.
@param pts The points representing the current verb and/or segment
@return The verb for the current segment
*/
@ -643,12 +643,12 @@ public:
line was the result of a close() command (i.e. the end point is the
initial moveto for this contour). If next() returned a different
verb, this returns an undefined value.
@return If the last call to next() returned kLine_Verb, return true
if it was the result of an explicit close command.
*/
bool isCloseLine() const { return SkToBool(fCloseLine); }
/** Returns true if the current contour is closed (has a kClose_Verb)
@return true if the current contour is closed (has a kClose_Verb)
*/
@ -663,7 +663,7 @@ public:
SkBool8 fForceClose;
SkBool8 fNeedClose;
SkBool8 fCloseLine;
uint8_t fSegmentState;
SkBool8 fSegmentState;
bool cons_moveTo(SkPoint pts[1]);
Verb autoClose(SkPoint pts[2]);
@ -718,4 +718,3 @@ private:
};
#endif

View File

@ -410,8 +410,17 @@ void SkPath::moveTo(SkScalar x, SkScalar y) {
int vc = fVerbs.count();
SkPoint* pt;
#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
if (vc > 0 && fVerbs[vc - 1] == kMove_Verb) {
pt = &fPts[fPts.count() - 1];
} else {
pt = fPts.append();
*fVerbs.append() = kMove_Verb;
}
#else
pt = fPts.append();
*fVerbs.append() = kMove_Verb;
#endif
pt->set(x, y);
GEN_ID_INC;
@ -505,7 +514,9 @@ void SkPath::close() {
case kLine_Verb:
case kQuad_Verb:
case kCubic_Verb:
#ifndef SK_OLD_EMPTY_PATH_BEHAVIOR
case kMove_Verb:
#endif
*fVerbs.append() = kClose_Verb;
GEN_ID_INC;
break;
@ -1275,7 +1286,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
// Keep a record of this most recent move
lastMoveVerb = fVerbs;
lastMovePt = fPts;
lastPt = fPts[0];
lastPt = fPts[0];
fVerbs++;
fPts++;
break;
@ -1330,7 +1341,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
fVerbs++;
fPts += 3;
break;
default:
SkASSERT(false && "Should never see kDone_Verb");
}
@ -1338,11 +1349,17 @@ void SkPath::Iter::consumeDegenerateSegments() {
}
SkPath::Verb SkPath::Iter::next(SkPoint pts[4]) {
#ifndef SK_OLD_EMPTY_PATH_BEHAVIOR
this->consumeDegenerateSegments();
#endif
if (fVerbs == fVerbStop) {
// Close the curve if requested and if there is some curve to close
#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
if (fNeedClose) {
#else
if (fNeedClose && fSegmentState == kAfterPrimitive_SegmentState) {
#endif
if (kLine_Verb == this->autoClose(pts)) {
return kLine_Verb;
}
@ -1368,11 +1385,18 @@ SkPath::Verb SkPath::Iter::next(SkPoint pts[4]) {
if (fVerbs == fVerbStop) { // might be a trailing moveto
return kDone_Verb;
}
#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
fMoveTo = *srcPts;
#endif
if (pts) {
pts[0] = *srcPts;
}
srcPts += 1;
#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
fSegmentState = kAfterMove_SegmentState;
#else
fLastPt = fMoveTo;
#endif
fNeedClose = fForceClose;
break;
case kLine_Verb:
@ -1412,9 +1436,15 @@ SkPath::Verb SkPath::Iter::next(SkPoint pts[4]) {
fVerbs -= 1;
} else {
fNeedClose = false;
#ifndef SK_OLD_EMPTY_PATH_BEHAVIOR
fSegmentState = kAfterClose_SegmentState;
#endif
}
#ifdef SK_OLD_EMPTY_PATH_BEHAVIOR
fSegmentState = kAfterClose_SegmentState;
#else
fLastPt = fMoveTo;
#endif
break;
}
fPts = srcPts;