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/dependency_task.h" |
13 #include "cc/raster/task_graph_runner.h" | 14 #include "cc/raster/task_graph_runner.h" |
14 #include "cc/resources/resource_format.h" | 15 #include "cc/resources/resource_format.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 class ImageDecodeTask; | |
18 class RasterTask; | |
19 class Resource; | |
20 class RasterBuffer; | |
21 | |
22 class CC_EXPORT TileTaskClient { | |
23 public: | |
24 virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster( | |
25 const Resource* resource, | |
26 uint64_t resource_content_id, | |
27 uint64_t previous_content_id) = 0; | |
28 virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) = 0; | |
29 | |
30 protected: | |
31 virtual ~TileTaskClient() {} | |
32 }; | |
33 | |
34 class CC_EXPORT TileTask : public Task { | |
35 public: | |
36 typedef std::vector<scoped_refptr<TileTask>> Vector; | |
37 | |
38 virtual void ScheduleOnOriginThread(TileTaskClient* client) = 0; | |
39 virtual void CompleteOnOriginThread(TileTaskClient* client) = 0; | |
40 | |
41 void WillSchedule(); | |
42 void DidSchedule(); | |
43 bool HasBeenScheduled() const; | |
44 | |
45 void WillComplete(); | |
46 void DidComplete(); | |
47 bool HasCompleted() const; | |
48 | |
49 protected: | |
50 TileTask(); | |
51 ~TileTask() override; | |
52 | |
53 bool did_schedule_; | |
54 bool did_complete_; | |
55 }; | |
56 | |
57 class CC_EXPORT ImageDecodeTask : public TileTask { | |
58 public: | |
59 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector; | |
60 | |
61 protected: | |
62 ImageDecodeTask(); | |
63 ~ImageDecodeTask() override; | |
64 }; | |
65 | |
66 class CC_EXPORT RasterTask : public TileTask { | |
67 public: | |
68 typedef std::vector<scoped_refptr<RasterTask>> Vector; | |
69 | |
70 const ImageDecodeTask::Vector& dependencies() const { return dependencies_; } | |
71 | |
72 protected: | |
73 explicit RasterTask(ImageDecodeTask::Vector* dependencies); | |
74 ~RasterTask() override; | |
75 | |
76 private: | |
77 ImageDecodeTask::Vector dependencies_; | |
78 }; | |
79 | 18 |
80 // This interface can be used to schedule and run tile tasks. | 19 // This interface can be used to schedule and run tile tasks. |
81 // The client can call CheckForCompletedTasks() at any time to dispatch | 20 // The client can call CheckForCompletedTasks() at any time to dispatch |
82 // pending completion callbacks for all tasks that have finished running. | 21 // pending completion callbacks for all tasks that have finished running. |
83 class CC_EXPORT TileTaskRunner { | 22 class CC_EXPORT TileTaskRunner { |
84 public: | 23 public: |
85 // Tells the worker pool to shutdown after canceling all previously scheduled | 24 // Tells the worker pool to shutdown after canceling all previously scheduled |
86 // tasks. Reply callbacks are still guaranteed to run when | 25 // tasks. Reply callbacks are still guaranteed to run when |
87 // CheckForCompletedTasks() is called. | 26 // CheckForCompletedTasks() is called. |
88 virtual void Shutdown() = 0; | 27 virtual void Shutdown() = 0; |
(...skipping 17 matching lines...) Expand all Loading... |
106 protected: | 45 protected: |
107 // Check if resource format matches output format. | 46 // Check if resource format matches output format. |
108 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 47 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
109 | 48 |
110 virtual ~TileTaskRunner() {} | 49 virtual ~TileTaskRunner() {} |
111 }; | 50 }; |
112 | 51 |
113 } // namespace cc | 52 } // namespace cc |
114 | 53 |
115 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ | 54 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ |
OLD | NEW |