Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1054)

Unified Diff: src/utils/SkDashPath.cpp

Issue 1766243004: don't create zero length intervals (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/bug530095.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDashPath.cpp
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index cd01a9972b94695e1a4b27e1e819bb675fcb56e0..0d2783eba257b35bef23ca56e7d71c8a51094bfc 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -16,11 +16,12 @@ static inline int is_even(int x) {
static SkScalar find_first_interval(const SkScalar intervals[], SkScalar phase,
int32_t* index, int count) {
for (int i = 0; i < count; ++i) {
- if (phase > intervals[i]) {
- phase -= intervals[i];
+ SkScalar gap = intervals[i];
+ if (phase > gap || (phase == gap && gap)) {
+ phase -= gap;
} else {
*index = i;
- return intervals[i] - phase;
+ return gap - phase;
}
}
// If we get here, phase "appears" to be larger than our length. This
« no previous file with comments | « gm/bug530095.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698