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

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

Powered by Google App Engine
This is Rietveld 408576698