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

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

Issue 1139063002: cc: Partial tile update for one-copy raster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: monocle: tilemanagerconsistency Created 5 years, 7 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
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 <deque>
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 15
16 namespace cc { 16 namespace cc {
17 class ScopedResource; 17 class ScopedResource;
18 18
19 class CC_EXPORT ResourcePool { 19 class CC_EXPORT ResourcePool {
20 public: 20 public:
21 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider, 21 static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider,
22 GLenum target) { 22 GLenum target) {
23 return make_scoped_ptr(new ResourcePool(resource_provider, target)); 23 return make_scoped_ptr(new ResourcePool(resource_provider, target));
24 } 24 }
25 25
26 virtual ~ResourcePool(); 26 virtual ~ResourcePool();
27 27
28 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size, 28 scoped_ptr<ScopedResource> AcquireResource(const gfx::Size& size,
29 ResourceFormat format); 29 ResourceFormat format);
30 void ReleaseResource(scoped_ptr<ScopedResource>); 30 scoped_ptr<ScopedResource> TryAcquireOldResource(const gfx::Size& size,
reveman 2015/05/22 17:15:13 OldResource -> ResourceWithContentsId ?
danakj 2015/05/26 23:37:34 Done.
31 ResourceFormat format,
32 uint64 id);
reveman 2015/05/22 17:15:13 Looking at this class in isolation it's hard to un
danakj 2015/05/26 23:37:34 Renamed to be explicitly content_id everywhere.
33 void ReleaseResource(scoped_ptr<ScopedResource> resource, uint64_t id);
31 34
32 void SetResourceUsageLimits(size_t max_memory_usage_bytes, 35 void SetResourceUsageLimits(size_t max_memory_usage_bytes,
33 size_t max_unused_memory_usage_bytes, 36 size_t max_unused_memory_usage_bytes,
34 size_t max_resource_count); 37 size_t max_resource_count);
35 38
36 void ReduceResourceUsage(); 39 void ReduceResourceUsage();
37 // This might block if |wait_if_needed| is true and one of the currently 40 // This might block if |wait_if_needed| is true and one of the currently
38 // busy resources has a read lock fence that needs to be waited upon before 41 // busy resources has a read lock fence that needs to be waited upon before
39 // it can be locked for write again. 42 // it can be locked for write again.
40 void CheckBusyResources(bool wait_if_needed); 43 void CheckBusyResources(bool wait_if_needed);
41 44
42 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; } 45 size_t total_memory_usage_bytes() const { return memory_usage_bytes_; }
43 size_t acquired_memory_usage_bytes() const { 46 size_t acquired_memory_usage_bytes() const {
44 return memory_usage_bytes_ - unused_memory_usage_bytes_; 47 return memory_usage_bytes_ - unused_memory_usage_bytes_;
45 } 48 }
46 size_t total_resource_count() const { return resource_count_; } 49 size_t total_resource_count() const { return resource_count_; }
47 size_t acquired_resource_count() const { 50 size_t acquired_resource_count() const {
48 return resource_count_ - unused_resources_.size(); 51 return resource_count_ - unused_resources_.size();
49 } 52 }
50 size_t busy_resource_count() const { return busy_resources_.size(); } 53 size_t busy_resource_count() const { return busy_resources_.size(); }
51 54
52 protected: 55 protected:
53 ResourcePool(ResourceProvider* resource_provider, GLenum target); 56 ResourcePool(ResourceProvider* resource_provider, GLenum target);
54 57
55 bool ResourceUsageTooHigh(); 58 bool ResourceUsageTooHigh();
56 59
57 private: 60 private:
58 void DidFinishUsingResource(ScopedResource* resource); 61 void DidFinishUsingResource(ScopedResource* resource, uint64_t id);
59 62
60 ResourceProvider* resource_provider_; 63 ResourceProvider* resource_provider_;
61 const GLenum target_; 64 const GLenum target_;
62 size_t max_memory_usage_bytes_; 65 size_t max_memory_usage_bytes_;
63 size_t max_unused_memory_usage_bytes_; 66 size_t max_unused_memory_usage_bytes_;
64 size_t max_resource_count_; 67 size_t max_resource_count_;
65 size_t memory_usage_bytes_; 68 size_t memory_usage_bytes_;
66 size_t unused_memory_usage_bytes_; 69 size_t unused_memory_usage_bytes_;
67 size_t resource_count_; 70 size_t resource_count_;
68 71
69 typedef std::list<ScopedResource*> ResourceList; 72 struct PoolResource {
73 PoolResource(ScopedResource* resource, uint64_t id)
74 : resource(resource), id(id) {}
75 ScopedResource* resource;
76 uint64_t id;
77 };
78 typedef std::deque<PoolResource> ResourceList;
70 ResourceList unused_resources_; 79 ResourceList unused_resources_;
71 ResourceList busy_resources_; 80 ResourceList busy_resources_;
72 81
73 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 82 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
74 }; 83 };
75 84
76 } // namespace cc 85 } // namespace cc
77 86
78 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 87 #endif // CC_RESOURCES_RESOURCE_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698