Chromium Code Reviews| 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 kNumberOfTaskSets = 3; | |
| 96 typedef size_t TaskSet; | |
| 97 typedef std::bitset<kNumberOfTaskSets> TaskSetCollection; | |
| 98 | |
| 88 class CC_EXPORT RasterizerClient { | 99 class CC_EXPORT RasterizerClient { |
| 89 public: | 100 public: |
| 90 virtual bool ShouldForceTasksRequiredForActivationToComplete() const = 0; | 101 virtual void DidFinishRunningTaskSet(TaskSet task_set) = 0; |
|
ernstm
2014/09/10 18:26:19
I also renamed this to DidFinishRunningTasks(TaskS
| |
| 91 virtual void DidFinishRunningTasks() = 0; | 102 virtual TaskSetCollection TasksThatShouldBeForcedToComplete() const = 0; |
| 92 virtual void DidFinishRunningTasksRequiredForActivation() = 0; | 103 virtual base::debug::TraceEventSyntheticDelay* SyntheticDelayForTaskSet( |
|
ernstm
2014/09/10 18:26:19
and renamed this to SyntheticDelayForTasks(TaskSet
| |
| 104 TaskSet task_set) const = 0; | |
| 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 { |
| 100 class TaskComparator { | 112 class TaskComparator { |
| 101 public: | 113 public: |
| 102 explicit TaskComparator(const RasterTask* task) : task_(task) {} | 114 explicit TaskComparator(const RasterTask* task) : task_(task) {} |
| 103 | 115 |
| 104 bool operator()(const Item& item) const { return item.task == task_; } | 116 bool operator()(const Item& item) const { return item.task == task_; } |
| 105 | 117 |
| 106 private: | 118 private: |
| 107 const RasterTask* task_; | 119 const RasterTask* task_; |
| 108 }; | 120 }; |
| 109 | 121 |
| 110 typedef std::vector<Item> Vector; | 122 typedef std::vector<Item> Vector; |
| 111 | 123 |
| 112 Item(RasterTask* task, bool required_for_activation); | 124 Item(RasterTask* task, const TaskSetCollection& task_sets); |
| 113 ~Item(); | 125 ~Item(); |
| 114 | 126 |
| 115 static bool IsRequiredForActivation(const Item& item) { | |
| 116 return item.required_for_activation; | |
| 117 } | |
| 118 | |
| 119 RasterTask* task; | 127 RasterTask* task; |
| 120 bool required_for_activation; | 128 TaskSetCollection task_sets; |
| 121 }; | 129 }; |
| 122 | 130 |
| 123 RasterTaskQueue(); | 131 RasterTaskQueue(); |
| 124 ~RasterTaskQueue(); | 132 ~RasterTaskQueue(); |
| 125 | 133 |
| 126 void Swap(RasterTaskQueue* other); | 134 void Swap(RasterTaskQueue* other); |
| 127 void Reset(); | 135 void Reset(); |
| 128 | 136 |
| 129 Item::Vector items; | 137 Item::Vector items; |
| 130 size_t required_for_activation_count; | |
| 131 }; | 138 }; |
| 132 | 139 |
| 133 // This interface can be used to schedule and run raster tasks. The client will | 140 // 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 | 141 // be notified asynchronously when the set of tasks marked as "required for |
| 135 // activation" have finished running and when all scheduled tasks have finished | 142 // activation" have finished running and when all scheduled tasks have finished |
| 136 // running. The client can call CheckForCompletedTasks() at any time to dispatch | 143 // running. The client can call CheckForCompletedTasks() at any time to dispatch |
| 137 // pending completion callbacks for all tasks that have finished running. | 144 // pending completion callbacks for all tasks that have finished running. |
| 138 class CC_EXPORT Rasterizer { | 145 class CC_EXPORT Rasterizer { |
| 139 public: | 146 public: |
| 140 // Set the client instance to be notified when finished running tasks. | 147 // 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. | 162 // Check for completed tasks and dispatch reply callbacks. |
| 156 virtual void CheckForCompletedTasks() = 0; | 163 virtual void CheckForCompletedTasks() = 0; |
| 157 | 164 |
| 158 protected: | 165 protected: |
| 159 virtual ~Rasterizer() {} | 166 virtual ~Rasterizer() {} |
| 160 }; | 167 }; |
| 161 | 168 |
| 162 } // namespace cc | 169 } // namespace cc |
| 163 | 170 |
| 164 #endif // CC_RESOURCES_RASTERIZER_H_ | 171 #endif // CC_RESOURCES_RASTERIZER_H_ |
| OLD | NEW |