| OLD | NEW |
| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 static void CalculateDrawPropertiesForTesting( | 133 static void CalculateDrawPropertiesForTesting( |
| 134 CalcDrawPropsMainInputsForTesting* inputs); | 134 CalcDrawPropsMainInputsForTesting* inputs); |
| 135 static void PreCalculateMetaInformation(Layer* root_layer); | 135 static void PreCalculateMetaInformation(Layer* root_layer); |
| 136 static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer); | 136 static void PreCalculateMetaInformationForTesting(LayerImpl* root_layer); |
| 137 static void PreCalculateMetaInformationForTesting(Layer* root_layer); | 137 static void PreCalculateMetaInformationForTesting(Layer* root_layer); |
| 138 | 138 |
| 139 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); | 139 static void CalculateDrawProperties(CalcDrawPropsImplInputs* inputs); |
| 140 static void CalculateDrawProperties( | 140 static void CalculateDrawProperties( |
| 141 CalcDrawPropsImplInputsForTesting* inputs); | 141 CalcDrawPropsImplInputsForTesting* inputs); |
| 142 | 142 |
| 143 template <typename LayerType> | |
| 144 static bool RenderSurfaceContributesToTarget(LayerType*, | |
| 145 int target_surface_layer_id); | |
| 146 | |
| 147 template <typename Function> | 143 template <typename Function> |
| 148 static void CallFunctionForEveryLayer(LayerTreeHost* layer, | 144 static void CallFunctionForEveryLayer(LayerTreeHost* layer, |
| 149 const Function& function, | 145 const Function& function, |
| 150 const CallFunctionLayerType& type); | 146 const CallFunctionLayerType& type); |
| 151 | 147 |
| 152 template <typename Function> | 148 template <typename Function> |
| 153 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, | 149 static void CallFunctionForEveryLayer(LayerTreeImpl* layer, |
| 154 const Function& function, | 150 const Function& function, |
| 155 const CallFunctionLayerType& type); | 151 const CallFunctionLayerType& type); |
| 156 | 152 |
| 157 static Layer* get_layer_as_raw_ptr(const LayerList& layers, size_t index) { | |
| 158 return layers[index].get(); | |
| 159 } | |
| 160 | |
| 161 static LayerImpl* get_layer_as_raw_ptr(const LayerImplList& layers, | |
| 162 size_t index) { | |
| 163 return layers[index]; | |
| 164 } | |
| 165 | |
| 166 struct CC_EXPORT ScrollUpdateInfo { | 153 struct CC_EXPORT ScrollUpdateInfo { |
| 167 int layer_id; | 154 int layer_id; |
| 168 // TODO(miletus): Use ScrollOffset once LayerTreeHost/Blink fully supports | 155 // TODO(miletus): Use ScrollOffset once LayerTreeHost/Blink fully supports |
| 169 // franctional scroll offset. | 156 // franctional scroll offset. |
| 170 gfx::Vector2d scroll_delta; | 157 gfx::Vector2d scroll_delta; |
| 171 | 158 |
| 172 bool operator==(const ScrollUpdateInfo& other) const; | 159 bool operator==(const ScrollUpdateInfo& other) const; |
| 173 | 160 |
| 174 void ToProtobuf(proto::ScrollUpdateInfo* proto) const; | 161 void ToProtobuf(proto::ScrollUpdateInfo* proto) const; |
| 175 void FromProtobuf(const proto::ScrollUpdateInfo& proto); | 162 void FromProtobuf(const proto::ScrollUpdateInfo& proto); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 187 std::vector<std::unique_ptr<SwapPromise>> swap_promises; | 174 std::vector<std::unique_ptr<SwapPromise>> swap_promises; |
| 188 | 175 |
| 189 bool EqualsForTesting(const ScrollAndScaleSet& other) const; | 176 bool EqualsForTesting(const ScrollAndScaleSet& other) const; |
| 190 void ToProtobuf(proto::ScrollAndScaleSet* proto) const; | 177 void ToProtobuf(proto::ScrollAndScaleSet* proto) const; |
| 191 void FromProtobuf(const proto::ScrollAndScaleSet& proto); | 178 void FromProtobuf(const proto::ScrollAndScaleSet& proto); |
| 192 | 179 |
| 193 private: | 180 private: |
| 194 DISALLOW_COPY_AND_ASSIGN(ScrollAndScaleSet); | 181 DISALLOW_COPY_AND_ASSIGN(ScrollAndScaleSet); |
| 195 }; | 182 }; |
| 196 | 183 |
| 197 template <typename LayerType> | |
| 198 bool LayerTreeHostCommon::RenderSurfaceContributesToTarget( | |
| 199 LayerType* layer, | |
| 200 int target_surface_layer_id) { | |
| 201 // A layer will either contribute its own content, or its render surface's | |
| 202 // content, to the target surface. The layer contributes its surface's content | |
| 203 // when both the following are true: | |
| 204 // (1) The layer actually has a render surface and rendering into that | |
| 205 // surface, and | |
| 206 // (2) The layer's render surface is not the same as the target surface. | |
| 207 // | |
| 208 // Otherwise, the layer just contributes itself to the target surface. | |
| 209 | |
| 210 return layer->has_render_surface() && | |
| 211 layer->render_target() == layer->render_surface() && | |
| 212 layer->id() != target_surface_layer_id; | |
| 213 } | |
| 214 | |
| 215 template <typename LayerType, typename Function> | 184 template <typename LayerType, typename Function> |
| 216 static void CallFunctionForLayer(LayerType* layer, | 185 static void CallFunctionForLayer(LayerType* layer, |
| 217 const Function& function, | 186 const Function& function, |
| 218 const CallFunctionLayerType& type) { | 187 const CallFunctionLayerType& type) { |
| 219 function(layer); | 188 function(layer); |
| 220 | 189 |
| 221 LayerType* mask_layer = layer->mask_layer(); | 190 LayerType* mask_layer = layer->mask_layer(); |
| 222 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer) | 191 if ((type & CallFunctionLayerType::MASK_LAYER) && mask_layer) |
| 223 function(mask_layer); | 192 function(mask_layer); |
| 224 LayerType* replica_layer = layer->replica_layer(); | 193 LayerType* replica_layer = layer->replica_layer(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 for (auto* layer : *host_impl) | 228 for (auto* layer : *host_impl) |
| 260 CallFunctionForLayer(layer, function, type); | 229 CallFunctionForLayer(layer, function, type); |
| 261 } | 230 } |
| 262 | 231 |
| 263 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); | 232 CC_EXPORT PropertyTrees* GetPropertyTrees(Layer* layer); |
| 264 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); | 233 CC_EXPORT PropertyTrees* GetPropertyTrees(LayerImpl* layer); |
| 265 | 234 |
| 266 } // namespace cc | 235 } // namespace cc |
| 267 | 236 |
| 268 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ | 237 #endif // CC_TREES_LAYER_TREE_HOST_COMMON_H_ |
| OLD | NEW |