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 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_ |
6 #define CC_RESOURCES_RESOURCE_POOL_H_ | 6 #define CC_RESOURCES_RESOURCE_POOL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/containers/scoped_ptr_map.h" | 10 #include "base/containers/scoped_ptr_map.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 Resource* AcquireResource(const gfx::Size& size, ResourceFormat format); | 35 Resource* AcquireResource(const gfx::Size& size, ResourceFormat format); |
36 Resource* TryAcquireResourceWithContentId(uint64 content_id); | 36 Resource* TryAcquireResourceWithContentId(uint64 content_id); |
37 void ReleaseResource(Resource* resource, uint64_t content_id); | 37 void ReleaseResource(Resource* resource, uint64_t content_id); |
38 | 38 |
39 void SetResourceUsageLimits(size_t max_memory_usage_bytes, | 39 void SetResourceUsageLimits(size_t max_memory_usage_bytes, |
40 size_t max_unused_memory_usage_bytes, | 40 size_t max_unused_memory_usage_bytes, |
41 size_t max_resource_count); | 41 size_t max_resource_count); |
42 | 42 |
43 void ReduceResourceUsage(); | 43 void ReduceResourceUsage(); |
44 // This might block if |wait_if_needed| is true and one of the currently | 44 void CheckBusyResources(); |
45 // busy resources has a read lock fence that needs to be waited upon before | |
46 // it can be locked for write again. | |
47 void CheckBusyResources(bool wait_if_needed); | |
48 | 45 |
49 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } | 46 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } |
50 size_t acquired_memory_usage_bytes() const { | 47 size_t acquired_memory_usage_bytes() const { |
51 return memory_usage_bytes_ - unused_memory_usage_bytes_; | 48 return memory_usage_bytes_ - unused_memory_usage_bytes_; |
52 } | 49 } |
53 size_t total_resource_count() const { return resource_count_; } | 50 size_t total_resource_count() const { return resource_count_; } |
54 size_t acquired_resource_count() const { | 51 size_t acquired_resource_count() const { |
55 return resource_count_ - unused_resources_.size(); | 52 return resource_count_ - unused_resources_.size(); |
56 } | 53 } |
57 size_t busy_resource_count() const { return busy_resources_.size(); } | 54 size_t busy_resource_count() const { return busy_resources_.size(); } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 101 |
105 using ResourceMap = base::ScopedPtrMap<ResourceId, scoped_ptr<PoolResource>>; | 102 using ResourceMap = base::ScopedPtrMap<ResourceId, scoped_ptr<PoolResource>>; |
106 ResourceMap in_use_resources_; | 103 ResourceMap in_use_resources_; |
107 | 104 |
108 DISALLOW_COPY_AND_ASSIGN(ResourcePool); | 105 DISALLOW_COPY_AND_ASSIGN(ResourcePool); |
109 }; | 106 }; |
110 | 107 |
111 } // namespace cc | 108 } // namespace cc |
112 | 109 |
113 #endif // CC_RESOURCES_RESOURCE_POOL_H_ | 110 #endif // CC_RESOURCES_RESOURCE_POOL_H_ |
OLD | NEW |