Chromium Code Reviews| 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 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "TreeSynchronizer.h" | 7 #include "TreeSynchronizer.h" |
| 8 | 8 |
| 9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
| 10 #include "CCScrollbarAnimationController.h" | 10 #include "CCScrollbarAnimationController.h" |
| 11 #include "CCScrollbarLayerImpl.h" | 11 #include "CCScrollbarLayerImpl.h" |
| 12 #include "LayerChromium.h" | 12 #include "LayerChromium.h" |
| 13 #include "ScrollbarLayerChromium.h" | 13 #include "ScrollbarLayerChromium.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 scoped_ptr<CCLayerImpl> TreeSynchronizer::synchronizeTrees(LayerChromium* layerC hromiumRoot, scoped_ptr<CCLayerImpl> oldCCLayerImplRoot, CCLayerTreeHostImpl* ho stImpl) | 17 scoped_ptr<CCLayerImpl> TreeSynchronizer::synchronizeTrees(LayerChromium* layerC hromiumRoot, scoped_ptr<CCLayerImpl> oldCCLayerImplRoot, CCLayerTreeHostImpl* ho stImpl) |
| 18 { | 18 { |
| 19 ScopedPtrCCLayerImplMap oldLayers; | 19 ScopedPtrCCLayerImplMap oldLayers; |
| 20 RawPtrCCLayerImplMap newLayers; | 20 RawPtrCCLayerImplMap newLayers; |
| 21 | 21 |
| 22 collectExistingCCLayerImplRecursive(oldLayers, oldCCLayerImplRoot.Pass()); | 22 collectExistingCCLayerImplRecursive(layerChromiumRoot, oldLayers, oldCCLayer ImplRoot.Pass()); |
| 23 | 23 |
| 24 scoped_ptr<CCLayerImpl> newTree = synchronizeTreeRecursive(newLayers, oldLay ers, layerChromiumRoot, hostImpl); | 24 scoped_ptr<CCLayerImpl> newTree = synchronizeTreeRecursive(newLayers, oldLay ers, layerChromiumRoot, hostImpl); |
| 25 | 25 |
| 26 updateScrollbarLayerPointersRecursive(newLayers, layerChromiumRoot); | 26 updateScrollbarLayerPointersRecursive(newLayers, layerChromiumRoot); |
| 27 | 27 |
| 28 return newTree.Pass(); | 28 return newTree.Pass(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void TreeSynchronizer::collectExistingCCLayerImplRecursive(ScopedPtrCCLayerImplM ap& oldLayers, scoped_ptr<CCLayerImpl> ccLayerImpl) | 31 void TreeSynchronizer::collectExistingCCLayerImplRecursive(LayerChromium* layer, ScopedPtrCCLayerImplMap& oldLayers, scoped_ptr<CCLayerImpl> ccLayerImpl) |
| 32 { | 32 { |
| 33 if (!ccLayerImpl) | 33 if (!layer || !ccLayerImpl || layer->id() != ccLayerImpl->id()) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 ScopedPtrVector<CCLayerImpl>& children = ccLayerImpl->m_children; | 36 if (!layer->deferUpdates()) { |
| 37 for (size_t i = 0; i < children.size(); ++i) | 37 ScopedPtrVector<CCLayerImpl>& oldChildren = ccLayerImpl->m_children; |
| 38 collectExistingCCLayerImplRecursive(oldLayers, children.take(i)); | 38 ScopedPtrCCLayerImplMap oldChildrenMap; |
| 39 for (size_t i = 0; i < oldChildren.size(); ++i) { | |
| 40 int oldChildId = oldChildren[i]->id(); | |
| 41 oldChildrenMap.set(oldChildId, oldChildren.take(i)); | |
| 42 } | |
| 39 | 43 |
| 40 collectExistingCCLayerImplRecursive(oldLayers, ccLayerImpl->m_maskLayer.Pass ()); | 44 const LayerChromium::LayerList& children = layer->children(); |
| 41 collectExistingCCLayerImplRecursive(oldLayers, ccLayerImpl->m_replicaLayer.P ass()); | 45 for (size_t i = 0; i < children.size(); ++i) |
| 46 collectExistingCCLayerImplRecursive(children[i].get(), oldLayers, ol dChildrenMap.take(children[i]->id())); | |
|
piman
2012/10/17 21:26:32
Why is it a problem to collect all the older layer
jonathan.backer
2012/10/18 20:20:35
Collecting all the old layers detroys the LayerImp
| |
| 47 | |
| 48 collectExistingCCLayerImplRecursive(layer->maskLayer(), oldLayers, ccLay erImpl->m_maskLayer.Pass()); | |
| 49 collectExistingCCLayerImplRecursive(layer->replicaLayer(), oldLayers, cc LayerImpl->m_replicaLayer.Pass()); | |
| 50 } | |
| 42 | 51 |
| 43 int id = ccLayerImpl->id(); | 52 int id = ccLayerImpl->id(); |
| 44 oldLayers.set(id, ccLayerImpl.Pass()); | 53 oldLayers.set(id, ccLayerImpl.Pass()); |
| 45 } | 54 } |
| 46 | 55 |
| 47 scoped_ptr<CCLayerImpl> TreeSynchronizer::reuseOrCreateCCLayerImpl(RawPtrCCLayer ImplMap& newLayers, ScopedPtrCCLayerImplMap& oldLayers, LayerChromium* layer) | 56 scoped_ptr<CCLayerImpl> TreeSynchronizer::reuseOrCreateCCLayerImpl(RawPtrCCLayer ImplMap& newLayers, ScopedPtrCCLayerImplMap& oldLayers, LayerChromium* layer) |
| 48 { | 57 { |
| 49 scoped_ptr<CCLayerImpl> ccLayerImpl = oldLayers.take(layer->id()); | 58 scoped_ptr<CCLayerImpl> ccLayerImpl = oldLayers.take(layer->id()); |
| 50 | 59 |
| 51 if (!ccLayerImpl) | 60 if (!ccLayerImpl) |
| 52 ccLayerImpl = layer->createCCLayerImpl(); | 61 ccLayerImpl = layer->createCCLayerImpl(); |
| 53 | 62 |
| 54 newLayers[layer->id()] = ccLayerImpl.get(); | 63 newLayers[layer->id()] = ccLayerImpl.get(); |
| 55 return ccLayerImpl.Pass(); | 64 return ccLayerImpl.Pass(); |
| 56 } | 65 } |
| 57 | 66 |
| 58 scoped_ptr<CCLayerImpl> TreeSynchronizer::synchronizeTreeRecursive(RawPtrCCLayer ImplMap& newLayers, ScopedPtrCCLayerImplMap& oldLayers, LayerChromium* layer, CC LayerTreeHostImpl* hostImpl) | 67 scoped_ptr<CCLayerImpl> TreeSynchronizer::synchronizeTreeRecursive(RawPtrCCLayer ImplMap& newLayers, ScopedPtrCCLayerImplMap& oldLayers, LayerChromium* layer, CC LayerTreeHostImpl* hostImpl) |
| 59 { | 68 { |
| 60 if (!layer) | 69 if (!layer) |
| 61 return scoped_ptr<CCLayerImpl>(); | 70 return scoped_ptr<CCLayerImpl>(); |
| 62 | 71 |
| 72 if (layer->deferUpdates()) | |
| 73 return oldLayers.take(layer->id()); | |
| 74 | |
| 63 scoped_ptr<CCLayerImpl> ccLayerImpl = reuseOrCreateCCLayerImpl(newLayers, ol dLayers, layer); | 75 scoped_ptr<CCLayerImpl> ccLayerImpl = reuseOrCreateCCLayerImpl(newLayers, ol dLayers, layer); |
| 64 | 76 |
| 65 ccLayerImpl->clearChildList(); | 77 ccLayerImpl->clearChildList(); |
| 66 const std::vector<scoped_refptr<LayerChromium> >& children = layer->children (); | 78 const std::vector<scoped_refptr<LayerChromium> >& children = layer->children (); |
| 67 for (size_t i = 0; i < children.size(); ++i) | 79 for (size_t i = 0; i < children.size(); ++i) |
| 68 ccLayerImpl->addChild(synchronizeTreeRecursive(newLayers, oldLayers, chi ldren[i].get(), hostImpl)); | 80 ccLayerImpl->addChild(synchronizeTreeRecursive(newLayers, oldLayers, chi ldren[i].get(), hostImpl)); |
| 69 | 81 |
| 70 ccLayerImpl->setMaskLayer(synchronizeTreeRecursive(newLayers, oldLayers, lay er->maskLayer(), hostImpl)); | 82 ccLayerImpl->setMaskLayer(synchronizeTreeRecursive(newLayers, oldLayers, lay er->maskLayer(), hostImpl)); |
| 71 ccLayerImpl->setReplicaLayer(synchronizeTreeRecursive(newLayers, oldLayers, layer->replicaLayer(), hostImpl)); | 83 ccLayerImpl->setReplicaLayer(synchronizeTreeRecursive(newLayers, oldLayers, layer->replicaLayer(), hostImpl)); |
| 72 | 84 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 103 ASSERT(ccScrollbarLayerImpl); | 115 ASSERT(ccScrollbarLayerImpl); |
| 104 ASSERT(ccScrollLayerImpl); | 116 ASSERT(ccScrollLayerImpl); |
| 105 | 117 |
| 106 if (ccScrollbarLayerImpl->orientation() == WebKit::WebScrollbar::Horizontal) | 118 if (ccScrollbarLayerImpl->orientation() == WebKit::WebScrollbar::Horizontal) |
| 107 ccScrollLayerImpl->setHorizontalScrollbarLayer(ccScrollbarLayerImpl); | 119 ccScrollLayerImpl->setHorizontalScrollbarLayer(ccScrollbarLayerImpl); |
| 108 else | 120 else |
| 109 ccScrollLayerImpl->setVerticalScrollbarLayer(ccScrollbarLayerImpl); | 121 ccScrollLayerImpl->setVerticalScrollbarLayer(ccScrollbarLayerImpl); |
| 110 } | 122 } |
| 111 | 123 |
| 112 } // namespace cc | 124 } // namespace cc |
| OLD | NEW |