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

Unified Diff: cc/resources/resource_pool.cc

Issue 43753002: cc: Keep track of busy resources in ResourcePool (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc: Keep track of busy resources in ResourcePool Created 7 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/resource_pool.h ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool.cc
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index cef86ded1788d770100d996a1b2d2afc3de42718..6e367af9a424ce6e11d9b35be36ced3ce69f5991 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
« no previous file with comments | « cc/resources/resource_pool.h ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698