From b16033a25b91f9e45d07bd4b955c8dbcfd23e8d5 Mon Sep 17 00:00:00 2001 From: "mike@reedtribe.org" Date: Fri, 4 Jan 2013 03:16:52 +0000 Subject: reorder internal files, in preparation for refactoring. no functional change. git-svn-id: http://skia.googlecode.com/svn/trunk@7009 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkPath.cpp | 186 ++++++++++++++++++++++++++-------------------------- 1 file changed, 93 insertions(+), 93 deletions(-) (limited to 'src/core/SkPath.cpp') diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 2f31082c56..88d7c43d6b 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -939,99 +939,6 @@ void SkPath::addPoly(const SkPoint pts[], int count, bool close) { SkDEBUGCODE(this->validate();) } -#define CUBIC_ARC_FACTOR ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3) - -void SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, - Direction dir) { - assert_known_direction(dir); - - SkScalar w = rect.width(); - SkScalar halfW = SkScalarHalf(w); - SkScalar h = rect.height(); - SkScalar halfH = SkScalarHalf(h); - - if (halfW <= 0 || halfH <= 0) { - return; - } - - bool skip_hori = rx >= halfW; - bool skip_vert = ry >= halfH; - - if (skip_hori && skip_vert) { - this->addOval(rect, dir); - return; - } - - fDirection = this->hasOnlyMoveTos() ? dir : kUnknown_Direction; - - SkAutoPathBoundsUpdate apbu(this, rect); - SkAutoDisableDirectionCheck(this); - - if (skip_hori) { - rx = halfW; - } else if (skip_vert) { - ry = halfH; - } - - SkScalar sx = SkScalarMul(rx, CUBIC_ARC_FACTOR); - SkScalar sy = SkScalarMul(ry, CUBIC_ARC_FACTOR); - - this->incReserve(17); - this->moveTo(rect.fRight - rx, rect.fTop); - if (dir == kCCW_Direction) { - if (!skip_hori) { - this->lineTo(rect.fLeft + rx, rect.fTop); // top - } - this->cubicTo(rect.fLeft + rx - sx, rect.fTop, - rect.fLeft, rect.fTop + ry - sy, - rect.fLeft, rect.fTop + ry); // top-left - if (!skip_vert) { - this->lineTo(rect.fLeft, rect.fBottom - ry); // left - } - this->cubicTo(rect.fLeft, rect.fBottom - ry + sy, - rect.fLeft + rx - sx, rect.fBottom, - rect.fLeft + rx, rect.fBottom); // bot-left - if (!skip_hori) { - this->lineTo(rect.fRight - rx, rect.fBottom); // bottom - } - this->cubicTo(rect.fRight - rx + sx, rect.fBottom, - rect.fRight, rect.fBottom - ry + sy, - rect.fRight, rect.fBottom - ry); // bot-right - if (!skip_vert) { - this->lineTo(rect.fRight, rect.fTop + ry); - } - this->cubicTo(rect.fRight, rect.fTop + ry - sy, - rect.fRight - rx + sx, rect.fTop, - rect.fRight - rx, rect.fTop); // top-right - } else { - this->cubicTo(rect.fRight - rx + sx, rect.fTop, - rect.fRight, rect.fTop + ry - sy, - rect.fRight, rect.fTop + ry); // top-right - if (!skip_vert) { - this->lineTo(rect.fRight, rect.fBottom - ry); - } - this->cubicTo(rect.fRight, rect.fBottom - ry + sy, - rect.fRight - rx + sx, rect.fBottom, - rect.fRight - rx, rect.fBottom); // bot-right - if (!skip_hori) { - this->lineTo(rect.fLeft + rx, rect.fBottom); // bottom - } - this->cubicTo(rect.fLeft + rx - sx, rect.fBottom, - rect.fLeft, rect.fBottom - ry + sy, - rect.fLeft, rect.fBottom - ry); // bot-left - if (!skip_vert) { - this->lineTo(rect.fLeft, rect.fTop + ry); // left - } - this->cubicTo(rect.fLeft, rect.fTop + ry - sy, - rect.fLeft + rx - sx, rect.fTop, - rect.fLeft + rx, rect.fTop); // top-left - if (!skip_hori) { - this->lineTo(rect.fRight - rx, rect.fTop); // top - } - } - this->close(); -} - static void add_corner_arc(SkPath* path, const SkRect& rect, SkScalar rx, SkScalar ry, int startAngle, SkPath::Direction dir, bool forceMoveTo) { @@ -1122,6 +1029,99 @@ bool SkPath::hasOnlyMoveTos() const { return true; } +#define CUBIC_ARC_FACTOR ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3) + +void SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, + Direction dir) { + assert_known_direction(dir); + + SkScalar w = rect.width(); + SkScalar halfW = SkScalarHalf(w); + SkScalar h = rect.height(); + SkScalar halfH = SkScalarHalf(h); + + if (halfW <= 0 || halfH <= 0) { + return; + } + + bool skip_hori = rx >= halfW; + bool skip_vert = ry >= halfH; + + if (skip_hori && skip_vert) { + this->addOval(rect, dir); + return; + } + + fDirection = this->hasOnlyMoveTos() ? dir : kUnknown_Direction; + + SkAutoPathBoundsUpdate apbu(this, rect); + SkAutoDisableDirectionCheck(this); + + if (skip_hori) { + rx = halfW; + } else if (skip_vert) { + ry = halfH; + } + + SkScalar sx = SkScalarMul(rx, CUBIC_ARC_FACTOR); + SkScalar sy = SkScalarMul(ry, CUBIC_ARC_FACTOR); + + this->incReserve(17); + this->moveTo(rect.fRight - rx, rect.fTop); + if (dir == kCCW_Direction) { + if (!skip_hori) { + this->lineTo(rect.fLeft + rx, rect.fTop); // top + } + this->cubicTo(rect.fLeft + rx - sx, rect.fTop, + rect.fLeft, rect.fTop + ry - sy, + rect.fLeft, rect.fTop + ry); // top-left + if (!skip_vert) { + this->lineTo(rect.fLeft, rect.fBottom - ry); // left + } + this->cubicTo(rect.fLeft, rect.fBottom - ry + sy, + rect.fLeft + rx - sx, rect.fBottom, + rect.fLeft + rx, rect.fBottom); // bot-left + if (!skip_hori) { + this->lineTo(rect.fRight - rx, rect.fBottom); // bottom + } + this->cubicTo(rect.fRight - rx + sx, rect.fBottom, + rect.fRight, rect.fBottom - ry + sy, + rect.fRight, rect.fBottom - ry); // bot-right + if (!skip_vert) { + this->lineTo(rect.fRight, rect.fTop + ry); + } + this->cubicTo(rect.fRight, rect.fTop + ry - sy, + rect.fRight - rx + sx, rect.fTop, + rect.fRight - rx, rect.fTop); // top-right + } else { + this->cubicTo(rect.fRight - rx + sx, rect.fTop, + rect.fRight, rect.fTop + ry - sy, + rect.fRight, rect.fTop + ry); // top-right + if (!skip_vert) { + this->lineTo(rect.fRight, rect.fBottom - ry); + } + this->cubicTo(rect.fRight, rect.fBottom - ry + sy, + rect.fRight - rx + sx, rect.fBottom, + rect.fRight - rx, rect.fBottom); // bot-right + if (!skip_hori) { + this->lineTo(rect.fLeft + rx, rect.fBottom); // bottom + } + this->cubicTo(rect.fLeft + rx - sx, rect.fBottom, + rect.fLeft, rect.fBottom - ry + sy, + rect.fLeft, rect.fBottom - ry); // bot-left + if (!skip_vert) { + this->lineTo(rect.fLeft, rect.fTop + ry); // left + } + this->cubicTo(rect.fLeft, rect.fTop + ry - sy, + rect.fLeft + rx - sx, rect.fTop, + rect.fLeft + rx, rect.fTop); // top-left + if (!skip_hori) { + this->lineTo(rect.fRight - rx, rect.fTop); // top + } + } + this->close(); +} + void SkPath::addOval(const SkRect& oval, Direction dir) { assert_known_direction(dir); -- cgit v1.2.3