| 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 28 matching lines...) Expand all Loading... |
| 39 ResourceProvider* resource_provider() { return resource_provider_; } | 39 ResourceProvider* resource_provider() { return resource_provider_; } |
| 40 | 40 |
| 41 scoped_ptr<ResourcePool::Resource> AcquireResource(gfx::Size size, | 41 scoped_ptr<ResourcePool::Resource> AcquireResource(gfx::Size size, |
| 42 GLenum format); | 42 GLenum format); |
| 43 void ReleaseResource(scoped_ptr<ResourcePool::Resource>); | 43 void ReleaseResource(scoped_ptr<ResourcePool::Resource>); |
| 44 | 44 |
| 45 void SetMaxMemoryUsageBytes( | 45 void SetMaxMemoryUsageBytes( |
| 46 size_t max_memory_usage_bytes, | 46 size_t max_memory_usage_bytes, |
| 47 size_t max_unused_memory_usage_bytes); | 47 size_t max_unused_memory_usage_bytes); |
| 48 | 48 |
| 49 size_t acquired_memory_usage_bytes() const { |
| 50 return memory_usage_bytes_ - unused_memory_usage_bytes_; |
| 51 } |
| 52 |
| 49 protected: | 53 protected: |
| 50 explicit ResourcePool(ResourceProvider* resource_provider); | 54 explicit ResourcePool(ResourceProvider* resource_provider); |
| 51 | 55 |
| 52 bool MemoryUsageTooHigh(); | 56 bool MemoryUsageTooHigh(); |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 ResourceProvider* resource_provider_; | 59 ResourceProvider* resource_provider_; |
| 56 size_t max_memory_usage_bytes_; | 60 size_t max_memory_usage_bytes_; |
| 57 size_t max_unused_memory_usage_bytes_; | 61 size_t max_unused_memory_usage_bytes_; |
| 58 size_t memory_usage_bytes_; | 62 size_t memory_usage_bytes_; |
| 59 size_t unused_memory_usage_bytes_; | 63 size_t unused_memory_usage_bytes_; |
| 60 | 64 |
| 61 typedef std::list<Resource*> ResourceList; | 65 typedef std::list<Resource*> ResourceList; |
| 62 ResourceList resources_; | 66 ResourceList resources_; |
| 63 | 67 |
| 64 DISALLOW_COPY_AND_ASSIGN(ResourcePool); | 68 DISALLOW_COPY_AND_ASSIGN(ResourcePool); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 } // namespace cc | 71 } // namespace cc |
| 68 | 72 |
| 69 #endif // CC_RESOURCES_RESOURCE_POOL_H_ | 73 #endif // CC_RESOURCES_RESOURCE_POOL_H_ |
| OLD | NEW |