share code between arcTo and addArc, update dox

BUG=skia:

Review URL: https://codereview.chromium.org/863123005
This commit is contained in:
reed 2015-01-29 12:59:11 -08:00 committed by Commit bot
parent f9a40723f5
commit c778904a5b
2 changed files with 19 additions and 47 deletions

View File

@ -458,26 +458,23 @@ public:
void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
SkScalar x3, SkScalar y3);
/** Append the specified arc to the path as a new contour. If the start of
the path is different from the path's current last point, then an
automatic lineTo() is added to connect the current contour to the start
of the arc. However, if the path is empty, then we call moveTo() with
the first point of the arc. The sweep angle is treated mod 360.
/**
* Append the specified arc to the path. If the start of the arc is different from the path's
* current last point, then an automatic lineTo() is added to connect the current contour
* to the start of the arc. However, if the path is empty, then we call moveTo() with
* the first point of the arc. The sweep angle is treated mod 360.
*
* @param oval The bounding oval defining the shape and size of the arc
* @param startAngle Starting angle (in degrees) where the arc begins
* @param sweepAngle Sweep angle (in degrees) measured clockwise. This is treated mod 360.
* @param forceMoveTo If true, always begin a new contour with the arc
*/
void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);
@param oval The bounding oval defining the shape and size of the arc
@param startAngle Starting angle (in degrees) where the arc begins
@param sweepAngle Sweep angle (in degrees) measured clockwise. This is
treated mod 360.
@param forceMoveTo If true, always begin a new contour with the arc
*/
void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
bool forceMoveTo);
/** Append a line and arc to the current path. This is the same as the
PostScript call "arct".
*/
void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
SkScalar radius);
/**
* Append a line and arc to the current path. This is the same as the PostScript call "arct".
*/
void arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius);
/** Append a line and arc to the current path. This is the same as the
PostScript call "arct".

View File

@ -1340,41 +1340,16 @@ void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle
if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle) {
this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction);
return;
} else {
this->arcTo(oval, startAngle, sweepAngle, true);
}
SkPoint lonePt;
if (arc_is_lone_point(oval, startAngle, sweepAngle, &lonePt)) {
this->moveTo(lonePt);
return;
}
SkPoint pts[kSkBuildQuadArcStorage];
int count = build_arc_points(oval, startAngle, sweepAngle, pts);
SkDEBUGCODE(this->validate();)
SkASSERT(count & 1);
fLastMoveToIndex = fPathRef->countPoints();
SkPathRef::Editor ed(&fPathRef, 1+(count-1)/2, count);
ed.growForVerb(kMove_Verb)->set(pts[0].fX, pts[0].fY);
if (count > 1) {
SkPoint* p = ed.growForRepeatedVerb(kQuad_Verb, (count-1)/2);
memcpy(p, &pts[1], (count-1) * sizeof(SkPoint));
}
DIRTY_AFTER_EDIT;
SkDEBUGCODE(this->validate();)
}
/*
Need to handle the case when the angle is sharp, and our computed end-points
for the arc go behind pt1 and/or p2...
*/
void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
SkScalar radius) {
void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar radius) {
if (radius == 0) {
this->lineTo(x1, y1);
return;