| 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_required.h" | 5 #include "cc/resources/tiling_set_raster_queue_required.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" |
| 11 #include "cc/resources/tile_priority.h" | 11 #include "cc/resources/tile_priority.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 TilingSetRasterQueueRequired::TilingSetRasterQueueRequired( | 15 TilingSetRasterQueueRequired::TilingSetRasterQueueRequired( |
| 16 PictureLayerTilingSet* tiling_set, | 16 PictureLayerTilingSet* tiling_set, |
| 17 RasterTilePriorityQueue::Type type) | 17 RasterTilePriorityQueue::Type type) |
| 18 : type_(type) { | 18 : type_(type) { |
| 19 DCHECK_NE(static_cast<int>(type), | 19 DCHECK_NE(static_cast<int>(type), |
| 20 static_cast<int>(RasterTilePriorityQueue::Type::ALL)); | 20 static_cast<int>(RasterTilePriorityQueue::Type::ALL)); |
| 21 | 21 |
| 22 // Any type of required tile would only come from a high resolution tiling. | 22 // Required tiles should only come from HIGH_RESOLUTION tilings. However, if |
| 23 // The functions that determine this value is | 23 // we want required for activation tiles on the active tree, then it will come |
| 24 // PictureLayerTiling::IsTileRequiredFor*, which all return false if the | 24 // from tilings whose pending twin is high resolution. |
| 25 // resolution is not HIGH_RESOLUTION. | 25 PictureLayerTiling* tiling = nullptr; |
| 26 PictureLayerTiling* tiling = | 26 if (type == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION && |
| 27 tiling_set->FindTilingWithResolution(HIGH_RESOLUTION); | 27 tiling_set->client()->GetTree() == ACTIVE_TREE) { |
| 28 // If we don't have a high res tiling, then this queue will yield no tiles. | 28 for (size_t i = 0; i < tiling_set->num_tilings(); ++i) { |
| 29 // See PictureLayerImpl::CanHaveTilings for examples of when a HIGH_RESOLUTION | 29 PictureLayerTiling* active_tiling = tiling_set->tiling_at(i); |
| 30 const PictureLayerTiling* pending_twin = |
| 31 tiling_set->client()->GetPendingOrActiveTwinTiling(active_tiling); |
| 32 if (pending_twin && pending_twin->resolution() == HIGH_RESOLUTION) { |
| 33 tiling = active_tiling; |
| 34 break; |
| 35 } |
| 36 } |
| 37 } else { |
| 38 tiling = tiling_set->FindTilingWithResolution(HIGH_RESOLUTION); |
| 39 } |
| 40 |
| 41 // If we don't have a tiling, then this queue will yield no tiles. See |
| 42 // PictureLayerImpl::CanHaveTilings for examples of when a HIGH_RESOLUTION |
| 30 // tiling would not be generated. | 43 // tiling would not be generated. |
| 31 if (!tiling) | 44 if (!tiling) |
| 32 return; | 45 return; |
| 33 | 46 |
| 34 iterator_ = TilingIterator(tiling, &tiling->tiling_data_); | 47 if (type == RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION) { |
| 48 iterator_ = TilingIterator(tiling, &tiling->tiling_data_, |
| 49 tiling->pending_visible_rect()); |
| 50 } else { |
| 51 iterator_ = TilingIterator(tiling, &tiling->tiling_data_, |
| 52 tiling->current_visible_rect()); |
| 53 } |
| 54 |
| 35 while (!iterator_.done() && !IsTileRequired(*iterator_)) | 55 while (!iterator_.done() && !IsTileRequired(*iterator_)) |
| 36 ++iterator_; | 56 ++iterator_; |
| 37 } | 57 } |
| 38 | 58 |
| 39 TilingSetRasterQueueRequired::~TilingSetRasterQueueRequired() { | 59 TilingSetRasterQueueRequired::~TilingSetRasterQueueRequired() { |
| 40 } | 60 } |
| 41 | 61 |
| 42 bool TilingSetRasterQueueRequired::IsEmpty() const { | 62 bool TilingSetRasterQueueRequired::IsEmpty() const { |
| 43 return iterator_.done(); | 63 return iterator_.done(); |
| 44 } | 64 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW && | 86 (type_ == RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW && |
| 67 tile->required_for_draw()); | 87 tile->required_for_draw()); |
| 68 } | 88 } |
| 69 | 89 |
| 70 TilingSetRasterQueueRequired::TilingIterator::TilingIterator() | 90 TilingSetRasterQueueRequired::TilingIterator::TilingIterator() |
| 71 : tiling_(nullptr), current_tile_(nullptr) { | 91 : tiling_(nullptr), current_tile_(nullptr) { |
| 72 } | 92 } |
| 73 | 93 |
| 74 TilingSetRasterQueueRequired::TilingIterator::TilingIterator( | 94 TilingSetRasterQueueRequired::TilingIterator::TilingIterator( |
| 75 PictureLayerTiling* tiling, | 95 PictureLayerTiling* tiling, |
| 76 TilingData* tiling_data) | 96 TilingData* tiling_data, |
| 97 const gfx::Rect& rect) |
| 77 : tiling_(tiling), tiling_data_(tiling_data), current_tile_(nullptr) { | 98 : tiling_(tiling), tiling_data_(tiling_data), current_tile_(nullptr) { |
| 78 if (!tiling_->has_visible_rect_tiles()) { | |
| 79 // Verify that if we would create the iterator, then it would be empty (ie | |
| 80 // it would return false when evaluated as a bool). | |
| 81 DCHECK(!TilingData::Iterator(tiling_data_, tiling->current_visible_rect(), | |
| 82 false)); | |
| 83 return; | |
| 84 } | |
| 85 | |
| 86 visible_iterator_ = | 99 visible_iterator_ = |
| 87 TilingData::Iterator(tiling_data_, tiling_->current_visible_rect(), | 100 TilingData::Iterator(tiling_data_, rect, false /* include_borders */); |
| 88 false /* include_borders */); | |
| 89 if (!visible_iterator_) | 101 if (!visible_iterator_) |
| 90 return; | 102 return; |
| 91 | 103 |
| 92 current_tile_ = | 104 current_tile_ = |
| 93 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | 105 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); |
| 94 | 106 |
| 95 // If this is a valid tile, return it. Note that we have to use a tiling check | 107 // If this is a valid tile, return it. Note that we have to use a tiling check |
| 96 // for occlusion, since the tile's internal state has not yet been updated. | 108 // for occlusion, since the tile's internal state has not yet been updated. |
| 97 if (current_tile_ && current_tile_->NeedsRaster() && | 109 if (current_tile_ && current_tile_->NeedsRaster() && |
| 98 !tiling_->IsTileOccluded(current_tile_)) { | 110 !tiling_->IsTileOccluded(current_tile_)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // in the NOW bin, which means that it can be required. | 144 // in the NOW bin, which means that it can be required. |
| 133 break; | 145 break; |
| 134 } | 146 } |
| 135 | 147 |
| 136 if (current_tile_) | 148 if (current_tile_) |
| 137 tiling_->UpdateTileAndTwinPriority(current_tile_); | 149 tiling_->UpdateTileAndTwinPriority(current_tile_); |
| 138 return *this; | 150 return *this; |
| 139 } | 151 } |
| 140 | 152 |
| 141 } // namespace cc | 153 } // namespace cc |
| OLD | NEW |