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

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

Issue 866883003: cc: Remove TilingSetRasterQueue virtual base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gyp/gn Created 5 years, 11 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 #include "cc/resources/tiling_set_raster_queue_required.h"
9 8
10 namespace cc { 9 namespace cc {
11 10
12 namespace { 11 namespace {
13 12
14 class RasterOrderComparator { 13 class RasterOrderComparator {
15 public: 14 public:
16 explicit RasterOrderComparator(TreePriority tree_priority) 15 explicit RasterOrderComparator(TreePriority tree_priority)
17 : tree_priority_(tree_priority) {} 16 : tree_priority_(tree_priority) {}
18 17
19 bool operator()( 18 bool operator()(
20 const RasterTilePriorityQueueAll::PairedTilingSetQueue* a, 19 const RasterTilePriorityQueueAll::PairedTilingSetQueue* a,
21 const RasterTilePriorityQueueAll::PairedTilingSetQueue* b) const { 20 const RasterTilePriorityQueueAll::PairedTilingSetQueue* b) const {
22 // Note that in this function, we have to return true if and only if 21 // Note that in this function, we have to return true if and only if
23 // a is strictly lower priority than b. Note that for the sake of 22 // a is strictly lower priority than b. Note that for the sake of
24 // completeness, empty queue is considered to have lowest priority. 23 // completeness, empty queue is considered to have lowest priority.
25 if (a->IsEmpty() || b->IsEmpty()) 24 if (a->IsEmpty() || b->IsEmpty())
26 return b->IsEmpty() < a->IsEmpty(); 25 return b->IsEmpty() < a->IsEmpty();
27 26
28 WhichTree a_tree = a->NextTileIteratorTree(tree_priority_); 27 WhichTree a_tree = a->NextTileIteratorTree(tree_priority_);
29 const TilingSetRasterQueue* a_queue = 28 const TilingSetRasterQueueAll* a_queue =
30 a_tree == ACTIVE_TREE ? a->active_queue() : a->pending_queue(); 29 a_tree == ACTIVE_TREE ? a->active_queue() : a->pending_queue();
31 30
32 WhichTree b_tree = b->NextTileIteratorTree(tree_priority_); 31 WhichTree b_tree = b->NextTileIteratorTree(tree_priority_);
33 const TilingSetRasterQueue* b_queue = 32 const TilingSetRasterQueueAll* b_queue =
34 b_tree == ACTIVE_TREE ? b->active_queue() : b->pending_queue(); 33 b_tree == ACTIVE_TREE ? b->active_queue() : b->pending_queue();
35 34
36 const Tile* a_tile = a_queue->Top(); 35 const Tile* a_tile = a_queue->Top();
37 const Tile* b_tile = b_queue->Top(); 36 const Tile* b_tile = b_queue->Top();
38 37
39 const TilePriority& a_priority = 38 const TilePriority& a_priority =
40 a_tile->priority_for_tree_priority(tree_priority_); 39 a_tile->priority_for_tree_priority(tree_priority_);
41 const TilePriority& b_priority = 40 const TilePriority& b_priority =
42 b_tile->priority_for_tree_priority(tree_priority_); 41 b_tile->priority_for_tree_priority(tree_priority_);
43 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; 42 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 76 }
78 77
79 return b_priority.IsHigherPriorityThan(a_priority); 78 return b_priority.IsHigherPriorityThan(a_priority);
80 } 79 }
81 80
82 private: 81 private:
83 TreePriority tree_priority_; 82 TreePriority tree_priority_;
84 }; 83 };
85 84
86 WhichTree HigherPriorityTree(TreePriority tree_priority, 85 WhichTree HigherPriorityTree(TreePriority tree_priority,
87 const TilingSetRasterQueue* active_queue, 86 const TilingSetRasterQueueAll* active_queue,
88 const TilingSetRasterQueue* pending_queue, 87 const TilingSetRasterQueueAll* pending_queue,
89 const Tile* shared_tile) { 88 const Tile* shared_tile) {
90 switch (tree_priority) { 89 switch (tree_priority) {
91 case SMOOTHNESS_TAKES_PRIORITY: { 90 case SMOOTHNESS_TAKES_PRIORITY: {
92 const Tile* active_tile = shared_tile ? shared_tile : active_queue->Top(); 91 const Tile* active_tile = shared_tile ? shared_tile : active_queue->Top();
93 const Tile* pending_tile = 92 const Tile* pending_tile =
94 shared_tile ? shared_tile : pending_queue->Top(); 93 shared_tile ? shared_tile : pending_queue->Top();
95 94
96 const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE); 95 const TilePriority& active_priority = active_tile->priority(ACTIVE_TREE);
97 const TilePriority& pending_priority = 96 const TilePriority& pending_priority =
98 pending_tile->priority(PENDING_TREE); 97 pending_tile->priority(PENDING_TREE);
(...skipping 21 matching lines...) Expand all
120 if (active_priority.IsHigherPriorityThan(pending_priority)) 119 if (active_priority.IsHigherPriorityThan(pending_priority))
121 return ACTIVE_TREE; 120 return ACTIVE_TREE;
122 return PENDING_TREE; 121 return PENDING_TREE;
123 } 122 }
124 default: 123 default:
125 NOTREACHED(); 124 NOTREACHED();
126 return ACTIVE_TREE; 125 return ACTIVE_TREE;
127 } 126 }
128 } 127 }
129 128
130 scoped_ptr<TilingSetRasterQueue> CreateTilingSetRasterQueue( 129 scoped_ptr<TilingSetRasterQueueAll> CreateTilingSetRasterQueue(
131 PictureLayerImpl* layer, 130 PictureLayerImpl* layer,
132 TreePriority tree_priority) { 131 TreePriority tree_priority) {
133 if (!layer) 132 if (!layer)
134 return nullptr; 133 return nullptr;
135 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); 134 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set();
136 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; 135 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY;
137 return make_scoped_ptr( 136 return make_scoped_ptr(
138 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res)); 137 new TilingSetRasterQueueAll(tiling_set, prioritize_low_res));
139 } 138 }
140 139
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 bool RasterTilePriorityQueueAll::PairedTilingSetQueue::IsEmpty() const { 203 bool RasterTilePriorityQueueAll::PairedTilingSetQueue::IsEmpty() const {
205 return (!active_queue_ || active_queue_->IsEmpty()) && 204 return (!active_queue_ || active_queue_->IsEmpty()) &&
206 (!pending_queue_ || pending_queue_->IsEmpty()); 205 (!pending_queue_ || pending_queue_->IsEmpty());
207 } 206 }
208 207
209 Tile* RasterTilePriorityQueueAll::PairedTilingSetQueue::Top( 208 Tile* RasterTilePriorityQueueAll::PairedTilingSetQueue::Top(
210 TreePriority tree_priority) { 209 TreePriority tree_priority) {
211 DCHECK(!IsEmpty()); 210 DCHECK(!IsEmpty());
212 211
213 WhichTree next_tree = NextTileIteratorTree(tree_priority); 212 WhichTree next_tree = NextTileIteratorTree(tree_priority);
214 TilingSetRasterQueue* next_queue = 213 TilingSetRasterQueueAll* next_queue =
215 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get(); 214 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get();
216 DCHECK(next_queue && !next_queue->IsEmpty()); 215 DCHECK(next_queue && !next_queue->IsEmpty());
217 Tile* tile = next_queue->Top(); 216 Tile* tile = next_queue->Top();
218 DCHECK(returned_tiles_for_debug_.find(tile) == 217 DCHECK(returned_tiles_for_debug_.find(tile) ==
219 returned_tiles_for_debug_.end()); 218 returned_tiles_for_debug_.end());
220 return tile; 219 return tile;
221 } 220 }
222 221
223 void RasterTilePriorityQueueAll::PairedTilingSetQueue::Pop( 222 void RasterTilePriorityQueueAll::PairedTilingSetQueue::Pop(
224 TreePriority tree_priority) { 223 TreePriority tree_priority) {
225 DCHECK(!IsEmpty()); 224 DCHECK(!IsEmpty());
226 225
227 WhichTree next_tree = NextTileIteratorTree(tree_priority); 226 WhichTree next_tree = NextTileIteratorTree(tree_priority);
228 TilingSetRasterQueue* next_queue = 227 TilingSetRasterQueueAll* next_queue =
229 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get(); 228 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get();
230 DCHECK(next_queue && !next_queue->IsEmpty()); 229 DCHECK(next_queue && !next_queue->IsEmpty());
231 DCHECK(returned_tiles_for_debug_.insert(next_queue->Top()).second); 230 DCHECK(returned_tiles_for_debug_.insert(next_queue->Top()).second);
232 next_queue->Pop(); 231 next_queue->Pop();
233 232
234 SkipTilesReturnedByTwin(tree_priority); 233 SkipTilesReturnedByTwin(tree_priority);
235 234
236 // If no empty, use Top to do DCHECK the next iterator. 235 // If no empty, use Top to do DCHECK the next iterator.
237 DCHECK(IsEmpty() || Top(tree_priority)); 236 DCHECK(IsEmpty() || Top(tree_priority));
238 } 237 }
239 238
240 void RasterTilePriorityQueueAll::PairedTilingSetQueue::SkipTilesReturnedByTwin( 239 void RasterTilePriorityQueueAll::PairedTilingSetQueue::SkipTilesReturnedByTwin(
241 TreePriority tree_priority) { 240 TreePriority tree_priority) {
242 if (!has_both_layers_) 241 if (!has_both_layers_)
243 return; 242 return;
244 243
245 // We have both layers (active and pending) thus we can encounter shared 244 // We have both layers (active and pending) thus we can encounter shared
246 // tiles twice (from the active iterator and from the pending iterator). 245 // tiles twice (from the active iterator and from the pending iterator).
247 while (!IsEmpty()) { 246 while (!IsEmpty()) {
248 WhichTree next_tree = NextTileIteratorTree(tree_priority); 247 WhichTree next_tree = NextTileIteratorTree(tree_priority);
249 TilingSetRasterQueue* next_queue = 248 TilingSetRasterQueueAll* next_queue =
250 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get(); 249 next_tree == ACTIVE_TREE ? active_queue_.get() : pending_queue_.get();
251 DCHECK(next_queue && !next_queue->IsEmpty()); 250 DCHECK(next_queue && !next_queue->IsEmpty());
252 251
253 // Accept all non-shared tiles. 252 // Accept all non-shared tiles.
254 const Tile* tile = next_queue->Top(); 253 const Tile* tile = next_queue->Top();
255 if (!tile->is_shared()) 254 if (!tile->is_shared())
256 break; 255 break;
257 256
258 // Accept a shared tile if the next tree is the higher priority one 257 // Accept a shared tile if the next tree is the higher priority one
259 // corresponding the iterator (active or pending) which usually (but due 258 // corresponding the iterator (active or pending) which usually (but due
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 313
315 state->BeginDictionary("pending_queue"); 314 state->BeginDictionary("pending_queue");
316 state->SetBoolean("has_tile", active_queue_has_tile); 315 state->SetBoolean("has_tile", active_queue_has_tile);
317 state->SetInteger("active_priority_bin", active_priority_bin); 316 state->SetInteger("active_priority_bin", active_priority_bin);
318 state->SetInteger("pending_priority_bin", pending_priority_bin); 317 state->SetInteger("pending_priority_bin", pending_priority_bin);
319 state->EndDictionary(); 318 state->EndDictionary();
320 return state; 319 return state;
321 } 320 }
322 321
323 } // namespace cc 322 } // 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