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 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
11 ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider, | 11 ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider, |
12 const gfx::Size& size, | 12 gfx::Size size, |
13 GLenum format) | 13 GLenum format) |
14 : cc::Resource(resource_provider->CreateManagedResource( | 14 : cc::Resource(resource_provider->CreateManagedResource( |
15 size, | 15 size, |
16 format, | 16 format, |
17 ResourceProvider::TextureUsageAny), | 17 ResourceProvider::TextureUsageAny), |
18 size, | 18 size, |
19 format), | 19 format), |
20 resource_provider_(resource_provider) { | 20 resource_provider_(resource_provider) { |
21 DCHECK(id()); | 21 DCHECK(id()); |
22 } | 22 } |
(...skipping 10 matching lines...) Expand all Loading... |
33 max_unused_memory_usage_bytes_(0), | 33 max_unused_memory_usage_bytes_(0), |
34 memory_usage_bytes_(0), | 34 memory_usage_bytes_(0), |
35 unused_memory_usage_bytes_(0) { | 35 unused_memory_usage_bytes_(0) { |
36 } | 36 } |
37 | 37 |
38 ResourcePool::~ResourcePool() { | 38 ResourcePool::~ResourcePool() { |
39 SetMaxMemoryUsageBytes(0, 0); | 39 SetMaxMemoryUsageBytes(0, 0); |
40 } | 40 } |
41 | 41 |
42 scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( | 42 scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( |
43 const gfx::Size& size, GLenum format) { | 43 gfx::Size size, GLenum format) { |
44 for (ResourceList::iterator it = resources_.begin(); | 44 for (ResourceList::iterator it = resources_.begin(); |
45 it != resources_.end(); ++it) { | 45 it != resources_.end(); ++it) { |
46 Resource* resource = *it; | 46 Resource* resource = *it; |
47 | 47 |
48 // TODO(epenner): It would be nice to DCHECK that this | 48 // TODO(epenner): It would be nice to DCHECK that this |
49 // doesn't happen two frames in a row for any resource | 49 // doesn't happen two frames in a row for any resource |
50 // in this pool. | 50 // in this pool. |
51 if (!resource_provider_->CanLockForWrite(resource->id())) | 51 if (!resource_provider_->CanLockForWrite(resource->id())) |
52 continue; | 52 continue; |
53 | 53 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 bool ResourcePool::MemoryUsageTooHigh() { | 108 bool ResourcePool::MemoryUsageTooHigh() { |
109 if (memory_usage_bytes_ > max_memory_usage_bytes_) | 109 if (memory_usage_bytes_ > max_memory_usage_bytes_) |
110 return true; | 110 return true; |
111 if (unused_memory_usage_bytes_ > max_unused_memory_usage_bytes_) | 111 if (unused_memory_usage_bytes_ > max_unused_memory_usage_bytes_) |
112 return true; | 112 return true; |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 } // namespace cc | 116 } // namespace cc |
OLD | NEW |