OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkScanPriv.h" | 8 #include "SkScanPriv.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "SkEdge.h" | 10 #include "SkEdge.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 SkEdge* prev = edge->fPrev; | 54 SkEdge* prev = edge->fPrev; |
55 while (prev->fX > x) { | 55 while (prev->fX > x) { |
56 prev = prev->fPrev; | 56 prev = prev->fPrev; |
57 } | 57 } |
58 if (prev->fNext != edge) { | 58 if (prev->fNext != edge) { |
59 remove_edge(edge); | 59 remove_edge(edge); |
60 insert_edge_after(edge, prev); | 60 insert_edge_after(edge, prev); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 #ifndef SK_SUPPORT_LEGACY_INSERT_NEW_EDGES | |
65 // Start from the right side, searching backwards for the point to begin the new
edge list | 64 // Start from the right side, searching backwards for the point to begin the new
edge list |
66 // insertion, marching forwards from here. The implementation could have started
from the left | 65 // insertion, marching forwards from here. The implementation could have started
from the left |
67 // of the prior insertion, and search to the right, or with some additional cach
ing, binary | 66 // of the prior insertion, and search to the right, or with some additional cach
ing, binary |
68 // search the starting point. More work could be done to determine optimal new e
dge insertion. | 67 // search the starting point. More work could be done to determine optimal new e
dge insertion. |
69 static SkEdge* backward_insert_start(SkEdge* prev, SkFixed x) { | 68 static SkEdge* backward_insert_start(SkEdge* prev, SkFixed x) { |
70 while (prev->fX > x) { | 69 while (prev->fX > x) { |
71 prev = prev->fPrev; | 70 prev = prev->fPrev; |
72 } | 71 } |
73 return prev; | 72 return prev; |
74 } | 73 } |
75 #endif | |
76 | 74 |
77 static void insert_new_edges(SkEdge* newEdge, int curr_y) { | 75 static void insert_new_edges(SkEdge* newEdge, int curr_y) { |
78 #ifdef SK_SUPPORT_LEGACY_INSERT_NEW_EDGES | |
79 SkASSERT(newEdge->fFirstY >= curr_y); | |
80 | |
81 while (newEdge->fFirstY == curr_y) { | |
82 SkEdge* next = newEdge->fNext; | |
83 backward_insert_edge_based_on_x(newEdge SkPARAM(curr_y)); | |
84 newEdge = next; | |
85 } | |
86 #else | |
87 if (newEdge->fFirstY != curr_y) { | 76 if (newEdge->fFirstY != curr_y) { |
88 return; | 77 return; |
89 } | 78 } |
90 SkEdge* prev = newEdge->fPrev; | 79 SkEdge* prev = newEdge->fPrev; |
91 if (prev->fX <= newEdge->fX) { | 80 if (prev->fX <= newEdge->fX) { |
92 return; | 81 return; |
93 } | 82 } |
94 // find first x pos to insert | 83 // find first x pos to insert |
95 SkEdge* start = backward_insert_start(prev, newEdge->fX); | 84 SkEdge* start = backward_insert_start(prev, newEdge->fX); |
96 // insert the lot, fixing up the links as we go | 85 // insert the lot, fixing up the links as we go |
97 do { | 86 do { |
98 SkEdge* next = newEdge->fNext; | 87 SkEdge* next = newEdge->fNext; |
99 do { | 88 do { |
100 if (start->fNext == newEdge) { | 89 if (start->fNext == newEdge) { |
101 goto nextEdge; | 90 goto nextEdge; |
102 } | 91 } |
103 SkEdge* after = start->fNext; | 92 SkEdge* after = start->fNext; |
104 if (after->fX >= newEdge->fX) { | 93 if (after->fX >= newEdge->fX) { |
105 break; | 94 break; |
106 } | 95 } |
107 start = after; | 96 start = after; |
108 } while (true); | 97 } while (true); |
109 remove_edge(newEdge); | 98 remove_edge(newEdge); |
110 insert_edge_after(newEdge, start); | 99 insert_edge_after(newEdge, start); |
111 nextEdge: | 100 nextEdge: |
112 start = newEdge; | 101 start = newEdge; |
113 newEdge = next; | 102 newEdge = next; |
114 } while (newEdge->fFirstY == curr_y); | 103 } while (newEdge->fFirstY == curr_y); |
115 #endif | |
116 } | 104 } |
117 | 105 |
118 #ifdef SK_DEBUG | 106 #ifdef SK_DEBUG |
119 static void validate_edges_for_y(const SkEdge* edge, int curr_y) { | 107 static void validate_edges_for_y(const SkEdge* edge, int curr_y) { |
120 while (edge->fFirstY <= curr_y) { | 108 while (edge->fFirstY <= curr_y) { |
121 SkASSERT(edge->fPrev && edge->fNext); | 109 SkASSERT(edge->fPrev && edge->fNext); |
122 SkASSERT(edge->fPrev->fNext == edge); | 110 SkASSERT(edge->fPrev->fNext == edge); |
123 SkASSERT(edge->fNext->fPrev == edge); | 111 SkASSERT(edge->fNext->fPrev == edge); |
124 SkASSERT(edge->fFirstY <= edge->fLastY); | 112 SkASSERT(edge->fFirstY <= edge->fLastY); |
125 | 113 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 clipRgn = &wrap.getRgn(); | 768 clipRgn = &wrap.getRgn(); |
781 blitter = wrap.getBlitter(); | 769 blitter = wrap.getBlitter(); |
782 } | 770 } |
783 | 771 |
784 SkScanClipper clipper(blitter, clipRgn, ir); | 772 SkScanClipper clipper(blitter, clipRgn, ir); |
785 blitter = clipper.getBlitter(); | 773 blitter = clipper.getBlitter(); |
786 if (blitter) { | 774 if (blitter) { |
787 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); | 775 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); |
788 } | 776 } |
789 } | 777 } |
OLD | NEW |