aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPath.cpp
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-04 03:16:52 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-04 03:16:52 +0000
commitb16033a25b91f9e45d07bd4b955c8dbcfd23e8d5 (patch)
tree515af783f8b9390d55473a73103ae9963e485150 /src/core/SkPath.cpp
parent5d688fb273d300cd163e7848bf2f0cb38a81ba82 (diff)
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
Diffstat (limited to 'src/core/SkPath.cpp')
-rw-r--r--src/core/SkPath.cpp186
1 files changed, 93 insertions, 93 deletions
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);