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

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

Issue 1130123003: cc: Separate the priority from the tile and put in new PrioritizedTile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 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 namespace cc { 7 namespace cc {
8 8
9 namespace { 9 namespace {
10 10
11 class EvictionOrderComparator { 11 class EvictionOrderComparator {
12 public: 12 public:
13 explicit EvictionOrderComparator(TreePriority tree_priority) 13 explicit EvictionOrderComparator(TreePriority tree_priority)
14 : tree_priority_(tree_priority) {} 14 : tree_priority_(tree_priority) {}
15 15
16 bool operator()(const TilingSetEvictionQueue* a_queue, 16 bool operator()(const TilingSetEvictionQueue* a_queue,
17 const TilingSetEvictionQueue* b_queue) const { 17 const TilingSetEvictionQueue* b_queue) const {
18 // Note that in this function, we have to return true if and only if 18 // Note that in this function, we have to return true if and only if
19 // b is strictly lower priority than a. 19 // b is strictly lower priority than a.
20 const Tile* a_tile = a_queue->Top(); 20 const PrioritizedTile& a_tile = a_queue->Top();
21 const Tile* b_tile = b_queue->Top(); 21 const PrioritizedTile& b_tile = b_queue->Top();
22 22
23 const TilePriority& a_priority = a_tile->priority(); 23 const TilePriority& a_priority = a_tile.priority();
24 const TilePriority& b_priority = b_tile->priority(); 24 const TilePriority& b_priority = b_tile.priority();
25 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; 25 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY;
26 26
27 // If the priority bin differs, b is lower priority if it has the higher 27 // If the priority bin differs, b is lower priority if it has the higher
28 // priority bin. 28 // priority bin.
29 if (a_priority.priority_bin != b_priority.priority_bin) 29 if (a_priority.priority_bin != b_priority.priority_bin)
30 return b_priority.priority_bin > a_priority.priority_bin; 30 return b_priority.priority_bin > a_priority.priority_bin;
31 31
32 // Otherwise if the resolution differs, then the order will be determined by 32 // Otherwise if the resolution differs, then the order will be determined by
33 // whether we prioritize low res or not. 33 // whether we prioritize low res or not.
34 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile 34 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile
35 // class but instead produced by the iterators. 35 // class but instead produced by the iterators.
36 if (b_priority.resolution != a_priority.resolution) { 36 if (b_priority.resolution != a_priority.resolution) {
37 // Non ideal resolution should be sorted higher than other resolutions. 37 // Non ideal resolution should be sorted higher than other resolutions.
38 if (a_priority.resolution == NON_IDEAL_RESOLUTION) 38 if (a_priority.resolution == NON_IDEAL_RESOLUTION)
39 return false; 39 return false;
40 40
41 if (b_priority.resolution == NON_IDEAL_RESOLUTION) 41 if (b_priority.resolution == NON_IDEAL_RESOLUTION)
42 return true; 42 return true;
43 43
44 if (prioritize_low_res) 44 if (prioritize_low_res)
45 return a_priority.resolution == LOW_RESOLUTION; 45 return a_priority.resolution == LOW_RESOLUTION;
46 return a_priority.resolution == HIGH_RESOLUTION; 46 return a_priority.resolution == HIGH_RESOLUTION;
47 } 47 }
48 48
49 // Otherwise if the occlusion differs, b is lower priority if it is 49 // Otherwise if the occlusion differs, b is lower priority if it is
50 // occluded. 50 // occluded.
51 bool a_is_occluded = a_tile->is_occluded(); 51 bool a_is_occluded = a_tile.is_occluded();
52 bool b_is_occluded = b_tile->is_occluded(); 52 bool b_is_occluded = b_tile.is_occluded();
53 if (a_is_occluded != b_is_occluded) 53 if (a_is_occluded != b_is_occluded)
54 return b_is_occluded; 54 return b_is_occluded;
55 55
56 // b is lower priorty if it is farther from visible. 56 // b is lower priorty if it is farther from visible.
57 return b_priority.distance_to_visible > a_priority.distance_to_visible; 57 return b_priority.distance_to_visible > a_priority.distance_to_visible;
58 } 58 }
59 59
60 private: 60 private:
61 TreePriority tree_priority_; 61 TreePriority tree_priority_;
62 }; 62 };
(...skipping 30 matching lines...) Expand all
93 93
94 CreateTilingSetEvictionQueues(active_layers, tree_priority, &active_queues_); 94 CreateTilingSetEvictionQueues(active_layers, tree_priority, &active_queues_);
95 CreateTilingSetEvictionQueues(pending_layers, tree_priority, 95 CreateTilingSetEvictionQueues(pending_layers, tree_priority,
96 &pending_queues_); 96 &pending_queues_);
97 } 97 }
98 98
99 bool EvictionTilePriorityQueue::IsEmpty() const { 99 bool EvictionTilePriorityQueue::IsEmpty() const {
100 return active_queues_.empty() && pending_queues_.empty(); 100 return active_queues_.empty() && pending_queues_.empty();
101 } 101 }
102 102
103 Tile* EvictionTilePriorityQueue::Top() { 103 const PrioritizedTile& EvictionTilePriorityQueue::Top() const {
104 DCHECK(!IsEmpty()); 104 DCHECK(!IsEmpty());
105 ScopedPtrVector<TilingSetEvictionQueue>& next_queues = GetNextQueues(); 105 const ScopedPtrVector<TilingSetEvictionQueue>& next_queues = GetNextQueues();
106 return next_queues.front()->Top(); 106 return next_queues.front()->Top();
107 } 107 }
108 108
109 void EvictionTilePriorityQueue::Pop() { 109 void EvictionTilePriorityQueue::Pop() {
110 DCHECK(!IsEmpty()); 110 DCHECK(!IsEmpty());
111 111
112 ScopedPtrVector<TilingSetEvictionQueue>& next_queues = GetNextQueues(); 112 ScopedPtrVector<TilingSetEvictionQueue>& next_queues = GetNextQueues();
113 next_queues.pop_heap(EvictionOrderComparator(tree_priority_)); 113 next_queues.pop_heap(EvictionOrderComparator(tree_priority_));
114 TilingSetEvictionQueue* queue = next_queues.back(); 114 TilingSetEvictionQueue* queue = next_queues.back();
115 queue->Pop(); 115 queue->Pop();
116 116
117 // Remove empty queues. 117 // Remove empty queues.
118 if (queue->IsEmpty()) 118 if (queue->IsEmpty())
119 next_queues.pop_back(); 119 next_queues.pop_back();
120 else 120 else
121 next_queues.push_heap(EvictionOrderComparator(tree_priority_)); 121 next_queues.push_heap(EvictionOrderComparator(tree_priority_));
122 } 122 }
123 123
124 ScopedPtrVector<TilingSetEvictionQueue>& 124 ScopedPtrVector<TilingSetEvictionQueue>&
125 EvictionTilePriorityQueue::GetNextQueues() { 125 EvictionTilePriorityQueue::GetNextQueues() {
126 return const_cast<ScopedPtrVector<TilingSetEvictionQueue>&>(
127 static_cast<const EvictionTilePriorityQueue*>(this)->GetNextQueues());
128 }
129
130 const ScopedPtrVector<TilingSetEvictionQueue>&
131 EvictionTilePriorityQueue::GetNextQueues() const {
126 DCHECK(!IsEmpty()); 132 DCHECK(!IsEmpty());
127 133
128 // If we only have one queue with tiles, return it. 134 // If we only have one queue with tiles, return it.
129 if (active_queues_.empty()) 135 if (active_queues_.empty())
130 return pending_queues_; 136 return pending_queues_;
131 if (pending_queues_.empty()) 137 if (pending_queues_.empty())
132 return active_queues_; 138 return active_queues_;
133 139
134 const Tile* active_tile = active_queues_.front()->Top(); 140 const PrioritizedTile& active_tile = active_queues_.front()->Top();
135 const Tile* pending_tile = pending_queues_.front()->Top(); 141 const PrioritizedTile& pending_tile = pending_queues_.front()->Top();
136 142
137 const TilePriority& active_priority = active_tile->priority(); 143 const TilePriority& active_priority = active_tile.priority();
138 const TilePriority& pending_priority = pending_tile->priority(); 144 const TilePriority& pending_priority = pending_tile.priority();
139 145
140 // If the bins are the same and activation differs, then return the tree of 146 // If the bins are the same and activation differs, then return the tree of
141 // the tile not required for activation. 147 // the tile not required for activation.
142 if (active_priority.priority_bin == pending_priority.priority_bin && 148 if (active_priority.priority_bin == pending_priority.priority_bin &&
143 active_tile->required_for_activation() != 149 active_tile.tile()->required_for_activation() !=
144 pending_tile->required_for_activation()) { 150 pending_tile.tile()->required_for_activation()) {
145 return active_tile->required_for_activation() ? pending_queues_ 151 return active_tile.tile()->required_for_activation() ? pending_queues_
146 : active_queues_; 152 : active_queues_;
147 } 153 }
148 154
149 // Return tile with a lower priority. 155 // Return tile with a lower priority.
150 if (pending_priority.IsHigherPriorityThan(active_priority)) 156 if (pending_priority.IsHigherPriorityThan(active_priority))
151 return active_queues_; 157 return active_queues_;
152 return pending_queues_; 158 return pending_queues_;
153 } 159 }
154 160
155 } // namespace cc 161 } // 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