OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/tiling_set_raster_queue_all.h" | 5 #include "cc/resources/tiling_set_raster_queue_all.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/resources/picture_layer_tiling_set.h" | 9 #include "cc/resources/picture_layer_tiling_set.h" |
10 #include "cc/resources/tile.h" | 10 #include "cc/resources/tile.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 while (current_stage_ < arraysize(stages_)) { | 105 while (current_stage_ < arraysize(stages_)) { |
106 IteratorType index = stages_[current_stage_].iterator_type; | 106 IteratorType index = stages_[current_stage_].iterator_type; |
107 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | 107 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; |
108 | 108 |
109 if (!iterators_[index].done() && iterators_[index].type() == tile_type) | 109 if (!iterators_[index].done() && iterators_[index].type() == tile_type) |
110 break; | 110 break; |
111 ++current_stage_; | 111 ++current_stage_; |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
| 115 // OnePriorityRectIterator |
| 116 TilingSetRasterQueueAll::OnePriorityRectIterator::OnePriorityRectIterator() |
| 117 : tile_(nullptr), tiling_(nullptr), tiling_data_(nullptr) { |
| 118 } |
| 119 |
| 120 TilingSetRasterQueueAll::OnePriorityRectIterator::OnePriorityRectIterator( |
| 121 PictureLayerTiling* tiling, |
| 122 TilingData* tiling_data) |
| 123 : tile_(nullptr), tiling_(tiling), tiling_data_(tiling_data) { |
| 124 } |
| 125 |
| 126 template <typename TilingIteratorType> |
| 127 void TilingSetRasterQueueAll::OnePriorityRectIterator::AdvanceToNextTile( |
| 128 TilingIteratorType* iterator) { |
| 129 tile_ = nullptr; |
| 130 while (!tile_ || !TileNeedsRaster(tile_)) { |
| 131 ++(*iterator); |
| 132 if (!(*iterator)) { |
| 133 tile_ = nullptr; |
| 134 return; |
| 135 } |
| 136 tile_ = tiling_->TileAt(iterator->index_x(), iterator->index_y()); |
| 137 } |
| 138 tiling_->UpdateTileAndTwinPriority(tile_); |
| 139 } |
| 140 |
| 141 template <typename TilingIteratorType> |
| 142 bool TilingSetRasterQueueAll::OnePriorityRectIterator:: |
| 143 GetFirstTileAndCheckIfValid(TilingIteratorType* iterator) { |
| 144 tile_ = tiling_->TileAt(iterator->index_x(), iterator->index_y()); |
| 145 if (!tile_ || !TileNeedsRaster(tile_)) { |
| 146 tile_ = nullptr; |
| 147 return false; |
| 148 } |
| 149 tiling_->UpdateTileAndTwinPriority(tile_); |
| 150 return true; |
| 151 } |
| 152 |
| 153 // VisibleTilingIterator. |
| 154 TilingSetRasterQueueAll::VisibleTilingIterator::VisibleTilingIterator( |
| 155 PictureLayerTiling* tiling, |
| 156 TilingData* tiling_data) |
| 157 : OnePriorityRectIterator(tiling, tiling_data) { |
| 158 if (!tiling_->has_visible_rect_tiles()) |
| 159 return; |
| 160 iterator_ = |
| 161 TilingData::Iterator(tiling_data_, tiling_->current_visible_rect(), |
| 162 false /* include_borders */); |
| 163 if (!iterator_) |
| 164 return; |
| 165 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
| 166 ++(*this); |
| 167 } |
| 168 |
| 169 TilingSetRasterQueueAll::VisibleTilingIterator& |
| 170 TilingSetRasterQueueAll::VisibleTilingIterator:: |
| 171 operator++() { |
| 172 AdvanceToNextTile(&iterator_); |
| 173 return *this; |
| 174 } |
| 175 |
| 176 // SkewportTilingIterator. |
| 177 TilingSetRasterQueueAll::SkewportTilingIterator::SkewportTilingIterator( |
| 178 PictureLayerTiling* tiling, |
| 179 TilingData* tiling_data) |
| 180 : OnePriorityRectIterator(tiling, tiling_data) { |
| 181 if (!tiling_->has_skewport_rect_tiles()) |
| 182 return; |
| 183 iterator_ = TilingData::SpiralDifferenceIterator( |
| 184 tiling_data_, tiling_->current_skewport_rect(), |
| 185 tiling_->current_visible_rect(), tiling_->current_visible_rect()); |
| 186 if (!iterator_) |
| 187 return; |
| 188 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
| 189 ++(*this); |
| 190 } |
| 191 |
| 192 TilingSetRasterQueueAll::SkewportTilingIterator& |
| 193 TilingSetRasterQueueAll::SkewportTilingIterator:: |
| 194 operator++() { |
| 195 AdvanceToNextTile(&iterator_); |
| 196 return *this; |
| 197 } |
| 198 |
| 199 // SoonBorderTilingIterator. |
| 200 TilingSetRasterQueueAll::SoonBorderTilingIterator::SoonBorderTilingIterator( |
| 201 PictureLayerTiling* tiling, |
| 202 TilingData* tiling_data) |
| 203 : OnePriorityRectIterator(tiling, tiling_data) { |
| 204 if (!tiling_->has_soon_border_rect_tiles()) |
| 205 return; |
| 206 iterator_ = TilingData::SpiralDifferenceIterator( |
| 207 tiling_data_, tiling_->current_soon_border_rect(), |
| 208 tiling_->current_skewport_rect(), tiling_->current_visible_rect()); |
| 209 if (!iterator_) |
| 210 return; |
| 211 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
| 212 ++(*this); |
| 213 } |
| 214 |
| 215 TilingSetRasterQueueAll::SoonBorderTilingIterator& |
| 216 TilingSetRasterQueueAll::SoonBorderTilingIterator:: |
| 217 operator++() { |
| 218 AdvanceToNextTile(&iterator_); |
| 219 return *this; |
| 220 } |
| 221 |
| 222 // EventuallyTilingIterator. |
| 223 TilingSetRasterQueueAll::EventuallyTilingIterator::EventuallyTilingIterator( |
| 224 PictureLayerTiling* tiling, |
| 225 TilingData* tiling_data) |
| 226 : OnePriorityRectIterator(tiling, tiling_data) { |
| 227 if (!tiling_->has_eventually_rect_tiles()) |
| 228 return; |
| 229 iterator_ = TilingData::SpiralDifferenceIterator( |
| 230 tiling_data_, tiling_->current_eventually_rect(), |
| 231 tiling_->current_skewport_rect(), tiling_->current_soon_border_rect()); |
| 232 if (!iterator_) |
| 233 return; |
| 234 if (!GetFirstTileAndCheckIfValid(&iterator_)) |
| 235 ++(*this); |
| 236 } |
| 237 |
| 238 TilingSetRasterQueueAll::EventuallyTilingIterator& |
| 239 TilingSetRasterQueueAll::EventuallyTilingIterator:: |
| 240 operator++() { |
| 241 AdvanceToNextTile(&iterator_); |
| 242 return *this; |
| 243 } |
| 244 |
| 245 // TilingIterator |
115 TilingSetRasterQueueAll::TilingIterator::TilingIterator() | 246 TilingSetRasterQueueAll::TilingIterator::TilingIterator() |
116 : tiling_(NULL), current_tile_(NULL) { | 247 : tiling_(NULL), current_tile_(NULL) { |
117 } | 248 } |
118 | 249 |
119 TilingSetRasterQueueAll::TilingIterator::TilingIterator( | 250 TilingSetRasterQueueAll::TilingIterator::TilingIterator( |
120 PictureLayerTiling* tiling, | 251 PictureLayerTiling* tiling, |
121 TilingData* tiling_data) | 252 TilingData* tiling_data) |
122 : tiling_(tiling), | 253 : tiling_(tiling), |
123 tiling_data_(tiling_data), | 254 tiling_data_(tiling_data), |
124 phase_(VISIBLE_RECT), | 255 phase_(VISIBLE_RECT), |
125 current_tile_(NULL) { | 256 current_tile_(NULL) { |
126 if (!tiling_->has_visible_rect_tiles()) { | 257 visible_iterator_ = VisibleTilingIterator(tiling_, tiling_data_); |
| 258 if (visible_iterator_.done()) { |
127 AdvancePhase(); | 259 AdvancePhase(); |
128 return; | 260 return; |
129 } | 261 } |
130 | 262 current_tile_ = *visible_iterator_; |
131 visible_iterator_ = | |
132 TilingData::Iterator(tiling_data_, tiling_->current_visible_rect(), | |
133 false /* include_borders */); | |
134 if (!visible_iterator_) { | |
135 AdvancePhase(); | |
136 return; | |
137 } | |
138 | |
139 current_tile_ = | |
140 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | |
141 if (!current_tile_ || !TileNeedsRaster(current_tile_)) { | |
142 ++(*this); | |
143 return; | |
144 } | |
145 tiling_->UpdateTileAndTwinPriority(current_tile_); | |
146 } | |
147 | |
148 TilingSetRasterQueueAll::TilingIterator::~TilingIterator() { | |
149 } | 263 } |
150 | 264 |
151 void TilingSetRasterQueueAll::TilingIterator::AdvancePhase() { | 265 void TilingSetRasterQueueAll::TilingIterator::AdvancePhase() { |
152 DCHECK_LT(phase_, EVENTUALLY_RECT); | 266 DCHECK_LT(phase_, EVENTUALLY_RECT); |
153 | 267 |
154 do { | 268 current_tile_ = nullptr; |
| 269 while (!current_tile_ && phase_ < EVENTUALLY_RECT) { |
155 phase_ = static_cast<Phase>(phase_ + 1); | 270 phase_ = static_cast<Phase>(phase_ + 1); |
156 switch (phase_) { | 271 switch (phase_) { |
157 case VISIBLE_RECT: | 272 case VISIBLE_RECT: |
158 NOTREACHED(); | 273 NOTREACHED(); |
159 return; | 274 return; |
160 case SKEWPORT_RECT: | 275 case SKEWPORT_RECT: |
161 if (!tiling_->has_skewport_rect_tiles()) | 276 skewport_iterator_ = SkewportTilingIterator(tiling_, tiling_data_); |
162 continue; | 277 if (!skewport_iterator_.done()) |
163 | 278 current_tile_ = *skewport_iterator_; |
164 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
165 tiling_data_, tiling_->current_skewport_rect(), | |
166 tiling_->current_visible_rect(), tiling_->current_visible_rect()); | |
167 break; | 279 break; |
168 case SOON_BORDER_RECT: | 280 case SOON_BORDER_RECT: |
169 if (!tiling_->has_soon_border_rect_tiles()) | 281 soon_border_iterator_ = SoonBorderTilingIterator(tiling_, tiling_data_); |
170 continue; | 282 if (!soon_border_iterator_.done()) |
171 | 283 current_tile_ = *soon_border_iterator_; |
172 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
173 tiling_data_, tiling_->current_soon_border_rect(), | |
174 tiling_->current_skewport_rect(), tiling_->current_visible_rect()); | |
175 break; | 284 break; |
176 case EVENTUALLY_RECT: | 285 case EVENTUALLY_RECT: |
177 if (!tiling_->has_eventually_rect_tiles()) { | 286 eventually_iterator_ = EventuallyTilingIterator(tiling_, tiling_data_); |
178 current_tile_ = NULL; | 287 if (!eventually_iterator_.done()) |
179 return; | 288 current_tile_ = *eventually_iterator_; |
180 } | |
181 | |
182 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
183 tiling_data_, tiling_->current_eventually_rect(), | |
184 tiling_->current_skewport_rect(), | |
185 tiling_->current_soon_border_rect()); | |
186 break; | 289 break; |
187 } | 290 } |
188 | 291 } |
189 while (spiral_iterator_) { | |
190 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(), | |
191 spiral_iterator_.index_y()); | |
192 if (current_tile_ && TileNeedsRaster(current_tile_)) | |
193 break; | |
194 ++spiral_iterator_; | |
195 } | |
196 | |
197 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) { | |
198 current_tile_ = NULL; | |
199 break; | |
200 } | |
201 } while (!spiral_iterator_); | |
202 | |
203 if (current_tile_) | |
204 tiling_->UpdateTileAndTwinPriority(current_tile_); | |
205 } | 292 } |
206 | 293 |
207 TilingSetRasterQueueAll::TilingIterator& | 294 TilingSetRasterQueueAll::TilingIterator& |
208 TilingSetRasterQueueAll::TilingIterator:: | 295 TilingSetRasterQueueAll::TilingIterator:: |
209 operator++() { | 296 operator++() { |
210 current_tile_ = NULL; | 297 switch (phase_) { |
211 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { | 298 case VISIBLE_RECT: |
212 std::pair<int, int> next_index; | 299 ++visible_iterator_; |
213 switch (phase_) { | 300 if (visible_iterator_.done()) { |
214 case VISIBLE_RECT: | 301 AdvancePhase(); |
215 ++visible_iterator_; | 302 return *this; |
216 if (!visible_iterator_) { | 303 } |
217 AdvancePhase(); | 304 current_tile_ = *visible_iterator_; |
218 return *this; | 305 break; |
219 } | 306 case SKEWPORT_RECT: |
220 next_index = visible_iterator_.index(); | 307 ++skewport_iterator_; |
221 break; | 308 if (skewport_iterator_.done()) { |
222 case SKEWPORT_RECT: | 309 AdvancePhase(); |
223 case SOON_BORDER_RECT: | 310 return *this; |
224 ++spiral_iterator_; | 311 } |
225 if (!spiral_iterator_) { | 312 current_tile_ = *skewport_iterator_; |
226 AdvancePhase(); | 313 break; |
227 return *this; | 314 case SOON_BORDER_RECT: |
228 } | 315 ++soon_border_iterator_; |
229 next_index = spiral_iterator_.index(); | 316 if (soon_border_iterator_.done()) { |
230 break; | 317 AdvancePhase(); |
231 case EVENTUALLY_RECT: | 318 return *this; |
232 ++spiral_iterator_; | 319 } |
233 if (!spiral_iterator_) { | 320 current_tile_ = *soon_border_iterator_; |
234 current_tile_ = NULL; | 321 break; |
235 return *this; | 322 case EVENTUALLY_RECT: |
236 } | 323 ++eventually_iterator_; |
237 next_index = spiral_iterator_.index(); | 324 if (eventually_iterator_.done()) { |
238 break; | 325 current_tile_ = nullptr; |
239 } | 326 return *this; |
240 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | 327 } |
241 } | 328 current_tile_ = *eventually_iterator_; |
242 | 329 break; |
243 if (current_tile_) | 330 } |
244 tiling_->UpdateTileAndTwinPriority(current_tile_); | 331 return *this; |
245 return *this; | 332 } |
246 } | 333 |
247 | |
248 } // namespace cc | 334 } // namespace cc |
OLD | NEW |