diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-09 17:45:15 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-09 17:45:15 +0000 |
commit | 5667e23083e38f10c8126888d3b6c50563ec64c8 (patch) | |
tree | e4ad7ef5c18cc6355022136cce21ef058e44c675 | |
parent | d733b27c77f6fa136eb5c2cb46fadb25b16d6d97 (diff) | |
download | chromium_src-5667e23083e38f10c8126888d3b6c50563ec64c8.zip chromium_src-5667e23083e38f10c8126888d3b6c50563ec64c8.tar.gz chromium_src-5667e23083e38f10c8126888d3b6c50563ec64c8.tar.bz2 |
Merge 237748 "More aggressively evict textures used by the paren..."
> More aggressively evict textures used by the parent compositor.
>
> Do not put textures that are in use by the parent compositor
> at the back of the eviction queue. Rather, put them in
> according to their priority, and use being in the parent
> compositor to break ties (preferring to evict resources in
> the parent compositor, because only once they are evicted
> is there a chance that they may be deleted).
>
> Rename CanBeRecycled to CanBeRecycledIfNotInExternalUse.
> This function was used in the sorting function, and
> CanBeRecycled is false for textures that are in the
> parent compositor. Can CanBeRecycled to not take into
> account the parent compositor, and rename the function
> accordingly.
>
> BUG=322299
>
> Review URL: https://codereview.chromium.org/88913007
TBR=ccameron@chromium.org
Review URL: https://codereview.chromium.org/105103005
git-svn-id: svn://svn.chromium.org/chrome/branches/1700/src@239517 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/resources/prioritized_resource.cc | 4 | ||||
-rw-r--r-- | cc/resources/prioritized_resource.h | 2 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_manager.cc | 12 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_manager.h | 23 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_unittest.cc | 13 |
5 files changed, 33 insertions, 21 deletions
diff --git a/cc/resources/prioritized_resource.cc b/cc/resources/prioritized_resource.cc index 8a7874d..f62ee40 100644 --- a/cc/resources/prioritized_resource.cc +++ b/cc/resources/prioritized_resource.cc @@ -155,10 +155,10 @@ bool PrioritizedResource::Backing::ResourceHasBeenDeleted() const { return resource_has_been_deleted_; } -bool PrioritizedResource::Backing::CanBeRecycled() const { +bool PrioritizedResource::Backing::CanBeRecycledIfNotInExternalUse() const { DCHECK(!proxy() || proxy()->IsImplThread()); return !was_above_priority_cutoff_at_last_priority_update_ && - !in_drawing_impl_tree_ && !in_parent_compositor_; + !in_drawing_impl_tree_; } void PrioritizedResource::Backing::UpdatePriority() { diff --git a/cc/resources/prioritized_resource.h b/cc/resources/prioritized_resource.h index bdd906d..ee90024 100644 --- a/cc/resources/prioritized_resource.h +++ b/cc/resources/prioritized_resource.h @@ -114,7 +114,7 @@ class CC_EXPORT PrioritizedResource { void UpdateState(ResourceProvider* resource_provider); PrioritizedResource* owner() { return owner_; } - bool CanBeRecycled() const; + bool CanBeRecycledIfNotInExternalUse() const; int request_priority_at_last_priority_update() const { return priority_at_last_priority_update_; } diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc index ece04b1..a494177 100644 --- a/cc/resources/prioritized_resource_manager.cc +++ b/cc/resources/prioritized_resource_manager.cc @@ -241,7 +241,7 @@ void PrioritizedResourceManager::AcquireBackingTextureIfNeeded( // First try to recycle for (BackingList::iterator it = backings_.begin(); it != backings_.end(); ++it) { - if (!(*it)->CanBeRecycled()) + if (!(*it)->CanBeRecycledIfNotInExternalUse()) break; if (resource_provider->InUseByConsumer((*it)->id())) continue; @@ -299,7 +299,8 @@ bool PrioritizedResourceManager::EvictBackingsToReduceMemory( backing->request_priority_at_last_priority_update(), priority_cutoff)) break; - if (eviction_policy == EVICT_ONLY_RECYCLABLE && !backing->CanBeRecycled()) + if (eviction_policy == EVICT_ONLY_RECYCLABLE && + !backing->CanBeRecycledIfNotInExternalUse()) break; if (unlink_policy == UNLINK_BACKINGS && backing->owner()) backing->owner()->Unlink(); @@ -368,6 +369,7 @@ bool PrioritizedResourceManager::ReduceMemoryOnImplThread( ResourceProvider* resource_provider) { DCHECK(proxy_->IsImplThread()); DCHECK(resource_provider); + // If we are in the process of uploading a new frame then the backings at the // very end of the list are not sorted by priority. Sort them before doing the // eviction. @@ -526,12 +528,12 @@ void PrioritizedResourceManager::AssertInvariants() { (!backings_tail_not_sorted_ || !backing->was_above_priority_cutoff_at_last_priority_update())) DCHECK(CompareBackings(previous_backing, backing)); - if (!backing->CanBeRecycled()) + if (!backing->CanBeRecycledIfNotInExternalUse()) reached_unrecyclable = true; if (reached_unrecyclable) - DCHECK(!backing->CanBeRecycled()); + DCHECK(!backing->CanBeRecycledIfNotInExternalUse()); else - DCHECK(backing->CanBeRecycled()); + DCHECK(backing->CanBeRecycledIfNotInExternalUse()); previous_backing = backing; } #endif diff --git a/cc/resources/prioritized_resource_manager.h b/cc/resources/prioritized_resource_manager.h index 8a7c275..9b558a4 100644 --- a/cc/resources/prioritized_resource_manager.h +++ b/cc/resources/prioritized_resource_manager.h @@ -152,29 +152,32 @@ class CC_EXPORT PrioritizedResourceManager { // Compare backings. Lowest priority first. static inline bool CompareBackings(PrioritizedResource::Backing* a, PrioritizedResource::Backing* b) { - // Make textures that can be recycled appear first - if (a->CanBeRecycled() != b->CanBeRecycled()) - return (a->CanBeRecycled() > b->CanBeRecycled()); - // Put textures in the parent compositor last since they can't be - // freed when they are evicted anyhow. - if (a->in_parent_compositor() != b->in_parent_compositor()) - return (a->in_parent_compositor() < b->in_parent_compositor()); + // Make textures that can be recycled appear first. + if (a->CanBeRecycledIfNotInExternalUse() != + b->CanBeRecycledIfNotInExternalUse()) + return (a->CanBeRecycledIfNotInExternalUse() > + b->CanBeRecycledIfNotInExternalUse()); // Then sort by being above or below the priority cutoff. if (a->was_above_priority_cutoff_at_last_priority_update() != b->was_above_priority_cutoff_at_last_priority_update()) return (a->was_above_priority_cutoff_at_last_priority_update() < b->was_above_priority_cutoff_at_last_priority_update()); // Then sort by priority (note that backings that no longer have owners will - // always have the lowest priority) + // always have the lowest priority). if (a->request_priority_at_last_priority_update() != b->request_priority_at_last_priority_update()) return PriorityCalculator::priority_is_lower( a->request_priority_at_last_priority_update(), b->request_priority_at_last_priority_update()); - // Finally sort by being in the impl tree versus being completely - // unreferenced + // Then sort by being in the impl tree versus being completely + // unreferenced. if (a->in_drawing_impl_tree() != b->in_drawing_impl_tree()) return (a->in_drawing_impl_tree() < b->in_drawing_impl_tree()); + // Finally, prefer to evict textures in the parent compositor because + // they will otherwise take another roundtrip to the parent compositor + // before they are evicted. + if (a->in_parent_compositor() != b->in_parent_compositor()) + return (a->in_parent_compositor() > b->in_parent_compositor()); return a < b; } diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc index b58774d..84e687c 100644 --- a/cc/resources/prioritized_resource_unittest.cc +++ b/cc/resources/prioritized_resource_unittest.cc @@ -451,7 +451,7 @@ TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { resource_manager->ClearAllMemory(ResourceProvider()); } -TEST_F(PrioritizedResourceTest, NotEvictingTexturesInParent) { +TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { const size_t kMaxTextures = 8; scoped_ptr<PrioritizedResourceManager> resource_manager = CreateManager(kMaxTextures); @@ -546,6 +546,13 @@ TEST_F(PrioritizedResourceTest, NotEvictingTexturesInParent) { to_send.push_back(textures[i]->resource_id()); resource_provider_->PrepareSendToParent(to_send, &transferable); + // Set the last two textures to be tied for prioity with the two + // before them. Being sent to the parent will break the tie. + textures[4]->set_request_priority(100 + 4); + textures[5]->set_request_priority(100 + 5); + textures[6]->set_request_priority(100 + 4); + textures[7]->set_request_priority(100 + 5); + for (size_t i = 0; i < 8; ++i) texture_resource_ids[i] = textures[i]->resource_id(); @@ -574,10 +581,10 @@ TEST_F(PrioritizedResourceTest, NotEvictingTexturesInParent) { std::vector<unsigned> remaining = BackingResources(resource_manager.get()); EXPECT_TRUE(std::find(remaining.begin(), remaining.end(), - texture_resource_ids[6]) != remaining.end()); + texture_resource_ids[6]) == remaining.end()); EXPECT_TRUE(std::find(remaining.begin(), remaining.end(), - texture_resource_ids[7]) != remaining.end()); + texture_resource_ids[7]) == remaining.end()); } resource_manager->UnlinkAndClearEvictedBackings(); EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryUseBytes()); |