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

Side by Side Diff: cc/resources/raster_tile_priority_queue_all.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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/raster_tile_priority_queue_all.h" 5 #include "cc/resources/raster_tile_priority_queue_all.h"
6 6
7 #include "cc/resources/tiling_set_raster_queue_all.h" 7 #include "cc/resources/tiling_set_raster_queue_all.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 namespace { 11 namespace {
12 12
13 class RasterOrderComparator { 13 class RasterOrderComparator {
14 public: 14 public:
15 explicit RasterOrderComparator(TreePriority tree_priority) 15 explicit RasterOrderComparator(TreePriority tree_priority)
16 : tree_priority_(tree_priority) {} 16 : tree_priority_(tree_priority) {}
17 17
18 bool operator()(const TilingSetRasterQueueAll* a_queue, 18 bool operator()(const TilingSetRasterQueueAll* a_queue,
19 const TilingSetRasterQueueAll* b_queue) const { 19 const TilingSetRasterQueueAll* b_queue) const {
20 // Note that in this function, we have to return true if and only if 20 // Note that in this function, we have to return true if and only if
21 // a is strictly lower priority than b. 21 // a is strictly lower priority than b.
22 const Tile* a_tile = a_queue->Top(); 22 const TilePriority& a_priority = a_queue->Top().priority();
23 const Tile* b_tile = b_queue->Top(); 23 const TilePriority& b_priority = b_queue->Top().priority();
24
25 const TilePriority& a_priority = a_tile->priority();
26 const TilePriority& b_priority = b_tile->priority();
27 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; 24 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY;
28 25
29 // If the bin is the same but the resolution is not, then the order will be 26 // If the bin is the same but the resolution is not, then the order will be
30 // determined by whether we prioritize low res or not. 27 // determined by whether we prioritize low res or not.
31 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile 28 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile
32 // class but instead produced by the iterators. 29 // class but instead produced by the iterators.
33 if (b_priority.priority_bin == a_priority.priority_bin && 30 if (b_priority.priority_bin == a_priority.priority_bin &&
34 b_priority.resolution != a_priority.resolution) { 31 b_priority.resolution != a_priority.resolution) {
35 // Non ideal resolution should be sorted lower than other resolutions. 32 // Non ideal resolution should be sorted lower than other resolutions.
36 if (a_priority.resolution == NON_IDEAL_RESOLUTION) 33 if (a_priority.resolution == NON_IDEAL_RESOLUTION)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 tree_priority_ = tree_priority; 84 tree_priority_ = tree_priority;
88 85
89 CreateTilingSetRasterQueues(active_layers, tree_priority_, &active_queues_); 86 CreateTilingSetRasterQueues(active_layers, tree_priority_, &active_queues_);
90 CreateTilingSetRasterQueues(pending_layers, tree_priority_, &pending_queues_); 87 CreateTilingSetRasterQueues(pending_layers, tree_priority_, &pending_queues_);
91 } 88 }
92 89
93 bool RasterTilePriorityQueueAll::IsEmpty() const { 90 bool RasterTilePriorityQueueAll::IsEmpty() const {
94 return active_queues_.empty() && pending_queues_.empty(); 91 return active_queues_.empty() && pending_queues_.empty();
95 } 92 }
96 93
97 Tile* RasterTilePriorityQueueAll::Top() { 94 const PrioritizedTile& RasterTilePriorityQueueAll::Top() const {
98 DCHECK(!IsEmpty()); 95 DCHECK(!IsEmpty());
99 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues(); 96 const ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues();
100 return next_queues.front()->Top(); 97 return next_queues.front()->Top();
101 } 98 }
102 99
103 void RasterTilePriorityQueueAll::Pop() { 100 void RasterTilePriorityQueueAll::Pop() {
104 DCHECK(!IsEmpty()); 101 DCHECK(!IsEmpty());
105 102
106 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues(); 103 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues();
107 next_queues.pop_heap(RasterOrderComparator(tree_priority_)); 104 next_queues.pop_heap(RasterOrderComparator(tree_priority_));
108 TilingSetRasterQueueAll* queue = next_queues.back(); 105 TilingSetRasterQueueAll* queue = next_queues.back();
109 queue->Pop(); 106 queue->Pop();
110 107
111 // Remove empty queues. 108 // Remove empty queues.
112 if (queue->IsEmpty()) 109 if (queue->IsEmpty())
113 next_queues.pop_back(); 110 next_queues.pop_back();
114 else 111 else
115 next_queues.push_heap(RasterOrderComparator(tree_priority_)); 112 next_queues.push_heap(RasterOrderComparator(tree_priority_));
116 } 113 }
117 114
118 ScopedPtrVector<TilingSetRasterQueueAll>& 115 ScopedPtrVector<TilingSetRasterQueueAll>&
119 RasterTilePriorityQueueAll::GetNextQueues() { 116 RasterTilePriorityQueueAll::GetNextQueues() {
117 return const_cast<ScopedPtrVector<TilingSetRasterQueueAll>&>(
118 static_cast<const RasterTilePriorityQueueAll*>(this)->GetNextQueues());
119 }
120
121 const ScopedPtrVector<TilingSetRasterQueueAll>&
122 RasterTilePriorityQueueAll::GetNextQueues() const {
120 DCHECK(!IsEmpty()); 123 DCHECK(!IsEmpty());
121 124
122 // If we only have one queue with tiles, return it. 125 // If we only have one queue with tiles, return it.
123 if (active_queues_.empty()) 126 if (active_queues_.empty())
124 return pending_queues_; 127 return pending_queues_;
125 if (pending_queues_.empty()) 128 if (pending_queues_.empty())
126 return active_queues_; 129 return active_queues_;
127 130
128 const Tile* active_tile = active_queues_.front()->Top(); 131 const PrioritizedTile& active_tile = active_queues_.front()->Top();
129 const Tile* pending_tile = pending_queues_.front()->Top(); 132 const PrioritizedTile& pending_tile = pending_queues_.front()->Top();
130 133
131 const TilePriority& active_priority = active_tile->priority(); 134 const TilePriority& active_priority = active_tile.priority();
132 const TilePriority& pending_priority = pending_tile->priority(); 135 const TilePriority& pending_priority = pending_tile.priority();
133 136
134 switch (tree_priority_) { 137 switch (tree_priority_) {
135 case SMOOTHNESS_TAKES_PRIORITY: { 138 case SMOOTHNESS_TAKES_PRIORITY: {
136 // If we're down to eventually bin tiles on the active tree, process the 139 // If we're down to eventually bin tiles on the active tree, process the
137 // pending tree to allow tiles required for activation to be initialized 140 // pending tree to allow tiles required for activation to be initialized
138 // when memory policy only allows prepaint. 141 // when memory policy only allows prepaint.
139 if (active_priority.priority_bin == TilePriority::EVENTUALLY && 142 if (active_priority.priority_bin == TilePriority::EVENTUALLY &&
140 pending_priority.priority_bin == TilePriority::NOW) { 143 pending_priority.priority_bin == TilePriority::NOW) {
141 return pending_queues_; 144 return pending_queues_;
142 } 145 }
(...skipping 15 matching lines...) Expand all
158 return active_queues_; 161 return active_queues_;
159 return pending_queues_; 162 return pending_queues_;
160 } 163 }
161 default: 164 default:
162 NOTREACHED(); 165 NOTREACHED();
163 return active_queues_; 166 return active_queues_;
164 } 167 }
165 } 168 }
166 169
167 } // namespace cc 170 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/raster_tile_priority_queue_all.h ('k') | cc/resources/raster_tile_priority_queue_required.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698