| 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 "SkGeometry.h" | 7 #include "SkGeometry.h" |
| 8 #include "SkOpEdgeBuilder.h" | 8 #include "SkOpEdgeBuilder.h" |
| 9 #include "SkReduceOrder.h" | 9 #include "SkReduceOrder.h" |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 return false; | 35 return false; |
| 36 } | 36 } |
| 37 complete(); | 37 complete(); |
| 38 if (fCurrentContour && !fCurrentContour->segments().count()) { | 38 if (fCurrentContour && !fCurrentContour->segments().count()) { |
| 39 fContours.pop_back(); | 39 fContours.pop_back(); |
| 40 } | 40 } |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SkOpEdgeBuilder::closeContour(const SkPoint& curveEnd, const SkPoint& curve
Start) { | 44 void SkOpEdgeBuilder::closeContour(const SkPoint& curveEnd, const SkPoint& curve
Start) { |
| 45 if ((!AlmostEqualUlps(curveEnd.fX, curveStart.fX) | 45 if (!SkDPoint::ApproximatelyEqual(curveEnd, curveStart)) { |
| 46 || !AlmostEqualUlps(curveEnd.fY, curveStart.fY))) { | |
| 47 fPathVerbs.push_back(SkPath::kLine_Verb); | 46 fPathVerbs.push_back(SkPath::kLine_Verb); |
| 48 fPathPts.push_back_n(1, &curveStart); | 47 fPathPts.push_back_n(1, &curveStart); |
| 49 } else { | 48 } else { |
| 50 if (curveEnd.fX != curveStart.fX || curveEnd.fY != curveStart.fY) { | 49 fPathPts[fPathPts.count() - 1] = curveStart; |
| 51 fPathPts[fPathPts.count() - 1] = curveStart; | |
| 52 } else { | |
| 53 fPathPts[fPathPts.count() - 1] = curveStart; | |
| 54 } | |
| 55 } | 50 } |
| 56 fPathVerbs.push_back(SkPath::kClose_Verb); | 51 fPathVerbs.push_back(SkPath::kClose_Verb); |
| 57 } | 52 } |
| 58 | 53 |
| 59 int SkOpEdgeBuilder::preFetch() { | 54 int SkOpEdgeBuilder::preFetch() { |
| 60 if (!fPath->isFinite()) { | 55 if (!fPath->isFinite()) { |
| 61 fUnparseable = true; | 56 fUnparseable = true; |
| 62 return 0; | 57 return 0; |
| 63 } | 58 } |
| 64 SkAutoConicToQuads quadder; | 59 SkAutoConicToQuads quadder; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 case SkPath::kMove_Verb: | 70 case SkPath::kMove_Verb: |
| 76 if (!fAllowOpenContours && lastCurve) { | 71 if (!fAllowOpenContours && lastCurve) { |
| 77 closeContour(curve[0], curveStart); | 72 closeContour(curve[0], curveStart); |
| 78 } | 73 } |
| 79 fPathVerbs.push_back(verb); | 74 fPathVerbs.push_back(verb); |
| 80 fPathPts.push_back(pts[0]); | 75 fPathPts.push_back(pts[0]); |
| 81 curveStart = curve[0] = pts[0]; | 76 curveStart = curve[0] = pts[0]; |
| 82 lastCurve = false; | 77 lastCurve = false; |
| 83 continue; | 78 continue; |
| 84 case SkPath::kLine_Verb: | 79 case SkPath::kLine_Verb: |
| 85 if (AlmostEqualUlps(curve[0].fX, pts[1].fX) | 80 if (SkDPoint::ApproximatelyEqual(curve[0], pts[1])) { |
| 86 && AlmostEqualUlps(curve[0].fY, pts[1].fY)) { | 81 uint8_t lastVerb = fPathVerbs.back(); |
| 87 if (fPathVerbs.back() != SkPath::kLine_Verb) { | 82 if (lastVerb != SkPath::kLine_Verb && lastVerb != SkPath::kM
ove_Verb) { |
| 88 fPathPts.back() = pts[1]; | 83 fPathPts.back() = pts[1]; |
| 89 } | 84 } |
| 90 continue; // skip degenerate points | 85 continue; // skip degenerate points |
| 91 } | 86 } |
| 92 break; | 87 break; |
| 93 case SkPath::kQuad_Verb: | 88 case SkPath::kQuad_Verb: |
| 94 curve[1] = pts[1]; | 89 curve[1] = pts[1]; |
| 95 curve[2] = pts[2]; | 90 curve[2] = pts[2]; |
| 96 verb = SkReduceOrder::Quad(curve, pts); | 91 verb = SkReduceOrder::Quad(curve, pts); |
| 97 if (verb == SkPath::kMove_Verb) { | 92 if (verb == SkPath::kMove_Verb) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return false; | 185 return false; |
| 191 } | 186 } |
| 192 pointsPtr += SkPathOpsVerbToPoints(verb); | 187 pointsPtr += SkPathOpsVerbToPoints(verb); |
| 193 SkASSERT(fCurrentContour); | 188 SkASSERT(fCurrentContour); |
| 194 } | 189 } |
| 195 if (fCurrentContour && !fAllowOpenContours && !close()) { | 190 if (fCurrentContour && !fAllowOpenContours && !close()) { |
| 196 return false; | 191 return false; |
| 197 } | 192 } |
| 198 return true; | 193 return true; |
| 199 } | 194 } |
| OLD | NEW |