OLD | NEW |
---|---|
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; | 21 static unsigned kRasterTaskSetFinishedTaskPriority; |
reveman
2014/09/10 16:41:50
I think you can just remove this and use kRasterFi
ernstm
2014/09/10 18:26:19
Done.
| |
22 static unsigned kRasterTaskPriorityBase; | 22 static unsigned kRasterTaskPriorityBase; |
23 | 23 |
24 class TaskSetSizes { | |
25 public: | |
26 TaskSetSizes(); | |
27 explicit TaskSetSizes(const RasterTaskQueue* queue); | |
28 TaskSetCollection ToTaskSetCollection() const; | |
29 size_t& operator[](TaskSet task_set); | |
30 const size_t& operator[](TaskSet task_set) const; | |
31 bool operator==(const TaskSetSizes& other) const; | |
32 void operator+=(const TaskSetCollection& task_set_collection); | |
33 void operator-=(const TaskSetCollection& task_set_collection); | |
34 | |
35 private: | |
36 size_t sizes_[kNumberOfTaskSets]; | |
37 }; | |
38 | |
24 RasterWorkerPool(); | 39 RasterWorkerPool(); |
25 virtual ~RasterWorkerPool(); | 40 virtual ~RasterWorkerPool(); |
26 | 41 |
27 // Set the number of threads to use for the global TaskGraphRunner instance. | 42 // 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 | 43 // This can only be called once and must be called prior to |
29 // GetNumRasterThreads(). | 44 // GetNumRasterThreads(). |
30 static void SetNumRasterThreads(int num_threads); | 45 static void SetNumRasterThreads(int num_threads); |
31 | 46 |
32 // Returns the number of threads used for the global TaskGraphRunner instance. | 47 // Returns the number of threads used for the global TaskGraphRunner instance. |
33 static int GetNumRasterThreads(); | 48 static int GetNumRasterThreads(); |
34 | 49 |
35 // Returns a pointer to the global TaskGraphRunner instance. | 50 // Returns a pointer to the global TaskGraphRunner instance. |
36 static TaskGraphRunner* GetTaskGraphRunner(); | 51 static TaskGraphRunner* GetTaskGraphRunner(); |
37 | 52 |
38 // Utility function that can be used to create a "raster finished" task that | 53 // Utility function that can be used to create a "raster finished" task that |
39 // posts |callback| to |task_runner| when run. | 54 // posts |callback| to |task_runner| when run. |
40 static scoped_refptr<RasterizerTask> CreateRasterFinishedTask( | 55 static scoped_refptr<RasterizerTask> CreateRasterFinishedTask( |
41 base::SequencedTaskRunner* task_runner, | 56 base::SequencedTaskRunner* task_runner, |
42 const base::Closure& callback); | 57 const base::Closure& callback, |
43 | 58 base::debug::TraceEventSyntheticDelay* synthetic_delay); |
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 | 59 |
52 // Utility function that can be used to call ::ScheduleOnOriginThread() for | 60 // Utility function that can be used to call ::ScheduleOnOriginThread() for |
53 // each task in |graph|. | 61 // each task in |graph|. |
54 static void ScheduleTasksOnOriginThread(RasterizerTaskClient* client, | 62 static void ScheduleTasksOnOriginThread(RasterizerTaskClient* client, |
55 TaskGraph* graph); | 63 TaskGraph* graph); |
56 | 64 |
57 // Utility function that can be used to build a task graph. Inserts a node | 65 // 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 | 66 // that represents |task| in |graph|. See TaskGraph definition for valid |
59 // |priority| values. | 67 // |priority| values. |
60 static void InsertNodeForTask(TaskGraph* graph, | 68 static void InsertNodeForTask(TaskGraph* graph, |
61 RasterizerTask* task, | 69 RasterizerTask* task, |
62 unsigned priority, | 70 unsigned priority, |
63 size_t dependencies); | 71 size_t dependencies); |
64 | 72 |
65 // Utility function that can be used to build a task graph. Inserts nodes that | 73 // 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|. | 74 // represent |task| and all its image decode dependencies in |graph|. |
67 static void InsertNodesForRasterTask( | 75 static void InsertNodesForRasterTask( |
68 TaskGraph* graph, | 76 TaskGraph* graph, |
69 RasterTask* task, | 77 RasterTask* task, |
70 const ImageDecodeTask::Vector& decode_tasks, | 78 const ImageDecodeTask::Vector& decode_tasks, |
71 unsigned priority); | 79 unsigned priority); |
72 | 80 |
73 // Type-checking downcast routine. | 81 // Type-checking downcast routine. |
74 virtual Rasterizer* AsRasterizer() = 0; | 82 virtual Rasterizer* AsRasterizer() = 0; |
75 }; | 83 }; |
76 | 84 |
77 } // namespace cc | 85 } // namespace cc |
78 | 86 |
79 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ | 87 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ |
OLD | NEW |