diff options
author | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 21:30:18 +0000 |
---|---|---|
committer | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 21:30:18 +0000 |
commit | b51c9ded73bbbe7f18d2490aab0318d5f75de4cd (patch) | |
tree | 39b19a675e7a06129a9e19ba9815cf047fa81374 /cc/resources | |
parent | c2fc0ab73b2892bb1ec2cd47c05faa76c872b826 (diff) | |
download | chromium_src-b51c9ded73bbbe7f18d2490aab0318d5f75de4cd.zip chromium_src-b51c9ded73bbbe7f18d2490aab0318d5f75de4cd.tar.gz chromium_src-b51c9ded73bbbe7f18d2490aab0318d5f75de4cd.tar.bz2 |
cc: Keep track of busy resources in ResourcePool
Instead of assuming every released resource could be potentially
reusable, manage a list of busy resources and a list of immediately
reusable resources. A busy resource is one which can not be locked for
write.
Recheck busy resources before the tile manager is to schedule new tasks,
in AssignGpuMemoryToTiles().
If this operation becomes too expensive, the CheckBusyResources()
function should only be called if some resource(s) are returned from the
parent compositor or when ResourcePool releases some resource.
BUG=
Review URL: https://codereview.chromium.org/43753002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233374 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r-- | cc/resources/resource_pool.cc | 28 | ||||
-rw-r--r-- | cc/resources/resource_pool.h | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager.cc | 7 |
3 files changed, 27 insertions, 10 deletions
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index cef86de..6e367af 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -47,9 +47,8 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( for (ResourceList::iterator it = unused_resources_.begin(); it != unused_resources_.end(); ++it) { Resource* resource = *it; + DCHECK(resource_provider_->CanLockForWrite(resource->id())); - if (!resource_provider_->CanLockForWrite(resource->id())) - continue; if (resource->size() != size) continue; if (resource->format() != format) @@ -75,14 +74,7 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( void ResourcePool::ReleaseResource( scoped_ptr<ResourcePool::Resource> resource) { - if (ResourceUsageTooHigh()) { - memory_usage_bytes_ -= resource->bytes(); - --resource_count_; - return; - } - - unused_memory_usage_bytes_ += resource->bytes(); - unused_resources_.push_back(resource.release()); + busy_resources_.push_back(resource.release()); } void ResourcePool::SetResourceUsageLimits( @@ -127,4 +119,20 @@ bool ResourcePool::ResourceUsageTooHigh() { return false; } +void ResourcePool::CheckBusyResources() { + ResourceList::iterator it = busy_resources_.begin(); + + while (it != busy_resources_.end()) { + Resource* resource = *it; + + if (resource_provider_->CanLockForWrite(resource->id())) { + unused_memory_usage_bytes_ += resource->bytes(); + unused_resources_.push_back(resource); + it = busy_resources_.erase(it); + } else { + ++it; + } + } +} + } // namespace cc diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h index 21bbb0a..3b92855 100644 --- a/cc/resources/resource_pool.h +++ b/cc/resources/resource_pool.h @@ -45,6 +45,7 @@ class CC_EXPORT ResourcePool { size_t max_resource_count); void ReduceResourceUsage(); + void CheckBusyResources(); size_t total_memory_usage_bytes() const { return memory_usage_bytes_; @@ -72,6 +73,7 @@ class CC_EXPORT ResourcePool { typedef std::list<Resource*> ResourceList; ResourceList unused_resources_; + ResourceList busy_resources_; DISALLOW_COPY_AND_ASSIGN(ResourcePool); }; diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index df69f70..6621b6f 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -595,6 +595,13 @@ void TileManager::AssignGpuMemoryToTiles( TileVector* tiles_that_need_to_be_rasterized) { TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); + // Maintain the list of released resources that can potentially be re-used + // or deleted. + // If this operation becomes expensive too, only do this after some + // resource(s) was returned. Note that in that case, one also need to + // invalidate when releasing some resource from the pool. + resource_pool_->CheckBusyResources(); + // Now give memory out to the tiles until we're out, and build // the needs-to-be-rasterized queue. all_tiles_that_need_to_be_rasterized_have_memory_ = true; |