aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-10 18:40:03 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-01-10 18:40:03 +0000
commitd1ab9320b09b922bd2f3b3d4f888c754fde5b58c (patch)
tree211edc69f0a303c94e33c833a6d87ef7fc222d9c
parentdf6bcb14126853b16bcca75401644cef6055d200 (diff)
restore (debugged) cheapComputeDirection
git-svn-id: http://skia.googlecode.com/svn/trunk@3000 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gm/strokefill.cpp83
-rw-r--r--src/core/SkPath.cpp8
-rw-r--r--src/core/SkStroke.cpp4
3 files changed, 42 insertions, 53 deletions
diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp
index 1fb5470dd1..274c4cdf83 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -10,48 +10,6 @@
#include "SkPath.h"
#include "SkTypeface.h"
-static void test10(SkCanvas* canvas) {
- SkPaint paint;
- const char text[] = "Hello"; // "Hello";
- const size_t len = sizeof(text) - 1;
- paint.setAntiAlias(true);
- paint.setTextSize(SkIntToScalar(100));
- SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro",
- SkTypeface::kNormal);
- paint.setTypeface(hira);
- SkScalar x = 180;
- SkScalar y = 88;
-
- canvas->drawText(text, len, x, y, paint);
- paint.setFakeBoldText(true);
- canvas->drawText(text, len, x, y + 100, paint);
- paint.setStyle(SkPaint::kStrokeAndFill_Style);
- paint.setStrokeWidth(5);
-
- SkPath path;
- path.setFillType(SkPath::kWinding_FillType);
- path.addCircle(x, y + 200, 50, SkPath::kCW_Direction);
- path.addCircle(x, y + 200, 40, SkPath::kCCW_Direction);
- canvas->drawPath(path, paint);
-
- SkPath path2;
- path2.setFillType(SkPath::kWinding_FillType);
- path2.addCircle(x + 120, y + 200, 50, SkPath::kCCW_Direction);
- path2.addCircle(x + 120, y + 200, 40, SkPath::kCW_Direction);
- canvas->drawPath(path2, paint);
-
- path2.reset();
- path2.addCircle(x + 240, y + 200, 50, SkPath::kCCW_Direction);
- canvas->drawPath(path2, paint);
- SkASSERT(path2.cheapIsDirection(SkPath::kCCW_Direction));
-
- path2.reset();
- SkASSERT(!path2.cheapComputeDirection(NULL));
- path2.addCircle(x + 360, y + 200, 50, SkPath::kCW_Direction);
- SkASSERT(path2.cheapIsDirection(SkPath::kCW_Direction));
- canvas->drawPath(path2, paint);
-}
-
static void test_path(SkCanvas* canvas, const SkPath& path) {
SkPaint paint;
paint.setAntiAlias(true);
@@ -120,8 +78,45 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) {
- // test10(canvas);
- // test_rev(canvas);
+ SkPaint paint;
+ const char text[] = "Hello"; // "Hello";
+ const size_t len = sizeof(text) - 1;
+ paint.setAntiAlias(true);
+ paint.setTextSize(SkIntToScalar(100));
+ SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro",
+ SkTypeface::kNormal);
+ paint.setTypeface(hira);
+ SkScalar x = 180;
+ SkScalar y = 88;
+
+ canvas->drawText(text, len, x, y, paint);
+ paint.setFakeBoldText(true);
+ canvas->drawText(text, len, x, y + 100, paint);
+ paint.setStyle(SkPaint::kStrokeAndFill_Style);
+ paint.setStrokeWidth(5);
+
+ SkPath path;
+ path.setFillType(SkPath::kWinding_FillType);
+ path.addCircle(x, y + 200, 50, SkPath::kCW_Direction);
+ path.addCircle(x, y + 200, 40, SkPath::kCCW_Direction);
+ canvas->drawPath(path, paint);
+
+ SkPath path2;
+ path2.setFillType(SkPath::kWinding_FillType);
+ path2.addCircle(x + 120, y + 200, 50, SkPath::kCCW_Direction);
+ path2.addCircle(x + 120, y + 200, 40, SkPath::kCW_Direction);
+ canvas->drawPath(path2, paint);
+
+ path2.reset();
+ path2.addCircle(x + 240, y + 200, 50, SkPath::kCCW_Direction);
+ canvas->drawPath(path2, paint);
+ SkASSERT(path2.cheapIsDirection(SkPath::kCCW_Direction));
+
+ path2.reset();
+ SkASSERT(!path2.cheapComputeDirection(NULL));
+ path2.addCircle(x + 360, y + 200, 50, SkPath::kCW_Direction);
+ SkASSERT(path2.cheapIsDirection(SkPath::kCW_Direction));
+ canvas->drawPath(path2, paint);
}
private:
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 960d2ab83a..50c7c59265 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1856,6 +1856,7 @@ private:
const uint8_t* fCurrVerb;
const uint8_t* fStopVerbs;
bool fDone;
+ SkDEBUGCODE(int fContourCounter;)
};
ContourIter::ContourIter(const SkTDArray<uint8_t>& verbs,
@@ -1866,6 +1867,7 @@ ContourIter::ContourIter(const SkTDArray<uint8_t>& verbs,
fCurrPt = pts.begin();
fCurrVerb = verbs.begin();
fCurrPtCount = 0;
+ SkDEBUGCODE(fContourCounter = 0;)
this->next();
}
@@ -1887,11 +1889,6 @@ void ContourIter::next() {
for (++verbs; verbs < fStopVerbs; ++verbs) {
switch (*verbs) {
case SkPath::kMove_Verb:
- if (ptCount > 1) {
- // back up to revisit this Move next time arround, unless
- // the prev verb was also Move, which we know if ptCount==1
- verbs -= 1;
- }
goto CONTOUR_END;
case SkPath::kLine_Verb:
ptCount += 1;
@@ -1909,6 +1906,7 @@ void ContourIter::next() {
CONTOUR_END:
fCurrPtCount = ptCount;
fCurrVerb = verbs;
+ SkDEBUGCODE(++fContourCounter;)
}
static SkScalar cross_prod(const SkPoint& p0, const SkPoint& p1, const SkPoint& p2) {
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index a7452beb99..1ec3a57dce 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -619,15 +619,11 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const {
#endif
if (fDoFill) {
-#if 0 // while I debug this
if (src.cheapIsDirection(SkPath::kCW_Direction)) {
dst->reverseAddPath(src);
} else {
dst->addPath(src);
}
-#else
- dst->addPath(src);
-#endif
} else {
// Seems like we can assume that a 2-point src would always result in
// a convex stroke, but testing has proved otherwise.