Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: cc/resources/eviction_tile_priority_queue.cc

Issue 900073003: cc: Rework how picture layer tiling set gets into raster queues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/eviction_tile_priority_queue.h ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "cc/resources/eviction_tile_priority_queue.h" 5 #include "cc/resources/eviction_tile_priority_queue.h"
6 6
7 #include "base/containers/hash_tables.h"
8
7 namespace cc { 9 namespace cc {
8 10
9 namespace { 11 namespace {
10 12
11 class EvictionOrderComparator { 13 class EvictionOrderComparator {
12 public: 14 public:
13 explicit EvictionOrderComparator(TreePriority tree_priority) 15 explicit EvictionOrderComparator(TreePriority tree_priority)
14 : tree_priority_(tree_priority) {} 16 : tree_priority_(tree_priority) {}
15 17
16 bool operator()( 18 bool operator()(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // b is lower priorty if it is farther from visible. 73 // b is lower priorty if it is farther from visible.
72 return b_priority.distance_to_visible > a_priority.distance_to_visible; 74 return b_priority.distance_to_visible > a_priority.distance_to_visible;
73 } 75 }
74 76
75 private: 77 private:
76 TreePriority tree_priority_; 78 TreePriority tree_priority_;
77 }; 79 };
78 80
79 } // namespace 81 } // namespace
80 82
83 // static
84 scoped_ptr<EvictionTilePriorityQueue> EvictionTilePriorityQueue::Create(
85 const base::hash_map<int, PictureLayerTilingSet::Pair>&
86 paired_picture_layer_tiling_sets,
87 bool has_pending_tree,
88 TreePriority tree_priority) {
89 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue);
90 queue->Build(paired_picture_layer_tiling_sets, has_pending_tree,
91 tree_priority);
92 return queue;
93 }
94
81 EvictionTilePriorityQueue::EvictionTilePriorityQueue() { 95 EvictionTilePriorityQueue::EvictionTilePriorityQueue() {
82 } 96 }
83 97
84 EvictionTilePriorityQueue::~EvictionTilePriorityQueue() { 98 EvictionTilePriorityQueue::~EvictionTilePriorityQueue() {
85 } 99 }
86 100
87 void EvictionTilePriorityQueue::Build( 101 void EvictionTilePriorityQueue::Build(
88 const std::vector<PictureLayerImpl::Pair>& paired_layers, 102 const base::hash_map<int, PictureLayerTilingSet::Pair>&
103 paired_picture_layer_tiling_sets,
104 bool has_pending_tree,
89 TreePriority tree_priority) { 105 TreePriority tree_priority) {
90 tree_priority_ = tree_priority; 106 tree_priority_ = tree_priority;
91 107
92 for (std::vector<PictureLayerImpl::Pair>::const_iterator it = 108 for (const auto& paired_tiling_set_pair : paired_picture_layer_tiling_sets) {
93 paired_layers.begin(); 109 const auto& paired_tiling_set = paired_tiling_set_pair.second;
94 it != paired_layers.end(); 110 PictureLayerTilingSet* active = paired_tiling_set.active;
95 ++it) { 111 PictureLayerTilingSet* pending =
96 paired_queues_.push_back( 112 has_pending_tree ? paired_tiling_set.pending : nullptr;
97 make_scoped_ptr(new PairedTilingSetQueue(*it, tree_priority_))); 113 paired_queues_.push_back(make_scoped_ptr(
114 new PairedTilingSetQueue(active, pending, tree_priority_)));
98 } 115 }
99 116
100 paired_queues_.make_heap(EvictionOrderComparator(tree_priority_)); 117 paired_queues_.make_heap(EvictionOrderComparator(tree_priority_));
101 } 118 }
102 119
103 bool EvictionTilePriorityQueue::IsEmpty() const { 120 bool EvictionTilePriorityQueue::IsEmpty() const {
104 return paired_queues_.empty() || paired_queues_.front()->IsEmpty(); 121 return paired_queues_.empty() || paired_queues_.front()->IsEmpty();
105 } 122 }
106 123
107 Tile* EvictionTilePriorityQueue::Top() { 124 Tile* EvictionTilePriorityQueue::Top() {
108 DCHECK(!IsEmpty()); 125 DCHECK(!IsEmpty());
109 return paired_queues_.front()->Top(tree_priority_); 126 return paired_queues_.front()->Top(tree_priority_);
110 } 127 }
111 128
112 void EvictionTilePriorityQueue::Pop() { 129 void EvictionTilePriorityQueue::Pop() {
113 DCHECK(!IsEmpty()); 130 DCHECK(!IsEmpty());
114 131
115 paired_queues_.pop_heap(EvictionOrderComparator(tree_priority_)); 132 paired_queues_.pop_heap(EvictionOrderComparator(tree_priority_));
116 PairedTilingSetQueue* paired_queue = paired_queues_.back(); 133 PairedTilingSetQueue* paired_queue = paired_queues_.back();
117 paired_queue->Pop(tree_priority_); 134 paired_queue->Pop(tree_priority_);
118 paired_queues_.push_heap(EvictionOrderComparator(tree_priority_)); 135 paired_queues_.push_heap(EvictionOrderComparator(tree_priority_));
119 } 136 }
120 137
121 EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue() { 138 EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue() {
122 } 139 }
123 140
124 EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue( 141 EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue(
125 const PictureLayerImpl::Pair& layer_pair, 142 PictureLayerTilingSet* active_set,
143 PictureLayerTilingSet* pending_set,
126 TreePriority tree_priority) { 144 TreePriority tree_priority) {
127 bool skip_shared_out_of_order_tiles = layer_pair.active && layer_pair.pending; 145 bool skip_shared_out_of_order_tiles = active_set && pending_set;
128 if (layer_pair.active) { 146 if (active_set) {
129 active_queue = make_scoped_ptr(new TilingSetEvictionQueue( 147 active_queue = make_scoped_ptr(new TilingSetEvictionQueue(
130 layer_pair.active->picture_layer_tiling_set(), tree_priority, 148 active_set, tree_priority, skip_shared_out_of_order_tiles));
131 skip_shared_out_of_order_tiles));
132 } 149 }
133 if (layer_pair.pending) { 150 if (pending_set) {
134 pending_queue = make_scoped_ptr(new TilingSetEvictionQueue( 151 pending_queue = make_scoped_ptr(new TilingSetEvictionQueue(
135 layer_pair.pending->picture_layer_tiling_set(), tree_priority, 152 pending_set, tree_priority, skip_shared_out_of_order_tiles));
136 skip_shared_out_of_order_tiles));
137 } 153 }
138 } 154 }
139 155
140 EvictionTilePriorityQueue::PairedTilingSetQueue::~PairedTilingSetQueue() { 156 EvictionTilePriorityQueue::PairedTilingSetQueue::~PairedTilingSetQueue() {
141 } 157 }
142 158
143 bool EvictionTilePriorityQueue::PairedTilingSetQueue::IsEmpty() const { 159 bool EvictionTilePriorityQueue::PairedTilingSetQueue::IsEmpty() const {
144 return (!active_queue || active_queue->IsEmpty()) && 160 return (!active_queue || active_queue->IsEmpty()) &&
145 (!pending_queue || pending_queue->IsEmpty()); 161 (!pending_queue || pending_queue->IsEmpty());
146 } 162 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE; 221 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE;
206 } 222 }
207 223
208 // Return tile with a lower priority. 224 // Return tile with a lower priority.
209 if (pending_priority.IsHigherPriorityThan(active_priority)) 225 if (pending_priority.IsHigherPriorityThan(active_priority))
210 return ACTIVE_TREE; 226 return ACTIVE_TREE;
211 return PENDING_TREE; 227 return PENDING_TREE;
212 } 228 }
213 229
214 } // namespace cc 230 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/eviction_tile_priority_queue.h ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698