| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/resources/tiling_set_raster_queue.h" | |
| 6 | |
| 7 namespace cc { | |
| 8 | |
| 9 TilingSetRasterQueue::TilingSetRasterQueue() | |
| 10 : tiling_set_(nullptr), current_stage_(arraysize(stages_)) { | |
| 11 } | |
| 12 | |
| 13 TilingSetRasterQueue::TilingSetRasterQueue(PictureLayerTilingSet* tiling_set, | |
| 14 bool prioritize_low_res) | |
| 15 : tiling_set_(tiling_set), current_stage_(0) { | |
| 16 DCHECK(tiling_set_); | |
| 17 | |
| 18 // Early out if the tiling set has no tilings. | |
| 19 if (!tiling_set_->num_tilings()) { | |
| 20 current_stage_ = arraysize(stages_); | |
| 21 return; | |
| 22 } | |
| 23 | |
| 24 // Find high and low res tilings and initialize the iterators. | |
| 25 for (size_t i = 0; i < tiling_set_->num_tilings(); ++i) { | |
| 26 PictureLayerTiling* tiling = tiling_set_->tiling_at(i); | |
| 27 if (tiling->resolution() == HIGH_RESOLUTION) { | |
| 28 iterators_[HIGH_RES] = | |
| 29 PictureLayerTiling::TilingRasterTileIterator(tiling); | |
| 30 } | |
| 31 | |
| 32 if (prioritize_low_res && tiling->resolution() == LOW_RESOLUTION) { | |
| 33 iterators_[LOW_RES] = | |
| 34 PictureLayerTiling::TilingRasterTileIterator(tiling); | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 if (prioritize_low_res) { | |
| 39 stages_[0].iterator_type = LOW_RES; | |
| 40 stages_[0].tile_type = TilePriority::NOW; | |
| 41 | |
| 42 stages_[1].iterator_type = HIGH_RES; | |
| 43 stages_[1].tile_type = TilePriority::NOW; | |
| 44 } else { | |
| 45 stages_[0].iterator_type = HIGH_RES; | |
| 46 stages_[0].tile_type = TilePriority::NOW; | |
| 47 | |
| 48 stages_[1].iterator_type = LOW_RES; | |
| 49 stages_[1].tile_type = TilePriority::NOW; | |
| 50 } | |
| 51 | |
| 52 stages_[2].iterator_type = HIGH_RES; | |
| 53 stages_[2].tile_type = TilePriority::SOON; | |
| 54 | |
| 55 stages_[3].iterator_type = HIGH_RES; | |
| 56 stages_[3].tile_type = TilePriority::EVENTUALLY; | |
| 57 | |
| 58 IteratorType index = stages_[current_stage_].iterator_type; | |
| 59 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | |
| 60 if (!iterators_[index] || iterators_[index].get_type() != tile_type) | |
| 61 AdvanceToNextStage(); | |
| 62 } | |
| 63 | |
| 64 TilingSetRasterQueue::~TilingSetRasterQueue() { | |
| 65 } | |
| 66 | |
| 67 bool TilingSetRasterQueue::IsEmpty() const { | |
| 68 return current_stage_ >= arraysize(stages_); | |
| 69 } | |
| 70 | |
| 71 void TilingSetRasterQueue::Pop() { | |
| 72 IteratorType index = stages_[current_stage_].iterator_type; | |
| 73 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | |
| 74 | |
| 75 // First advance the iterator. | |
| 76 DCHECK(iterators_[index]); | |
| 77 DCHECK(iterators_[index].get_type() == tile_type); | |
| 78 ++iterators_[index]; | |
| 79 | |
| 80 if (!iterators_[index] || iterators_[index].get_type() != tile_type) | |
| 81 AdvanceToNextStage(); | |
| 82 } | |
| 83 | |
| 84 Tile* TilingSetRasterQueue::Top() { | |
| 85 DCHECK(!IsEmpty()); | |
| 86 | |
| 87 IteratorType index = stages_[current_stage_].iterator_type; | |
| 88 DCHECK(iterators_[index]); | |
| 89 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type); | |
| 90 | |
| 91 return *iterators_[index]; | |
| 92 } | |
| 93 | |
| 94 const Tile* TilingSetRasterQueue::Top() const { | |
| 95 DCHECK(!IsEmpty()); | |
| 96 | |
| 97 IteratorType index = stages_[current_stage_].iterator_type; | |
| 98 DCHECK(iterators_[index]); | |
| 99 DCHECK(iterators_[index].get_type() == stages_[current_stage_].tile_type); | |
| 100 | |
| 101 return *iterators_[index]; | |
| 102 } | |
| 103 | |
| 104 void TilingSetRasterQueue::AdvanceToNextStage() { | |
| 105 DCHECK_LT(current_stage_, arraysize(stages_)); | |
| 106 ++current_stage_; | |
| 107 while (current_stage_ < arraysize(stages_)) { | |
| 108 IteratorType index = stages_[current_stage_].iterator_type; | |
| 109 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | |
| 110 | |
| 111 if (iterators_[index] && iterators_[index].get_type() == tile_type) | |
| 112 break; | |
| 113 ++current_stage_; | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 } // namespace cc | |
| OLD | NEW |