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

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

Issue 523243002: cc: Generalize raster task notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RASTER_WORKER_POOL_H_ 5 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_
6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_ 6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_
7 7
8 #include "cc/resources/rasterizer.h" 8 #include "cc/resources/rasterizer.h"
9 9
10 namespace base { 10 namespace base {
11 class SequencedTaskRunner; 11 class SequencedTaskRunner;
12 } 12 }
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class CC_EXPORT RasterWorkerPool { 16 class CC_EXPORT RasterWorkerPool {
17 public: 17 public:
18 static unsigned kOnDemandRasterTaskPriority; 18 static unsigned kOnDemandRasterTaskPriority;
19 static unsigned kBenchmarkRasterTaskPriority; 19 static unsigned kBenchmarkRasterTaskPriority;
20 static unsigned kRasterFinishedTaskPriority; 20 static unsigned kRasterFinishedTaskPriority;
21 static unsigned kRasterRequiredForActivationFinishedTaskPriority;
22 static unsigned kRasterTaskPriorityBase; 21 static unsigned kRasterTaskPriorityBase;
23 22
24 RasterWorkerPool(); 23 RasterWorkerPool();
25 virtual ~RasterWorkerPool(); 24 virtual ~RasterWorkerPool();
26 25
27 // Set the number of threads to use for the global TaskGraphRunner instance. 26 // Set the number of threads to use for the global TaskGraphRunner instance.
28 // This can only be called once and must be called prior to 27 // This can only be called once and must be called prior to
29 // GetNumRasterThreads(). 28 // GetNumRasterThreads().
30 static void SetNumRasterThreads(int num_threads); 29 static void SetNumRasterThreads(int num_threads);
31 30
32 // Returns the number of threads used for the global TaskGraphRunner instance. 31 // Returns the number of threads used for the global TaskGraphRunner instance.
33 static int GetNumRasterThreads(); 32 static int GetNumRasterThreads();
34 33
35 // Returns a pointer to the global TaskGraphRunner instance. 34 // Returns a pointer to the global TaskGraphRunner instance.
36 static TaskGraphRunner* GetTaskGraphRunner(); 35 static TaskGraphRunner* GetTaskGraphRunner();
37 36
38 // Utility function that can be used to create a "raster finished" task that 37 // Utility function that can be used to create a "raster finished" task that
39 // posts |callback| to |task_runner| when run. 38 // posts |callback| to |task_runner| when run.
40 static scoped_refptr<RasterizerTask> CreateRasterFinishedTask( 39 static scoped_refptr<RasterizerTask> CreateRasterFinishedTask(
41 base::SequencedTaskRunner* task_runner, 40 base::SequencedTaskRunner* task_runner,
42 const base::Closure& callback); 41 const base::Closure& callback);
43 42
44 // Utility function that can be used to create a "raster required for
45 // activation finished" task that posts |callback| to |task_runner| when run.
46 static scoped_refptr<RasterizerTask>
47 CreateRasterRequiredForActivationFinishedTask(
48 size_t tasks_required_for_activation_count,
49 base::SequencedTaskRunner* task_runner,
50 const base::Closure& callback);
51
52 // Utility function that can be used to call ::ScheduleOnOriginThread() for 43 // Utility function that can be used to call ::ScheduleOnOriginThread() for
53 // each task in |graph|. 44 // each task in |graph|.
54 static void ScheduleTasksOnOriginThread(RasterizerTaskClient* client, 45 static void ScheduleTasksOnOriginThread(RasterizerTaskClient* client,
55 TaskGraph* graph); 46 TaskGraph* graph);
56 47
57 // Utility function that can be used to build a task graph. Inserts a node 48 // Utility function that can be used to build a task graph. Inserts a node
58 // that represents |task| in |graph|. See TaskGraph definition for valid 49 // that represents |task| in |graph|. See TaskGraph definition for valid
59 // |priority| values. 50 // |priority| values.
60 static void InsertNodeForTask(TaskGraph* graph, 51 static void InsertNodeForTask(TaskGraph* graph,
61 RasterizerTask* task, 52 RasterizerTask* task,
62 unsigned priority, 53 unsigned priority,
63 size_t dependencies); 54 size_t dependencies);
64 55
65 // Utility function that can be used to build a task graph. Inserts nodes that 56 // Utility function that can be used to build a task graph. Inserts nodes that
66 // represent |task| and all its image decode dependencies in |graph|. 57 // represent |task| and all its image decode dependencies in |graph|.
67 static void InsertNodesForRasterTask( 58 static void InsertNodesForRasterTask(
68 TaskGraph* graph, 59 TaskGraph* graph,
69 RasterTask* task, 60 RasterTask* task,
70 const ImageDecodeTask::Vector& decode_tasks, 61 const ImageDecodeTask::Vector& decode_tasks,
71 unsigned priority); 62 unsigned priority);
72 63
73 // Type-checking downcast routine. 64 // Type-checking downcast routine.
74 virtual Rasterizer* AsRasterizer() = 0; 65 virtual Rasterizer* AsRasterizer() = 0;
75 }; 66 };
76 67
77 } // namespace cc 68 } // namespace cc
78 69
79 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ 70 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698