| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/resource_pool.h" | 5 #include "cc/resources/resource_pool.h" |
| 6 | 6 |
| 7 #include "cc/resources/resource_provider.h" | 7 #include "cc/resources/resource_provider.h" |
| 8 #include "cc/resources/scoped_resource.h" | 8 #include "cc/resources/scoped_resource.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 busy_resources_.pop_front(); | 28 busy_resources_.pop_front(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SetResourceUsageLimits(0, 0, 0); | 31 SetResourceUsageLimits(0, 0, 0); |
| 32 DCHECK_EQ(0u, unused_resources_.size()); | 32 DCHECK_EQ(0u, unused_resources_.size()); |
| 33 DCHECK_EQ(0u, memory_usage_bytes_); | 33 DCHECK_EQ(0u, memory_usage_bytes_); |
| 34 DCHECK_EQ(0u, unused_memory_usage_bytes_); | 34 DCHECK_EQ(0u, unused_memory_usage_bytes_); |
| 35 DCHECK_EQ(0u, resource_count_); | 35 DCHECK_EQ(0u, resource_count_); |
| 36 } | 36 } |
| 37 | 37 |
| 38 scoped_ptr<ScopedResource> ResourcePool::AcquireResource(gfx::Size size) { | 38 scoped_ptr<ScopedResource> ResourcePool::AcquireResource( |
| 39 const gfx::Size& size) { |
| 39 for (ResourceList::iterator it = unused_resources_.begin(); | 40 for (ResourceList::iterator it = unused_resources_.begin(); |
| 40 it != unused_resources_.end(); | 41 it != unused_resources_.end(); |
| 41 ++it) { | 42 ++it) { |
| 42 ScopedResource* resource = *it; | 43 ScopedResource* resource = *it; |
| 43 DCHECK(resource_provider_->CanLockForWrite(resource->id())); | 44 DCHECK(resource_provider_->CanLockForWrite(resource->id())); |
| 44 | 45 |
| 45 if (resource->size() != size) | 46 if (resource->size() != size) |
| 46 continue; | 47 continue; |
| 47 | 48 |
| 48 unused_resources_.erase(it); | 49 unused_resources_.erase(it); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 } | 127 } |
| 127 | 128 |
| 128 void ResourcePool::DidFinishUsingResource(ScopedResource* resource) { | 129 void ResourcePool::DidFinishUsingResource(ScopedResource* resource) { |
| 129 unused_memory_usage_bytes_ += resource->bytes(); | 130 unused_memory_usage_bytes_ += resource->bytes(); |
| 130 unused_resources_.push_back(resource); | 131 unused_resources_.push_back(resource); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace cc | 134 } // namespace cc |
| OLD | NEW |