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 | 7 |
8 #include "SkTileGrid.h" | 8 #include "SkTileGrid.h" |
9 | 9 |
10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
Info& info) | 10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
Info& info) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 for (int y = startY; y < endY; y++) { | 115 for (int y = startY; y < endY; y++) { |
116 starts[i] = fTiles[y * fXTiles + x].begin(); | 116 starts[i] = fTiles[y * fXTiles + x].begin(); |
117 ends[i] = fTiles[y * fXTiles + x].end(); | 117 ends[i] = fTiles[y * fXTiles + x].end(); |
118 i++; | 118 i++; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // Merge tiles into results until they're fully consumed. | 122 // Merge tiles into results until they're fully consumed. |
123 results->reset(); | 123 results->reset(); |
124 while (true) { | 124 while (true) { |
125 // The tiles themselves are already ordered, so the earliest is at the f
ront of some tile. | 125 // The tiles themselves are already ordered, so the earliest op is at th
e front of some |
126 // It may be at the front of several, even all, tiles. | 126 // tile. It may be at the front of several, even all, tiles. |
127 const unsigned* earliest = NULL; | 127 unsigned earliest = SK_MaxU32; |
128 for (int i = 0; i < starts.count(); i++) { | 128 for (int i = 0; i < starts.count(); i++) { |
129 if (starts[i] < ends[i]) { | 129 if (starts[i] < ends[i]) { |
130 if (NULL == earliest || *starts[i]< *earliest) { | 130 earliest = SkTMin(earliest, *starts[i]); |
131 earliest = starts[i]; | |
132 } | |
133 } | 131 } |
134 } | 132 } |
135 | 133 |
136 // If we didn't find an earliest entry, there isn't anything left to mer
ge. | 134 // If we didn't find an earliest op, there isn't anything left to merge. |
137 if (NULL == earliest) { | 135 if (SK_MaxU32 == earliest) { |
138 return; | 136 return; |
139 } | 137 } |
140 | 138 |
141 // We did find an earliest entry. Output it, and step forward every tile
that contains it. | 139 // We did find an earliest op. Output it, and step forward every tile th
at contains it. |
142 results->push(*earliest); | 140 results->push(earliest); |
143 for (int i = 0; i < starts.count(); i++) { | 141 for (int i = 0; i < starts.count(); i++) { |
144 if (starts[i] < ends[i] && *starts[i] == *earliest) { | 142 if (starts[i] < ends[i] && *starts[i] == earliest) { |
145 starts[i]++; | 143 starts[i]++; |
146 } | 144 } |
147 } | 145 } |
148 } | 146 } |
149 } | 147 } |
150 | 148 |
151 void SkTileGrid::clear() { | 149 void SkTileGrid::clear() { |
152 for (int i = 0; i < fXTiles * fYTiles; i++) { | 150 for (int i = 0; i < fXTiles * fYTiles; i++) { |
153 fTiles[i].reset(); | 151 fTiles[i].reset(); |
154 } | 152 } |
155 } | 153 } |
156 | 154 |
OLD | NEW |