| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 SkScalar dy = pts[1].y() - pts[0].y(); | 108 SkScalar dy = pts[1].y() - pts[0].y(); |
| 109 | 109 |
| 110 // just do horizontal lines for now (lazy) | 110 // just do horizontal lines for now (lazy) |
| 111 if (dy) { | 111 if (dy) { |
| 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 (maxX < bounds.fLeft || minX > bounds.fRight) { | |
| 119 return false; | |
| 120 } | |
| 121 | |
| 122 if (dx < 0) { | 118 if (dx < 0) { |
| 123 SkTSwap(minX, maxX); | 119 SkTSwap(minX, maxX); |
| 124 } | 120 } |
| 125 | 121 |
| 122 SkASSERT(minX <= maxX); |
| 123 if (maxX < bounds.fLeft || minX > bounds.fRight) { |
| 124 return false; |
| 125 } |
| 126 |
| 126 // 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 |
| 127 // 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, |
| 128 // hence the (mod intervalLength). | 129 // hence the (mod intervalLength). |
| 129 | 130 |
| 130 if (minX < bounds.fLeft) { | 131 if (minX < bounds.fLeft) { |
| 131 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, | 132 minX = bounds.fLeft - SkScalarMod(bounds.fLeft - minX, |
| 132 intervalLength); | 133 intervalLength); |
| 133 } | 134 } |
| 134 if (maxX > bounds.fRight) { | 135 if (maxX > bounds.fRight) { |
| 135 maxX = bounds.fRight + SkScalarMod(maxX - bounds.fRight, | 136 maxX = bounds.fRight + SkScalarMod(maxX - bounds.fRight, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 bool SkDashPath::FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec
, | 320 bool SkDashPath::FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec* rec
, |
| 320 const SkRect* cullRect, const SkPathEffect::Dash
Info& info) { | 321 const SkRect* cullRect, const SkPathEffect::Dash
Info& info) { |
| 321 SkScalar initialDashLength = 0; | 322 SkScalar initialDashLength = 0; |
| 322 int32_t initialDashIndex = 0; | 323 int32_t initialDashIndex = 0; |
| 323 SkScalar intervalLength = 0; | 324 SkScalar intervalLength = 0; |
| 324 CalcDashParameters(info.fPhase, info.fIntervals, info.fCount, | 325 CalcDashParameters(info.fPhase, info.fIntervals, info.fCount, |
| 325 &initialDashLength, &initialDashIndex, &intervalLength); | 326 &initialDashLength, &initialDashIndex, &intervalLength); |
| 326 return FilterDashPath(dst, src, rec, cullRect, info.fIntervals, info.fCount,
initialDashLength, | 327 return FilterDashPath(dst, src, rec, cullRect, info.fIntervals, info.fCount,
initialDashLength, |
| 327 initialDashIndex, intervalLength); | 328 initialDashIndex, intervalLength); |
| 328 } | 329 } |
| OLD | NEW |