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

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

Issue 2520353004: Disabled ink drop animations based on gfx::Animation::ShouldRenderRichAnimation(). (Closed)
Patch Set: Updated comment wording. 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"
12 #include "ui/gfx/geometry/insets.h" 13 #include "ui/gfx/geometry/insets.h"
13 #include "ui/views/animation/ink_drop_highlight_observer.h" 14 #include "ui/views/animation/ink_drop_highlight_observer.h"
14 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" 15 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
15 16
16 namespace views { 17 namespace views {
17 18
18 namespace { 19 namespace {
19 20
20 // The opacity of the highlight when it is not visible. 21 // The opacity of the highlight when it is not visible.
21 const float kHiddenOpacity = 0.0f; 22 const float kHiddenOpacity = 0.0f;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 88 }
88 89
89 test::InkDropHighlightTestApi* InkDropHighlight::GetTestApi() { 90 test::InkDropHighlightTestApi* InkDropHighlight::GetTestApi() {
90 return nullptr; 91 return nullptr;
91 } 92 }
92 93
93 void InkDropHighlight::AnimateFade(AnimationType animation_type, 94 void InkDropHighlight::AnimateFade(AnimationType animation_type,
94 const base::TimeDelta& duration, 95 const base::TimeDelta& duration,
95 const gfx::Size& initial_size, 96 const gfx::Size& initial_size,
96 const gfx::Size& target_size) { 97 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();
97 last_animation_initiated_was_fade_in_ = animation_type == FADE_IN; 103 last_animation_initiated_was_fade_in_ = animation_type == FADE_IN;
98 104
99 layer_->SetTransform(CalculateTransform(initial_size)); 105 layer_->SetTransform(CalculateTransform(initial_size));
100 106
101 // The |animation_observer| will be destroyed when the 107 // The |animation_observer| will be destroyed when the
102 // AnimationStartedCallback() returns true. 108 // AnimationStartedCallback() returns true.
103 ui::CallbackLayerAnimationObserver* animation_observer = 109 ui::CallbackLayerAnimationObserver* animation_observer =
104 new ui::CallbackLayerAnimationObserver( 110 new ui::CallbackLayerAnimationObserver(
105 base::Bind(&InkDropHighlight::AnimationStartedCallback, 111 base::Bind(&InkDropHighlight::AnimationStartedCallback,
106 base::Unretained(this), animation_type), 112 base::Unretained(this), animation_type),
107 base::Bind(&InkDropHighlight::AnimationEndedCallback, 113 base::Bind(&InkDropHighlight::AnimationEndedCallback,
108 base::Unretained(this), animation_type)); 114 base::Unretained(this), animation_type));
109 115
110 ui::LayerAnimator* animator = layer_->GetAnimator(); 116 ui::LayerAnimator* animator = layer_->GetAnimator();
111 ui::ScopedLayerAnimationSettings animation(animator); 117 ui::ScopedLayerAnimationSettings animation(animator);
112 animation.SetTweenType(gfx::Tween::EASE_IN_OUT); 118 animation.SetTweenType(gfx::Tween::EASE_IN_OUT);
113 animation.SetPreemptionStrategy( 119 animation.SetPreemptionStrategy(
114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 120 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
115 121
116 ui::LayerAnimationElement* opacity_element = 122 ui::LayerAnimationElement* opacity_element =
117 ui::LayerAnimationElement::CreateOpacityElement( 123 ui::LayerAnimationElement::CreateOpacityElement(
118 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity, 124 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity,
119 duration); 125 effective_duration);
120 ui::LayerAnimationSequence* opacity_sequence = 126 ui::LayerAnimationSequence* opacity_sequence =
121 new ui::LayerAnimationSequence(opacity_element); 127 new ui::LayerAnimationSequence(opacity_element);
122 opacity_sequence->AddObserver(animation_observer); 128 opacity_sequence->AddObserver(animation_observer);
123 animator->StartAnimation(opacity_sequence); 129 animator->StartAnimation(opacity_sequence);
124 130
125 if (initial_size != target_size) { 131 if (initial_size != target_size) {
126 ui::LayerAnimationElement* transform_element = 132 ui::LayerAnimationElement* transform_element =
127 ui::LayerAnimationElement::CreateTransformElement( 133 ui::LayerAnimationElement::CreateTransformElement(
128 CalculateTransform(target_size), duration); 134 CalculateTransform(target_size), effective_duration);
129 ui::LayerAnimationSequence* transform_sequence = 135 ui::LayerAnimationSequence* transform_sequence =
130 new ui::LayerAnimationSequence(transform_element); 136 new ui::LayerAnimationSequence(transform_element);
131 transform_sequence->AddObserver(animation_observer); 137 transform_sequence->AddObserver(animation_observer);
132 animator->StartAnimation(transform_sequence); 138 animator->StartAnimation(transform_sequence);
133 } 139 }
134 140
135 animation_observer->SetActive(); 141 animation_observer->SetActive();
136 } 142 }
137 143
138 gfx::Transform InkDropHighlight::CalculateTransform( 144 gfx::Transform InkDropHighlight::CalculateTransform(
(...skipping 27 matching lines...) Expand all
166 if (observer_) { 172 if (observer_) {
167 observer_->AnimationEnded(animation_type, 173 observer_->AnimationEnded(animation_type,
168 observer.aborted_count() 174 observer.aborted_count()
169 ? InkDropAnimationEndedReason::PRE_EMPTED 175 ? InkDropAnimationEndedReason::PRE_EMPTED
170 : InkDropAnimationEndedReason::SUCCESS); 176 : InkDropAnimationEndedReason::SUCCESS);
171 } 177 }
172 return true; 178 return true;
173 } 179 }
174 180
175 } // namespace views 181 } // 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