Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: cc/resources/resource_pool.h

Issue 23231002: cc: Prevent the tile manager from allocating more memory than allowed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 } 35 }
36 36
37 virtual ~ResourcePool(); 37 virtual ~ResourcePool();
38 38
39 scoped_ptr<ResourcePool::Resource> AcquireResource(gfx::Size size, 39 scoped_ptr<ResourcePool::Resource> AcquireResource(gfx::Size size,
40 GLenum format); 40 GLenum format);
41 void ReleaseResource(scoped_ptr<ResourcePool::Resource>); 41 void ReleaseResource(scoped_ptr<ResourcePool::Resource>);
42 42
43 void SetMemoryUsageLimits(size_t max_memory_usage_bytes, 43 void SetMemoryUsageLimits(size_t max_memory_usage_bytes,
44 size_t max_unused_memory_usage_bytes, 44 size_t max_unused_memory_usage_bytes,
45 size_t num_resources_limit); 45 size_t max_resource_count);
46
47 void ReduceMemoryUsage();
46 48
47 size_t total_memory_usage_bytes() const { 49 size_t total_memory_usage_bytes() const {
48 return memory_usage_bytes_; 50 return memory_usage_bytes_;
49 } 51 }
50 size_t acquired_memory_usage_bytes() const { 52 size_t acquired_memory_usage_bytes() const {
51 return memory_usage_bytes_ - unused_memory_usage_bytes_; 53 return memory_usage_bytes_ - unused_memory_usage_bytes_;
52 } 54 }
53 size_t NumResources() const { return resources_.size(); } 55 size_t acquired_resource_count() const {
56 return resource_count_ - resources_.size();
57 }
54 58
55 protected: 59 protected:
56 explicit ResourcePool(ResourceProvider* resource_provider); 60 explicit ResourcePool(ResourceProvider* resource_provider);
57 61
58 bool MemoryUsageTooHigh(); 62 bool MemoryUsageTooHigh();
59 63
60 private: 64 private:
61 ResourceProvider* resource_provider_; 65 ResourceProvider* resource_provider_;
62 size_t max_memory_usage_bytes_; 66 size_t max_memory_usage_bytes_;
63 size_t max_unused_memory_usage_bytes_; 67 size_t max_unused_memory_usage_bytes_;
68 size_t max_resource_count_;
64 size_t memory_usage_bytes_; 69 size_t memory_usage_bytes_;
65 size_t unused_memory_usage_bytes_; 70 size_t unused_memory_usage_bytes_;
66 size_t num_resources_limit_; 71 size_t resource_count_;
67 72
68 typedef std::list<Resource*> ResourceList; 73 typedef std::list<Resource*> ResourceList;
69 ResourceList resources_; 74 ResourceList resources_;
aelias_OOO_until_Jul13 2013/08/15 02:06:00 Please rename this to unused_resources_, that woul
reveman 2013/08/15 15:14:15 Done.
70 75
71 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 76 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
72 }; 77 };
73 78
74 } // namespace cc 79 } // namespace cc
75 80
76 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 81 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698