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

Side by Side Diff: ui/compositor/layer_owner.cc

Issue 983933002: Reset the root layer on the compositor when recreating a root layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | ui/compositor/layer_owner_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/layer_owner.h" 5 #include "ui/compositor/layer_owner.h"
6 6
7 #include "ui/compositor/layer_owner_delegate.h" 7 #include "ui/compositor/layer_owner_delegate.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Migrate all the child layers over to the new layer. Copy the list because 59 // Migrate all the child layers over to the new layer. Copy the list because
60 // the items are removed during iteration. 60 // the items are removed during iteration.
61 std::vector<ui::Layer*> children_copy = old_layer->children(); 61 std::vector<ui::Layer*> children_copy = old_layer->children();
62 for (std::vector<ui::Layer*>::const_iterator it = children_copy.begin(); 62 for (std::vector<ui::Layer*>::const_iterator it = children_copy.begin();
63 it != children_copy.end(); 63 it != children_copy.end();
64 ++it) { 64 ++it) {
65 ui::Layer* child = *it; 65 ui::Layer* child = *it;
66 new_layer->Add(child); 66 new_layer->Add(child);
67 } 67 }
68 68
69 ui::Layer* root_layer = old_layer.get();
70 while (root_layer->parent())
71 root_layer = root_layer->parent();
sadrul 2015/03/06 14:33:49 You don't actually need to walk up to the root, ri
bruthig 2015/03/06 15:20:41 Done.
72
73 // If old_layer was the layer tree root then we need to move the Compositor
74 // over to the new root.
75 if (root_layer == old_layer.get() && old_layer->GetCompositor())
76 old_layer->GetCompositor()->SetRootLayer(new_layer);
77
69 // Install the delegate last so that the delegate isn't notified as we copy 78 // Install the delegate last so that the delegate isn't notified as we copy
70 // state to the new layer. 79 // state to the new layer.
71 new_layer->set_delegate(old_delegate); 80 new_layer->set_delegate(old_delegate);
72 81
73 if (layer_owner_delegate_) 82 if (layer_owner_delegate_)
74 layer_owner_delegate_->OnLayerRecreated(old_layer.get(), new_layer); 83 layer_owner_delegate_->OnLayerRecreated(old_layer.get(), new_layer);
75 84
76 return old_layer.Pass(); 85 return old_layer.Pass();
77 } 86 }
78 87
79 void LayerOwner::DestroyLayer() { 88 void LayerOwner::DestroyLayer() {
80 layer_ = NULL; 89 layer_ = NULL;
81 layer_owner_.reset(); 90 layer_owner_.reset();
82 } 91 }
83 92
84 bool LayerOwner::OwnsLayer() const { 93 bool LayerOwner::OwnsLayer() const {
85 return !!layer_owner_; 94 return !!layer_owner_;
86 } 95 }
87 96
88 } // namespace ui 97 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/layer_owner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698