OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDashPathPriv.h" | 8 #include "SkDashPathPriv.h" |
9 #include "SkPathMeasure.h" | 9 #include "SkPathMeasure.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return false; | 112 return false; |
113 } | 113 } |
114 | 114 |
115 SkScalar minX = pts[0].fX; | 115 SkScalar minX = pts[0].fX; |
116 SkScalar maxX = pts[1].fX; | 116 SkScalar maxX = pts[1].fX; |
117 | 117 |
118 if (dx < 0) { | 118 if (dx < 0) { |
119 SkTSwap(minX, maxX); | 119 SkTSwap(minX, maxX); |
120 } | 120 } |
121 | 121 |
122 SkASSERT(minX < maxX); | 122 SkASSERT(minX <= maxX); |
123 if (maxX < bounds.fLeft || minX > bounds.fRight) { | 123 if (maxX < bounds.fLeft || minX > bounds.fRight) { |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 // Now we actually perform the chop, removing the excess to the left and | 127 // Now we actually perform the chop, removing the excess to the left and |
128 // right of the bounds (keeping our new line "in phase" with the dash, | 128 // right of the bounds (keeping our new line "in phase" with the dash, |
129 // hence the (mod intervalLength). | 129 // hence the (mod intervalLength). |
130 | 130 |
131 if (minX < bounds.fLeft) { | 131 if (minX < bounds.fLeft) { |
132 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, | 132 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 bool SkDashPath::FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec
, | 320 bool SkDashPath::FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec
, |
321 const SkRect* cullRect, const SkPathEffect::Dash
Info& info) { | 321 const SkRect* cullRect, const SkPathEffect::Dash
Info& info) { |
322 SkScalar initialDashLength = 0; | 322 SkScalar initialDashLength = 0; |
323 int32_t initialDashIndex = 0; | 323 int32_t initialDashIndex = 0; |
324 SkScalar intervalLength = 0; | 324 SkScalar intervalLength = 0; |
325 CalcDashParameters(info.fPhase, info.fIntervals, info.fCount, | 325 CalcDashParameters(info.fPhase, info.fIntervals, info.fCount, |
326 &initialDashLength, &initialDashIndex, &intervalLength); | 326 &initialDashLength, &initialDashIndex, &intervalLength); |
327 return FilterDashPath(dst, src, rec, cullRect, info.fIntervals, info.fCount,
initialDashLength, | 327 return FilterDashPath(dst, src, rec, cullRect, info.fIntervals, info.fCount,
initialDashLength, |
328 initialDashIndex, intervalLength); | 328 initialDashIndex, intervalLength); |
329 } | 329 } |
OLD | NEW |