diff options
author | 2009-03-03 02:56:05 +0000 | |
---|---|---|
committer | 2009-03-03 02:56:05 +0000 | |
commit | 5755a2a9ab531192fd26b523960ae0c551c7b24c (patch) | |
tree | 02fce0e904619400cdb41cca5eebf4904afba975 /src/core | |
parent | 4896f9e017db7ebc232a1b19c3abfb69f1ca465a (diff) |
Unit test and bug fixes for cubic Bezier clipping.
git-svn-id: http://skia.googlecode.com/svn/trunk@102 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkCubicClipper.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/SkCubicClipper.cpp b/src/core/SkCubicClipper.cpp index 9022ff30e6..d11eb9922f 100644 --- a/src/core/SkCubicClipper.cpp +++ b/src/core/SkCubicClipper.cpp @@ -122,39 +122,41 @@ bool SkCubicClipper::clipCubic(const SkPoint srcPts[4], SkPoint dst[4]) { bool reverse; // we need the data to be monotonically descending in Y - if (srcPts[0].fY > srcPts[2].fY) { + if (srcPts[0].fY > srcPts[3].fY) { dst[0] = srcPts[3]; dst[1] = srcPts[2]; dst[2] = srcPts[1]; dst[3] = srcPts[0]; reverse = true; } else { - memcpy(dst, srcPts, 3 * sizeof(SkPoint)); + memcpy(dst, srcPts, 4 * sizeof(SkPoint)); reverse = false; } // are we completely above or below const SkScalar ctop = fClip.fTop; const SkScalar cbot = fClip.fBottom; - if (dst[2].fY <= ctop || dst[0].fY >= cbot) { + if (dst[3].fY <= ctop || dst[0].fY >= cbot) { return false; } SkScalar t; - SkPoint tmp[5]; // for SkChopCubicAt + SkPoint tmp[7]; // for SkChopCubicAt // are we partially above if (dst[0].fY < ctop && chopMonoCubicAtY(dst, ctop, &t)) { SkChopCubicAt(dst, tmp, t); - dst[0] = tmp[2]; - dst[1] = tmp[3]; + dst[0] = tmp[3]; + dst[1] = tmp[4]; + dst[2] = tmp[5]; } // are we partially below - if (dst[2].fY > cbot && chopMonoCubicAtY(dst, cbot, &t)) { + if (dst[3].fY > cbot && chopMonoCubicAtY(dst, cbot, &t)) { SkChopCubicAt(dst, tmp, t); dst[1] = tmp[1]; dst[2] = tmp[2]; + dst[3] = tmp[3]; } if (reverse) { |