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

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

Issue 43753002: cc: Keep track of busy resources in ResourcePool (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_pool.cc » ('J')
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"
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/output/renderer.h" 12 #include "cc/output/renderer.h"
13 #include "cc/resources/resource.h" 13 #include "cc/resources/resource.h"
14 #include "cc/resources/resource_format.h" 14 #include "cc/resources/resource_format.h"
15 #include "cc/resources/resource_provider.h"
15 16
16 namespace cc { 17 namespace cc {
17 18
18 class CC_EXPORT ResourcePool { 19 class CC_EXPORT ResourcePool : public ResourceProviderClient {
19 public: 20 public:
20 class CC_EXPORT Resource : public cc::Resource { 21 class CC_EXPORT Resource : public cc::Resource {
21 public: 22 public:
22 Resource(ResourceProvider* resource_provider, 23 Resource(ResourceProvider* resource_provider,
23 gfx::Size size, 24 gfx::Size size,
24 ResourceFormat format); 25 ResourceFormat format);
25 ~Resource(); 26 ~Resource();
26 27
27 private: 28 private:
28 ResourceProvider* resource_provider_; 29 ResourceProvider* resource_provider_;
(...skipping 20 matching lines...) Expand all
49 size_t total_memory_usage_bytes() const { 50 size_t total_memory_usage_bytes() const {
50 return memory_usage_bytes_; 51 return memory_usage_bytes_;
51 } 52 }
52 size_t acquired_memory_usage_bytes() const { 53 size_t acquired_memory_usage_bytes() const {
53 return memory_usage_bytes_ - unused_memory_usage_bytes_; 54 return memory_usage_bytes_ - unused_memory_usage_bytes_;
54 } 55 }
55 size_t acquired_resource_count() const { 56 size_t acquired_resource_count() const {
56 return resource_count_ - unused_resources_.size(); 57 return resource_count_ - unused_resources_.size();
57 } 58 }
58 59
60 // ResourceProviderClient implementation
61 virtual void ResourceExported(ResourceProvider::ResourceId id) OVERRIDE;
62 virtual void ResourceReturned(ResourceProvider::ResourceId id) OVERRIDE;
63
59 protected: 64 protected:
60 explicit ResourcePool(ResourceProvider* resource_provider); 65 explicit ResourcePool(ResourceProvider* resource_provider);
61 66
62 bool ResourceUsageTooHigh(); 67 bool ResourceUsageTooHigh();
63 68
64 private: 69 private:
65 ResourceProvider* resource_provider_; 70 base::WeakPtr<ResourceProvider> resource_provider_;
66 size_t max_memory_usage_bytes_; 71 size_t max_memory_usage_bytes_;
67 size_t max_unused_memory_usage_bytes_; 72 size_t max_unused_memory_usage_bytes_;
68 size_t max_resource_count_; 73 size_t max_resource_count_;
69 size_t memory_usage_bytes_; 74 size_t memory_usage_bytes_;
70 size_t unused_memory_usage_bytes_; 75 size_t unused_memory_usage_bytes_;
71 size_t resource_count_; 76 size_t resource_count_;
72 77
73 typedef std::list<Resource*> ResourceList; 78 typedef std::list<Resource*> ResourceList;
74 ResourceList unused_resources_; 79 ResourceList unused_resources_;
80 ResourceList exported_resources_;
75 81
76 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 82 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
77 }; 83 };
78 84
79 } // namespace cc 85 } // namespace cc
80 86
81 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 87 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | cc/resources/resource_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698