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/task_graph_runner.h" | 13 #include "cc/raster/task_graph_runner.h" |
14 #include "cc/resources/resource_format.h" | 14 #include "cc/resources/resource_format.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class ImageDecodeTask; | 17 class ImageDecodeTask; |
18 class RasterTask; | 18 class RasterTask; |
19 class Resource; | 19 class Resource; |
20 class RasterBuffer; | 20 class RasterBuffer; |
21 | 21 |
| 22 const TaskTypeId kRasterTaskTypeId = kDefaultTaskTypeId + 1; |
| 23 const TaskTypeId kImageDecodeTaskTypeId = kDefaultTaskTypeId + 2; |
| 24 |
22 class CC_EXPORT TileTaskClient { | 25 class CC_EXPORT TileTaskClient { |
23 public: | 26 public: |
24 virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster( | 27 virtual std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
25 const Resource* resource, | 28 const Resource* resource, |
26 uint64_t resource_content_id, | 29 uint64_t resource_content_id, |
27 uint64_t previous_content_id) = 0; | 30 uint64_t previous_content_id) = 0; |
28 virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0; | 31 virtual void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) = 0; |
29 | 32 |
30 protected: | 33 protected: |
31 virtual ~TileTaskClient() {} | 34 virtual ~TileTaskClient() {} |
32 }; | 35 }; |
33 | 36 |
34 class CC_EXPORT TileTask : public Task { | 37 class CC_EXPORT TileTask : public Task { |
35 public: | 38 public: |
36 typedef std::vector<scoped_refptr<TileTask>> Vector; | 39 typedef std::vector<scoped_refptr<TileTask>> Vector; |
37 | 40 |
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(); | 41 void DidComplete(); |
47 bool HasCompleted() const; | 42 bool HasCompleted() const; |
48 | 43 |
49 protected: | 44 protected: |
50 TileTask(); | 45 TileTask(); |
51 ~TileTask() override; | 46 ~TileTask() override; |
52 | 47 |
53 bool did_schedule_; | 48 // TODO(prashant.n): Remove this. |
54 bool did_complete_; | 49 bool did_complete_; |
55 }; | 50 }; |
56 | 51 |
57 class CC_EXPORT ImageDecodeTask : public TileTask { | 52 class CC_EXPORT ImageDecodeTask : public TileTask { |
58 public: | 53 public: |
59 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector; | 54 typedef std::vector<scoped_refptr<ImageDecodeTask>> Vector; |
60 | 55 |
61 protected: | 56 protected: |
62 ImageDecodeTask(); | 57 ImageDecodeTask(); |
63 ~ImageDecodeTask() override; | 58 ~ImageDecodeTask() override; |
(...skipping 23 matching lines...) Expand all Loading... |
87 // CheckForCompletedTasks() is called. | 82 // CheckForCompletedTasks() is called. |
88 virtual void Shutdown() = 0; | 83 virtual void Shutdown() = 0; |
89 | 84 |
90 // Schedule running of tile tasks in |graph| and all dependencies. | 85 // Schedule running of tile tasks in |graph| and all dependencies. |
91 // Previously scheduled tasks that are not in |graph| will be canceled unless | 86 // Previously scheduled tasks that are not in |graph| will be canceled unless |
92 // already running. Once scheduled, reply callbacks are guaranteed to run for | 87 // already running. Once scheduled, reply callbacks are guaranteed to run for |
93 // all tasks even if they later get canceled by another call to | 88 // all tasks even if they later get canceled by another call to |
94 // ScheduleTasks(). | 89 // ScheduleTasks(). |
95 virtual void ScheduleTasks(TaskGraph* graph) = 0; | 90 virtual void ScheduleTasks(TaskGraph* graph) = 0; |
96 | 91 |
97 // Check for completed tasks and dispatch reply callbacks. | 92 // Collect completed tasks. |
98 virtual void CheckForCompletedTasks() = 0; | 93 virtual void CollectCompletedTasks(Task::Vector* completed_tasks) = 0; |
99 | 94 |
100 // Returns the format to use for the tiles. | 95 // Returns the format to use for the tiles. |
101 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; | 96 virtual ResourceFormat GetResourceFormat(bool must_support_alpha) const = 0; |
102 | 97 |
103 // Determine if the resource requires swizzling. | 98 // Determine if the resource requires swizzling. |
104 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; | 99 virtual bool GetResourceRequiresSwizzle(bool must_support_alpha) const = 0; |
105 | 100 |
| 101 // TODO(prashant.n): This will be removed soon. Don't use this. |
| 102 virtual TileTaskClient* AsTileTaskClient() = 0; |
| 103 |
106 protected: | 104 protected: |
107 // Check if resource format matches output format. | 105 // Check if resource format matches output format. |
108 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); | 106 static bool ResourceFormatRequiresSwizzle(ResourceFormat format); |
109 | 107 |
110 virtual ~TileTaskRunner() {} | 108 virtual ~TileTaskRunner() {} |
111 }; | 109 }; |
112 | 110 |
113 } // namespace cc | 111 } // namespace cc |
114 | 112 |
115 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ | 113 #endif // CC_RASTER_TILE_TASK_RUNNER_H_ |
OLD | NEW |