aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/strokefill.cpp54
-rw-r--r--src/core/SkPath.cpp18
2 files changed, 5 insertions, 67 deletions
diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp
index 193e850580..a37af806f4 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -10,56 +10,6 @@
#include "SkPath.h"
#include "SkTypeface.h"
-static void test_path(SkCanvas* canvas, const SkPath& path) {
- SkPaint paint;
- paint.setAntiAlias(true);
- canvas->drawPath(path, paint);
-
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setColor(SK_ColorRED);
- canvas->drawPath(path, paint);
-}
-
-static void test_rev(SkCanvas* canvas, const SkPath& path) {
- test_path(canvas, path);
-
- SkPath rev;
- rev.reverseAddPath(path);
- canvas->save();
- canvas->translate(SkIntToScalar(150), 0);
- test_path(canvas, rev);
- canvas->restore();
-}
-
-static void test_rev(SkCanvas* canvas) {
- SkRect r = { 10, 10, 100, 60 };
-
- SkPath path;
-
- path.addRect(r); test_rev(canvas, path);
-
- canvas->translate(0, 100);
- path.offset(20, 20);
- path.addRect(r); test_rev(canvas, path);
-
- canvas->translate(0, 100);
- path.reset();
- path.moveTo(10, 10); path.lineTo(30, 30);
- path.addOval(r);
- r.offset(50, 20);
- path.addOval(r);
- test_rev(canvas, path);
-
- SkPaint paint;
- paint.setTextSize(SkIntToScalar(100));
- SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal);
- SkSafeUnref(paint.setTypeface(hira));
- path.reset();
- paint.getTextPath("e", 1, 50, 50, &path);
- canvas->translate(0, 100);
- test_rev(canvas, path);
-}
-
namespace skiagm {
class StrokeFillGM : public GM {
@@ -83,8 +33,8 @@ protected:
const size_t len = sizeof(text) - 1;
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(100));
- SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro",
- SkTypeface::kNormal);
+// SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal);
+ SkTypeface* hira = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal);
paint.setTypeface(hira);
SkScalar x = SkIntToScalar(180);
SkScalar y = SkIntToScalar(88);
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 50c7c59265..fc2ba42346 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1947,21 +1947,9 @@ bool SkPath::cheapComputeDirection(Direction* dir) const {
}
} else {
int i = find_max_y(pts, n);
- // loop around until we get a non-zero cross
- for (int j = 0; j < n; ++j) {
- if (i < n - 2) {
- cross = cross_prod(pts[i], pts[i + 1], pts[i + 2]);
- } else {
- cross = cross_prod(pts[i], pts[(i + 1) % n], pts[(i + 2) % n]);
- }
- if (cross) {
- break;
- }
- SkASSERT(i < n);
- if (++i == n) {
- i = 0;
- }
- }
+ // can't always say (i-1) % n, in case i-1 goes negative, so we
+ // use (i+n-1) % n instead
+ cross = cross_prod(pts[(i + n - 1) % n], pts[i], pts[(i + 1) % n]);
}
if (cross) {
if (dir) {