restore (debugged) cheapComputeDirection
git-svn-id: http://skia.googlecode.com/svn/trunk@3000 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
df6bcb1412
commit
d1ab9320b0
@ -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:
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user