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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 void ResourcePool::DeleteResource(ScopedResource* resource) { | 186 void ResourcePool::DeleteResource(ScopedResource* resource) { |
187 size_t resource_bytes = ResourceUtil::UncheckedSizeInBytes<size_t>( | 187 size_t resource_bytes = ResourceUtil::UncheckedSizeInBytes<size_t>( |
188 resource->size(), resource->format()); | 188 resource->size(), resource->format()); |
189 memory_usage_bytes_ -= resource_bytes; | 189 memory_usage_bytes_ -= resource_bytes; |
190 --resource_count_; | 190 --resource_count_; |
191 delete resource; | 191 delete resource; |
192 } | 192 } |
193 | 193 |
194 void ResourcePool::CheckBusyResources(bool wait_if_needed) { | 194 void ResourcePool::CheckBusyResources() { |
195 ResourceList::iterator it = busy_resources_.begin(); | 195 ResourceList::iterator it = busy_resources_.begin(); |
196 | 196 |
197 while (it != busy_resources_.end()) { | 197 while (it != busy_resources_.end()) { |
198 ScopedResource* resource = it->resource; | 198 ScopedResource* resource = it->resource; |
199 | 199 |
200 if (wait_if_needed) | |
201 resource_provider_->WaitReadLockIfNeeded(resource->id()); | |
202 | |
203 if (resource_provider_->CanLockForWrite(resource->id())) { | 200 if (resource_provider_->CanLockForWrite(resource->id())) { |
204 DidFinishUsingResource(resource, it->content_id); | 201 DidFinishUsingResource(resource, it->content_id); |
205 it = busy_resources_.erase(it); | 202 it = busy_resources_.erase(it); |
206 } else if (resource_provider_->IsLost(resource->id())) { | 203 } else if (resource_provider_->IsLost(resource->id())) { |
207 // Remove lost resources from pool. | 204 // Remove lost resources from pool. |
208 DeleteResource(resource); | 205 DeleteResource(resource); |
209 it = busy_resources_.erase(it); | 206 it = busy_resources_.erase(it); |
210 } else { | 207 } else { |
211 ++it; | 208 ++it; |
212 } | 209 } |
(...skipping 14 matching lines...) Expand all Loading... |
227 } | 224 } |
228 for (const auto& resource : busy_resources_) { | 225 for (const auto& resource : busy_resources_) { |
229 resource.OnMemoryDump(pmd, resource_provider_, false /* is_free */); | 226 resource.OnMemoryDump(pmd, resource_provider_, false /* is_free */); |
230 } | 227 } |
231 // TODO(ericrk): Dump vended out resources once that data is available. | 228 // TODO(ericrk): Dump vended out resources once that data is available. |
232 // crbug.com/516541 | 229 // crbug.com/516541 |
233 return true; | 230 return true; |
234 } | 231 } |
235 | 232 |
236 } // namespace cc | 233 } // namespace cc |
OLD | NEW |