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/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
9 #include "ui/gfx/geometry/rect_conversions.h" | 10 #include "ui/gfx/geometry/rect_conversions.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 ScrollbarLayerImplBase::ScrollbarLayerImplBase( | 14 ScrollbarLayerImplBase::ScrollbarLayerImplBase( |
14 LayerTreeImpl* tree_impl, | 15 LayerTreeImpl* tree_impl, |
15 int id, | 16 int id, |
16 ScrollbarOrientation orientation, | 17 ScrollbarOrientation orientation, |
17 bool is_left_side_vertical_scrollbar, | 18 bool is_left_side_vertical_scrollbar, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 ? bounds().width() - thumb_thickness | 194 ? bounds().width() - thumb_thickness |
194 : thumb_thickness_adjustment, | 195 : thumb_thickness_adjustment, |
195 thumb_offset, | 196 thumb_offset, |
196 thumb_thickness - thumb_thickness_adjustment, | 197 thumb_thickness - thumb_thickness_adjustment, |
197 thumb_length); | 198 thumb_length); |
198 } | 199 } |
199 | 200 |
200 return gfx::ToEnclosingRect(thumb_rect); | 201 return gfx::ToEnclosingRect(thumb_rect); |
201 } | 202 } |
202 | 203 |
| 204 void ScrollbarLayerImplBase::SetOverlayScrollbarLayerOpacityAnimated( |
| 205 float opacity) { |
| 206 DCHECK(is_overlay_scrollbar()); |
| 207 if (!layer_tree_impl()) |
| 208 return; |
| 209 |
| 210 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); |
| 211 int effect_node_index = |
| 212 property_trees->effect_tree.FindNodeIndexFromOwningLayerId(id()); |
| 213 // If this method is called during LayerImpl::PushPropertiesTo, we may not yet |
| 214 // have valid owning_layer_id_to_node_index entries in effect tree as property |
| 215 // trees are pushed after layers during activation. We can skip updating |
| 216 // opacity in that case as we are only registering a scrollbar and because |
| 217 // opacity will be overwritten anyway when property trees are pushed. |
| 218 if (effect_node_index == EffectTree::kInvalidNodeId || |
| 219 effect_node_index != effect_tree_index()) |
| 220 return; |
| 221 |
| 222 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); |
| 223 if (node->opacity == opacity) |
| 224 return; |
| 225 |
| 226 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); |
| 227 |
| 228 node->opacity = opacity; |
| 229 node->effect_changed = true; |
| 230 property_trees->changed = true; |
| 231 property_trees->effect_tree.set_needs_update(true); |
| 232 layer_tree_impl()->set_needs_update_draw_properties(); |
| 233 } |
| 234 |
203 } // namespace cc | 235 } // namespace cc |
OLD | NEW |