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

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

Issue 2007163002: cc: Separate raster and decode prepaint regions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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_TILES_TILE_MANAGER_H_ 5 #ifndef CC_TILES_TILE_MANAGER_H_
6 #define CC_TILES_TILE_MANAGER_H_ 6 #define CC_TILES_TILE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // This class manages tiles, deciding which should get rasterized and which 92 // This class manages tiles, deciding which should get rasterized and which
93 // should no longer have any memory assigned to them. Tile objects are "owned" 93 // should no longer have any memory assigned to them. Tile objects are "owned"
94 // by layers; they automatically register with the manager when they are 94 // by layers; they automatically register with the manager when they are
95 // created, and unregister from the manager when they are deleted. 95 // created, and unregister from the manager when they are deleted.
96 class CC_EXPORT TileManager { 96 class CC_EXPORT TileManager {
97 public: 97 public:
98 TileManager(TileManagerClient* client, 98 TileManager(TileManagerClient* client,
99 scoped_refptr<base::SequencedTaskRunner> task_runner, 99 scoped_refptr<base::SequencedTaskRunner> task_runner,
100 size_t scheduled_raster_task_limit, 100 size_t scheduled_raster_task_limit,
101 bool use_partial_raster); 101 bool use_partial_raster,
102 int max_preraster_distance_in_screen_pixels);
102 virtual ~TileManager(); 103 virtual ~TileManager();
103 104
104 // Assigns tile memory and schedules work to prepare tiles for drawing. 105 // Assigns tile memory and schedules work to prepare tiles for drawing.
105 // - Runs client_->NotifyReadyToActivate() when all tiles required for 106 // - Runs client_->NotifyReadyToActivate() when all tiles required for
106 // activation are prepared, or failed to prepare due to OOM. 107 // activation are prepared, or failed to prepare due to OOM.
107 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are 108 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are
108 // prepared, or failed to prepare due to OOM. 109 // prepared, or failed to prepare due to OOM.
109 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); 110 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state);
110 111
111 // Synchronously finish any in progress work, cancel the rest, and clean up as 112 // Synchronously finish any in progress work, cancel the rest, and clean up as
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 197
197 protected: 198 protected:
198 void FreeResourcesForReleasedTiles(); 199 void FreeResourcesForReleasedTiles();
199 void CleanUpReleasedTiles(); 200 void CleanUpReleasedTiles();
200 201
201 friend class Tile; 202 friend class Tile;
202 // Virtual for testing. 203 // Virtual for testing.
203 virtual void Release(Tile* tile); 204 virtual void Release(Tile* tile);
204 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } 205 Tile::Id GetUniqueTileId() { return ++next_tile_id_; }
205 206
206 // Virtual for test
207 virtual void ScheduleTasks(
208 const std::vector<PrioritizedTile>& tiles_that_need_to_be_rasterized);
209
210 private: 207 private:
211 class MemoryUsage { 208 class MemoryUsage {
212 public: 209 public:
213 MemoryUsage(); 210 MemoryUsage();
214 MemoryUsage(size_t memory_bytes, size_t resource_count); 211 MemoryUsage(size_t memory_bytes, size_t resource_count);
215 212
216 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); 213 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format);
217 static MemoryUsage FromTile(const Tile* tile); 214 static MemoryUsage FromTile(const Tile* tile);
218 215
219 MemoryUsage& operator+=(const MemoryUsage& other); 216 MemoryUsage& operator+=(const MemoryUsage& other);
220 MemoryUsage& operator-=(const MemoryUsage& other); 217 MemoryUsage& operator-=(const MemoryUsage& other);
221 MemoryUsage operator-(const MemoryUsage& other); 218 MemoryUsage operator-(const MemoryUsage& other);
222 219
223 bool Exceeds(const MemoryUsage& limit) const; 220 bool Exceeds(const MemoryUsage& limit) const;
224 int64_t memory_bytes() const { return memory_bytes_; } 221 int64_t memory_bytes() const { return memory_bytes_; }
225 222
226 private: 223 private:
227 int64_t memory_bytes_; 224 int64_t memory_bytes_;
228 int resource_count_; 225 int resource_count_;
229 }; 226 };
230 227
228 struct Signals {
229 Signals();
230
231 void reset();
232
233 bool ready_to_activate;
234 bool did_notify_ready_to_activate;
235 bool ready_to_draw;
236 bool did_notify_ready_to_draw;
237 bool all_tile_tasks_completed;
238 bool did_notify_all_tile_tasks_completed;
239 };
240
241 struct PrioritizedWorkToSchedule {
242 PrioritizedWorkToSchedule();
243 PrioritizedWorkToSchedule(PrioritizedWorkToSchedule&& other);
244 ~PrioritizedWorkToSchedule();
245
246 std::vector<PrioritizedTile> tiles_to_raster;
247 std::vector<PrioritizedTile> tiles_to_process_for_images;
248 };
249
231 void OnRasterTaskCompleted( 250 void OnRasterTaskCompleted(
232 Tile::Id tile, 251 Tile::Id tile,
233 Resource* resource, 252 Resource* resource,
234 bool was_canceled); 253 bool was_canceled);
235 254
236 void FreeResourcesForTile(Tile* tile); 255 void FreeResourcesForTile(Tile* tile);
237 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); 256 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile);
238 scoped_refptr<TileTask> CreateRasterTask( 257 scoped_refptr<TileTask> CreateRasterTask(
239 const PrioritizedTile& prioritized_tile); 258 const PrioritizedTile& prioritized_tile);
240 259
(...skipping 17 matching lines...) Expand all
258 277
259 ResourceFormat DetermineResourceFormat(const Tile* tile) const; 278 ResourceFormat DetermineResourceFormat(const Tile* tile) const;
260 bool DetermineResourceRequiresSwizzle(const Tile* tile) const; 279 bool DetermineResourceRequiresSwizzle(const Tile* tile) const;
261 280
262 void DidFinishRunningTileTasksRequiredForActivation(); 281 void DidFinishRunningTileTasksRequiredForActivation();
263 void DidFinishRunningTileTasksRequiredForDraw(); 282 void DidFinishRunningTileTasksRequiredForDraw();
264 void DidFinishRunningAllTileTasks(); 283 void DidFinishRunningAllTileTasks();
265 284
266 scoped_refptr<TileTask> CreateTaskSetFinishedTask( 285 scoped_refptr<TileTask> CreateTaskSetFinishedTask(
267 void (TileManager::*callback)()); 286 void (TileManager::*callback)());
268 std::vector<PrioritizedTile> AssignGpuMemoryToTiles(); 287 PrioritizedWorkToSchedule AssignGpuMemoryToTiles();
288 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule);
269 289
270 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 290 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
271 ScheduledTasksStateAsValue() const; 291 ScheduledTasksStateAsValue() const;
272 292
273 TileManagerClient* client_; 293 TileManagerClient* client_;
274 scoped_refptr<base::SequencedTaskRunner> task_runner_; 294 scoped_refptr<base::SequencedTaskRunner> task_runner_;
275 ResourcePool* resource_pool_; 295 ResourcePool* resource_pool_;
276 TileTaskManager* tile_task_manager_; 296 TileTaskManager* tile_task_manager_;
277 GlobalStateThatImpactsTilePriority global_state_; 297 GlobalStateThatImpactsTilePriority global_state_;
278 size_t scheduled_raster_task_limit_; 298 size_t scheduled_raster_task_limit_;
(...skipping 16 matching lines...) Expand all
295 315
296 std::vector<scoped_refptr<TileTask>> orphan_tasks_; 316 std::vector<scoped_refptr<TileTask>> orphan_tasks_;
297 317
298 TaskGraph graph_; 318 TaskGraph graph_;
299 scoped_refptr<TileTask> required_for_activation_done_task_; 319 scoped_refptr<TileTask> required_for_activation_done_task_;
300 scoped_refptr<TileTask> required_for_draw_done_task_; 320 scoped_refptr<TileTask> required_for_draw_done_task_;
301 scoped_refptr<TileTask> all_done_task_; 321 scoped_refptr<TileTask> all_done_task_;
302 322
303 UniqueNotifier more_tiles_need_prepare_check_notifier_; 323 UniqueNotifier more_tiles_need_prepare_check_notifier_;
304 324
305 struct Signals { 325 Signals signals_;
306 Signals();
307
308 void reset();
309
310 bool ready_to_activate;
311 bool did_notify_ready_to_activate;
312 bool ready_to_draw;
313 bool did_notify_ready_to_draw;
314 bool all_tile_tasks_completed;
315 bool did_notify_all_tile_tasks_completed;
316 } signals_;
317 326
318 UniqueNotifier signals_check_notifier_; 327 UniqueNotifier signals_check_notifier_;
319 328
320 bool has_scheduled_tile_tasks_; 329 bool has_scheduled_tile_tasks_;
321 330
322 uint64_t prepare_tiles_count_; 331 uint64_t prepare_tiles_count_;
323 uint64_t next_tile_id_; 332 uint64_t next_tile_id_;
324 333
325 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; 334 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_;
335 const int max_preraster_distance_in_screen_pixels_;
336 std::vector<std::pair<DrawImage, scoped_refptr<TileTask>>> locked_images_;
326 337
327 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; 338 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_;
328 339
329 DISALLOW_COPY_AND_ASSIGN(TileManager); 340 DISALLOW_COPY_AND_ASSIGN(TileManager);
330 }; 341 };
331 342
332 } // namespace cc 343 } // namespace cc
333 344
334 #endif // CC_TILES_TILE_MANAGER_H_ 345 #endif // CC_TILES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/test/fake_tile_manager.cc ('k') | cc/tiles/tile_manager.cc » ('j') | cc/tiles/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698