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