aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkLineClipper.cpp
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-11-23 20:10:41 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-11-23 20:10:41 +0000
commite522ca5d5f249bd51a00cb68bb051f811d0a9e85 (patch)
treef69fea7ec607bbc9cb88e1a154b5c37a3c626852 /src/core/SkLineClipper.cpp
parent90209caa686464cad70dd9d60b53c3d967eb57da (diff)
fix winding bug in lineclipper
expose path.dump() all the time UP arrow now toggles a grid of clip rects in sample app git-svn-id: http://skia.googlecode.com/svn/trunk@443 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkLineClipper.cpp')
-rw-r--r--src/core/SkLineClipper.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/SkLineClipper.cpp b/src/core/SkLineClipper.cpp
index 9164f7c13f..58bf6033a7 100644
--- a/src/core/SkLineClipper.cpp
+++ b/src/core/SkLineClipper.cpp
@@ -124,21 +124,26 @@ int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip,
SkPoint resultStorage[kMaxPoints];
SkPoint* result; // points to our results, either tmp or resultStorage
int lineCount = 1;
+ bool reverse;
if (pts[0].fX < pts[1].fX) {
index0 = 0;
index1 = 1;
+ reverse = false;
} else {
index0 = 1;
index1 = 0;
+ reverse = true;
}
-
+
if (tmp[index1].fX <= clip.fLeft) { // wholly to the left
tmp[0].fX = tmp[1].fX = clip.fLeft;
result = tmp;
+ reverse = false;
} else if (tmp[index0].fX >= clip.fRight) { // wholly to the right
tmp[0].fX = tmp[1].fX = clip.fRight;
result = tmp;
+ reverse = false;
} else {
result = resultStorage;
SkPoint* r = result;
@@ -164,7 +169,7 @@ int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip,
}
// Now copy the results into the caller's lines[] parameter
- if (0 == index1) {
+ if (reverse) {
// copy the pts in reverse order to maintain winding order
for (int i = 0; i <= lineCount; i++) {
lines[lineCount - i] = result[i];