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

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

Issue 2507963003: Pass correct texture hint for GPU raster (Closed)
Patch Set: rebase 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 private: 113 private:
108 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource); 114 FRIEND_TEST_ALL_PREFIXES(ResourcePoolTest, ReuseResource);
109 class PoolResource : public ScopedResource { 115 class PoolResource : public ScopedResource {
110 public: 116 public:
111 static std::unique_ptr<PoolResource> Create( 117 static std::unique_ptr<PoolResource> Create(
112 ResourceProvider* resource_provider) { 118 ResourceProvider* resource_provider) {
113 return base::WrapUnique(new PoolResource(resource_provider)); 119 return base::WrapUnique(new PoolResource(resource_provider));
114 } 120 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 uint64_t new_content_id, 158 uint64_t new_content_id,
153 const gfx::Rect& new_invalidated_rect); 159 const gfx::Rect& new_invalidated_rect);
154 160
155 // Functions which manage periodic eviction of expired resources. 161 // Functions which manage periodic eviction of expired resources.
156 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now); 162 void ScheduleEvictExpiredResourcesIn(base::TimeDelta time_from_now);
157 void EvictExpiredResources(); 163 void EvictExpiredResources();
158 void EvictResourcesNotUsedSince(base::TimeTicks time_limit); 164 void EvictResourcesNotUsedSince(base::TimeTicks time_limit);
159 bool HasEvictableResources() const; 165 bool HasEvictableResources() const;
160 base::TimeTicks GetUsageTimeForLRUResource() const; 166 base::TimeTicks GetUsageTimeForLRUResource() const;
161 167
162 ResourceProvider* resource_provider_; 168 ResourceProvider* resource_provider_ = nullptr;
163 bool use_gpu_memory_buffers_; 169 bool use_gpu_memory_buffers_ = false;
164 gfx::BufferUsage usage_; 170 gfx::BufferUsage usage_ = gfx::BufferUsage::GPU_READ_CPU_READ_WRITE;
165 size_t max_memory_usage_bytes_; 171 ResourceProvider::TextureHint hint_ = ResourceProvider::TEXTURE_HINT_DEFAULT;
166 size_t max_resource_count_; 172 size_t max_memory_usage_bytes_ = 0;
167 size_t in_use_memory_usage_bytes_; 173 size_t max_resource_count_ = 0;
168 size_t total_memory_usage_bytes_; 174 size_t in_use_memory_usage_bytes_ = 0;
169 size_t total_resource_count_; 175 size_t total_memory_usage_bytes_ = 0;
176 size_t total_resource_count_ = 0;
170 177
171 // Holds most recently used resources at the front of the queue. 178 // Holds most recently used resources at the front of the queue.
172 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>; 179 using ResourceDeque = std::deque<std::unique_ptr<PoolResource>>;
173 ResourceDeque unused_resources_; 180 ResourceDeque unused_resources_;
174 ResourceDeque busy_resources_; 181 ResourceDeque busy_resources_;
175 182
176 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>; 183 using InUseResourceMap = std::map<ResourceId, std::unique_ptr<PoolResource>>;
177 InUseResourceMap in_use_resources_; 184 InUseResourceMap in_use_resources_;
178 185
179 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 186 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
180 bool evict_expired_resources_pending_; 187 bool evict_expired_resources_pending_ = false;
181 const base::TimeDelta resource_expiration_delay_; 188 const base::TimeDelta resource_expiration_delay_;
182 189
183 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_; 190 base::WeakPtrFactory<ResourcePool> weak_ptr_factory_;
184 191
185 DISALLOW_COPY_AND_ASSIGN(ResourcePool); 192 DISALLOW_COPY_AND_ASSIGN(ResourcePool);
186 }; 193 };
187 194
188 } // namespace cc 195 } // namespace cc
189 196
190 #endif // CC_RESOURCES_RESOURCE_POOL_H_ 197 #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