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

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

Issue 2507963003: Pass correct texture hint for GPU raster (Closed)
Patch Set: Created 4 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') | 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 16 matching lines...) Expand all
27 public base::MemoryCoordinatorClient { 27 public base::MemoryCoordinatorClient {
28 public: 28 public:
29 // Delay before a resource is considered expired. 29 // Delay before a resource is considered expired.
30 static base::TimeDelta kDefaultExpirationDelay; 30 static base::TimeDelta kDefaultExpirationDelay;
31 31
32 static std::unique_ptr<ResourcePool> CreateForGpuMemoryBufferResources( 32 static std::unique_ptr<ResourcePool> CreateForGpuMemoryBufferResources(
33 ResourceProvider* resource_provider, 33 ResourceProvider* resource_provider,
34 base::SingleThreadTaskRunner* task_runner, 34 base::SingleThreadTaskRunner* task_runner,
35 gfx::BufferUsage usage, 35 gfx::BufferUsage usage,
36 const base::TimeDelta& expiration_delay) { 36 const base::TimeDelta& expiration_delay) {
37 std::unique_ptr<ResourcePool> pool(new ResourcePool( 37 return base::WrapUnique(new ResourcePool(resource_provider, task_runner,
38 resource_provider, task_runner, true, expiration_delay)); 38 usage, expiration_delay));
39 pool->usage_ = usage;
40 return pool;
41 } 39 }
42 40
43 static std::unique_ptr<ResourcePool> Create( 41 static std::unique_ptr<ResourcePool> Create(
44 ResourceProvider* resource_provider, 42 ResourceProvider* resource_provider,
45 base::SingleThreadTaskRunner* task_runner, 43 base::SingleThreadTaskRunner* task_runner,
44 ResourceProvider::TextureHint hint,
46 const base::TimeDelta& expiration_delay) { 45 const base::TimeDelta& expiration_delay) {
47 return base::WrapUnique(new ResourcePool(resource_provider, task_runner, 46 return base::WrapUnique(new ResourcePool(resource_provider, task_runner,
48 false, expiration_delay)); 47 hint, expiration_delay));
49 } 48 }
50 49
51 ~ResourcePool() override; 50 ~ResourcePool() override;
52 51
53 // Tries to reuse a resource. If none are available, makes a new one. 52 // Tries to reuse a resource. If none are available, makes a new one.
54 Resource* AcquireResource(const gfx::Size& size, 53 Resource* AcquireResource(const gfx::Size& size,
55 ResourceFormat format, 54 ResourceFormat format,
56 const gfx::ColorSpace& color_space); 55 const gfx::ColorSpace& color_space);
57 56
58 // Tries to acquire the resource with |previous_content_id| for us in partial 57 // Tries to acquire the resource with |previous_content_id| for us in partial
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return total_memory_usage_bytes_; 91 return total_memory_usage_bytes_;
93 } 92 }
94 size_t GetTotalResourceCountForTesting() const { 93 size_t GetTotalResourceCountForTesting() const {
95 return total_resource_count_; 94 return total_resource_count_;
96 } 95 }
97 size_t GetBusyResourceCountForTesting() const { 96 size_t GetBusyResourceCountForTesting() const {
98 return busy_resources_.size(); 97 return busy_resources_.size();
99 } 98 }
100 99
101 protected: 100 protected:
101 // Constructor for creating GPU memory buffer resources.
102 ResourcePool(ResourceProvider* resource_provider, 102 ResourcePool(ResourceProvider* resource_provider,
103 base::SingleThreadTaskRunner* task_runner, 103 base::SingleThreadTaskRunner* task_runner,
104 bool use_gpu_memory_buffers, 104 gfx::BufferUsage usage,
105 const base::TimeDelta& expiration_delay);
106
107 // Constructor for creating standard resources.
108 ResourcePool(ResourceProvider* resource_provider,
109 base::SingleThreadTaskRunner* task_runner,
110 ResourceProvider::TextureHint hint,
105 const base::TimeDelta& expiration_delay); 111 const base::TimeDelta& expiration_delay);
106 112
107 bool ResourceUsageTooHigh(); 113 bool ResourceUsageTooHigh();
108 114
109 private: 115 private:
110 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource); 116 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource);
111 class PoolResource : public ScopedResource { 117 class PoolResource : public ScopedResource {
112 public: 118 public:
113 static std::unique_ptr<PoolResource> Create( 119 static std::unique_ptr<PoolResource> Create(
114 ResourceProvider* resource_provider) { 120 ResourceProvider* resource_provider) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 uint64_t new_content_id, 160 uint64_t new_content_id,
155 const gfx::Rect& new_invalidated_rect); 161 const gfx::Rect& new_invalidated_rect);
156 162
157 // Functions which manage periodic eviction of expired resources. 163 // Functions which manage periodic eviction of expired resources.
158 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now); 164 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now);
159 void EvictExpiredResources(); 165 void EvictExpiredResources();
160 void EvictResourcesNotUsedSince(base::TimeTicks time_limit); 166 void EvictResourcesNotUsedSince(base::TimeTicks time_limit);
161 bool HasEvictableResources() const; 167 bool HasEvictableResources() const;
162 base::TimeTicks GetUsageTimeForLRUResource() const; 168 base::TimeTicks GetUsageTimeForLRUResource() const;
163 169
164 ResourceProvider* resource_provider_; 170 ResourceProvider* resource_provider_;
vmpstr 2016/11/17 19:17:56 While here, do you mind initializing these as well
165 bool use_gpu_memory_buffers_; 171 bool use_gpu_memory_buffers_;
166 gfx::BufferUsage usage_; 172 gfx::BufferUsage usage_;
167 size_t max_memory_usage_bytes_; 173 ResourceProvider::TextureHint hint_;
168 size_t max_resource_count_; 174 size_t max_memory_usage_bytes_ = 0;
169 size_t in_use_memory_usage_bytes_; 175 size_t max_resource_count_ = 0;
170 size_t total_memory_usage_bytes_; 176 size_t in_use_memory_usage_bytes_ = 0;
171 size_t total_resource_count_; 177 size_t total_memory_usage_bytes_ = 0;
178 size_t total_resource_count_ = 0;
172 179
173 // Holds most recently used resources at the front of the queue. 180 // Holds most recently used resources at the front of the queue.
174 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>; 181 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>;
175 ResourceDeque unused_resources_; 182 ResourceDeque unused_resources_;
176 ResourceDeque busy_resources_; 183 ResourceDeque busy_resources_;
177 184
178 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>; 185 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>;
179 InUseResourceMap in_use_resources_; 186 InUseResourceMap in_use_resources_;
180 187
181 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 188 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
182 bool evict_expired_resources_pending_; 189 bool evict_expired_resources_pending_ = false;
183 const base::TimeDelta resource_expiration_delay_; 190 const base::TimeDelta resource_expiration_delay_;
184 191
185 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_; 192 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_;
186 193
187 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 194 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
188 }; 195 };
189 196
190 } // namespace cc 197 } // namespace cc
191 198
192 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 199 #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