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

Unified Diff: ui/compositor/layer.cc

Issue 1159633002: Clean up ui<->cc layers interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_animation_element.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 2b6f9219c574b40c1bdd6d6e0742c0d47d0a1478..41106d3a7bc503625c6ebf35bf2e1e92759754ec 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -124,6 +124,7 @@ Layer::~Layer() {
layer_mask_back_link_->SetMaskLayer(NULL);
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_);
- if (compositor_) {
+
+ 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_)
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) {
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_animation_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698