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 |
14 namespace cc { | 15 namespace cc { |
15 class ImageDecodeTask; | 16 class ImageDecodeTask; |
16 class RasterTask; | 17 class RasterTask; |
17 class Resource; | 18 class Resource; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 79 |
79 protected: | 80 protected: |
80 RasterTask(const Resource* resource, ImageDecodeTask::Vector* dependencies); | 81 RasterTask(const Resource* resource, ImageDecodeTask::Vector* dependencies); |
81 virtual ~RasterTask(); | 82 virtual ~RasterTask(); |
82 | 83 |
83 private: | 84 private: |
84 const Resource* resource_; | 85 const Resource* resource_; |
85 ImageDecodeTask::Vector dependencies_; | 86 ImageDecodeTask::Vector dependencies_; |
86 }; | 87 }; |
87 | 88 |
| 89 static const size_t kNumberOfTaskSets = 2; |
| 90 typedef size_t TaskSet; |
| 91 typedef std::bitset<kNumberOfTaskSets> TaskSetCollection; |
| 92 |
88 class CC_EXPORT RasterizerClient { | 93 class CC_EXPORT RasterizerClient { |
89 public: | 94 public: |
90 virtual bool ShouldForceTasksRequiredForActivationToComplete() const = 0; | 95 virtual void DidFinishRunningTasks(TaskSet task_set) = 0; |
91 virtual void DidFinishRunningTasks() = 0; | 96 virtual TaskSetCollection TasksThatShouldBeForcedToComplete() const = 0; |
92 virtual void DidFinishRunningTasksRequiredForActivation() = 0; | |
93 | 97 |
94 protected: | 98 protected: |
95 virtual ~RasterizerClient() {} | 99 virtual ~RasterizerClient() {} |
96 }; | 100 }; |
97 | 101 |
98 struct CC_EXPORT RasterTaskQueue { | 102 struct CC_EXPORT RasterTaskQueue { |
99 struct CC_EXPORT Item { | 103 struct CC_EXPORT Item { |
100 class TaskComparator { | 104 class TaskComparator { |
101 public: | 105 public: |
102 explicit TaskComparator(const RasterTask* task) : task_(task) {} | 106 explicit TaskComparator(const RasterTask* task) : task_(task) {} |
103 | 107 |
104 bool operator()(const Item& item) const { return item.task == task_; } | 108 bool operator()(const Item& item) const { return item.task == task_; } |
105 | 109 |
106 private: | 110 private: |
107 const RasterTask* task_; | 111 const RasterTask* task_; |
108 }; | 112 }; |
109 | 113 |
110 typedef std::vector<Item> Vector; | 114 typedef std::vector<Item> Vector; |
111 | 115 |
112 Item(RasterTask* task, bool required_for_activation); | 116 Item(RasterTask* task, const TaskSetCollection& task_sets); |
113 ~Item(); | 117 ~Item(); |
114 | 118 |
115 static bool IsRequiredForActivation(const Item& item) { | |
116 return item.required_for_activation; | |
117 } | |
118 | |
119 RasterTask* task; | 119 RasterTask* task; |
120 bool required_for_activation; | 120 TaskSetCollection task_sets; |
121 }; | 121 }; |
122 | 122 |
123 RasterTaskQueue(); | 123 RasterTaskQueue(); |
124 ~RasterTaskQueue(); | 124 ~RasterTaskQueue(); |
125 | 125 |
126 void Swap(RasterTaskQueue* other); | 126 void Swap(RasterTaskQueue* other); |
127 void Reset(); | 127 void Reset(); |
128 | 128 |
129 Item::Vector items; | 129 Item::Vector items; |
130 }; | 130 }; |
(...skipping 23 matching lines...) Expand all Loading... |
154 // Check for completed tasks and dispatch reply callbacks. | 154 // Check for completed tasks and dispatch reply callbacks. |
155 virtual void CheckForCompletedTasks() = 0; | 155 virtual void CheckForCompletedTasks() = 0; |
156 | 156 |
157 protected: | 157 protected: |
158 virtual ~Rasterizer() {} | 158 virtual ~Rasterizer() {} |
159 }; | 159 }; |
160 | 160 |
161 } // namespace cc | 161 } // namespace cc |
162 | 162 |
163 #endif // CC_RESOURCES_RASTERIZER_H_ | 163 #endif // CC_RESOURCES_RASTERIZER_H_ |
OLD | NEW |