Index: cc/layers/layer.cc |
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc |
index 4b2df1cd73cf01669a5c87bc7c5aedb328a3e604..3352c1f22a03762df78a68a7b695acff4e8afbe8 100644 |
--- a/cc/layers/layer.cc |
+++ b/cc/layers/layer.cc |
@@ -82,6 +82,7 @@ Layer::Layer() |
: ignore_set_needs_commit_(false), |
parent_(nullptr), |
layer_tree_host_(nullptr), |
+ layer_tree_(nullptr), |
num_descendants_that_draw_content_(0), |
transform_tree_index_(TransformTree::kInvalidNodeId), |
effect_tree_index_(EffectTree::kInvalidNodeId), |
@@ -129,7 +130,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
if (layer_tree_host_) { |
layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
layer_tree_host_->property_trees()->needs_rebuild = true; |
- layer_tree_host_->UnregisterLayer(this); |
+ layer_tree_->UnregisterLayer(this); |
if (inputs_.element_id) { |
layer_tree_host_->animation_host()->UnregisterElement( |
inputs_.element_id, ElementListType::ACTIVE); |
@@ -138,7 +139,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
} |
if (host) { |
host->property_trees()->needs_rebuild = true; |
- host->RegisterLayer(this); |
+ host->GetLayerTree()->RegisterLayer(this); |
if (inputs_.element_id) { |
host->AddToElementMap(this); |
host->animation_host()->RegisterElement(inputs_.element_id, |
@@ -147,6 +148,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
} |
layer_tree_host_ = host; |
+ layer_tree_ = host ? host->GetLayerTree() : nullptr; |
InvalidatePropertyTreesIndices(); |
// When changing hosts, the layer needs to commit its properties to the impl |
@@ -214,19 +216,20 @@ void Layer::SetNextCommitWaitsForActivation() { |
} |
void Layer::SetNeedsPushProperties() { |
- if (layer_tree_host_) |
- layer_tree_host_->AddLayerShouldPushProperties(this); |
+ if (layer_tree_) |
+ layer_tree_->AddLayerShouldPushProperties(this); |
} |
void Layer::ResetNeedsPushPropertiesForTesting() { |
- layer_tree_host_->RemoveLayerShouldPushProperties(this); |
+ if (layer_tree_) |
+ layer_tree_->RemoveLayerShouldPushProperties(this); |
} |
bool Layer::IsPropertyChangeAllowed() const { |
- if (!layer_tree_host_) |
+ if (!layer_tree_) |
return true; |
- return !layer_tree_host_->in_paint_layer_contents(); |
+ return !layer_tree_->in_paint_layer_contents(); |
} |
sk_sp<SkPicture> Layer::GetPicture() const { |
@@ -1201,7 +1204,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { |
layer_property_changed_ = false; |
inputs_.update_rect = gfx::Rect(); |
- layer_tree_host()->RemoveLayerShouldPushProperties(this); |
+ layer_tree_->RemoveLayerShouldPushProperties(this); |
} |
void Layer::TakeCopyRequests( |
@@ -1252,10 +1255,12 @@ void Layer::ClearLayerTreePropertiesForDeserializationAndAddToMap( |
LayerIdMap* layer_map) { |
(*layer_map)[inputs_.layer_id] = this; |
- if (layer_tree_host_) |
- layer_tree_host_->UnregisterLayer(this); |
+ if (layer_tree_) |
+ layer_tree_->UnregisterLayer(this); |
layer_tree_host_ = nullptr; |
+ layer_tree_ = nullptr; |
+ |
parent_ = nullptr; |
// Clear these properties for all the children and add them to the map. |
@@ -1291,7 +1296,8 @@ void Layer::FromLayerNodeProto(const proto::LayerNode& proto, |
inputs_.layer_id = proto.id(); |
layer_tree_host_ = layer_tree_host; |
- layer_tree_host_->RegisterLayer(this); |
+ layer_tree_ = layer_tree_host ? layer_tree_host->GetLayerTree() : nullptr; |
+ layer_tree_->RegisterLayer(this); |
for (int i = 0; i < proto.children_size(); ++i) { |
const proto::LayerNode& child_proto = proto.children(i); |
@@ -1774,7 +1780,7 @@ void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
} |
AnimationHost* Layer::GetAnimationHost() const { |
- return layer_tree_host_ ? layer_tree_host_->animation_host() : nullptr; |
+ return layer_tree_ ? layer_tree_->animation_host() : nullptr; |
} |
ElementListType Layer::GetElementTypeForAnimation() const { |
@@ -1876,4 +1882,8 @@ gfx::Transform Layer::screen_space_transform() const { |
this, layer_tree_host_->property_trees()->transform_tree); |
} |
+LayerTree* Layer::GetLayerTree() const { |
+ return layer_tree_; |
+} |
+ |
} // namespace cc |