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_RESOURCES_RASTERIZER_H_ | 5 #ifndef CC_RESOURCES_RASTERIZER_H_ |
6 #define CC_RESOURCES_RASTERIZER_H_ | 6 #define CC_RESOURCES_RASTERIZER_H_ |
7 | 7 |
8 #include <bitset> | |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "cc/resources/resource_format.h" | 12 #include "cc/resources/resource_format.h" |
12 #include "cc/resources/task_graph_runner.h" | 13 #include "cc/resources/task_graph_runner.h" |
13 | 14 |
15 namespace base { | |
16 namespace debug { | |
17 class TraceEventSyntheticDelay; | |
18 } | |
19 } | |
20 | |
14 namespace cc { | 21 namespace cc { |
15 class ImageDecodeTask; | 22 class ImageDecodeTask; |
16 class RasterTask; | 23 class RasterTask; |
17 class Resource; | 24 class Resource; |
18 class RasterBuffer; | 25 class RasterBuffer; |
19 | 26 |
20 class CC_EXPORT RasterizerTaskClient { | 27 class CC_EXPORT RasterizerTaskClient { |
21 public: | 28 public: |
22 virtual RasterBuffer* AcquireBufferForRaster(RasterTask* task) = 0; | 29 virtual RasterBuffer* AcquireBufferForRaster(RasterTask* task) = 0; |
23 virtual void ReleaseBufferForRaster(RasterTask* task) = 0; | 30 virtual void ReleaseBufferForRaster(RasterTask* task) = 0; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 85 |
79 protected: | 86 protected: |
80 RasterTask(const Resource* resource, ImageDecodeTask::Vector* dependencies); | 87 RasterTask(const Resource* resource, ImageDecodeTask::Vector* dependencies); |
81 virtual ~RasterTask(); | 88 virtual ~RasterTask(); |
82 | 89 |
83 private: | 90 private: |
84 const Resource* resource_; | 91 const Resource* resource_; |
85 ImageDecodeTask::Vector dependencies_; | 92 ImageDecodeTask::Vector dependencies_; |
86 }; | 93 }; |
87 | 94 |
95 static const size_t kMaxTaskSet = 2; | |
reveman
2014/09/05 08:38:59
This is really number of task sets. Either set it
ernstm
2014/09/05 21:36:11
Done.
| |
96 typedef size_t TaskSet; | |
97 | |
88 class CC_EXPORT RasterizerClient { | 98 class CC_EXPORT RasterizerClient { |
89 public: | 99 public: |
90 virtual bool ShouldForceTasksRequiredForActivationToComplete() const = 0; | |
91 virtual void DidFinishRunningTasks() = 0; | 100 virtual void DidFinishRunningTasks() = 0; |
92 virtual void DidFinishRunningTasksRequiredForActivation() = 0; | 101 virtual void DidFinishRunningTaskSet(TaskSet task_set) = 0; |
102 virtual bool ShouldForceTaskSetToComplete(TaskSet task_set) const = 0; | |
103 virtual base::debug::TraceEventSyntheticDelay* SyntheticDelayForTaskSet( | |
104 TaskSet task_set) const = 0; | |
reveman
2014/09/05 08:38:59
Not a fan of how much influence this synthetic del
ernstm
2014/09/05 21:36:11
I don't think so, because now only the TileManager
| |
93 | 105 |
94 protected: | 106 protected: |
95 virtual ~RasterizerClient() {} | 107 virtual ~RasterizerClient() {} |
96 }; | 108 }; |
97 | 109 |
98 struct CC_EXPORT RasterTaskQueue { | 110 struct CC_EXPORT RasterTaskQueue { |
99 struct CC_EXPORT Item { | 111 struct CC_EXPORT Item { |
112 typedef std::bitset<kMaxTaskSet> TaskSetCollection; | |
ernstm
2014/08/29 23:32:10
should we call this TaskSetFlags, because it is no
reveman
2014/09/05 08:38:59
Moving it up next to the TaskSet typedef sgtm. I w
ernstm
2014/09/05 21:36:11
Done.
| |
113 | |
100 class TaskComparator { | 114 class TaskComparator { |
101 public: | 115 public: |
102 explicit TaskComparator(const RasterTask* task) : task_(task) {} | 116 explicit TaskComparator(const RasterTask* task) : task_(task) {} |
103 | 117 |
104 bool operator()(const Item& item) const { return item.task == task_; } | 118 bool operator()(const Item& item) const { return item.task == task_; } |
105 | 119 |
106 private: | 120 private: |
107 const RasterTask* task_; | 121 const RasterTask* task_; |
108 }; | 122 }; |
109 | 123 |
110 typedef std::vector<Item> Vector; | 124 typedef std::vector<Item> Vector; |
111 | 125 |
112 Item(RasterTask* task, bool required_for_activation); | 126 Item(RasterTask* task, const TaskSetCollection& task_sets); |
113 ~Item(); | 127 ~Item(); |
114 | 128 |
115 static bool IsRequiredForActivation(const Item& item) { | 129 RasterTask* task; |
116 return item.required_for_activation; | 130 TaskSetCollection task_sets; |
117 } | 131 }; |
118 | 132 |
119 RasterTask* task; | 133 class TaskSetSizes { |
ernstm
2014/08/29 23:32:10
Should we move this into cc namespace, because it
| |
120 bool required_for_activation; | 134 public: |
135 TaskSetSizes(); | |
136 Item::TaskSetCollection ToTaskSetCollection() const; | |
137 size_t& operator[](TaskSet task_set); | |
138 const size_t& operator[](TaskSet task_set) const; | |
139 bool operator==(const TaskSetSizes& other) const; | |
140 void operator+=(const Item::TaskSetCollection& task_set_collection); | |
141 void operator-=(const Item::TaskSetCollection& task_set_collection); | |
142 | |
143 private: | |
144 size_t sizes_[kMaxTaskSet]; | |
121 }; | 145 }; |
122 | 146 |
123 RasterTaskQueue(); | 147 RasterTaskQueue(); |
124 ~RasterTaskQueue(); | 148 ~RasterTaskQueue(); |
125 | 149 |
150 bool VerifyTaskSetSizes() const; | |
reveman
2014/09/05 08:38:59
I'd prefer if this was not part of the API as it's
ernstm
2014/09/05 21:36:11
Done. We don't need it anymore, if TaskSetSizes is
| |
126 void Swap(RasterTaskQueue* other); | 151 void Swap(RasterTaskQueue* other); |
127 void Reset(); | 152 void Reset(); |
128 | 153 |
129 Item::Vector items; | 154 Item::Vector items; |
130 size_t required_for_activation_count; | 155 TaskSetSizes task_set_sizes; |
reveman
2014/09/05 08:38:59
I think we can remove this and make it internal to
ernstm
2014/09/05 21:36:11
Done. Although I'm not sure if this is the best tr
| |
131 }; | 156 }; |
132 | 157 |
133 // This interface can be used to schedule and run raster tasks. The client will | 158 // This interface can be used to schedule and run raster tasks. The client will |
134 // be notified asynchronously when the set of tasks marked as "required for | 159 // be notified asynchronously when the set of tasks marked as "required for |
135 // activation" have finished running and when all scheduled tasks have finished | 160 // activation" have finished running and when all scheduled tasks have finished |
136 // running. The client can call CheckForCompletedTasks() at any time to dispatch | 161 // running. The client can call CheckForCompletedTasks() at any time to dispatch |
137 // pending completion callbacks for all tasks that have finished running. | 162 // pending completion callbacks for all tasks that have finished running. |
138 class CC_EXPORT Rasterizer { | 163 class CC_EXPORT Rasterizer { |
139 public: | 164 public: |
140 // Set the client instance to be notified when finished running tasks. | 165 // Set the client instance to be notified when finished running tasks. |
(...skipping 14 matching lines...) Expand all Loading... | |
155 // Check for completed tasks and dispatch reply callbacks. | 180 // Check for completed tasks and dispatch reply callbacks. |
156 virtual void CheckForCompletedTasks() = 0; | 181 virtual void CheckForCompletedTasks() = 0; |
157 | 182 |
158 protected: | 183 protected: |
159 virtual ~Rasterizer() {} | 184 virtual ~Rasterizer() {} |
160 }; | 185 }; |
161 | 186 |
162 } // namespace cc | 187 } // namespace cc |
163 | 188 |
164 #endif // CC_RESOURCES_RASTERIZER_H_ | 189 #endif // CC_RESOURCES_RASTERIZER_H_ |
OLD | NEW |