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

Side by Side Diff: ui/views/animation/ink_drop_highlight.cc

Issue 2539913004: Revert of Disabled ink drop animations based on gfx::Animation::ShouldRenderRichAnimation(). (Closed)
Patch Set: Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/animation/ink_drop_highlight.h" 5 #include "ui/views/animation/ink_drop_highlight.h"
6 6
7 #include "third_party/skia/include/core/SkColor.h" 7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/compositor/callback_layer_animation_observer.h" 8 #include "ui/compositor/callback_layer_animation_observer.h"
9 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer.h"
10 #include "ui/compositor/layer_animation_sequence.h" 10 #include "ui/compositor/layer_animation_sequence.h"
11 #include "ui/compositor/scoped_layer_animation_settings.h" 11 #include "ui/compositor/scoped_layer_animation_settings.h"
12 #include "ui/gfx/animation/animation.h"
13 #include "ui/gfx/geometry/insets.h" 12 #include "ui/gfx/geometry/insets.h"
14 #include "ui/views/animation/ink_drop_highlight_observer.h" 13 #include "ui/views/animation/ink_drop_highlight_observer.h"
15 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" 14 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
16 15
17 namespace views { 16 namespace views {
18 17
19 namespace { 18 namespace {
20 19
21 // The opacity of the highlight when it is not visible. 20 // The opacity of the highlight when it is not visible.
22 const float kHiddenOpacity = 0.0f; 21 const float kHiddenOpacity = 0.0f;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 87 }
89 88
90 test::InkDropHighlightTestApi* InkDropHighlight::GetTestApi() { 89 test::InkDropHighlightTestApi* InkDropHighlight::GetTestApi() {
91 return nullptr; 90 return nullptr;
92 } 91 }
93 92
94 void InkDropHighlight::AnimateFade(AnimationType animation_type, 93 void InkDropHighlight::AnimateFade(AnimationType animation_type,
95 const base::TimeDelta& duration, 94 const base::TimeDelta& duration,
96 const gfx::Size& initial_size, 95 const gfx::Size& initial_size,
97 const gfx::Size& target_size) { 96 const gfx::Size& target_size) {
98 // Ink drop animations are controlled by the system animation settings for
99 // accessibility reasons."See https://crbug.com/658384.
100 const base::TimeDelta effective_duration =
101 gfx::Animation::ShouldRenderRichAnimation() ? duration
102 : base::TimeDelta();
103 last_animation_initiated_was_fade_in_ = animation_type == FADE_IN; 97 last_animation_initiated_was_fade_in_ = animation_type == FADE_IN;
104 98
105 layer_->SetTransform(CalculateTransform(initial_size)); 99 layer_->SetTransform(CalculateTransform(initial_size));
106 100
107 // The |animation_observer| will be destroyed when the 101 // The |animation_observer| will be destroyed when the
108 // AnimationStartedCallback() returns true. 102 // AnimationStartedCallback() returns true.
109 ui::CallbackLayerAnimationObserver* animation_observer = 103 ui::CallbackLayerAnimationObserver* animation_observer =
110 new ui::CallbackLayerAnimationObserver( 104 new ui::CallbackLayerAnimationObserver(
111 base::Bind(&InkDropHighlight::AnimationStartedCallback, 105 base::Bind(&InkDropHighlight::AnimationStartedCallback,
112 base::Unretained(this), animation_type), 106 base::Unretained(this), animation_type),
113 base::Bind(&InkDropHighlight::AnimationEndedCallback, 107 base::Bind(&InkDropHighlight::AnimationEndedCallback,
114 base::Unretained(this), animation_type)); 108 base::Unretained(this), animation_type));
115 109
116 ui::LayerAnimator* animator = layer_->GetAnimator(); 110 ui::LayerAnimator* animator = layer_->GetAnimator();
117 ui::ScopedLayerAnimationSettings animation(animator); 111 ui::ScopedLayerAnimationSettings animation(animator);
118 animation.SetTweenType(gfx::Tween::EASE_IN_OUT); 112 animation.SetTweenType(gfx::Tween::EASE_IN_OUT);
119 animation.SetPreemptionStrategy( 113 animation.SetPreemptionStrategy(
120 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
121 115
122 ui::LayerAnimationElement* opacity_element = 116 ui::LayerAnimationElement* opacity_element =
123 ui::LayerAnimationElement::CreateOpacityElement( 117 ui::LayerAnimationElement::CreateOpacityElement(
124 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity, 118 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity,
125 effective_duration); 119 duration);
126 ui::LayerAnimationSequence* opacity_sequence = 120 ui::LayerAnimationSequence* opacity_sequence =
127 new ui::LayerAnimationSequence(opacity_element); 121 new ui::LayerAnimationSequence(opacity_element);
128 opacity_sequence->AddObserver(animation_observer); 122 opacity_sequence->AddObserver(animation_observer);
129 animator->StartAnimation(opacity_sequence); 123 animator->StartAnimation(opacity_sequence);
130 124
131 if (initial_size != target_size) { 125 if (initial_size != target_size) {
132 ui::LayerAnimationElement* transform_element = 126 ui::LayerAnimationElement* transform_element =
133 ui::LayerAnimationElement::CreateTransformElement( 127 ui::LayerAnimationElement::CreateTransformElement(
134 CalculateTransform(target_size), effective_duration); 128 CalculateTransform(target_size), duration);
135 ui::LayerAnimationSequence* transform_sequence = 129 ui::LayerAnimationSequence* transform_sequence =
136 new ui::LayerAnimationSequence(transform_element); 130 new ui::LayerAnimationSequence(transform_element);
137 transform_sequence->AddObserver(animation_observer); 131 transform_sequence->AddObserver(animation_observer);
138 animator->StartAnimation(transform_sequence); 132 animator->StartAnimation(transform_sequence);
139 } 133 }
140 134
141 animation_observer->SetActive(); 135 animation_observer->SetActive();
142 } 136 }
143 137
144 gfx::Transform InkDropHighlight::CalculateTransform( 138 gfx::Transform InkDropHighlight::CalculateTransform(
(...skipping 27 matching lines...) Expand all
172 if (observer_) { 166 if (observer_) {
173 observer_->AnimationEnded(animation_type, 167 observer_->AnimationEnded(animation_type,
174 observer.aborted_count() 168 observer.aborted_count()
175 ? InkDropAnimationEndedReason::PRE_EMPTED 169 ? InkDropAnimationEndedReason::PRE_EMPTED
176 : InkDropAnimationEndedReason::SUCCESS); 170 : InkDropAnimationEndedReason::SUCCESS);
177 } 171 }
178 return true; 172 return true;
179 } 173 }
180 174
181 } // namespace views 175 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/flood_fill_ink_drop_ripple.cc ('k') | ui/views/animation/square_ink_drop_ripple.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698