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"
15 // This queue returns all tiles required to be rasterized from HIGH_RESOLUTION
16 // and LOW_RESOLUTION tilings.
17 class CC_EXPORT TilingSetRasterQueueAll
{
19 TilingSetRasterQueueAll(PictureLayerTilingSet
* tiling_set
,
20 bool prioritize_low_res
);
21 ~TilingSetRasterQueueAll();
24 const Tile
* Top() const;
29 // Helper base class for individual region iterators.
30 class OnePriorityRectIterator
{
32 OnePriorityRectIterator();
33 OnePriorityRectIterator(PictureLayerTiling
* tiling
,
34 TilingData
* tiling_data
);
36 bool done() const { return !tile_
; }
37 Tile
* operator*() const { return tile_
; }
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
);
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
{
58 VisibleTilingIterator() = default;
59 VisibleTilingIterator(PictureLayerTiling
* tiling
, TilingData
* tiling_data
);
61 VisibleTilingIterator
& operator++();
64 TilingData::Iterator iterator_
;
67 // Iterates over skewport only, spiral around the visible rect.
68 class SkewportTilingIterator
: public OnePriorityRectIterator
{
70 SkewportTilingIterator() = default;
71 SkewportTilingIterator(PictureLayerTiling
* tiling
, TilingData
* tiling_data
);
73 SkewportTilingIterator
& operator++();
76 TilingData::SpiralDifferenceIterator iterator_
;
79 // Iterates over soon border only, spiral around the visible rect.
80 class SoonBorderTilingIterator
: public OnePriorityRectIterator
{
82 SoonBorderTilingIterator() = default;
83 SoonBorderTilingIterator(PictureLayerTiling
* tiling
,
84 TilingData
* tiling_data
);
86 SoonBorderTilingIterator
& operator++();
89 TilingData::SpiralDifferenceIterator iterator_
;
92 // Iterates over eventually rect only, spiral around the soon rect.
93 class EventuallyTilingIterator
: public OnePriorityRectIterator
{
95 EventuallyTilingIterator() = default;
96 EventuallyTilingIterator(PictureLayerTiling
* tiling
,
97 TilingData
* tiling_data
);
99 EventuallyTilingIterator
& operator++();
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
{
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 {
120 return TilePriority::NOW
;
122 case SOON_BORDER_RECT
:
123 return TilePriority::SOON
;
124 case EVENTUALLY_RECT
:
125 return TilePriority::EVENTUALLY
;
128 return TilePriority::EVENTUALLY
;
131 TilingIterator
& operator++();
143 PictureLayerTiling
* tiling_
;
144 TilingData
* tiling_data_
;
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
];
175 #endif // CC_RESOURCES_TILING_SET_RASTER_QUEUE_ALL_H_