| 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 <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 virtual ~ResourcePool(); | 27 virtual ~ResourcePool(); |
| 28 | 28 |
| 29 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size); | 29 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size); |
| 30 void ReleaseResource(scoped_ptr<ScopedResource>); | 30 void ReleaseResource(scoped_ptr<ScopedResource>); |
| 31 | 31 |
| 32 void SetResourceUsageLimits(size_t max_memory_usage_bytes, | 32 void SetResourceUsageLimits(size_t max_memory_usage_bytes, |
| 33 size_t max_unused_memory_usage_bytes, | 33 size_t max_unused_memory_usage_bytes, |
| 34 size_t max_resource_count); | 34 size_t max_resource_count); |
| 35 | 35 |
| 36 void ReduceResourceUsage(); | 36 void ReduceResourceUsage(); |
| 37 void CheckBusyResources(); | 37 // This might block if |wait_if_needed| is true and one of the currently |
| 38 // busy resources has a read lock fence that needs to be waited upon before |
| 39 // it can be locked for write again. |
| 40 void CheckBusyResources(bool wait_if_needed); |
| 38 | 41 |
| 39 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } | 42 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } |
| 40 size_t acquired_memory_usage_bytes() const { | 43 size_t acquired_memory_usage_bytes() const { |
| 41 return memory_usage_bytes_ - unused_memory_usage_bytes_; | 44 return memory_usage_bytes_ - unused_memory_usage_bytes_; |
| 42 } | 45 } |
| 43 size_t total_resource_count() const { return resource_count_; } | 46 size_t total_resource_count() const { return resource_count_; } |
| 44 size_t acquired_resource_count() const { | 47 size_t acquired_resource_count() const { |
| 45 return resource_count_ - unused_resources_.size(); | 48 return resource_count_ - unused_resources_.size(); |
| 46 } | 49 } |
| 50 size_t busy_resource_count() const { return busy_resources_.size(); } |
| 47 | 51 |
| 48 ResourceFormat resource_format() const { return format_; } | 52 ResourceFormat resource_format() const { return format_; } |
| 49 | 53 |
| 50 protected: | 54 protected: |
| 51 ResourcePool(ResourceProvider* resource_provider, | 55 ResourcePool(ResourceProvider* resource_provider, |
| 52 GLenum target, | 56 GLenum target, |
| 53 ResourceFormat format); | 57 ResourceFormat format); |
| 54 | 58 |
| 55 bool ResourceUsageTooHigh(); | 59 bool ResourceUsageTooHigh(); |
| 56 | 60 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 typedef std::list<ScopedResource*> ResourceList; | 74 typedef std::list<ScopedResource*> ResourceList; |
| 71 ResourceList unused_resources_; | 75 ResourceList unused_resources_; |
| 72 ResourceList busy_resources_; | 76 ResourceList busy_resources_; |
| 73 | 77 |
| 74 DISALLOW_COPY_AND_ASSIGN(ResourcePool); | 78 DISALLOW_COPY_AND_ASSIGN(ResourcePool); |
| 75 }; | 79 }; |
| 76 | 80 |
| 77 } // namespace cc | 81 } // namespace cc |
| 78 | 82 |
| 79 #endif // CC_RESOURCES_RESOURCE_POOL_H_ | 83 #endif // CC_RESOURCES_RESOURCE_POOL_H_ |
| OLD | NEW |