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

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

Issue 2000323004: cc: Remove InUseByMacOSWindowServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video2
Patch Set: Created 4 years, 7 months 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 | cc/resources/resource_provider.h » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 Resource* ResourcePool::AcquireResource(const gfx::Size& size, 97 Resource* ResourcePool::AcquireResource(const gfx::Size& size,
98 ResourceFormat format) { 98 ResourceFormat format) {
99 // Finding resources in |unused_resources_| from MRU to LRU direction, touches 99 // Finding resources in |unused_resources_| from MRU to LRU direction, touches
100 // LRU resources only if needed, which increases possibility of expiring more 100 // LRU resources only if needed, which increases possibility of expiring more
101 // LRU resources within kResourceExpirationDelayMs. 101 // LRU resources within kResourceExpirationDelayMs.
102 for (ResourceDeque::iterator it = unused_resources_.begin(); 102 for (ResourceDeque::iterator it = unused_resources_.begin();
103 it != unused_resources_.end(); ++it) { 103 it != unused_resources_.end(); ++it) {
104 ScopedResource* resource = it->get(); 104 ScopedResource* resource = it->get();
105 // TODO(ccameron): The allowance for IsInUseByMacOSWindowServer should not 105 DCHECK(resource_provider_->CanLockForWrite(resource->id()));
106 // be needed.
107 // http://crbug.com/577121
108 DCHECK(resource_provider_->CanLockForWrite(resource->id()) ||
109 resource_provider_->IsInUseByMacOSWindowServer(resource->id()));
110 106
111 if (resource->format() != format) 107 if (resource->format() != format)
112 continue; 108 continue;
113 if (resource->size() != size) 109 if (resource->size() != size)
114 continue; 110 continue;
115 111
116 // Transfer resource to |in_use_resources_|. 112 // Transfer resource to |in_use_resources_|.
117 in_use_resources_[resource->id()] = std::move(*it); 113 in_use_resources_[resource->id()] = std::move(*it);
118 unused_resources_.erase(it); 114 unused_resources_.erase(it);
119 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( 115 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>(
(...skipping 29 matching lines...) Expand all
149 145
150 auto it = std::find_if( 146 auto it = std::find_if(
151 unused_resources_.begin(), unused_resources_.end(), 147 unused_resources_.begin(), unused_resources_.end(),
152 [content_id](const std::unique_ptr<PoolResource>& pool_resource) { 148 [content_id](const std::unique_ptr<PoolResource>& pool_resource) {
153 return pool_resource->content_id() == content_id; 149 return pool_resource->content_id() == content_id;
154 }); 150 });
155 if (it == unused_resources_.end()) 151 if (it == unused_resources_.end())
156 return nullptr; 152 return nullptr;
157 153
158 Resource* resource = it->get(); 154 Resource* resource = it->get();
159 // TODO(ccameron): The allowance for IsInUseByMacOSWindowServer should not 155 DCHECK(resource_provider_->CanLockForWrite(resource->id()));
160 // be needed.
161 // http://crbug.com/577121
162 DCHECK(resource_provider_->CanLockForWrite(resource->id()) ||
163 resource_provider_->IsInUseByMacOSWindowServer(resource->id()));
164 156
165 // Transfer resource to |in_use_resources_|. 157 // Transfer resource to |in_use_resources_|.
166 in_use_resources_[resource->id()] = std::move(*it); 158 in_use_resources_[resource->id()] = std::move(*it);
167 unused_resources_.erase(it); 159 unused_resources_.erase(it);
168 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>( 160 in_use_memory_usage_bytes_ += ResourceUtil::UncheckedSizeInBytes<size_t>(
169 resource->size(), resource->format()); 161 resource->size(), resource->format());
170 return resource; 162 return resource;
171 } 163 }
172 164
173 void ResourcePool::ReleaseResource(Resource* resource, uint64_t content_id) { 165 void ResourcePool::ReleaseResource(Resource* resource, uint64_t content_id) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 for (const auto& resource : busy_resources_) { 350 for (const auto& resource : busy_resources_) {
359 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 351 resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
360 } 352 }
361 for (const auto& entry : in_use_resources_) { 353 for (const auto& entry : in_use_resources_) {
362 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */); 354 entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
363 } 355 }
364 return true; 356 return true;
365 } 357 }
366 358
367 } // namespace cc 359 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698