Index: ui/compositor/layer.cc |
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
index 2b6f9219c574b40c1bdd6d6e0742c0d47d0a1478..c69151fa5d2b9c631c32d5fad2beeb36410dadf2 100644 |
--- a/ui/compositor/layer.cc |
+++ b/ui/compositor/layer.cc |
@@ -125,6 +125,7 @@ Layer::~Layer() { |
for (size_t i = 0; i < children_.size(); ++i) |
children_[i]->parent_ = NULL; |
cc_layer_->RemoveLayerAnimationEventObserver(this); |
+ |
cc_layer_->RemoveFromParent(); |
} |
@@ -141,22 +142,29 @@ float Layer::opacity() const { |
return cc_layer_->opacity(); |
} |
-void Layer::SetCompositor(Compositor* compositor) { |
- // This function must only be called to set the compositor on the root layer, |
- // or to reset it. |
- DCHECK(!compositor || !compositor_); |
- DCHECK(!compositor || compositor->root_layer() == this); |
+void Layer::SetCompositor(Compositor* compositor, |
+ scoped_refptr<cc::Layer> root_layer) { |
+ // This function must only be called to set the compositor on the root ui |
+ // layer. |
+ DCHECK(compositor); |
+ DCHECK(!compositor_); |
+ DCHECK(compositor->root_layer() == this); |
+ DCHECK(!parent_); |
+ |
+ compositor_ = compositor; |
+ OnDeviceScaleFactorChanged(compositor->device_scale_factor()); |
+ AddAnimatorsInTreeToCollection(compositor_->layer_animator_collection()); |
+ |
+ root_layer->AddChild(cc_layer_); |
+ SendPendingThreadedAnimations(); |
+} |
+ |
+void Layer::ResetCompositor() { |
DCHECK(!parent_); |
- if (compositor_) { |
+ if (compositor_) |
RemoveAnimatorsInTreeFromCollection( |
compositor_->layer_animator_collection()); |
- } |
- compositor_ = compositor; |
- if (compositor) { |
- OnDeviceScaleFactorChanged(compositor->device_scale_factor()); |
- SendPendingThreadedAnimations(); |
- AddAnimatorsInTreeToCollection(compositor_->layer_animator_collection()); |
- } |
+ compositor_ = nullptr; |
} |
void Layer::Add(Layer* child) { |
@@ -337,8 +345,7 @@ void Layer::SetMaskLayer(Layer* layer_mask) { |
if (layer_mask_) |
layer_mask_->layer_mask_back_link_ = NULL; |
layer_mask_ = layer_mask; |
- cc_layer_->SetMaskLayer( |
- layer_mask ? layer_mask->cc_layer() : NULL); |
+ cc_layer_->SetMaskLayer(layer_mask ? layer_mask->cc_layer_ : NULL); |
// We need to reference the linked object so that it can properly break the |
// link to us when it gets deleted. |
if (layer_mask) { |
@@ -475,6 +482,8 @@ void Layer::SetFillsBoundsCompletely(bool fills_bounds_completely) { |
} |
void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { |
+ DCHECK(!new_layer->parent()); |
+ |
// Finish animations being handled by cc_layer_. |
if (animator_.get()) { |
animator_->StopAnimatingProperty(LayerAnimationElement::TRANSFORM); |