From 9da1ae3f35a6f25adf4f58ae2589129ceec6d11b Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Wed, 22 Jul 2009 17:06:15 +0000 Subject: [PATCH] fix NaN in path iterator fix case where cubic is big/degenerate, and never returns a valid edge git-svn-id: http://skia.googlecode.com/svn/trunk@280 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkEdge.cpp | 5 +++-- src/core/SkPath.cpp | 4 ++-- src/core/SkScan_Path.cpp | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp index f790d02a8b..92c78c8264 100644 --- a/src/core/SkEdge.cpp +++ b/src/core/SkEdge.cpp @@ -419,8 +419,9 @@ int SkCubicEdge::setCubic(const SkPoint pts[4], const SkIRect* clip, int shift) if (clip) { do { - for (;!this->updateCubic();) - ; + if (!this->updateCubic()) { + return 0; + } } while (!this->intersectsClip(*clip)); this->chopLineWithClip(*clip); return 1; diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 082d2e8667..794681c81e 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -986,8 +986,8 @@ SkPath::Verb SkPath::Iter::autoClose(SkPoint pts[2]) { // A special case: if both points are NaN, SkPoint::operation== returns // false, but the iterator expects that they are treated as the same. // (consider SkPoint is a 2-dimension float point). - if (SkScalarIsNaN(fLastPt.fX) && SkScalarIsNaN(fLastPt.fY) && - SkScalarIsNaN(fMoveTo.fX) && SkScalarIsNaN(fMoveTo.fY)) { + if (SkScalarIsNaN(fLastPt.fX) || SkScalarIsNaN(fLastPt.fY) || + SkScalarIsNaN(fMoveTo.fX) || SkScalarIsNaN(fMoveTo.fY)) { return kClose_Verb; } diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp index ead1b8573a..211259fcf7 100644 --- a/src/core/SkScan_Path.cpp +++ b/src/core/SkScan_Path.cpp @@ -479,10 +479,9 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte SkEdge headEdge, tailEdge, *last; SkASSERT(count <= maxCount); - if (count == 0) { + if (count < 2) { return; } - SkASSERT(count > 1); // this returns the first and last edge after they're sorted into a dlink list edge = sort_edges(list, count, &last);