OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/scrollbar_layer_impl_base.h" | 5 #include "cc/layers/scrollbar_layer_impl_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "cc/trees/effect_node.h" | 8 #include "cc/trees/effect_node.h" |
9 #include "cc/trees/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
10 #include "ui/gfx/geometry/rect_conversions.h" | 10 #include "ui/gfx/geometry/rect_conversions.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 thumb_thickness_scale_factor_); | 217 thumb_thickness_scale_factor_); |
218 } | 218 } |
219 | 219 |
220 void ScrollbarLayerImplBase::SetOverlayScrollbarLayerOpacityAnimated( | 220 void ScrollbarLayerImplBase::SetOverlayScrollbarLayerOpacityAnimated( |
221 float opacity) { | 221 float opacity) { |
222 DCHECK(is_overlay_scrollbar()); | 222 DCHECK(is_overlay_scrollbar()); |
223 if (!layer_tree_impl()) | 223 if (!layer_tree_impl()) |
224 return; | 224 return; |
225 | 225 |
226 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); | 226 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); |
227 int effect_node_index = | |
228 property_trees->effect_tree.FindNodeIndexFromOwningLayerId(id()); | |
229 // If this method is called during LayerImpl::PushPropertiesTo, we may not yet | |
230 // have valid owning_layer_id_to_node_index entries in effect tree as property | |
231 // trees are pushed after layers during activation. We can skip updating | |
232 // opacity in that case as we are only registering a scrollbar and because | |
233 // opacity will be overwritten anyway when property trees are pushed. | |
234 if (effect_node_index == EffectTree::kInvalidNodeId || | |
235 effect_node_index != effect_tree_index()) | |
236 return; | |
237 | 227 |
238 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); | 228 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); |
239 if (node->opacity == opacity) | 229 if (node->opacity == opacity) |
240 return; | 230 return; |
241 | 231 |
242 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); | 232 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); |
243 | 233 |
244 node->opacity = opacity; | 234 node->opacity = opacity; |
245 node->effect_changed = true; | 235 node->effect_changed = true; |
246 property_trees->changed = true; | 236 property_trees->changed = true; |
247 property_trees->effect_tree.set_needs_update(true); | 237 property_trees->effect_tree.set_needs_update(true); |
248 layer_tree_impl()->set_needs_update_draw_properties(); | 238 layer_tree_impl()->set_needs_update_draw_properties(); |
249 } | 239 } |
250 | 240 |
251 } // namespace cc | 241 } // namespace cc |
OLD | NEW |