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

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

Issue 1535833002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-5
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « cc/resources/resource_format.cc ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_RESOURCES_RESOURCE_POOL_H_
6 #define CC_RESOURCES_RESOURCE_POOL_H_
7
8 #include <list>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/output/renderer.h"
12 #include "cc/resources/resource.h"
13 #include "cc/resources/resource_format.h"
14
15 namespace cc {
16 class ScopedResource;
17
18 class ResourcePool {
19 public:
20 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider,
21 GLenum target) {
22 return make_scoped_ptr(new ResourcePool(resource_provider, target));
23 }
24
25 virtual ~ResourcePool();
26
27 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size,
28 ResourceFormat format);
29 void ReleaseResource(scoped_ptr<ScopedResource>);
30
31 void SetResourceUsageLimits(size_t max_memory_usage_bytes,
32 size_t max_unused_memory_usage_bytes,
33 size_t max_resource_count);
34
35 void ReduceResourceUsage();
36 // This might block if |wait_if_needed| is true and one of the currently
37 // busy resources has a read lock fence that needs to be waited upon before
38 // it can be locked for write again.
39 void CheckBusyResources(bool wait_if_needed);
40
41 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; }
42 size_t acquired_memory_usage_bytes() const {
43 return memory_usage_bytes_ - unused_memory_usage_bytes_;
44 }
45 size_t total_resource_count() const { return resource_count_; }
46 size_t acquired_resource_count() const {
47 return resource_count_ - unused_resources_.size();
48 }
49 size_t busy_resource_count() const { return busy_resources_.size(); }
50
51 protected:
52 ResourcePool(ResourceProvider* resource_provider, GLenum target);
53
54 bool ResourceUsageTooHigh();
55
56 private:
57 void DidFinishUsingResource(ScopedResource* resource);
58
59 ResourceProvider* resource_provider_;
60 const GLenum target_;
61 size_t max_memory_usage_bytes_;
62 size_t max_unused_memory_usage_bytes_;
63 size_t max_resource_count_;
64 size_t memory_usage_bytes_;
65 size_t unused_memory_usage_bytes_;
66 size_t resource_count_;
67
68 typedef std::list<ScopedResource*> ResourceList;
69 ResourceList unused_resources_;
70 ResourceList busy_resources_;
71
72 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
73 };
74
75 } // namespace cc
76
77 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW
« no previous file with comments | « cc/resources/resource_format.cc ('k') | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698