Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 } | 117 } |
| 118 | 118 |
| 119 void Layer::SetLayerTreeHost(LayerTreeHost* host) { | 119 void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
| 120 if (layer_tree_host_ == host) | 120 if (layer_tree_host_ == host) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 if (layer_tree_host_) { | 123 if (layer_tree_host_) { |
| 124 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); | 124 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
| 125 layer_tree_host_->property_trees()->needs_rebuild = true; | 125 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 126 layer_tree_host_->UnregisterLayer(this); | 126 layer_tree_host_->UnregisterLayer(this); |
| 127 if (inputs_.element_id) { | 127 bool use_layer_lists = layer_tree_host_->GetSettings().use_layer_lists; |
| 128 if (!use_layer_lists && inputs_.element_id) { | |
| 128 layer_tree_host_->UnregisterElement(inputs_.element_id, | 129 layer_tree_host_->UnregisterElement(inputs_.element_id, |
| 129 ElementListType::ACTIVE, this); | 130 ElementListType::ACTIVE, this); |
| 130 } | 131 } |
| 131 } | 132 } |
| 132 if (host) { | 133 if (host) { |
| 133 host->property_trees()->needs_rebuild = true; | 134 host->property_trees()->needs_rebuild = true; |
| 134 host->RegisterLayer(this); | 135 host->RegisterLayer(this); |
| 135 if (inputs_.element_id) { | 136 bool use_layer_lists = host->GetSettings().use_layer_lists; |
| 137 if (!use_layer_lists && inputs_.element_id) { | |
| 136 host->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, this); | 138 host->RegisterElement(inputs_.element_id, ElementListType::ACTIVE, this); |
| 137 } | 139 } |
| 138 } | 140 } |
| 139 | 141 |
| 140 layer_tree_host_ = host; | 142 layer_tree_host_ = host; |
| 141 InvalidatePropertyTreesIndices(); | 143 InvalidatePropertyTreesIndices(); |
| 142 | 144 |
| 143 // When changing hosts, the layer needs to commit its properties to the impl | 145 // When changing hosts, the layer needs to commit its properties to the impl |
| 144 // side for the new host. | 146 // side for the new host. |
| 145 SetNeedsPushProperties(); | 147 SetNeedsPushProperties(); |
| 146 | 148 |
| 147 for (size_t i = 0; i < inputs_.children.size(); ++i) | 149 for (size_t i = 0; i < inputs_.children.size(); ++i) |
| 148 inputs_.children[i]->SetLayerTreeHost(host); | 150 inputs_.children[i]->SetLayerTreeHost(host); |
| 149 | 151 |
| 150 if (inputs_.mask_layer.get()) | 152 if (inputs_.mask_layer.get()) |
| 151 inputs_.mask_layer->SetLayerTreeHost(host); | 153 inputs_.mask_layer->SetLayerTreeHost(host); |
| 152 | 154 |
| 153 const bool has_any_animation = | 155 bool use_layer_lists = |
| 154 layer_tree_host_ ? GetMutatorHost()->HasAnyAnimation(element_id()) | 156 layer_tree_host_ && layer_tree_host_->GetSettings().use_layer_lists; |
| 155 : false; | 157 if (!use_layer_lists) { |
|
pdr.
2017/05/16 02:46:35
can this be simplified like:
if (host && host->Get
wkorman
2017/05/16 21:42:42
Done and combined the two if's into one with an ad
| |
| 156 | 158 const bool has_any_animation = |
| 157 if (host && has_any_animation) | 159 layer_tree_host_ ? GetMutatorHost()->HasAnyAnimation(element_id()) |
| 158 host->SetNeedsCommit(); | 160 : false; |
| 161 if (host && has_any_animation) | |
| 162 host->SetNeedsCommit(); | |
| 163 } | |
| 159 } | 164 } |
| 160 | 165 |
| 161 void Layer::SetNeedsCommit() { | 166 void Layer::SetNeedsCommit() { |
| 162 if (!layer_tree_host_) | 167 if (!layer_tree_host_) |
| 163 return; | 168 return; |
| 164 | 169 |
| 165 SetNeedsPushProperties(); | 170 SetNeedsPushProperties(); |
| 166 | 171 |
| 167 if (ignore_set_needs_commit_) | 172 if (ignore_set_needs_commit_) |
| 168 return; | 173 return; |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1424 ->subtree_has_copy_request; | 1429 ->subtree_has_copy_request; |
| 1425 } | 1430 } |
| 1426 | 1431 |
| 1427 gfx::Transform Layer::ScreenSpaceTransform() const { | 1432 gfx::Transform Layer::ScreenSpaceTransform() const { |
| 1428 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1433 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1429 return draw_property_utils::ScreenSpaceTransform( | 1434 return draw_property_utils::ScreenSpaceTransform( |
| 1430 this, layer_tree_host_->property_trees()->transform_tree); | 1435 this, layer_tree_host_->property_trees()->transform_tree); |
| 1431 } | 1436 } |
| 1432 | 1437 |
| 1433 } // namespace cc | 1438 } // namespace cc |
| OLD | NEW |