add explicit clamping after chopping w/ t to ensure we're in the clip
git-svn-id: http://skia.googlecode.com/svn/trunk@430 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleLineClipper.cpp b/samplecode/SampleLineClipper.cpp
index ccf4281..9573810 100644
--- a/samplecode/SampleLineClipper.cpp
+++ b/samplecode/SampleLineClipper.cpp
@@ -34,6 +34,23 @@
SkASSERT(pts[i].fY >= clip.fTop);
SkASSERT(pts[i].fY <= clip.fBottom);
}
+
+ if (count > 1) {
+ // now check that we're monotonic in Y
+ if (pts[0].fY > pts[count - 1].fY) {
+ for (int i = 1; i < count; i++) {
+ SkASSERT(pts[i - 1].fY >= pts[i].fY);
+ }
+ } else if (pts[0].fY < pts[count - 1].fY) {
+ for (int i = 1; i < count; i++) {
+ SkASSERT(pts[i - 1].fY <= pts[i].fY);
+ }
+ } else {
+ for (int i = 1; i < count; i++) {
+ SkASSERT(pts[i - 1].fY == pts[i].fY);
+ }
+ }
+ }
}
static void line_clipper(const SkPoint src[], const SkRect& clip,
@@ -59,9 +76,11 @@
while ((verb = clipper.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case SkPath::kLine_Verb:
+ check_clipper(2, pts, clip);
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p0);
break;
case SkPath::kQuad_Verb:
+ check_clipper(3, pts, clip);
drawQuad(canvas, pts, p0);
break;
default:
@@ -84,6 +103,7 @@
};
class LineClipperView : public SkView {
+ int fCounter;
int fProcIndex;
SkRect fClip;
SkRandom fRand;
@@ -94,16 +114,18 @@
fPts[i].set(fRand.nextUScalar1() * 640,
fRand.nextUScalar1() * 480);
}
+ fCounter += 1;
}
public:
LineClipperView() {
+ fProcIndex = 1;
+ fCounter = 0;
+
int x = (640 - W)/2;
int y = (480 - H)/2;
fClip.set(x, y, x + W, y + H);
this->randPts();
-
- fProcIndex = 1;
}
protected: