Chromium Code Reviews| 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 #ifndef CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ | 5 #ifndef CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ |
| 6 #define CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ | 6 #define CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "cc/resources/picture_layer_tiling_set.h" | 11 #include "cc/resources/picture_layer_tiling_set.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 // This eviction queue returned tiles from all tilings in a tiling set in | 15 // This eviction queue returned tiles from all tilings in a tiling set in |
| 16 // the following order: | 16 // the order in which the tiles should be evicted. It can be thought of as the |
| 17 // 1) Eventually rect tiles (EVENTUALLY tiles). | 17 // following: |
| 18 // 1) Eventually rect tiles not required for activation from each tiling in | 18 // for all phases: |
| 19 // the tiling set, in turn, in the following order: | 19 // for all ordered tilings: |
| 20 // 1) the first higher than high res tiling, the second one and so on | 20 // yield the next tile for the given phase from the given tiling |
| 21 // 2) the first lower than low res tiling, the second one and so on | |
| 22 // 3) the first between high and low res tiling, the second one and so on | |
| 23 // 4) low res tiling | |
| 24 // 5) high res tiling | |
| 25 // 2) Eventually rect tiles required for activation from the tiling with | |
| 26 // required for activation tiles. In the case of a pending tree tiling | |
| 27 // set that is the high res tiling. In the case of an active tree tiling | |
| 28 // set that is a tiling whose twin tiling is a pending tree high res | |
| 29 // tiling. | |
| 30 // 2) Soon border rect and skewport rect tiles (whose priority bin is SOON | |
| 31 // unless the max tile priority bin is lowered by PictureLayerTilingClient). | |
| 32 // 1) Soon border rect and skewport rect tiles not required for activation | |
| 33 // from each tiling in the tiling set. | |
| 34 // * Tilings are iterated in the same order as in the case of eventually | |
| 35 // rect tiles not required for activation. | |
| 36 // * For each tiling, first soon border rect tiles and then skewport | |
| 37 // rect tiles are returned. | |
| 38 // 2) Soon border rect and skewport rect tiles required for activation from | |
| 39 // the tiling with required for activation tiles. | |
| 40 // * First soon border rect tiles and then skewport rect tiles are | |
| 41 // returned. | |
| 42 // 3) Visible rect tiles (whose priority bin is NOW unless the max tile | |
| 43 // priority bin is lowered by PictureLayerTilingClient). | |
| 44 // 1) Visible rect tiles not required for activation from each tiling in | |
| 45 // the tiling set. | |
| 46 // * Tilings are iterated in the same order as in the case of eventually | |
| 47 // rect tiles not required for activation. | |
| 48 // * For each tiling, first occluded tiles and then unoccluded tiles | |
| 49 // are returned. | |
| 50 // 2) Visible rect tiles required for activation from the tiling with | |
| 51 // required for activation tiles. | |
| 52 // * First occluded tiles and then unoccluded tiles are returned. | |
| 53 // If the max tile priority bin is lowered by PictureLayerTilingClient, | |
| 54 // occlusion is not taken into account as occlusion is meaningful only for | |
| 55 // NOW tiles. | |
| 56 // | 21 // |
| 57 // Within each tiling and tile priority rect, tiles are returned in reverse | 22 // Phases are the following (in order in which they are processed): |
| 58 // spiral order i.e. in (mostly) decreasing distance-to-visible order. | 23 // EVENTUALLY_RECT - Tiles in the eventually region of the tiling. |
| 24 // SOON_BORDER_RECT - Tiles in the prepainting skirt of the tiling. | |
| 25 // SKEWPORT_RECT - Tiles in the skewport of the tiling. | |
| 26 // VISIBLE_RECT_OCCLUDED - Occluded, not required for activation, visible tiles. | |
| 27 // VISIBLE_RECT_UNOCCLUDED - Unoccluded, not required for activation, visible | |
| 28 // tiles. | |
| 29 // VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED - Occluded, but required for | |
| 30 // activation, visible tiles. This can happen when an active tree tile is | |
| 31 // occluded, but is not occluded on the pending tree (and is required for | |
| 32 // activation). | |
| 33 // VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED - Unoccluded, required for | |
| 34 // activation, tiles. | |
| 59 // | 35 // |
| 60 // If the skip_shared_out_of_order_tiles value passed to the constructor is | 36 // The tilings are ordered as follows. Suppose we have tilings with the scales |
| 61 // true (like it should be when there is a twin layer with a twin tiling set), | 37 // below: |
| 62 // eviction queue does not return shared which are out of order because their | 38 // 2.0 1.5 1.0(HR) 0.8 0.5 0.25(LR) 0.2 0.1 |
| 63 // priority for tree priority is lowered or raised by a twin layer. | 39 // With HR referring to high res tiling and LR referring to low res tiling, |
| 64 // * If tree_priority is SAME_PRIORITY_FOR_BOTH_TREES, this happens for | 40 // then tilings are processed in this order: |
| 65 // a tile specific lower priority tree eviction queue (because priority for | 41 // 2.0 1.5 0.1 0.2 0.5 0.8 0.25(LR) 1.0(HR). |
| 66 // tree priority is a merged priority). | 42 // |
| 67 // * If tree priority is NEW_CONTENT_TAKES_PRIORITY, this happens for | 43 // To put it differently: |
| 68 // an active tree eviction queue (because priority for tree priority is | 44 // 1. Process higher than high res tilings. |
|
enne (OOO)
2015/03/27 19:12:11
I feel like this needs wording like "down to" or "
vmpstr
2015/03/27 20:19:27
Done.
| |
| 69 // the pending priority). | 45 // 2. Process lower than low res tilings. |
| 70 // * If tree_priority is SMOOTHNESS_TAKES_PRIORITY, this happens for a pending | 46 // 3. Process tilings between high and low res. |
| 71 // tree eviction queue (because priority for tree priority is the active | 47 // 4. Process the low res tiling. |
| 72 // priority). | 48 // 5. Process the high res tiling. |
| 73 // Those skipped shared out of order tiles are when returned only by the twin | 49 // |
| 74 // eviction queue. | 50 // Additional notes: |
| 51 // Since eventually the tiles are considered to have the priority which is the | |
| 52 // higher of the two trees, we might visit a tile that should actually be | |
| 53 // returned by its twin. In those situations, the tiles are not returned. That | |
| 54 // is, since the twin has higher priority, it should return it when it gets to | |
| 55 // it. This ensures that we don't block raster because we've returned a tile | |
| 56 // with low priority on one tree, but high combined priority. | |
| 75 class CC_EXPORT TilingSetEvictionQueue { | 57 class CC_EXPORT TilingSetEvictionQueue { |
| 76 public: | 58 public: |
| 77 TilingSetEvictionQueue(PictureLayerTilingSet* tiling_set, | 59 TilingSetEvictionQueue(PictureLayerTilingSet* tiling_set, |
| 78 TreePriority tree_priority, | 60 TreePriority tree_priority, |
| 79 bool skip_shared_out_of_order_tiles); | 61 bool skip_shared_out_of_order_tiles); |
| 80 ~TilingSetEvictionQueue(); | 62 ~TilingSetEvictionQueue(); |
| 81 | 63 |
| 82 Tile* Top(); | 64 Tile* Top(); |
| 83 const Tile* Top() const; | 65 const Tile* Top() const; |
| 84 void Pop(); | 66 void Pop(); |
| 85 bool IsEmpty() const; | 67 bool IsEmpty() const; |
| 86 | 68 |
| 87 private: | 69 private: |
| 88 bool AdvanceToNextEvictionTile(); | 70 enum Phase { |
| 89 bool AdvanceToNextPriorityBin(); | 71 EVENTUALLY_RECT, |
| 90 bool AdvanceToNextTilingRangeType(); | 72 SOON_BORDER_RECT, |
| 91 bool AdvanceToNextValidTiling(); | 73 SKEWPORT_RECT, |
| 74 VISIBLE_RECT_OCCLUDED, | |
| 75 VISIBLE_RECT_UNOCCLUDED, | |
| 76 VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_OCCLUDED, | |
| 77 VISIBLE_RECT_REQUIRED_FOR_ACTIVATION_UNOCCLUDED | |
| 78 }; | |
| 92 | 79 |
| 93 PictureLayerTilingSet::TilingRange CurrentTilingRange() const; | 80 void GenerateTilingOrder(PictureLayerTilingSet* tiling_set); |
| 94 size_t CurrentTilingIndex() const; | |
| 95 bool IsSharedOutOfOrderTile(const Tile* tile) const; | |
| 96 size_t TilingIndexWithRequiredForActivationTiles() const; | |
| 97 | 81 |
| 98 PictureLayerTilingSet* tiling_set_; | 82 // Helper base class for individual region iterators. |
| 83 class OnePriorityRectIterator { | |
|
enne (OOO)
2015/03/27 19:12:11
What does "one priority" mean?
vmpstr
2015/03/27 20:19:27
Well, it's just one priority rect as in eventually
enne (OOO)
2015/03/27 21:48:05
I guess it's the "OnePriority" part that confuses
vmpstr
2015/03/27 22:46:55
Done.
| |
| 84 public: | |
| 85 OnePriorityRectIterator(); | |
| 86 OnePriorityRectIterator(std::vector<PictureLayerTiling*>* tilings, | |
| 87 WhichTree tree, | |
| 88 TreePriority tree_priority, | |
| 89 bool skip_shared_out_of_order_tiles, | |
| 90 bool skip_all_shared_tiles); | |
| 91 | |
| 92 bool done() const { return !tile_; } | |
| 93 Tile* operator*() const { return tile_; } | |
| 94 | |
| 95 protected: | |
| 96 ~OnePriorityRectIterator() = default; | |
| 97 | |
| 98 template <typename TilingIteratorType> | |
| 99 bool AdvanceToNextTile(TilingIteratorType* iterator); | |
| 100 template <typename TilingIteratorType> | |
| 101 bool GetFirstTileAndCheckIfValid(TilingIteratorType* iterator); | |
| 102 | |
| 103 Tile* tile_; | |
| 104 std::vector<PictureLayerTiling*>* tilings_; | |
| 105 WhichTree tree_; | |
| 106 TreePriority tree_priority_; | |
| 107 bool skip_shared_out_of_order_tiles_; | |
| 108 bool skip_all_shared_tiles_; | |
| 109 size_t tiling_index_; | |
| 110 }; | |
| 111 | |
| 112 class VisibleTilingIterator : public OnePriorityRectIterator { | |
| 113 public: | |
| 114 VisibleTilingIterator() = default; | |
| 115 VisibleTilingIterator(std::vector<PictureLayerTiling*>* tilings, | |
| 116 WhichTree tree, | |
| 117 TreePriority tree_priority, | |
| 118 bool skip_shared_out_of_order_tiles, | |
| 119 bool skip_all_shared_tiles, | |
| 120 bool return_occluded_tiles, | |
| 121 bool return_required_for_activation_tiles); | |
| 122 | |
| 123 VisibleTilingIterator& operator++(); | |
| 124 | |
| 125 private: | |
| 126 bool TileMatchesRequiredFlags(const Tile* tile) const; | |
| 127 | |
| 128 TilingData::Iterator iterator_; | |
| 129 bool return_occluded_tiles_; | |
| 130 bool return_required_for_activation_tiles_; | |
| 131 }; | |
| 132 | |
| 133 class SkewportTilingIterator : public OnePriorityRectIterator { | |
| 134 public: | |
| 135 SkewportTilingIterator() = default; | |
| 136 SkewportTilingIterator(std::vector<PictureLayerTiling*>* tilings, | |
| 137 WhichTree tree, | |
| 138 TreePriority tree_priority, | |
| 139 bool skip_shared_out_of_order_tiles, | |
| 140 bool skip_all_shared_tiles); | |
| 141 | |
| 142 SkewportTilingIterator& operator++(); | |
| 143 | |
| 144 private: | |
| 145 TilingData::ReverseSpiralDifferenceIterator iterator_; | |
| 146 }; | |
| 147 | |
| 148 class SoonBorderTilingIterator : public OnePriorityRectIterator { | |
| 149 public: | |
| 150 SoonBorderTilingIterator() = default; | |
| 151 SoonBorderTilingIterator(std::vector<PictureLayerTiling*>* tilings, | |
| 152 WhichTree tree, | |
| 153 TreePriority tree_priority, | |
| 154 bool skip_shared_out_of_order_tiles, | |
| 155 bool skip_all_shared_tiles); | |
| 156 | |
| 157 SoonBorderTilingIterator& operator++(); | |
| 158 | |
| 159 private: | |
| 160 TilingData::ReverseSpiralDifferenceIterator iterator_; | |
| 161 }; | |
| 162 | |
| 163 class EventuallyTilingIterator : public OnePriorityRectIterator { | |
| 164 public: | |
| 165 EventuallyTilingIterator() = default; | |
| 166 EventuallyTilingIterator(std::vector<PictureLayerTiling*>* tilings, | |
| 167 WhichTree tree, | |
| 168 TreePriority tree_priority, | |
| 169 bool skip_shared_out_of_order_tiles, | |
| 170 bool skip_all_shared_tiles); | |
| 171 | |
| 172 EventuallyTilingIterator& operator++(); | |
| 173 | |
| 174 private: | |
| 175 TilingData::ReverseSpiralDifferenceIterator iterator_; | |
| 176 }; | |
| 177 | |
| 178 void AdvancePhase(); | |
| 179 | |
| 99 WhichTree tree_; | 180 WhichTree tree_; |
| 100 TreePriority tree_priority_; | 181 TreePriority tree_priority_; |
| 101 bool skip_all_shared_tiles_; | 182 bool skip_all_shared_tiles_; |
| 102 bool skip_shared_out_of_order_tiles_; | 183 bool skip_shared_out_of_order_tiles_; |
| 103 bool processing_soon_border_rect_; | 184 Phase phase_; |
| 104 bool processing_tiling_with_required_for_activation_tiles_; | 185 Tile* current_tile_; |
| 105 size_t tiling_index_with_required_for_activation_tiles_; | 186 std::vector<PictureLayerTiling*> tilings_; |
| 106 | 187 |
| 107 TilePriority::PriorityBin current_priority_bin_; | 188 EventuallyTilingIterator eventually_iterator_; |
| 108 PictureLayerTiling* current_tiling_; | 189 SoonBorderTilingIterator soon_iterator_; |
| 109 size_t current_tiling_index_; | 190 SkewportTilingIterator skewport_iterator_; |
| 110 PictureLayerTilingSet::TilingRangeType current_tiling_range_type_; | 191 VisibleTilingIterator visible_iterator_; |
| 111 Tile* current_eviction_tile_; | |
| 112 | |
| 113 TilingData::ReverseSpiralDifferenceIterator spiral_iterator_; | |
| 114 TilingData::Iterator visible_iterator_; | |
| 115 std::vector<Tile*> unoccluded_now_tiles_; | |
| 116 }; | 192 }; |
| 117 | 193 |
| 118 } // namespace cc | 194 } // namespace cc |
| 119 | 195 |
| 120 #endif // CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ | 196 #endif // CC_RESOURCES_TILING_SET_EVICTION_QUEUE_H_ |
| OLD | NEW |