Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
reveman
2016/04/19 00:05:30
Note: I think we can rename this file to tile_task
prashant.n
2016/04/19 01:19:02
Yes. I've a patch which merges TileTaskRunner inte
| |
| 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; | |
|
reveman
2016/04/19 00:05:30
can this be a implemented using a "const bool supp
prashant.n
2016/04/19 01:19:02
Yes.
| |
| 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 TileTask(); |
| 44 explicit TileTask(TileTask::Vector* dependencies); | |
| 36 ~TileTask() override; | 45 ~TileTask() override; |
| 37 | 46 |
| 47 TileTask::Vector dependencies_; | |
| 38 bool did_schedule_; | 48 bool did_schedule_; |
| 39 bool did_complete_; | 49 bool did_complete_; |
| 40 }; | 50 }; |
| 41 | 51 |
| 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. | 52 // This interface can be used to schedule and run tile tasks. |
| 79 // The client can call CheckForCompletedTasks() at any time to dispatch | 53 // The client can call CheckForCompletedTasks() at any time to dispatch |
| 80 // pending completion callbacks for all tasks that have finished running. | 54 // pending completion callbacks for all tasks that have finished running. |
| 81 class CC_EXPORT TileTaskRunner { | 55 class CC_EXPORT TileTaskRunner { |
| 82 public: | 56 public: |
| 83 // Tells the worker pool to shutdown after canceling all previously scheduled | 57 // Tells the worker pool to shutdown after canceling all previously scheduled |
| 84 // tasks. Reply callbacks are still guaranteed to run when | 58 // tasks. Reply callbacks are still guaranteed to run when |
| 85 // CheckForCompletedTasks() is called. | 59 // CheckForCompletedTasks() is called. |
| 86 virtual void Shutdown() = 0; | 60 virtual void Shutdown() = 0; |
| 87 | 61 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 107 protected: | 81 protected: |
| 108 // Check if resource format matches output format. | 82 // Check if resource format matches output format. |
| 109 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 83 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
| 110 | 84 |
| 111 virtual ~TileTaskRunner() {} | 85 virtual ~TileTaskRunner() {} |
| 112 }; | 86 }; |
| 113 | 87 |
| 114 } // namespace cc | 88 } // namespace cc |
| 115 | 89 |
| 116 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ | 90 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ |
| OLD | NEW |