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.
5 #ifndef TreeSynchronizer_h
6 #define TreeSynchronizer_h
8 #include "base/basictypes.h"
9 #include <wtf/HashMap.h>
10 #include <wtf/OwnPtr.h>
11 #include <wtf/PassOwnPtr.h>
16 class CCLayerTreeHostImpl
;
19 class TreeSynchronizer
{
21 // Accepts a LayerChromium tree and returns a reference to a CCLayerImpl tree that duplicates the structure
22 // of the LayerChromium tree, reusing the CCLayerImpls in the tree provided by oldCCLayerImplRoot if possible.
23 static PassOwnPtr
<CCLayerImpl
> synchronizeTrees(LayerChromium
* layerRoot
, PassOwnPtr
<CCLayerImpl
> oldCCLayerImplRoot
, CCLayerTreeHostImpl
*);
26 TreeSynchronizer(); // Not instantiable.
28 typedef HashMap
<int, OwnPtr
<CCLayerImpl
> > OwnPtrCCLayerImplMap
;
29 typedef HashMap
<int, CCLayerImpl
*> RawPtrCCLayerImplMap
;
31 // Declared as static member functions so they can access functions on LayerChromium as a friend class.
32 static PassOwnPtr
<CCLayerImpl
> reuseOrCreateCCLayerImpl(RawPtrCCLayerImplMap
& newLayers
, OwnPtrCCLayerImplMap
& oldLayers
, LayerChromium
*);
33 static void collectExistingCCLayerImplRecursive(OwnPtrCCLayerImplMap
& oldLayers
, PassOwnPtr
<CCLayerImpl
>);
34 static PassOwnPtr
<CCLayerImpl
> synchronizeTreeRecursive(RawPtrCCLayerImplMap
& newLayers
, OwnPtrCCLayerImplMap
& oldLayers
, LayerChromium
*, CCLayerTreeHostImpl
*);
35 static void updateScrollbarLayerPointersRecursive(const RawPtrCCLayerImplMap
& newLayers
, LayerChromium
*);
37 DISALLOW_COPY_AND_ASSIGN(TreeSynchronizer
);
42 #endif // TreeSynchronizer_h