OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkEdgeBuilder.h" | 7 #include "SkEdgeBuilder.h" |
8 #include "SkPath.h" | 8 #include "SkPath.h" |
9 #include "SkEdge.h" | 9 #include "SkEdge.h" |
10 #include "SkAnalyticEdge.h" | 10 #include "SkAnalyticEdge.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return kPartial_Combine; | 56 return kPartial_Combine; |
57 } | 57 } |
58 last->fLastY = last->fFirstY - 1; | 58 last->fLastY = last->fFirstY - 1; |
59 last->fFirstY = edge->fFirstY; | 59 last->fFirstY = edge->fFirstY; |
60 last->fWinding = edge->fWinding; | 60 last->fWinding = edge->fWinding; |
61 return kPartial_Combine; | 61 return kPartial_Combine; |
62 } | 62 } |
63 return kNo_Combine; | 63 return kNo_Combine; |
64 } | 64 } |
65 | 65 |
| 66 static inline bool approximatelyEqual(SkFixed a, SkFixed b) { |
| 67 return SkAbs32(a - b) < 0x100; |
| 68 } |
| 69 |
66 SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical( | 70 SkEdgeBuilder::Combine SkEdgeBuilder::CombineVertical( |
67 const SkAnalyticEdge* edge, SkAnalyticEdge* last) { | 71 const SkAnalyticEdge* edge, SkAnalyticEdge* last) { |
68 SkASSERT(fAnalyticAA); | 72 SkASSERT(fAnalyticAA); |
69 if (last->fCurveCount || last->fDX || edge->fX != last->fX) { | 73 if (last->fCurveCount || last->fDX || edge->fX != last->fX) { |
70 return kNo_Combine; | 74 return kNo_Combine; |
71 } | 75 } |
72 if (edge->fWinding == last->fWinding) { | 76 if (edge->fWinding == last->fWinding) { |
73 if (edge->fLowerY == last->fUpperY) { | 77 if (edge->fLowerY == last->fUpperY) { |
74 last->fUpperY = edge->fUpperY; | 78 last->fUpperY = edge->fUpperY; |
75 last->fY = last->fUpperY; | 79 last->fY = last->fUpperY; |
76 return kPartial_Combine; | 80 return kPartial_Combine; |
77 } | 81 } |
78 if (edge->fUpperY == last->fLowerY) { | 82 if (approximatelyEqual(edge->fUpperY, last->fLowerY)) { |
79 last->fLowerY = edge->fLowerY; | 83 last->fLowerY = edge->fLowerY; |
80 return kPartial_Combine; | 84 return kPartial_Combine; |
81 } | 85 } |
82 return kNo_Combine; | 86 return kNo_Combine; |
83 } | 87 } |
84 if (edge->fUpperY == last->fUpperY) { | 88 if (approximatelyEqual(edge->fUpperY, last->fUpperY)) { |
85 if (edge->fLowerY == last->fLowerY) { | 89 if (approximatelyEqual(edge->fLowerY, last->fLowerY)) { |
86 return kTotal_Combine; | 90 return kTotal_Combine; |
87 } | 91 } |
88 if (edge->fLowerY < last->fLowerY) { | 92 if (edge->fLowerY < last->fLowerY) { |
89 last->fUpperY = edge->fLowerY; | 93 last->fUpperY = edge->fLowerY; |
90 last->fY = last->fUpperY; | 94 last->fY = last->fUpperY; |
91 return kPartial_Combine; | 95 return kPartial_Combine; |
92 } | 96 } |
93 last->fUpperY = last->fLowerY; | 97 last->fUpperY = last->fLowerY; |
94 last->fY = last->fUpperY; | 98 last->fY = last->fUpperY; |
95 last->fLowerY = edge->fLowerY; | 99 last->fLowerY = edge->fLowerY; |
96 last->fWinding = edge->fWinding; | 100 last->fWinding = edge->fWinding; |
97 return kPartial_Combine; | 101 return kPartial_Combine; |
98 } | 102 } |
99 if (edge->fLowerY == last->fLowerY) { | 103 if (approximatelyEqual(edge->fLowerY, last->fLowerY)) { |
100 if (edge->fUpperY > last->fUpperY) { | 104 if (edge->fUpperY > last->fUpperY) { |
101 last->fLowerY = edge->fUpperY; | 105 last->fLowerY = edge->fUpperY; |
102 return kPartial_Combine; | 106 return kPartial_Combine; |
103 } | 107 } |
104 last->fLowerY = last->fUpperY; | 108 last->fLowerY = last->fUpperY; |
105 last->fUpperY = edge->fUpperY; | 109 last->fUpperY = edge->fUpperY; |
106 last->fY = last->fUpperY; | 110 last->fY = last->fUpperY; |
107 last->fWinding = edge->fWinding; | 111 last->fWinding = edge->fWinding; |
108 return kPartial_Combine; | 112 return kPartial_Combine; |
109 } | 113 } |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 443 } |
440 default: | 444 default: |
441 SkDEBUGFAIL("unexpected verb"); | 445 SkDEBUGFAIL("unexpected verb"); |
442 break; | 446 break; |
443 } | 447 } |
444 } | 448 } |
445 } | 449 } |
446 fEdgeList = fList.begin(); | 450 fEdgeList = fList.begin(); |
447 return fList.count(); | 451 return fList.count(); |
448 } | 452 } |
OLD | NEW |