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 virtual bool SupportsConcurrentExecution() const; | |
prashant.n
2016/04/19 04:38:23
OR we can have pure virtual function to make deriv
reveman
2016/04/19 05:02:16
The point of adding the member was to remove the n
prashant.n
2016/04/19 05:28:07
Aaah. I missed to remove virtual keyword.
I took
| |
30 | |
23 virtual void ScheduleOnOriginThread(RasterBufferProvider* provider) = 0; | 31 virtual void ScheduleOnOriginThread(RasterBufferProvider* provider) = 0; |
24 virtual void CompleteOnOriginThread(RasterBufferProvider* provider) = 0; | 32 virtual void CompleteOnOriginThread(RasterBufferProvider* provider) = 0; |
25 | 33 |
26 void WillSchedule(); | 34 void WillSchedule(); |
27 void DidSchedule(); | 35 void DidSchedule(); |
28 bool HasBeenScheduled() const; | 36 bool HasBeenScheduled() const; |
29 | 37 |
30 void WillComplete(); | 38 void WillComplete(); |
31 void DidComplete(); | 39 void DidComplete(); |
32 bool HasCompleted() const; | 40 bool HasCompleted() const; |
33 | 41 |
34 protected: | 42 protected: |
35 TileTask(); | 43 explicit TileTask(bool supports_concurrent_execution); |
prashant.n
2016/04/19 04:06:02
Here we cannot prevent implicit cast of pointer to
| |
44 TileTask(bool supports_concurrent_execution, TileTask::Vector* dependencies); | |
36 ~TileTask() override; | 45 ~TileTask() override; |
37 | 46 |
47 const bool supports_concurrent_execution_; | |
48 TileTask::Vector dependencies_; | |
38 bool did_schedule_; | 49 bool did_schedule_; |
39 bool did_complete_; | 50 bool did_complete_; |
40 }; | 51 }; |
41 | 52 |
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. | 53 // This interface can be used to schedule and run tile tasks. |
79 // The client can call CheckForCompletedTasks() at any time to dispatch | 54 // The client can call CheckForCompletedTasks() at any time to dispatch |
80 // pending completion callbacks for all tasks that have finished running. | 55 // pending completion callbacks for all tasks that have finished running. |
81 class CC_EXPORT TileTaskRunner { | 56 class CC_EXPORT TileTaskRunner { |
82 public: | 57 public: |
83 // Tells the worker pool to shutdown after canceling all previously scheduled | 58 // Tells the worker pool to shutdown after canceling all previously scheduled |
84 // tasks. Reply callbacks are still guaranteed to run when | 59 // tasks. Reply callbacks are still guaranteed to run when |
85 // CheckForCompletedTasks() is called. | 60 // CheckForCompletedTasks() is called. |
86 virtual void Shutdown() = 0; | 61 virtual void Shutdown() = 0; |
87 | 62 |
(...skipping 19 matching lines...) Expand all Loading... | |
107 protected: | 82 protected: |
108 // Check if resource format matches output format. | 83 // Check if resource format matches output format. |
109 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 84 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
110 | 85 |
111 virtual ~TileTaskRunner() {} | 86 virtual ~TileTaskRunner() {} |
112 }; | 87 }; |
113 | 88 |
114 } // namespace cc | 89 } // namespace cc |
115 | 90 |
116 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ | 91 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ |
OLD | NEW |