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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 SetResourceUsageLimits(0, 0); | 85 SetResourceUsageLimits(0, 0); |
86 DCHECK_EQ(0u, unused_resources_.size()); | 86 DCHECK_EQ(0u, unused_resources_.size()); |
87 DCHECK_EQ(0u, in_use_memory_usage_bytes_); | 87 DCHECK_EQ(0u, in_use_memory_usage_bytes_); |
88 DCHECK_EQ(0u, total_memory_usage_bytes_); | 88 DCHECK_EQ(0u, total_memory_usage_bytes_); |
89 DCHECK_EQ(0u, total_resource_count_); | 89 DCHECK_EQ(0u, total_resource_count_); |
90 } | 90 } |
91 | 91 |
92 Resource* ResourcePool::AcquireResource(const gfx::Size& size, | 92 Resource* ResourcePool::AcquireResource(const gfx::Size& size, |
93 ResourceFormat format) { | 93 ResourceFormat format) { |
94 // Finding resources in |unused_resources_| from MRU to LRU direction, touches | 94 // Finding resources in |unused_resources_| from MRU to LRU direction, touches |
95 // LRU resources only if needed, which inreases possibility of expiring more | 95 // LRU resources only if needed, which increases possibility of expiring more |
96 // LRU resources within kResourceExpirationDelayMs. | 96 // LRU resources within kResourceExpirationDelayMs. |
97 for (ResourceDeque::iterator it = unused_resources_.begin(); | 97 for (ResourceDeque::iterator it = unused_resources_.begin(); |
98 it != unused_resources_.end(); ++it) { | 98 it != unused_resources_.end(); ++it) { |
99 ScopedResource* resource = *it; | 99 ScopedResource* resource = *it; |
100 DCHECK(resource_provider_->CanLockForWrite(resource->id())); | 100 DCHECK(resource_provider_->CanLockForWrite(resource->id())); |
101 | 101 |
102 if (resource->format() != format) | 102 if (resource->format() != format) |
103 continue; | 103 continue; |
104 if (resource->size() != size) | 104 if (resource->size() != size) |
105 continue; | 105 continue; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 for (const auto& resource : busy_resources_) { | 299 for (const auto& resource : busy_resources_) { |
300 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 300 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
301 } | 301 } |
302 for (const auto& entry : in_use_resources_) { | 302 for (const auto& entry : in_use_resources_) { |
303 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 303 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
304 } | 304 } |
305 return true; | 305 return true; |
306 } | 306 } |
307 | 307 |
308 } // namespace cc | 308 } // namespace cc |
OLD | NEW |