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 3 // found in the LICENSE file. 4 5 #ifndef CC_TREES_TREE_SYNCHRONIZER_H_ 6 #define CC_TREES_TREE_SYNCHRONIZER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "cc/base/cc_export.h" 11 #include "cc/base/scoped_ptr_hash_map.h" 12 13 namespace cc { 14 15 class LayerImpl; 16 class LayerTreeImpl; 17 class Layer; 18 19 class CC_EXPORT TreeSynchronizer { 20 public: 21 // Accepts a Layer tree and returns a reference to a LayerImpl tree that 22 // duplicates the structure of the Layer tree, reusing the LayerImpls in the 23 // tree provided by old_layer_impl_root if possible. 24 static scoped_ptr<LayerImpl> SynchronizeTrees( 25 Layer* layer_root, 26 scoped_ptr<LayerImpl> old_layer_impl_root, 27 LayerTreeImpl* tree_impl); 28 static scoped_ptr<LayerImpl> SynchronizeTrees( 29 LayerImpl* layer_root, 30 scoped_ptr<LayerImpl> old_layer_impl_root, 31 LayerTreeImpl* tree_impl); 32 33 // Pushes properties from a Layer or LayerImpl tree to a structurally 34 // equivalent LayerImpl tree. 35 static void PushProperties(Layer* layer_root, 36 LayerImpl* layer_impl_root); 37 static void PushProperties(LayerImpl* layer_root, LayerImpl* layer_impl_root); 38 39 private: 40 TreeSynchronizer(); // Not instantiable. 41 42 static void SetNumDependentsNeedPushProperties(Layer* layer, size_t num); 43 static void SetNumDependentsNeedPushProperties(LayerImpl* layer, size_t num); 44 45 template <typename LayerType> 46 static void PushPropertiesInternal( 47 LayerType* layer, 48 LayerImpl* layer_impl, 49 size_t* num_dependents_need_push_properties_for_parent); 50 51 DISALLOW_COPY_AND_ASSIGN(TreeSynchronizer); 52 }; 53 54 } // namespace cc 55 56 #endif // CC_TREES_TREE_SYNCHRONIZER_H_ 57