Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1113)

Side by Side Diff: cc/input/scrollbar_animation_controller_thinning.cc

Issue 2345823003: Overlay scrollbars are painted onload. (Closed)
Patch Set: nit fixed. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/input/scrollbar_animation_controller_thinning.h" 5 #include "cc/input/scrollbar_animation_controller_thinning.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "cc/layers/scrollbar_layer_impl_base.h" 10 #include "cc/layers/scrollbar_layer_impl_base.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ThumbThicknessScaleAtAnimationProgress(float progress) { 117 ThumbThicknessScaleAtAnimationProgress(float progress) {
118 if (thickness_change_ == NONE) 118 if (thickness_change_ == NONE)
119 return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale; 119 return mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale;
120 float factor = thickness_change_ == INCREASE ? progress : (1.f - progress); 120 float factor = thickness_change_ == INCREASE ? progress : (1.f - progress);
121 return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale; 121 return ((1.f - kIdleThicknessScale) * factor) + kIdleThicknessScale;
122 } 122 }
123 123
124 float ScrollbarAnimationControllerThinning::AdjustScale( 124 float ScrollbarAnimationControllerThinning::AdjustScale(
125 float new_value, 125 float new_value,
126 float current_value, 126 float current_value,
127 AnimationChange animation_change) { 127 AnimationChange animation_change,
128 float min_value,
129 float max_value) {
130 float result;
128 if (animation_change == INCREASE && current_value > new_value) 131 if (animation_change == INCREASE && current_value > new_value)
129 return current_value; 132 result = current_value;
130 if (animation_change == DECREASE && current_value < new_value) 133 else if (animation_change == DECREASE && current_value < new_value)
131 return current_value; 134 result = current_value;
132 return new_value; 135 else
136 result = new_value;
137 if (result > max_value)
138 return max_value;
139 if (result < min_value)
140 return min_value;
141 return result;
133 } 142 }
134 143
135 void ScrollbarAnimationControllerThinning::ApplyOpacityAndThumbThicknessScale( 144 void ScrollbarAnimationControllerThinning::ApplyOpacityAndThumbThicknessScale(
136 float opacity, 145 float opacity,
137 float thumb_thickness_scale) { 146 float thumb_thickness_scale) {
138 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { 147 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) {
139 if (!scrollbar->is_overlay_scrollbar()) 148 if (!scrollbar->is_overlay_scrollbar())
140 continue; 149 continue;
141 float effective_opacity = 150 float effective_opacity =
142 scrollbar->CanScrollOrientation() 151 scrollbar->CanScrollOrientation()
143 ? AdjustScale(opacity, scrollbar->Opacity(), opacity_change_) 152 ? AdjustScale(opacity, scrollbar->Opacity(), opacity_change_,
153 kIdleOpacity, 1)
144 : 0; 154 : 0;
145
146 PropertyTrees* property_trees = 155 PropertyTrees* property_trees =
147 scrollbar->layer_tree_impl()->property_trees(); 156 scrollbar->layer_tree_impl()->property_trees();
148 // If this method is called during LayerImpl::PushPropertiesTo, we may not 157 // If this method is called during LayerImpl::PushPropertiesTo, we may not
149 // yet have valid effect_id_to_index_map entries as property trees are 158 // yet have valid effect_id_to_index_map entries as property trees are
150 // pushed after layers during activation. We can skip updating opacity in 159 // pushed after layers during activation. We can skip updating opacity in
151 // that case as we are only registering a scrollbar and because opacity will 160 // that case as we are only registering a scrollbar and because opacity will
152 // be overwritten anyway when property trees are pushed. 161 // be overwritten anyway when property trees are pushed.
153 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, 162 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT,
154 scrollbar->id())) { 163 scrollbar->id())) {
155 property_trees->effect_tree.OnOpacityAnimated( 164 property_trees->effect_tree.OnOpacityAnimated(
156 effective_opacity, 165 effective_opacity,
157 property_trees->effect_id_to_index_map[scrollbar->id()], 166 property_trees->effect_id_to_index_map[scrollbar->id()],
158 scrollbar->layer_tree_impl()); 167 scrollbar->layer_tree_impl());
159 } 168 }
160 scrollbar->SetThumbThicknessScaleFactor(AdjustScale( 169 scrollbar->SetThumbThicknessScaleFactor(AdjustScale(
161 thumb_thickness_scale, scrollbar->thumb_thickness_scale_factor(), 170 thumb_thickness_scale, scrollbar->thumb_thickness_scale_factor(),
162 thickness_change_)); 171 thickness_change_, kIdleThicknessScale, 1));
163 } 172 }
164 } 173 }
165 174
166 } // namespace cc 175 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller_thinning.h ('k') | cc/input/scrollbar_animation_controller_thinning_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698