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_RASTER_TILE_PRIORITY_QUEUE_H_ | 5 #ifndef CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_ |
6 #define CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_ | 6 #define CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
13 #include "cc/layers/picture_layer_impl.h" | 13 #include "cc/layers/picture_layer_impl.h" |
14 #include "cc/resources/tile_priority.h" | 14 #include "cc/resources/tile_priority.h" |
15 #include "cc/resources/tiling_set_raster_queue.h" | 15 #include "cc/resources/tiling_set_raster_queue.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
| 19 // TODO(vmpstr): Consider virtualizing this and adding ::Create with the |
| 20 // parameters of ::Build that would create a simpler queue for required only |
| 21 // tiles (ie, there's no need for the heap if all we're interested in are the |
| 22 // required tiles. |
19 class CC_EXPORT RasterTilePriorityQueue { | 23 class CC_EXPORT RasterTilePriorityQueue { |
20 public: | 24 public: |
21 struct PairedTilingSetQueue { | 25 enum class Type { ALL, REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW }; |
| 26 |
| 27 class PairedTilingSetQueue { |
| 28 public: |
22 PairedTilingSetQueue(); | 29 PairedTilingSetQueue(); |
23 PairedTilingSetQueue(const PictureLayerImpl::Pair& layer_pair, | 30 PairedTilingSetQueue(const PictureLayerImpl::Pair& layer_pair, |
24 TreePriority tree_priority); | 31 TreePriority tree_priority, |
| 32 Type type); |
25 ~PairedTilingSetQueue(); | 33 ~PairedTilingSetQueue(); |
26 | 34 |
27 bool IsEmpty() const; | 35 bool IsEmpty() const; |
28 Tile* Top(TreePriority tree_priority); | 36 Tile* Top(TreePriority tree_priority); |
29 void Pop(TreePriority tree_priority); | 37 void Pop(TreePriority tree_priority); |
30 | 38 |
31 WhichTree NextTileIteratorTree(TreePriority tree_priority) const; | 39 WhichTree NextTileIteratorTree(TreePriority tree_priority) const; |
32 void SkipTilesReturnedByTwin(TreePriority tree_priority); | 40 void SkipTilesReturnedByTwin(TreePriority tree_priority); |
33 | 41 |
34 scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; | 42 scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; |
35 | 43 |
36 scoped_ptr<TilingSetRasterQueue> active_queue; | 44 const TilingSetRasterQueue* active_queue() const { |
37 scoped_ptr<TilingSetRasterQueue> pending_queue; | 45 return active_queue_.get(); |
38 bool has_both_layers; | 46 } |
| 47 const TilingSetRasterQueue* pending_queue() const { |
| 48 return pending_queue_.get(); |
| 49 } |
| 50 |
| 51 private: |
| 52 scoped_ptr<TilingSetRasterQueue> active_queue_; |
| 53 scoped_ptr<TilingSetRasterQueue> pending_queue_; |
| 54 bool has_both_layers_; |
39 | 55 |
40 // Set of returned tiles (excluding the current one) for DCHECKing. | 56 // Set of returned tiles (excluding the current one) for DCHECKing. |
41 std::set<const Tile*> returned_tiles_for_debug; | 57 std::set<const Tile*> returned_tiles_for_debug_; |
42 }; | 58 }; |
43 | 59 |
44 RasterTilePriorityQueue(); | 60 RasterTilePriorityQueue(); |
45 ~RasterTilePriorityQueue(); | 61 ~RasterTilePriorityQueue(); |
46 | 62 |
47 void Build(const std::vector<PictureLayerImpl::Pair>& paired_layers, | 63 void Build(const std::vector<PictureLayerImpl::Pair>& paired_layers, |
48 TreePriority tree_priority); | 64 TreePriority tree_priority, |
| 65 Type type); |
49 void Reset(); | 66 void Reset(); |
50 | 67 |
51 bool IsEmpty() const; | 68 bool IsEmpty() const; |
52 Tile* Top(); | 69 Tile* Top(); |
53 void Pop(); | 70 void Pop(); |
54 | 71 |
55 private: | 72 private: |
56 // TODO(vmpstr): This is potentially unnecessary if it becomes the case that | 73 // TODO(vmpstr): This is potentially unnecessary if it becomes the case that |
57 // PairedTilingSetQueue is fast enough to copy. In that case, we can use | 74 // PairedTilingSetQueue is fast enough to copy. In that case, we can use |
58 // objects directly (ie std::vector<PairedTilingSetQueue>. | 75 // objects directly (ie std::vector<PairedTilingSetQueue>. |
59 ScopedPtrVector<PairedTilingSetQueue> paired_queues_; | 76 ScopedPtrVector<PairedTilingSetQueue> paired_queues_; |
60 TreePriority tree_priority_; | 77 TreePriority tree_priority_; |
61 | 78 |
62 DISALLOW_COPY_AND_ASSIGN(RasterTilePriorityQueue); | 79 DISALLOW_COPY_AND_ASSIGN(RasterTilePriorityQueue); |
63 }; | 80 }; |
64 | 81 |
65 } // namespace cc | 82 } // namespace cc |
66 | 83 |
67 #endif // CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_ | 84 #endif // CC_RESOURCES_RASTER_TILE_PRIORITY_QUEUE_H_ |
OLD | NEW |