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 | |
66 // 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 | |
68 // 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) { | |
70 while (prev->fX > x) { | |
71 prev = prev->fPrev; | |
72 } | |
73 return prev; | |
74 } | |
75 #endif | |
76 | |
77 static void insert_new_edges(SkEdge* newEdge, int curr_y) { | 64 static void insert_new_edges(SkEdge* newEdge, int curr_y) { |
78 #ifdef SK_SUPPORT_LEGACY_INSERT_NEW_EDGES | |
79 SkASSERT(newEdge->fFirstY >= curr_y); | 65 SkASSERT(newEdge->fFirstY >= curr_y); |
80 | 66 |
81 while (newEdge->fFirstY == curr_y) { | 67 while (newEdge->fFirstY == curr_y) { |
82 SkEdge* next = newEdge->fNext; | 68 SkEdge* next = newEdge->fNext; |
83 backward_insert_edge_based_on_x(newEdge SkPARAM(curr_y)); | 69 backward_insert_edge_based_on_x(newEdge SkPARAM(curr_y)); |
84 newEdge = next; | 70 newEdge = next; |
85 } | 71 } |
86 } | 72 } |
87 #else | |
88 if (newEdge->fFirstY != curr_y) { | |
89 return; | |
90 } | |
91 SkEdge* prev = newEdge->fPrev; | |
92 if (prev->fX <= newEdge->fX) { | |
93 return; | |
94 } | |
95 // find first x pos to insert | |
96 SkEdge* start = backward_insert_start(prev, newEdge->fX); | |
97 // insert the lot, fixing up the links as we go | |
98 do { | |
99 SkEdge* next = newEdge->fNext; | |
100 do { | |
101 if (start->fNext == newEdge) { | |
102 goto nextEdge; | |
103 } | |
104 SkEdge* after = start->fNext; | |
105 if (after->fX >= newEdge->fX) { | |
106 break; | |
107 } | |
108 start = after; | |
109 } while (true); | |
110 remove_edge(newEdge); | |
111 insert_edge_after(newEdge, start); | |
112 nextEdge: | |
113 start = newEdge; | |
114 newEdge = next; | |
115 } while (newEdge->fFirstY == curr_y); | |
116 #endif | |
117 } | |
118 | 73 |
119 #ifdef SK_DEBUG | 74 #ifdef SK_DEBUG |
120 static void validate_edges_for_y(const SkEdge* edge, int curr_y) { | 75 static void validate_edges_for_y(const SkEdge* edge, int curr_y) { |
121 while (edge->fFirstY <= curr_y) { | 76 while (edge->fFirstY <= curr_y) { |
122 SkASSERT(edge->fPrev && edge->fNext); | 77 SkASSERT(edge->fPrev && edge->fNext); |
123 SkASSERT(edge->fPrev->fNext == edge); | 78 SkASSERT(edge->fPrev->fNext == edge); |
124 SkASSERT(edge->fNext->fPrev == edge); | 79 SkASSERT(edge->fNext->fPrev == edge); |
125 SkASSERT(edge->fFirstY <= edge->fLastY); | 80 SkASSERT(edge->fFirstY <= edge->fLastY); |
126 | 81 |
127 SkASSERT(edge->fPrev->fX <= edge->fX); | 82 SkASSERT(edge->fPrev->fX <= edge->fX); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 clipRgn = &wrap.getRgn(); | 736 clipRgn = &wrap.getRgn(); |
782 blitter = wrap.getBlitter(); | 737 blitter = wrap.getBlitter(); |
783 } | 738 } |
784 | 739 |
785 SkScanClipper clipper(blitter, clipRgn, ir); | 740 SkScanClipper clipper(blitter, clipRgn, ir); |
786 blitter = clipper.getBlitter(); | 741 blitter = clipper.getBlitter(); |
787 if (blitter) { | 742 if (blitter) { |
788 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); | 743 sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); |
789 } | 744 } |
790 } | 745 } |
OLD | NEW |