Don't add extra app list launcher page webviews.
[chromium-blink-merge.git] / cc / resources / tiling_set_raster_queue_all.h
blobebca838f232b288c00e6e6770d3d97e997d23bf2
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.
5 #ifndef CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_
6 #define CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/resources/picture_layer_tiling_set.h"
10 #include "cc/resources/tile.h"
11 #include "cc/resources/tile_priority.h"
13 namespace cc {
15 // This queue returns all tiles required to be rasterized from HIGH_RESOLUTION
16 // and LOW_RESOLUTION tilings.
17 class CC_EXPORT TilingSetRasterQueueAll {
18 public:
19 TilingSetRasterQueueAll(PictureLayerTilingSet* tiling_set,
20 bool prioritize_low_res);
21 ~TilingSetRasterQueueAll();
23 Tile* Top();
24 const Tile* Top() const;
25 void Pop();
26 bool IsEmpty() const;
28 private:
29 // Helper base class for individual region iterators.
30 class OnePriorityRectIterator {
31 public:
32 OnePriorityRectIterator();
33 OnePriorityRectIterator(PictureLayerTiling* tiling,
34 TilingData* tiling_data);
36 bool done() const { return !tile_; }
37 Tile* operator*() const { return tile_; }
39 protected:
40 ~OnePriorityRectIterator() = default;
41 bool TileNeedsRaster(Tile* tile) const {
42 return tile->NeedsRaster() && !tiling_->IsTileOccluded(tile);
45 template <typename TilingIteratorType>
46 void AdvanceToNextTile(TilingIteratorType* iterator);
47 template <typename TilingIteratorType>
48 bool GetFirstTileAndCheckIfValid(TilingIteratorType* iterator);
50 Tile* tile_;
51 PictureLayerTiling* tiling_;
52 TilingData* tiling_data_;
55 // Iterates over visible rect only, left to right top to bottom order.
56 class VisibleTilingIterator : public OnePriorityRectIterator {
57 public:
58 VisibleTilingIterator() = default;
59 VisibleTilingIterator(PictureLayerTiling* tiling, TilingData* tiling_data);
61 VisibleTilingIterator& operator++();
63 private:
64 TilingData::Iterator iterator_;
67 // Iterates over skewport only, spiral around the visible rect.
68 class SkewportTilingIterator : public OnePriorityRectIterator {
69 public:
70 SkewportTilingIterator() = default;
71 SkewportTilingIterator(PictureLayerTiling* tiling, TilingData* tiling_data);
73 SkewportTilingIterator& operator++();
75 private:
76 TilingData::SpiralDifferenceIterator iterator_;
79 // Iterates over soon border only, spiral around the visible rect.
80 class SoonBorderTilingIterator : public OnePriorityRectIterator {
81 public:
82 SoonBorderTilingIterator() = default;
83 SoonBorderTilingIterator(PictureLayerTiling* tiling,
84 TilingData* tiling_data);
86 SoonBorderTilingIterator& operator++();
88 private:
89 TilingData::SpiralDifferenceIterator iterator_;
92 // Iterates over eventually rect only, spiral around the soon rect.
93 class EventuallyTilingIterator : public OnePriorityRectIterator {
94 public:
95 EventuallyTilingIterator() = default;
96 EventuallyTilingIterator(PictureLayerTiling* tiling,
97 TilingData* tiling_data);
99 EventuallyTilingIterator& operator++();
101 private:
102 TilingData::SpiralDifferenceIterator iterator_;
105 // Iterates over all of the above phases in the following order: visible,
106 // skewport, soon border, eventually.
107 class TilingIterator {
108 public:
109 TilingIterator();
110 explicit TilingIterator(PictureLayerTiling* tiling,
111 TilingData* tiling_data);
112 ~TilingIterator() = default;
114 bool done() const { return current_tile_ == nullptr; }
115 const Tile* operator*() const { return current_tile_; }
116 Tile* operator*() { return current_tile_; }
117 TilePriority::PriorityBin type() const {
118 switch (phase_) {
119 case VISIBLE_RECT:
120 return TilePriority::NOW;
121 case SKEWPORT_RECT:
122 case SOON_BORDER_RECT:
123 return TilePriority::SOON;
124 case EVENTUALLY_RECT:
125 return TilePriority::EVENTUALLY;
127 NOTREACHED();
128 return TilePriority::EVENTUALLY;
131 TilingIterator& operator++();
133 private:
134 enum Phase {
135 VISIBLE_RECT,
136 SKEWPORT_RECT,
137 SOON_BORDER_RECT,
138 EVENTUALLY_RECT
141 void AdvancePhase();
143 PictureLayerTiling* tiling_;
144 TilingData* tiling_data_;
146 Phase phase_;
148 Tile* current_tile_;
149 VisibleTilingIterator visible_iterator_;
150 SkewportTilingIterator skewport_iterator_;
151 SoonBorderTilingIterator soon_border_iterator_;
152 EventuallyTilingIterator eventually_iterator_;
155 enum IteratorType { LOW_RES, HIGH_RES, NUM_ITERATORS };
157 void AdvanceToNextStage();
159 PictureLayerTilingSet* tiling_set_;
161 struct IterationStage {
162 IteratorType iterator_type;
163 TilePriority::PriorityBin tile_type;
166 size_t current_stage_;
168 // One low res stage, and three high res stages.
169 IterationStage stages_[4];
170 TilingIterator iterators_[NUM_ITERATORS];
173 } // namespace cc
175 #endif // CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_