| 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
|
|
|