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

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

Issue 1063493002: cc: Remove all traces of synchronous GPU rasterization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 8 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/software_rasterizer.cc ('k') | cc/resources/tile_manager.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_TILE_MANAGER_H_ 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_
6 #define CC_RESOURCES_TILE_MANAGER_H_ 6 #define CC_RESOURCES_TILE_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 16 matching lines...) Expand all
27 27
28 namespace base { 28 namespace base {
29 namespace trace_event { 29 namespace trace_event {
30 class ConvertableToTraceFormat; 30 class ConvertableToTraceFormat;
31 class TracedValue; 31 class TracedValue;
32 } 32 }
33 } 33 }
34 34
35 namespace cc { 35 namespace cc {
36 class PictureLayerImpl; 36 class PictureLayerImpl;
37 class Rasterizer;
38 class ResourceProvider; 37 class ResourceProvider;
39 38
40 class CC_EXPORT TileManagerClient { 39 class CC_EXPORT TileManagerClient {
41 public: 40 public:
42 // Called when all tiles marked as required for activation are ready to draw. 41 // Called when all tiles marked as required for activation are ready to draw.
43 virtual void NotifyReadyToActivate() = 0; 42 virtual void NotifyReadyToActivate() = 0;
44 43
45 // Called when all tiles marked as required for draw are ready to draw. 44 // Called when all tiles marked as required for draw are ready to draw.
46 virtual void NotifyReadyToDraw() = 0; 45 virtual void NotifyReadyToDraw() = 0;
47 46
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // created, and unregister from the manager when they are deleted. 88 // created, and unregister from the manager when they are deleted.
90 class CC_EXPORT TileManager : public TileTaskRunnerClient, 89 class CC_EXPORT TileManager : public TileTaskRunnerClient,
91 public RefCountedManager<Tile> { 90 public RefCountedManager<Tile> {
92 public: 91 public:
93 enum NamedTaskSet { 92 enum NamedTaskSet {
94 REQUIRED_FOR_ACTIVATION, 93 REQUIRED_FOR_ACTIVATION,
95 REQUIRED_FOR_DRAW, 94 REQUIRED_FOR_DRAW,
96 // PixelBufferTileTaskWorkerPool depends on ALL being last. 95 // PixelBufferTileTaskWorkerPool depends on ALL being last.
97 ALL 96 ALL
98 // Adding additional values requires increasing kNumberOfTaskSets in 97 // Adding additional values requires increasing kNumberOfTaskSets in
99 // rasterizer.h 98 // tile_task_runner.h
100 }; 99 };
101 100
102 static_assert(NamedTaskSet::ALL == (kNumberOfTaskSets - 1), 101 static_assert(NamedTaskSet::ALL == (kNumberOfTaskSets - 1),
103 "NamedTaskSet::ALL should be equal to kNumberOfTaskSets" 102 "NamedTaskSet::ALL should be equal to kNumberOfTaskSets"
104 "minus 1"); 103 "minus 1");
105 104
106 static scoped_ptr<TileManager> Create(TileManagerClient* client, 105 static scoped_ptr<TileManager> Create(TileManagerClient* client,
107 base::SequencedTaskRunner* task_runner, 106 base::SequencedTaskRunner* task_runner,
108 ResourcePool* resource_pool, 107 ResourcePool* resource_pool,
109 TileTaskRunner* tile_task_runner, 108 TileTaskRunner* tile_task_runner,
110 Rasterizer* rasterizer,
111 size_t scheduled_raster_task_limit); 109 size_t scheduled_raster_task_limit);
112 ~TileManager() override; 110 ~TileManager() override;
113 111
114 // Assigns tile memory and schedules work to prepare tiles for drawing. 112 // Assigns tile memory and schedules work to prepare tiles for drawing.
115 // - Runs client_->NotifyReadyToActivate() when all tiles required for 113 // - Runs client_->NotifyReadyToActivate() when all tiles required for
116 // activation are prepared, or failed to prepare due to OOM. 114 // activation are prepared, or failed to prepare due to OOM.
117 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are 115 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are
118 // prepared, or failed to prepare due to OOM. 116 // prepared, or failed to prepare due to OOM.
119 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); 117 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state);
120 118
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 180
183 void CheckIfMoreTilesNeedToBePreparedForTesting() { 181 void CheckIfMoreTilesNeedToBePreparedForTesting() {
184 CheckIfMoreTilesNeedToBePrepared(); 182 CheckIfMoreTilesNeedToBePrepared();
185 } 183 }
186 184
187 protected: 185 protected:
188 TileManager(TileManagerClient* client, 186 TileManager(TileManagerClient* client,
189 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 187 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
190 ResourcePool* resource_pool, 188 ResourcePool* resource_pool,
191 TileTaskRunner* tile_task_runner, 189 TileTaskRunner* tile_task_runner,
192 Rasterizer* rasterizer,
193 size_t scheduled_raster_task_limit); 190 size_t scheduled_raster_task_limit);
194 191
195 void FreeResourcesForReleasedTiles(); 192 void FreeResourcesForReleasedTiles();
196 void CleanUpReleasedTiles(); 193 void CleanUpReleasedTiles();
197 194
198 // Overriden from RefCountedManager<Tile>: 195 // Overriden from RefCountedManager<Tile>:
199 friend class Tile; 196 friend class Tile;
200 void Release(Tile* tile) override; 197 void Release(Tile* tile) override;
201 198
202 // Overriden from TileTaskRunnerClient: 199 // Overriden from TileTaskRunnerClient:
203 void DidFinishRunningTileTasks(TaskSet task_set) override; 200 void DidFinishRunningTileTasks(TaskSet task_set) override;
204 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; 201 TaskSetCollection TasksThatShouldBeForcedToComplete() const override;
205 202
206 typedef std::vector<Tile*> TileVector; 203 typedef std::vector<Tile*> TileVector;
207 typedef std::set<Tile*> TileSet; 204 typedef std::set<Tile*> TileSet;
208 205
209 // Virtual for test 206 // Virtual for test
210 virtual void ScheduleTasks( 207 virtual void ScheduleTasks(
211 const TileVector& tiles_that_need_to_be_rasterized); 208 const TileVector& tiles_that_need_to_be_rasterized);
212 209
213 void AssignGpuMemoryToTiles(RasterTilePriorityQueue* raster_priority_queue, 210 void AssignGpuMemoryToTiles(RasterTilePriorityQueue* raster_priority_queue,
214 size_t scheduled_raser_task_limit, 211 size_t scheduled_raser_task_limit,
215 TileVector* tiles_that_need_to_be_rasterized); 212 TileVector* tiles_that_need_to_be_rasterized);
216 213
217 void SynchronouslyRasterizeTiles(
218 const GlobalStateThatImpactsTilePriority& state);
219
220 private: 214 private:
221 class MemoryUsage { 215 class MemoryUsage {
222 public: 216 public:
223 MemoryUsage(); 217 MemoryUsage();
224 MemoryUsage(int64 memory_bytes, int resource_count); 218 MemoryUsage(int64 memory_bytes, int resource_count);
225 219
226 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); 220 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format);
227 static MemoryUsage FromTile(const Tile* tile); 221 static MemoryUsage FromTile(const Tile* tile);
228 222
229 MemoryUsage& operator+=(const MemoryUsage& other); 223 MemoryUsage& operator+=(const MemoryUsage& other);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 void NotifyReadyToActivate(); 265 void NotifyReadyToActivate();
272 void NotifyReadyToDraw(); 266 void NotifyReadyToDraw();
273 void CheckIfReadyToActivate(); 267 void CheckIfReadyToActivate();
274 void CheckIfReadyToDraw(); 268 void CheckIfReadyToDraw();
275 void CheckIfMoreTilesNeedToBePrepared(); 269 void CheckIfMoreTilesNeedToBePrepared();
276 270
277 TileManagerClient* client_; 271 TileManagerClient* client_;
278 scoped_refptr<base::SequencedTaskRunner> task_runner_; 272 scoped_refptr<base::SequencedTaskRunner> task_runner_;
279 ResourcePool* resource_pool_; 273 ResourcePool* resource_pool_;
280 TileTaskRunner* tile_task_runner_; 274 TileTaskRunner* tile_task_runner_;
281 Rasterizer* rasterizer_;
282 GlobalStateThatImpactsTilePriority global_state_; 275 GlobalStateThatImpactsTilePriority global_state_;
283 size_t scheduled_raster_task_limit_; 276 size_t scheduled_raster_task_limit_;
284 277
285 typedef base::hash_map<Tile::Id, Tile*> TileMap; 278 typedef base::hash_map<Tile::Id, Tile*> TileMap;
286 TileMap tiles_; 279 TileMap tiles_;
287 280
288 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; 281 bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
289 MemoryHistory::Entry memory_stats_from_last_assign_; 282 MemoryHistory::Entry memory_stats_from_last_assign_;
290 283
291 bool did_check_for_completed_tasks_since_last_schedule_tasks_; 284 bool did_check_for_completed_tasks_since_last_schedule_tasks_;
292 bool did_oom_on_last_assign_; 285 bool did_oom_on_last_assign_;
293 286
294 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>> 287 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>>
295 PixelRefTaskMap; 288 PixelRefTaskMap;
296 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 289 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
297 LayerPixelRefTaskMap image_decode_tasks_; 290 LayerPixelRefTaskMap image_decode_tasks_;
298 291
299 typedef base::hash_map<int, int> LayerCountMap; 292 typedef base::hash_map<int, int> LayerCountMap;
300 LayerCountMap used_layer_counts_; 293 LayerCountMap used_layer_counts_;
301 294
302 RasterTaskCompletionStats update_visible_tiles_stats_; 295 RasterTaskCompletionStats update_visible_tiles_stats_;
303 296
304 std::vector<Tile*> released_tiles_; 297 std::vector<Tile*> released_tiles_;
305 298
306 // Queue used when scheduling raster tasks. 299 // Queue used when scheduling raster tasks.
307 TileTaskQueue raster_queue_; 300 TileTaskQueue raster_queue_;
308 301
309 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; 302 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_;
310 303
311 UniqueNotifier ready_to_activate_notifier_;
312 UniqueNotifier ready_to_draw_notifier_;
313 UniqueNotifier ready_to_activate_check_notifier_; 304 UniqueNotifier ready_to_activate_check_notifier_;
314 UniqueNotifier ready_to_draw_check_notifier_; 305 UniqueNotifier ready_to_draw_check_notifier_;
315 UniqueNotifier more_tiles_need_prepare_check_notifier_; 306 UniqueNotifier more_tiles_need_prepare_check_notifier_;
316 307
317 bool did_notify_ready_to_activate_; 308 bool did_notify_ready_to_activate_;
318 bool did_notify_ready_to_draw_; 309 bool did_notify_ready_to_draw_;
319 310
320 DISALLOW_COPY_AND_ASSIGN(TileManager); 311 DISALLOW_COPY_AND_ASSIGN(TileManager);
321 }; 312 };
322 313
323 } // namespace cc 314 } // namespace cc
324 315
325 #endif // CC_RESOURCES_TILE_MANAGER_H_ 316 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/software_rasterizer.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698