OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RASTER_TILE_TASK_RUNNER_H_ | 5 #ifndef CC_RASTER_TILE_TASK_RUNNER_H_ |
6 #define CC_RASTER_TILE_TASK_RUNNER_H_ | 6 #define CC_RASTER_TILE_TASK_RUNNER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "cc/raster/raster_buffer.h" | 13 #include "cc/raster/raster_buffer.h" |
14 #include "cc/raster/task_graph_runner.h" | 14 #include "cc/raster/task.h" |
15 #include "cc/resources/resource_format.h" | 15 #include "cc/resources/resource_format.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 class CC_EXPORT TileTask : public Task { | 19 class CC_EXPORT TileTask : public Task { |
20 public: | 20 public: |
21 typedef std::vector<scoped_refptr<TileTask>> Vector; | 21 typedef std::vector<scoped_refptr<TileTask>> Vector; |
22 | 22 |
23 const TileTask::Vector& dependencies() const { return dependencies_; } | |
24 | |
25 // Indicates whether this TileTask can be run at the same time as other tasks | |
26 // in the task graph. If false, this task will be scheduled with | |
27 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND. The base implementation always | |
28 // returns true. | |
29 bool SupportsConcurrentExecution() const { | |
reveman
2016/04/19 07:08:17
This should not be CamelCase as a simple getter. S
| |
30 return supports_concurrent_execution_; | |
31 } | |
32 | |
23 virtual void ScheduleOnOriginThread(RasterBufferProvider* provider) = 0; | 33 virtual void ScheduleOnOriginThread(RasterBufferProvider* provider) = 0; |
24 virtual void CompleteOnOriginThread(RasterBufferProvider* provider) = 0; | 34 virtual void CompleteOnOriginThread(RasterBufferProvider* provider) = 0; |
25 | 35 |
26 void WillSchedule(); | 36 void WillSchedule(); |
27 void DidSchedule(); | 37 void DidSchedule(); |
28 bool HasBeenScheduled() const; | 38 bool HasBeenScheduled() const; |
29 | 39 |
30 void WillComplete(); | 40 void WillComplete(); |
31 void DidComplete(); | 41 void DidComplete(); |
32 bool HasCompleted() const; | 42 bool HasCompleted() const; |
33 | 43 |
34 protected: | 44 protected: |
35 TileTask(); | 45 explicit TileTask(bool supports_concurrent_execution); |
46 TileTask(bool supports_concurrent_execution, TileTask::Vector* dependencies); | |
36 ~TileTask() override; | 47 ~TileTask() override; |
37 | 48 |
49 const bool supports_concurrent_execution_; | |
50 TileTask::Vector dependencies_; | |
38 bool did_schedule_; | 51 bool did_schedule_; |
39 bool did_complete_; | 52 bool did_complete_; |
40 }; | 53 }; |
41 | 54 |
42 class CC_EXPORT ImageDecodeTask : public TileTask { | |
43 public: | |
44 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector; | |
45 | |
46 // Indicates whether this ImageDecodeTask can be run at the same time as | |
47 // other tasks in the task graph. If false, this task will be scheduled with | |
48 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND. The base implementation always | |
49 // returns true. | |
50 virtual bool SupportsConcurrentExecution() const; | |
51 | |
52 // Returns an optional task which this task depends on. May be null. | |
53 const scoped_refptr<ImageDecodeTask>& dependency() { return dependency_; } | |
54 | |
55 protected: | |
56 ImageDecodeTask(); | |
57 explicit ImageDecodeTask(scoped_refptr<ImageDecodeTask> dependency); | |
58 ~ImageDecodeTask() override; | |
59 | |
60 private: | |
61 scoped_refptr<ImageDecodeTask> dependency_; | |
62 }; | |
63 | |
64 class CC_EXPORT RasterTask : public TileTask { | |
65 public: | |
66 typedef std::vector<scoped_refptr<RasterTask>> Vector; | |
67 | |
68 const ImageDecodeTask::Vector& dependencies() const { return dependencies_; } | |
69 | |
70 protected: | |
71 explicit RasterTask(ImageDecodeTask::Vector* dependencies); | |
72 ~RasterTask() override; | |
73 | |
74 private: | |
75 ImageDecodeTask::Vector dependencies_; | |
76 }; | |
77 | |
78 // This interface can be used to schedule and run tile tasks. | 55 // This interface can be used to schedule and run tile tasks. |
79 // The client can call CheckForCompletedTasks() at any time to dispatch | 56 // The client can call CheckForCompletedTasks() at any time to dispatch |
80 // pending completion callbacks for all tasks that have finished running. | 57 // pending completion callbacks for all tasks that have finished running. |
81 class CC_EXPORT TileTaskRunner { | 58 class CC_EXPORT TileTaskRunner { |
82 public: | 59 public: |
83 // Tells the worker pool to shutdown after canceling all previously scheduled | 60 // Tells the worker pool to shutdown after canceling all previously scheduled |
84 // tasks. Reply callbacks are still guaranteed to run when | 61 // tasks. Reply callbacks are still guaranteed to run when |
85 // CheckForCompletedTasks() is called. | 62 // CheckForCompletedTasks() is called. |
86 virtual void Shutdown() = 0; | 63 virtual void Shutdown() = 0; |
87 | 64 |
(...skipping 19 matching lines...) Expand all Loading... | |
107 protected: | 84 protected: |
108 // Check if resource format matches output format. | 85 // Check if resource format matches output format. |
109 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 86 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
110 | 87 |
111 virtual ~TileTaskRunner() {} | 88 virtual ~TileTaskRunner() {} |
112 }; | 89 }; |
113 | 90 |
114 } // namespace cc | 91 } // namespace cc |
115 | 92 |
116 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ | 93 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ |
OLD | NEW |