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

Unified Diff: cc/resources/eviction_tile_priority_queue.cc

Issue 741683003: cc: Move LayerEvictionTileIterator to a separate file and make it a queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/eviction_tile_priority_queue.cc
diff --git a/cc/resources/eviction_tile_priority_queue.cc b/cc/resources/eviction_tile_priority_queue.cc
index 9f05e816764613ee7424cff8bff3d6f6376e8430..4d6698745897caaa320a0584b2e8a4bae120ccac 100644
--- a/cc/resources/eviction_tile_priority_queue.cc
+++ b/cc/resources/eviction_tile_priority_queue.cc
@@ -14,8 +14,8 @@ class EvictionOrderComparator {
: tree_priority_(tree_priority) {}
bool operator()(
- const EvictionTilePriorityQueue::PairedPictureLayerQueue* a,
- const EvictionTilePriorityQueue::PairedPictureLayerQueue* b) const {
+ const EvictionTilePriorityQueue::PairedTilingSetQueue* a,
+ const EvictionTilePriorityQueue::PairedTilingSetQueue* b) const {
// Note that in this function, we have to return true if and only if
// b is strictly lower priority than a. Note that for the sake of
// completeness, empty queue is considered to have lowest priority.
@@ -23,15 +23,15 @@ class EvictionOrderComparator {
return b->IsEmpty() < a->IsEmpty();
WhichTree a_tree = a->NextTileIteratorTree(tree_priority_);
- const PictureLayerImpl::LayerEvictionTileIterator* a_iterator =
- a_tree == ACTIVE_TREE ? &a->active_iterator : &a->pending_iterator;
+ const TilingSetEvictionQueue* a_queue =
+ a_tree == ACTIVE_TREE ? a->active_queue.get() : a->pending_queue.get();
WhichTree b_tree = b->NextTileIteratorTree(tree_priority_);
- const PictureLayerImpl::LayerEvictionTileIterator* b_iterator =
- b_tree == ACTIVE_TREE ? &b->active_iterator : &b->pending_iterator;
+ const TilingSetEvictionQueue* b_queue =
+ b_tree == ACTIVE_TREE ? b->active_queue.get() : b->pending_queue.get();
- const Tile* a_tile = **a_iterator;
- const Tile* b_tile = **b_iterator;
+ const Tile* a_tile = a_queue->Top();
+ const Tile* b_tile = b_queue->Top();
const TilePriority& a_priority =
a_tile->priority_for_tree_priority(tree_priority_);
@@ -94,7 +94,7 @@ void EvictionTilePriorityQueue::Build(
it != paired_layers.end();
++it) {
paired_queues_.push_back(
- make_scoped_ptr(new PairedPictureLayerQueue(*it, tree_priority_)));
+ make_scoped_ptr(new PairedTilingSetQueue(*it, tree_priority_)));
}
paired_queues_.make_heap(EvictionOrderComparator(tree_priority_));
@@ -117,94 +117,89 @@ void EvictionTilePriorityQueue::Pop() {
DCHECK(!IsEmpty());
paired_queues_.pop_heap(EvictionOrderComparator(tree_priority_));
- PairedPictureLayerQueue* paired_queue = paired_queues_.back();
+ PairedTilingSetQueue* paired_queue = paired_queues_.back();
paired_queue->Pop(tree_priority_);
paired_queues_.push_heap(EvictionOrderComparator(tree_priority_));
}
-EvictionTilePriorityQueue::PairedPictureLayerQueue::PairedPictureLayerQueue() {
+EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue() {
}
-EvictionTilePriorityQueue::PairedPictureLayerQueue::PairedPictureLayerQueue(
+EvictionTilePriorityQueue::PairedTilingSetQueue::PairedTilingSetQueue(
const PictureLayerImpl::Pair& layer_pair,
- TreePriority tree_priority)
- : active_iterator(
- layer_pair.active
- ? PictureLayerImpl::LayerEvictionTileIterator(layer_pair.active,
- tree_priority)
- : PictureLayerImpl::LayerEvictionTileIterator()),
- pending_iterator(
- layer_pair.pending
- ? PictureLayerImpl::LayerEvictionTileIterator(layer_pair.pending,
- tree_priority)
- : PictureLayerImpl::LayerEvictionTileIterator()) {
+ TreePriority tree_priority) {
+ if (layer_pair.active)
+ active_queue = layer_pair.active->CreateEvictionQueue(tree_priority);
+ if (layer_pair.pending)
+ pending_queue = layer_pair.pending->CreateEvictionQueue(tree_priority);
}
-EvictionTilePriorityQueue::PairedPictureLayerQueue::~PairedPictureLayerQueue() {
+EvictionTilePriorityQueue::PairedTilingSetQueue::~PairedTilingSetQueue() {
}
-bool EvictionTilePriorityQueue::PairedPictureLayerQueue::IsEmpty() const {
- return !active_iterator && !pending_iterator;
+bool EvictionTilePriorityQueue::PairedTilingSetQueue::IsEmpty() const {
+ return (!active_queue || active_queue->IsEmpty()) &&
+ (!pending_queue || pending_queue->IsEmpty());
}
-Tile* EvictionTilePriorityQueue::PairedPictureLayerQueue::Top(
+Tile* EvictionTilePriorityQueue::PairedTilingSetQueue::Top(
TreePriority tree_priority) {
DCHECK(!IsEmpty());
WhichTree next_tree = NextTileIteratorTree(tree_priority);
- PictureLayerImpl::LayerEvictionTileIterator* next_iterator =
- next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
- DCHECK(*next_iterator);
+ TilingSetEvictionQueue* next_queue =
+ next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get();
+ DCHECK(next_queue && !next_queue->IsEmpty());
- Tile* tile = **next_iterator;
+ Tile* tile = next_queue->Top();
DCHECK(std::find(returned_shared_tiles.begin(),
returned_shared_tiles.end(),
tile) == returned_shared_tiles.end());
return tile;
}
-void EvictionTilePriorityQueue::PairedPictureLayerQueue::Pop(
+void EvictionTilePriorityQueue::PairedTilingSetQueue::Pop(
TreePriority tree_priority) {
DCHECK(!IsEmpty());
WhichTree next_tree = NextTileIteratorTree(tree_priority);
- PictureLayerImpl::LayerEvictionTileIterator* next_iterator =
- next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
- DCHECK(*next_iterator);
- returned_shared_tiles.push_back(**next_iterator);
- ++(*next_iterator);
+ TilingSetEvictionQueue* next_queue =
+ next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get();
+ DCHECK(next_queue && !next_queue->IsEmpty());
+ returned_shared_tiles.push_back(next_queue->Top());
+ next_queue->Pop();
if (IsEmpty())
return;
next_tree = NextTileIteratorTree(tree_priority);
- next_iterator =
- next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
+ next_queue =
+ next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get();
while (std::find(returned_shared_tiles.begin(),
returned_shared_tiles.end(),
- **next_iterator) != returned_shared_tiles.end()) {
- ++(*next_iterator);
+ next_queue->Top()) != returned_shared_tiles.end()) {
+ next_queue->Pop();
if (IsEmpty())
break;
next_tree = NextTileIteratorTree(tree_priority);
- next_iterator =
- next_tree == ACTIVE_TREE ? &active_iterator : &pending_iterator;
+ next_queue =
+ next_tree == ACTIVE_TREE ? active_queue.get() : pending_queue.get();
}
}
WhichTree
-EvictionTilePriorityQueue::PairedPictureLayerQueue::NextTileIteratorTree(
+EvictionTilePriorityQueue::PairedTilingSetQueue::NextTileIteratorTree(
TreePriority tree_priority) const {
DCHECK(!IsEmpty());
// If we only have one iterator with tiles, return it.
- if (!active_iterator)
+ if (!active_queue || active_queue->IsEmpty())
return PENDING_TREE;
- if (!pending_iterator)
+ if (!pending_queue || pending_queue->IsEmpty())
return ACTIVE_TREE;
- const Tile* active_tile = *active_iterator;
- const Tile* pending_tile = *pending_iterator;
+ const Tile* active_tile = active_queue->Top();
+ const Tile* pending_tile = pending_queue->Top();
if (active_tile == pending_tile)
return ACTIVE_TREE;
« 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