Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / tiles / tiling_set_raster_queue_all.h
blobd6f79463fed3f7ff19006528ebdb535ef5ab377e
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_TILES_TILING_SET_RASTER_QUEUE_ALL_H_
6 #define CC_TILES_TILING_SET_RASTER_QUEUE_ALL_H_
8 #include "base/containers/stack_container.h"
9 #include "cc/base/cc_export.h"
10 #include "cc/tiles/picture_layer_tiling_set.h"
11 #include "cc/tiles/prioritized_tile.h"
12 #include "cc/tiles/tile.h"
13 #include "cc/tiles/tile_priority.h"
15 namespace cc {
17 // This queue returns all tiles required to be rasterized from HIGH_RESOLUTION
18 // and LOW_RESOLUTION tilings.
19 class CC_EXPORT TilingSetRasterQueueAll {
20 public:
21 TilingSetRasterQueueAll(PictureLayerTilingSet* tiling_set,
22 bool prioritize_low_res);
23 ~TilingSetRasterQueueAll();
25 const PrioritizedTile& Top() const;
26 void Pop();
27 bool IsEmpty() const;
29 private:
30 // Helper base class for individual region iterators.
31 class OnePriorityRectIterator {
32 public:
33 OnePriorityRectIterator();
34 OnePriorityRectIterator(
35 PictureLayerTiling* tiling,
36 TilingData* tiling_data,
37 PictureLayerTiling::PriorityRectType priority_rect_type);
39 bool done() const { return !current_tile_.tile(); }
40 const PrioritizedTile& operator*() const { return current_tile_; }
42 protected:
43 ~OnePriorityRectIterator() = default;
44 bool TileNeedsRaster(const Tile* tile) const {
45 return tile->draw_info().NeedsRaster() && !tiling_->IsTileOccluded(tile);
48 template <typename TilingIteratorType>
49 void AdvanceToNextTile(TilingIteratorType* iterator);
50 template <typename TilingIteratorType>
51 bool GetFirstTileAndCheckIfValid(TilingIteratorType* iterator);
52 bool IsTileValid(const Tile* tile) const;
54 PrioritizedTile current_tile_;
55 PictureLayerTiling* tiling_;
56 TilingData* tiling_data_;
57 PictureLayerTiling::PriorityRectType priority_rect_type_;
58 gfx::Rect pending_visible_rect_;
61 // Iterates over visible rect only, left to right top to bottom order.
62 class VisibleTilingIterator : public OnePriorityRectIterator {
63 public:
64 VisibleTilingIterator() = default;
65 VisibleTilingIterator(PictureLayerTiling* tiling, TilingData* tiling_data);
67 VisibleTilingIterator& operator++();
69 private:
70 TilingData::Iterator iterator_;
73 class PendingVisibleTilingIterator : public OnePriorityRectIterator {
74 public:
75 PendingVisibleTilingIterator() = default;
76 PendingVisibleTilingIterator(PictureLayerTiling* tiling,
77 TilingData* tiling_data);
79 PendingVisibleTilingIterator& operator++();
81 private:
82 TilingData::DifferenceIterator iterator_;
85 // Iterates over skewport only, spiral around the visible rect.
86 class SkewportTilingIterator : public OnePriorityRectIterator {
87 public:
88 SkewportTilingIterator() = default;
89 SkewportTilingIterator(PictureLayerTiling* tiling, TilingData* tiling_data);
91 SkewportTilingIterator& operator++();
93 private:
94 TilingData::SpiralDifferenceIterator iterator_;
97 // Iterates over soon border only, spiral around the visible rect.
98 class SoonBorderTilingIterator : public OnePriorityRectIterator {
99 public:
100 SoonBorderTilingIterator() = default;
101 SoonBorderTilingIterator(PictureLayerTiling* tiling,
102 TilingData* tiling_data);
104 SoonBorderTilingIterator& operator++();
106 private:
107 TilingData::SpiralDifferenceIterator iterator_;
110 // Iterates over eventually rect only, spiral around the soon rect.
111 class EventuallyTilingIterator : public OnePriorityRectIterator {
112 public:
113 EventuallyTilingIterator() = default;
114 EventuallyTilingIterator(PictureLayerTiling* tiling,
115 TilingData* tiling_data);
117 EventuallyTilingIterator& operator++();
119 private:
120 TilingData::SpiralDifferenceIterator iterator_;
123 // Iterates over all of the above phases in the following order: visible,
124 // skewport, soon border, eventually.
125 class TilingIterator {
126 public:
127 TilingIterator();
128 explicit TilingIterator(PictureLayerTiling* tiling,
129 TilingData* tiling_data);
130 ~TilingIterator();
132 bool done() const { return !current_tile_.tile(); }
133 const PrioritizedTile& operator*() const { return current_tile_; }
134 TilePriority::PriorityBin type() const {
135 switch (phase_) {
136 case Phase::VISIBLE_RECT:
137 return TilePriority::NOW;
138 case Phase::PENDING_VISIBLE_RECT:
139 case Phase::SKEWPORT_RECT:
140 case Phase::SOON_BORDER_RECT:
141 return TilePriority::SOON;
142 case Phase::EVENTUALLY_RECT:
143 return TilePriority::EVENTUALLY;
145 NOTREACHED();
146 return TilePriority::EVENTUALLY;
149 TilingIterator& operator++();
151 private:
152 using Phase = PictureLayerTiling::PriorityRectType;
154 void AdvancePhase();
156 PictureLayerTiling* tiling_;
157 TilingData* tiling_data_;
159 Phase phase_;
161 PrioritizedTile current_tile_;
162 VisibleTilingIterator visible_iterator_;
163 PendingVisibleTilingIterator pending_visible_iterator_;
164 SkewportTilingIterator skewport_iterator_;
165 SoonBorderTilingIterator soon_border_iterator_;
166 EventuallyTilingIterator eventually_iterator_;
169 enum IteratorType {
170 LOW_RES,
171 HIGH_RES,
172 ACTIVE_NON_IDEAL_PENDING_HIGH_RES,
173 NUM_ITERATORS
176 void MakeTilingIterator(IteratorType type, PictureLayerTiling* tiling);
177 void AdvanceToNextStage();
179 PictureLayerTilingSet* tiling_set_;
181 struct IterationStage {
182 IterationStage(IteratorType type, TilePriority::PriorityBin bin);
183 IteratorType iterator_type;
184 TilePriority::PriorityBin tile_type;
187 size_t current_stage_;
189 // The max number of stages is 6: 1 low res, 3 high res, and 2 active non
190 // ideal pending high res.
191 base::StackVector<IterationStage, 6> stages_;
192 TilingIterator iterators_[NUM_ITERATORS];
194 DISALLOW_COPY_AND_ASSIGN(TilingSetRasterQueueAll);
197 } // namespace cc
199 #endif // CC_TILES_TILING_SET_RASTER_QUEUE_ALL_H_