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 return; | |
220 | |
221 DCHECK_EQ(effect_tree_index(), effect_node_index); | |
222 if (EffectNode* node = | |
223 property_trees->effect_tree.Node(effect_tree_index())) { | |
ajuma
2017/03/21 22:00:30
Since we're already checking for an invalid id abo
weiliangc
2017/03/22 18:44:15
I early out for the DCHECK now because when the la
| |
224 if (node->opacity == opacity) | |
225 return; | |
226 | |
227 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); | |
228 | |
229 node->opacity = opacity; | |
230 node->effect_changed = true; | |
231 property_trees->changed = true; | |
232 property_trees->effect_tree.set_needs_update(true); | |
233 layer_tree_impl()->set_needs_update_draw_properties(); | |
234 } | |
235 } | |
236 | |
203 } // namespace cc | 237 } // namespace cc |
OLD | NEW |