| 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_PRIORITIZED_RESOURCE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
| 6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ | 6 #define CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
| 16 #include "cc/resources/prioritized_resource.h" | 16 #include "cc/resources/prioritized_resource.h" |
| 17 #include "cc/resources/priority_calculator.h" | 17 #include "cc/resources/priority_calculator.h" |
| 18 #include "cc/resources/resource.h" | 18 #include "cc/resources/resource.h" |
| 19 #include "cc/trees/proxy.h" | 19 #include "cc/trees/proxy.h" |
| 20 #include "third_party/khronos/GLES2/gl2.h" | |
| 21 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
| 22 | 21 |
| 23 #if defined(COMPILER_GCC) | 22 #if defined(COMPILER_GCC) |
| 24 namespace BASE_HASH_NAMESPACE { | 23 namespace BASE_HASH_NAMESPACE { |
| 25 template <> struct hash<cc::PrioritizedResource*> { | 24 template <> struct hash<cc::PrioritizedResource*> { |
| 26 size_t operator()(cc::PrioritizedResource* ptr) const { | 25 size_t operator()(cc::PrioritizedResource* ptr) const { |
| 27 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 26 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
| 28 } | 27 } |
| 29 }; | 28 }; |
| 30 } // namespace BASE_HASH_NAMESPACE | 29 } // namespace BASE_HASH_NAMESPACE |
| 31 #endif // COMPILER | 30 #endif // COMPILER |
| 32 | 31 |
| 33 namespace cc { | 32 namespace cc { |
| 34 | 33 |
| 35 class PriorityCalculator; | 34 class PriorityCalculator; |
| 36 class Proxy; | 35 class Proxy; |
| 37 | 36 |
| 38 class CC_EXPORT PrioritizedResourceManager { | 37 class CC_EXPORT PrioritizedResourceManager { |
| 39 public: | 38 public: |
| 40 static scoped_ptr<PrioritizedResourceManager> Create(const Proxy* proxy) { | 39 static scoped_ptr<PrioritizedResourceManager> Create(const Proxy* proxy) { |
| 41 return make_scoped_ptr(new PrioritizedResourceManager(proxy)); | 40 return make_scoped_ptr(new PrioritizedResourceManager(proxy)); |
| 42 } | 41 } |
| 43 scoped_ptr<PrioritizedResource> CreateTexture(gfx::Size size, GLenum format) { | 42 scoped_ptr<PrioritizedResource> CreateTexture( |
| 43 gfx::Size size, ResourceFormat format) { |
| 44 return make_scoped_ptr(new PrioritizedResource(this, size, format)); | 44 return make_scoped_ptr(new PrioritizedResource(this, size, format)); |
| 45 } | 45 } |
| 46 ~PrioritizedResourceManager(); | 46 ~PrioritizedResourceManager(); |
| 47 | 47 |
| 48 typedef std::list<PrioritizedResource::Backing*> BackingList; | 48 typedef std::list<PrioritizedResource::Backing*> BackingList; |
| 49 | 49 |
| 50 // TODO(epenner): (http://crbug.com/137094) This 64MB default is a straggler | 50 // TODO(epenner): (http://crbug.com/137094) This 64MB default is a straggler |
| 51 // from the old texture manager and is just to give us a default memory | 51 // from the old texture manager and is just to give us a default memory |
| 52 // allocation before we get a callback from the GPU memory manager. We | 52 // allocation before we get a callback from the GPU memory manager. We |
| 53 // should probaby either: | 53 // should probaby either: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 explicit PrioritizedResourceManager(const Proxy* proxy); | 178 explicit PrioritizedResourceManager(const Proxy* proxy); |
| 179 | 179 |
| 180 bool EvictBackingsToReduceMemory(size_t limit_bytes, | 180 bool EvictBackingsToReduceMemory(size_t limit_bytes, |
| 181 int priority_cutoff, | 181 int priority_cutoff, |
| 182 EvictionPolicy eviction_policy, | 182 EvictionPolicy eviction_policy, |
| 183 UnlinkPolicy unlink_policy, | 183 UnlinkPolicy unlink_policy, |
| 184 ResourceProvider* resource_provider); | 184 ResourceProvider* resource_provider); |
| 185 PrioritizedResource::Backing* CreateBacking( | 185 PrioritizedResource::Backing* CreateBacking( |
| 186 gfx::Size size, | 186 gfx::Size size, |
| 187 GLenum format, | 187 ResourceFormat format, |
| 188 ResourceProvider* resource_provider); | 188 ResourceProvider* resource_provider); |
| 189 void EvictFirstBackingResource(ResourceProvider* resource_provider); | 189 void EvictFirstBackingResource(ResourceProvider* resource_provider); |
| 190 void SortBackings(); | 190 void SortBackings(); |
| 191 | 191 |
| 192 void AssertInvariants(); | 192 void AssertInvariants(); |
| 193 | 193 |
| 194 size_t max_memory_limit_bytes_; | 194 size_t max_memory_limit_bytes_; |
| 195 // The priority cutoff based on memory pressure. This is not a strict | 195 // The priority cutoff based on memory pressure. This is not a strict |
| 196 // cutoff -- RequestLate allows textures with priority equal to this | 196 // cutoff -- RequestLate allows textures with priority equal to this |
| 197 // cutoff to be allowed. | 197 // cutoff to be allowed. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // Statistics copied at the time of PushTexturePrioritiesToBackings. | 232 // Statistics copied at the time of PushTexturePrioritiesToBackings. |
| 233 size_t memory_visible_last_pushed_bytes_; | 233 size_t memory_visible_last_pushed_bytes_; |
| 234 size_t memory_visible_and_nearby_last_pushed_bytes_; | 234 size_t memory_visible_and_nearby_last_pushed_bytes_; |
| 235 | 235 |
| 236 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); | 236 DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 } // namespace cc | 239 } // namespace cc |
| 240 | 240 |
| 241 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ | 241 #endif // CC_RESOURCES_PRIORITIZED_RESOURCE_MANAGER_H_ |
| OLD | NEW |