| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
| 8 #include "SkPathOpsBounds.h" | 8 #include "SkPathOpsBounds.h" |
| 9 #include "SkPathOpsConic.h" | 9 #include "SkPathOpsConic.h" |
| 10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 SkTArray<double, true> ts; | 134 SkTArray<double, true> ts; |
| 135 toQuadraticTs(&cubic, precision, &ts); | 135 toQuadraticTs(&cubic, precision, &ts); |
| 136 if (ts.count() <= 0) { | 136 if (ts.count() <= 0) { |
| 137 SkDQuad quad = cubic.toQuad(); | 137 SkDQuad quad = cubic.toQuad(); |
| 138 quads.push_back(quad); | 138 quads.push_back(quad); |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 double tStart = 0; | 141 double tStart = 0; |
| 142 for (int i1 = 0; i1 <= ts.count(); ++i1) { | 142 for (int i1 = 0; i1 <= ts.count(); ++i1) { |
| 143 const double tEnd = i1 < ts.count() ? ts[i1] : 1; | 143 const double tEnd = i1 < ts.count() ? ts[i1] : 1; |
| 144 SkDRect bounds; |
| 145 bounds.setBounds(cubic); |
| 144 SkDCubic part = cubic.subDivide(tStart, tEnd); | 146 SkDCubic part = cubic.subDivide(tStart, tEnd); |
| 145 SkDQuad quad = part.toQuad(); | 147 SkDQuad quad = part.toQuad(); |
| 148 if (quad[1].fX < bounds.fLeft) { |
| 149 quad[1].fX = bounds.fLeft; |
| 150 } else if (quad[1].fX > bounds.fRight) { |
| 151 quad[1].fX = bounds.fRight; |
| 152 } |
| 153 if (quad[1].fY < bounds.fTop) { |
| 154 quad[1].fY = bounds.fTop; |
| 155 } else if (quad[1].fY > bounds.fBottom) { |
| 156 quad[1].fY = bounds.fBottom; |
| 157 } |
| 146 quads.push_back(quad); | 158 quads.push_back(quad); |
| 147 tStart = tEnd; | 159 tStart = tEnd; |
| 148 } | 160 } |
| 149 } | 161 } |
| 150 | 162 |
| 151 void CubicPathToQuads(const SkPath& cubicPath, SkPath* quadPath) { | 163 void CubicPathToQuads(const SkPath& cubicPath, SkPath* quadPath) { |
| 152 quadPath->reset(); | 164 quadPath->reset(); |
| 153 SkDCubic cubic; | 165 SkDCubic cubic; |
| 154 SkTArray<SkDQuad, true> quads; | 166 SkTArray<SkDQuad, true> quads; |
| 155 SkPath::RawIter iter(cubicPath); | 167 SkPath::RawIter iter(cubicPath); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 322 } |
| 311 return true; | 323 return true; |
| 312 } | 324 } |
| 313 | 325 |
| 314 bool ValidVector(const SkDVector& v) { | 326 bool ValidVector(const SkDVector& v) { |
| 315 if (SkDoubleIsNaN(v.fX)) { | 327 if (SkDoubleIsNaN(v.fX)) { |
| 316 return false; | 328 return false; |
| 317 } | 329 } |
| 318 return !SkDoubleIsNaN(v.fY); | 330 return !SkDoubleIsNaN(v.fY); |
| 319 } | 331 } |
| OLD | NEW |