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

Side by Side Diff: cc/resources/resource_pool.cc

Issue 1423073005: fixup! cc: Keep most recently used resources at the front of resource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_evict
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698