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

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: Tile too friendly, lets fix that 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 tree_priority_ = tree_priority; 81 tree_priority_ = tree_priority;
85 82
86 CreateTilingSetRasterQueues(active_layers, tree_priority_, &active_queues_); 83 CreateTilingSetRasterQueues(active_layers, tree_priority_, &active_queues_);
87 CreateTilingSetRasterQueues(pending_layers, tree_priority_, &pending_queues_); 84 CreateTilingSetRasterQueues(pending_layers, tree_priority_, &pending_queues_);
88 } 85 }
89 86
90 bool RasterTilePriorityQueueAll::IsEmpty() const { 87 bool RasterTilePriorityQueueAll::IsEmpty() const {
91 return active_queues_.empty() && pending_queues_.empty(); 88 return active_queues_.empty() && pending_queues_.empty();
92 } 89 }
93 90
94 Tile* RasterTilePriorityQueueAll::Top() { 91 const PrioritizedTile& RasterTilePriorityQueueAll::Top() const {
95 DCHECK(!IsEmpty()); 92 DCHECK(!IsEmpty());
96 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues(); 93 const ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues();
97 return next_queues.front()->Top(); 94 return next_queues.front()->Top();
98 } 95 }
99 96
100 void RasterTilePriorityQueueAll::Pop() { 97 void RasterTilePriorityQueueAll::Pop() {
101 DCHECK(!IsEmpty()); 98 DCHECK(!IsEmpty());
102 99
103 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues(); 100 ScopedPtrVector<TilingSetRasterQueueAll>& next_queues = GetNextQueues();
104 next_queues.pop_heap(RasterOrderComparator(tree_priority_)); 101 next_queues.pop_heap(RasterOrderComparator(tree_priority_));
105 TilingSetRasterQueueAll* queue = next_queues.back(); 102 TilingSetRasterQueueAll* queue = next_queues.back();
106 queue->Pop(); 103 queue->Pop();
107 104
108 // Remove empty queues. 105 // Remove empty queues.
109 if (queue->IsEmpty()) 106 if (queue->IsEmpty())
110 next_queues.pop_back(); 107 next_queues.pop_back();
111 else 108 else
112 next_queues.push_heap(RasterOrderComparator(tree_priority_)); 109 next_queues.push_heap(RasterOrderComparator(tree_priority_));
113 } 110 }
114 111
115 ScopedPtrVector<TilingSetRasterQueueAll>& 112 ScopedPtrVector<TilingSetRasterQueueAll>&
116 RasterTilePriorityQueueAll::GetNextQueues() { 113 RasterTilePriorityQueueAll::GetNextQueues() {
114 return const_cast<ScopedPtrVector<TilingSetRasterQueueAll>&>(
115 static_cast<const RasterTilePriorityQueueAll*>(this)->GetNextQueues());
116 }
117
118 const ScopedPtrVector<TilingSetRasterQueueAll>&
119 RasterTilePriorityQueueAll::GetNextQueues() const {
117 DCHECK(!IsEmpty()); 120 DCHECK(!IsEmpty());
118 121
119 // If we only have one queue with tiles, return it. 122 // If we only have one queue with tiles, return it.
120 if (active_queues_.empty()) 123 if (active_queues_.empty())
121 return pending_queues_; 124 return pending_queues_;
122 if (pending_queues_.empty()) 125 if (pending_queues_.empty())
123 return active_queues_; 126 return active_queues_;
124 127
125 const Tile* active_tile = active_queues_.front()->Top(); 128 const PrioritizedTile& active_tile = active_queues_.front()->Top();
126 const Tile* pending_tile = pending_queues_.front()->Top(); 129 const PrioritizedTile& pending_tile = pending_queues_.front()->Top();
127 130
128 const TilePriority& active_priority = active_tile->priority(); 131 const TilePriority& active_priority = active_tile.priority();
129 const TilePriority& pending_priority = pending_tile->priority(); 132 const TilePriority& pending_priority = pending_tile.priority();
130 133
131 switch (tree_priority_) { 134 switch (tree_priority_) {
132 case SMOOTHNESS_TAKES_PRIORITY: { 135 case SMOOTHNESS_TAKES_PRIORITY: {
133 // If we're down to eventually bin tiles on the active tree, process the 136 // If we're down to eventually bin tiles on the active tree, process the
134 // pending tree to allow tiles required for activation to be initialized 137 // pending tree to allow tiles required for activation to be initialized
135 // when memory policy only allows prepaint. 138 // when memory policy only allows prepaint.
136 if (active_priority.priority_bin == TilePriority::EVENTUALLY && 139 if (active_priority.priority_bin == TilePriority::EVENTUALLY &&
137 pending_priority.priority_bin == TilePriority::NOW) { 140 pending_priority.priority_bin == TilePriority::NOW) {
138 return pending_queues_; 141 return pending_queues_;
139 } 142 }
(...skipping 15 matching lines...) Expand all
155 return active_queues_; 158 return active_queues_;
156 return pending_queues_; 159 return pending_queues_;
157 } 160 }
158 default: 161 default:
159 NOTREACHED(); 162 NOTREACHED();
160 return active_queues_; 163 return active_queues_;
161 } 164 }
162 } 165 }
163 166
164 } // namespace cc 167 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698