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_EVICTION_TILE_PRIORITY_QUEUE_H_ | 5 #ifndef CC_RESOURCES_EVICTION_TILE_PRIORITY_QUEUE_H_ |
6 #define CC_RESOURCES_EVICTION_TILE_PRIORITY_QUEUE_H_ | 6 #define CC_RESOURCES_EVICTION_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 "base/containers/hash_tables.h" |
12 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
13 #include "cc/layers/picture_layer_impl.h" | 14 #include "cc/layers/picture_layer_impl.h" |
14 #include "cc/resources/tile_priority.h" | 15 #include "cc/resources/tile_priority.h" |
15 #include "cc/resources/tiling_set_eviction_queue.h" | 16 #include "cc/resources/tiling_set_eviction_queue.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 class CC_EXPORT EvictionTilePriorityQueue { | 20 class CC_EXPORT EvictionTilePriorityQueue { |
20 public: | 21 public: |
21 struct PairedTilingSetQueue { | 22 struct PairedTilingSetQueue { |
22 PairedTilingSetQueue(); | 23 PairedTilingSetQueue(); |
23 PairedTilingSetQueue(const PictureLayerImpl::Pair& layer_pair, | 24 PairedTilingSetQueue(PictureLayerTilingSet* active_set, |
| 25 PictureLayerTilingSet* pending_set, |
24 TreePriority tree_priority); | 26 TreePriority tree_priority); |
25 ~PairedTilingSetQueue(); | 27 ~PairedTilingSetQueue(); |
26 | 28 |
27 bool IsEmpty() const; | 29 bool IsEmpty() const; |
28 Tile* Top(TreePriority tree_priority); | 30 Tile* Top(TreePriority tree_priority); |
29 void Pop(TreePriority tree_priority); | 31 void Pop(TreePriority tree_priority); |
30 | 32 |
31 WhichTree NextTileIteratorTree(TreePriority tree_priority) const; | 33 WhichTree NextTileIteratorTree(TreePriority tree_priority) const; |
32 | 34 |
33 scoped_ptr<TilingSetEvictionQueue> active_queue; | 35 scoped_ptr<TilingSetEvictionQueue> active_queue; |
34 scoped_ptr<TilingSetEvictionQueue> pending_queue; | 36 scoped_ptr<TilingSetEvictionQueue> pending_queue; |
35 | 37 |
36 // Set of returned tiles (excluding the current one) for DCHECKing. | 38 // Set of returned tiles (excluding the current one) for DCHECKing. |
37 std::set<const Tile*> returned_tiles_for_debug; | 39 std::set<const Tile*> returned_tiles_for_debug; |
38 }; | 40 }; |
39 | 41 |
40 EvictionTilePriorityQueue(); | 42 static scoped_ptr<EvictionTilePriorityQueue> Create( |
| 43 const base::hash_map<int, PictureLayerTilingSet::Pair>& |
| 44 paired_picture_layer_tiling_sets, |
| 45 bool has_pending_tree, |
| 46 TreePriority tree_priority); |
| 47 |
41 ~EvictionTilePriorityQueue(); | 48 ~EvictionTilePriorityQueue(); |
42 | 49 |
43 void Build(const std::vector<PictureLayerImpl::Pair>& paired_layers, | |
44 TreePriority tree_priority); | |
45 | |
46 bool IsEmpty() const; | 50 bool IsEmpty() const; |
47 Tile* Top(); | 51 Tile* Top(); |
48 void Pop(); | 52 void Pop(); |
49 | 53 |
50 private: | 54 private: |
| 55 EvictionTilePriorityQueue(); |
| 56 |
| 57 void Build(const base::hash_map<int, PictureLayerTilingSet::Pair>& |
| 58 paired_picture_layer_tiling_sets, |
| 59 bool has_pending_tree, |
| 60 TreePriority tree_priority); |
| 61 |
51 // TODO(vmpstr): This is potentially unnecessary if it becomes the case that | 62 // TODO(vmpstr): This is potentially unnecessary if it becomes the case that |
52 // PairedTilingSetQueue is fast enough to copy. In that case, we can use | 63 // PairedTilingSetQueue is fast enough to copy. In that case, we can use |
53 // objects directly (ie std::vector<PairedTilingSetQueue>). | 64 // objects directly (ie std::vector<PairedTilingSetQueue>). |
54 ScopedPtrVector<PairedTilingSetQueue> paired_queues_; | 65 ScopedPtrVector<PairedTilingSetQueue> paired_queues_; |
55 TreePriority tree_priority_; | 66 TreePriority tree_priority_; |
56 | 67 |
57 DISALLOW_COPY_AND_ASSIGN(EvictionTilePriorityQueue); | 68 DISALLOW_COPY_AND_ASSIGN(EvictionTilePriorityQueue); |
58 }; | 69 }; |
59 | 70 |
60 } // namespace cc | 71 } // namespace cc |
61 | 72 |
62 #endif // CC_RESOURCES_EVICTION_TILE_PRIORITY_QUEUE_H_ | 73 #endif // CC_RESOURCES_EVICTION_TILE_PRIORITY_QUEUE_H_ |
OLD | NEW |