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_RASTER_QUEUE_H_ | 5 #ifndef CC_RESOURCES_TILING_SET_RASTER_QUEUE_H_ |
6 #define CC_RESOURCES_TILING_SET_RASTER_QUEUE_H_ | 6 #define CC_RESOURCES_TILING_SET_RASTER_QUEUE_H_ |
7 | 7 |
8 #include "cc/base/cc_export.h" | 8 namespace cc { |
9 #include "cc/resources/picture_layer_tiling_set.h" | 9 class Tile; |
10 #include "cc/resources/tile.h" | |
11 #include "cc/resources/tile_priority.h" | |
12 | 10 |
13 namespace cc { | 11 class TilingSetRasterQueue { |
| 12 public: |
| 13 virtual ~TilingSetRasterQueue() {} |
14 | 14 |
15 class CC_EXPORT TilingSetRasterQueue { | 15 virtual Tile* Top() = 0; |
16 public: | 16 virtual const Tile* Top() const = 0; |
17 TilingSetRasterQueue(); | 17 virtual void Pop() = 0; |
18 TilingSetRasterQueue(PictureLayerTilingSet* tiling_set, | 18 virtual bool IsEmpty() const = 0; |
19 bool prioritize_low_res); | |
20 ~TilingSetRasterQueue(); | |
21 | |
22 Tile* Top(); | |
23 const Tile* Top() const; | |
24 void Pop(); | |
25 bool IsEmpty() const; | |
26 | |
27 private: | |
28 class TilingIterator { | |
29 public: | |
30 TilingIterator(); | |
31 explicit TilingIterator(PictureLayerTiling* tiling, | |
32 TilingData* tiling_data); | |
33 ~TilingIterator(); | |
34 | |
35 operator bool() const { return !!current_tile_; } | |
36 const Tile* operator*() const { return current_tile_; } | |
37 Tile* operator*() { return current_tile_; } | |
38 TilePriority::PriorityBin type() const { | |
39 switch (phase_) { | |
40 case VISIBLE_RECT: | |
41 return TilePriority::NOW; | |
42 case SKEWPORT_RECT: | |
43 case SOON_BORDER_RECT: | |
44 return TilePriority::SOON; | |
45 case EVENTUALLY_RECT: | |
46 return TilePriority::EVENTUALLY; | |
47 } | |
48 NOTREACHED(); | |
49 return TilePriority::EVENTUALLY; | |
50 } | |
51 | |
52 TilingIterator& operator++(); | |
53 | |
54 private: | |
55 enum Phase { | |
56 VISIBLE_RECT, | |
57 SKEWPORT_RECT, | |
58 SOON_BORDER_RECT, | |
59 EVENTUALLY_RECT | |
60 }; | |
61 | |
62 void AdvancePhase(); | |
63 bool TileNeedsRaster(Tile* tile) const { | |
64 return tile->NeedsRaster() && !tiling_->IsTileOccluded(tile); | |
65 } | |
66 | |
67 PictureLayerTiling* tiling_; | |
68 TilingData* tiling_data_; | |
69 | |
70 Phase phase_; | |
71 | |
72 Tile* current_tile_; | |
73 TilingData::Iterator visible_iterator_; | |
74 TilingData::SpiralDifferenceIterator spiral_iterator_; | |
75 }; | |
76 | |
77 enum IteratorType { LOW_RES, HIGH_RES, NUM_ITERATORS }; | |
78 | |
79 void AdvanceToNextStage(); | |
80 | |
81 PictureLayerTilingSet* tiling_set_; | |
82 | |
83 struct IterationStage { | |
84 IteratorType iterator_type; | |
85 TilePriority::PriorityBin tile_type; | |
86 }; | |
87 | |
88 size_t current_stage_; | |
89 | |
90 // One low res stage, and three high res stages. | |
91 IterationStage stages_[4]; | |
92 TilingIterator iterators_[NUM_ITERATORS]; | |
93 }; | 19 }; |
94 | 20 |
95 } // namespace cc | 21 } // namespace cc |
96 | 22 |
97 #endif // CC_RESOURCES_TILING_SET_RASTER_QUEUE_H_ | 23 #endif // CC_RESOURCES_TILING_SET_RASTER_QUEUE_H_ |
OLD | NEW |