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

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

Issue 2692243005: Merge Compositor's ScrollbarAnimationControllers into single class (Closed)
Patch Set: fix confict constant Created 3 years, 10 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
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/input/scrollbar_animation_controller_linear_fade.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/time/time.h"
9 #include "cc/layers/layer_impl.h"
10 #include "cc/layers/scrollbar_layer_impl_base.h"
11 #include "cc/trees/layer_tree_impl.h"
12
13 namespace cc {
14
15 std::unique_ptr<ScrollbarAnimationControllerLinearFade>
16 ScrollbarAnimationControllerLinearFade::Create(
17 int scroll_layer_id,
18 ScrollbarAnimationControllerClient* client,
19 base::TimeDelta delay_before_starting,
20 base::TimeDelta resize_delay_before_starting,
21 base::TimeDelta duration) {
22 return base::WrapUnique(new ScrollbarAnimationControllerLinearFade(
23 scroll_layer_id, client, delay_before_starting,
24 resize_delay_before_starting, duration));
25 }
26
27 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
28 int scroll_layer_id,
29 ScrollbarAnimationControllerClient* client,
30 base::TimeDelta delay_before_starting,
31 base::TimeDelta resize_delay_before_starting,
32 base::TimeDelta duration)
33 : ScrollbarAnimationController(scroll_layer_id,
34 client,
35 delay_before_starting,
36 resize_delay_before_starting),
37 duration_(duration) {}
38
39 ScrollbarAnimationControllerLinearFade::
40 ~ScrollbarAnimationControllerLinearFade() {}
41
42 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) {
43 ApplyOpacityToScrollbars(1.f - progress);
44 client_->SetNeedsRedrawForScrollbarAnimation();
45 if (progress == 1.f)
46 StopAnimation();
47 }
48
49 const base::TimeDelta& ScrollbarAnimationControllerLinearFade::Duration() {
50 return duration_;
51 }
52
53 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) {
54 ScrollbarAnimationController::DidScrollUpdate(on_resize);
55 ApplyOpacityToScrollbars(1.f);
56 }
57
58 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars(
59 float opacity) {
60 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) {
61 if (!scrollbar->is_overlay_scrollbar())
62 continue;
63 PropertyTrees* property_trees =
64 scrollbar->layer_tree_impl()->property_trees();
65 // If this method is called during LayerImpl::PushPropertiesTo, we may not
66 // yet have valid layer_id_to_effect_node_index entries as property trees
67 // are pushed after layers during activation. We can skip updating opacity
68 // in that case as we are only registering a scrollbar and because opacity
69 // will be overwritten anyway when property trees are pushed.
70 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT,
71 scrollbar->id())) {
72 property_trees->effect_tree.OnOpacityAnimated(
73 scrollbar->CanScrollOrientation() ? opacity : 0,
74 property_trees->layer_id_to_effect_node_index[scrollbar->id()],
75 scrollbar->layer_tree_impl());
76 }
77 }
78 }
79
80 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698