Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: cc/trees/layer_tree_host_common.h

Issue 1907053004: cc: Make CallFunctionForEveryLayer use LayerListIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FindLayers should skip layers instead of returning when switching from call-function to iteration l… Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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_TREES_LAYER_TREE_HOST_COMMON_H_ 5 #ifndef CC_TREES_LAYER_TREE_HOST_COMMON_H_
6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_ 6 #define CC_TREES_LAYER_TREE_HOST_COMMON_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 18 matching lines...) Expand all
29 namespace proto { 29 namespace proto {
30 class ScrollUpdateInfo; 30 class ScrollUpdateInfo;
31 class ScrollAndScaleSet; 31 class ScrollAndScaleSet;
32 } 32 }
33 33
34 class LayerImpl; 34 class LayerImpl;
35 class Layer; 35 class Layer;
36 class SwapPromise; 36 class SwapPromise;
37 class PropertyTrees; 37 class PropertyTrees;
38 38
39 enum CallFunctionLayerType : uint32_t {
40 BASIC_LAYER = 0,
41 MASK_LAYER = 1,
42 REPLICA_LAYER = 2,
43 ALL_LAYERS = MASK_LAYER | REPLICA_LAYER
44 };
45
46 class CC_EXPORT LayerTreeHostCommon { 39 class CC_EXPORT LayerTreeHostCommon {
47 public: 40 public:
48 struct CC_EXPORT CalcDrawPropsMainInputsForTesting { 41 struct CC_EXPORT CalcDrawPropsMainInputsForTesting {
49 public: 42 public:
50 CalcDrawPropsMainInputsForTesting(Layer* root_layer, 43 CalcDrawPropsMainInputsForTesting(Layer* root_layer,
51 const gfx::Size& device_viewport_size, 44 const gfx::Size& device_viewport_size,
52 const gfx::Transform& device_transform, 45 const gfx::Transform& device_transform,
53 float device_scale_factor, 46 float device_scale_factor,
54 float page_scale_factor, 47 float page_scale_factor,
55 const Layer* page_scale_layer, 48 const Layer* page_scale_layer,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 static void PreCalculateMetaInformation(Layer* root_layer); 124 static void PreCalculateMetaInformation(Layer* root_layer);
132 static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer); 125 static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer);
133 static void PreCalculateMetaInformationForTesting(Layer* root_layer); 126 static void PreCalculateMetaInformationForTesting(Layer* root_layer);
134 127
135 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); 128 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs);
136 static void CalculateDrawProperties( 129 static void CalculateDrawProperties(
137 CalcDrawPropsImplInputsForTesting* inputs); 130 CalcDrawPropsImplInputsForTesting* inputs);
138 131
139 template <typename Function> 132 template <typename Function>
140 static void CallFunctionForEveryLayer(LayerTreeHost* layer, 133 static void CallFunctionForEveryLayer(LayerTreeHost* layer,
141 const Function& function, 134 const Function& function);
142 const CallFunctionLayerType& type);
143 135
144 template <typename Function> 136 template <typename Function>
145 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, 137 static void CallFunctionForEveryLayer(LayerTreeImpl* layer,
146 const Function& function, 138 const Function& function);
147 const CallFunctionLayerType& type);
148 139
149 struct CC_EXPORT ScrollUpdateInfo { 140 struct CC_EXPORT ScrollUpdateInfo {
150 int layer_id; 141 int layer_id;
151 // TODO(miletus): Use ScrollOffset once LayerTreeHost/Blink fully supports 142 // TODO(miletus): Use ScrollOffset once LayerTreeHost/Blink fully supports
152 // franctional scroll offset. 143 // franctional scroll offset.
153 gfx::Vector2d scroll_delta; 144 gfx::Vector2d scroll_delta;
154 145
155 bool operator==(const ScrollUpdateInfo& other) const; 146 bool operator==(const ScrollUpdateInfo& other) const;
156 147
157 void ToProtobuf(proto::ScrollUpdateInfo* proto) const; 148 void ToProtobuf(proto::ScrollUpdateInfo* proto) const;
(...skipping 13 matching lines...) Expand all
171 162
172 bool EqualsForTesting(const ScrollAndScaleSet& other) const; 163 bool EqualsForTesting(const ScrollAndScaleSet& other) const;
173 void ToProtobuf(proto::ScrollAndScaleSet* proto) const; 164 void ToProtobuf(proto::ScrollAndScaleSet* proto) const;
174 void FromProtobuf(const proto::ScrollAndScaleSet& proto); 165 void FromProtobuf(const proto::ScrollAndScaleSet& proto);
175 166
176 private: 167 private:
177 DISALLOW_COPY_AND_ASSIGN(ScrollAndScaleSet); 168 DISALLOW_COPY_AND_ASSIGN(ScrollAndScaleSet);
178 }; 169 };
179 170
180 template <typename LayerType, typename Function> 171 template <typename LayerType, typename Function>
181 static void CallFunctionForLayer(LayerType* layer, 172 static void CallFunctionForLayer(LayerType* layer, const Function& function) {
182 const Function& function,
183 const CallFunctionLayerType& type) {
184 function(layer); 173 function(layer);
185 174
186 LayerType* mask_layer = layer->mask_layer(); 175 if (LayerType* mask_layer = layer->mask_layer())
187 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer)
188 function(mask_layer); 176 function(mask_layer);
189 LayerType* replica_layer = layer->replica_layer(); 177 if (LayerType* replica_layer = layer->replica_layer()) {
190 if ((type & CallFunctionLayerType::REPLICA_LAYER) && replica_layer) {
191 function(replica_layer); 178 function(replica_layer);
192 mask_layer = replica_layer->mask_layer(); 179 if (LayerType* mask_layer = replica_layer->mask_layer())
193 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer)
194 function(mask_layer); 180 function(mask_layer);
195 } 181 }
196 } 182 }
197 183
198 template <typename Function> 184 template <typename Function>
199 static void CallFunctionForEveryLayerInternal( 185 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeHost* host,
200 Layer* layer, 186 const Function& function) {
201 const Function& function, 187 for (auto* layer : *host)
202 const CallFunctionLayerType& type) { 188 CallFunctionForLayer(layer, function);
203 CallFunctionForLayer(layer, function, type);
204
205 for (size_t i = 0; i < layer->children().size(); ++i) {
206 CallFunctionForEveryLayerInternal(layer->children()[i].get(), function,
207 type);
208 }
209 } 189 }
210 190
211 template <typename Function> 191 template <typename Function>
212 void LayerTreeHostCommon::CallFunctionForEveryLayer( 192 void LayerTreeHostCommon::CallFunctionForEveryLayer(LayerTreeImpl* host_impl,
213 LayerTreeHost* host, 193 const Function& function) {
214 const Function& function,
215 const CallFunctionLayerType& type) {
216 CallFunctionForEveryLayerInternal(host->root_layer(), function, type);
217 }
218
219 template <typename Function>
220 void LayerTreeHostCommon::CallFunctionForEveryLayer(
221 LayerTreeImpl* host_impl,
222 const Function& function,
223 const CallFunctionLayerType& type) {
224 for (auto* layer : *host_impl) 194 for (auto* layer : *host_impl)
225 CallFunctionForLayer(layer, function, type); 195 CallFunctionForLayer(layer, function);
226 } 196 }
227 197
228 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); 198 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer);
229 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); 199 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer);
230 200
231 } // namespace cc 201 } // namespace cc
232 202
233 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ 203 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698