OLD | NEW |
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" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::Unretained(this), animation_type), | 106 base::Unretained(this), animation_type), |
107 base::Bind(&InkDropHighlight::AnimationEndedCallback, | 107 base::Bind(&InkDropHighlight::AnimationEndedCallback, |
108 base::Unretained(this), animation_type)); | 108 base::Unretained(this), animation_type)); |
109 | 109 |
110 ui::LayerAnimator* animator = layer_->GetAnimator(); | 110 ui::LayerAnimator* animator = layer_->GetAnimator(); |
111 ui::ScopedLayerAnimationSettings animation(animator); | 111 ui::ScopedLayerAnimationSettings animation(animator); |
112 animation.SetTweenType(gfx::Tween::EASE_IN_OUT); | 112 animation.SetTweenType(gfx::Tween::EASE_IN_OUT); |
113 animation.SetPreemptionStrategy( | 113 animation.SetPreemptionStrategy( |
114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 114 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
115 | 115 |
116 ui::LayerAnimationElement* opacity_element = | 116 std::unique_ptr<ui::LayerAnimationElement> opacity_element = |
117 ui::LayerAnimationElement::CreateOpacityElement( | 117 ui::LayerAnimationElement::CreateOpacityElement( |
118 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity, | 118 animation_type == FADE_IN ? visible_opacity_ : kHiddenOpacity, |
119 duration); | 119 duration); |
120 ui::LayerAnimationSequence* opacity_sequence = | 120 ui::LayerAnimationSequence* opacity_sequence = |
121 new ui::LayerAnimationSequence(opacity_element); | 121 new ui::LayerAnimationSequence(std::move(opacity_element)); |
122 opacity_sequence->AddObserver(animation_observer); | 122 opacity_sequence->AddObserver(animation_observer); |
123 animator->StartAnimation(opacity_sequence); | 123 animator->StartAnimation(opacity_sequence); |
124 | 124 |
125 if (initial_size != target_size) { | 125 if (initial_size != target_size) { |
126 ui::LayerAnimationElement* transform_element = | 126 std::unique_ptr<ui::LayerAnimationElement> transform_element = |
127 ui::LayerAnimationElement::CreateTransformElement( | 127 ui::LayerAnimationElement::CreateTransformElement( |
128 CalculateTransform(target_size), duration); | 128 CalculateTransform(target_size), duration); |
| 129 |
129 ui::LayerAnimationSequence* transform_sequence = | 130 ui::LayerAnimationSequence* transform_sequence = |
130 new ui::LayerAnimationSequence(transform_element); | 131 new ui::LayerAnimationSequence(std::move(transform_element)); |
| 132 |
131 transform_sequence->AddObserver(animation_observer); | 133 transform_sequence->AddObserver(animation_observer); |
132 animator->StartAnimation(transform_sequence); | 134 animator->StartAnimation(transform_sequence); |
133 } | 135 } |
134 | 136 |
135 animation_observer->SetActive(); | 137 animation_observer->SetActive(); |
136 } | 138 } |
137 | 139 |
138 gfx::Transform InkDropHighlight::CalculateTransform( | 140 gfx::Transform InkDropHighlight::CalculateTransform( |
139 const gfx::Size& size) const { | 141 const gfx::Size& size) const { |
140 gfx::Transform transform; | 142 gfx::Transform transform; |
(...skipping 25 matching lines...) Expand all Loading... |
166 if (observer_) { | 168 if (observer_) { |
167 observer_->AnimationEnded(animation_type, | 169 observer_->AnimationEnded(animation_type, |
168 observer.aborted_count() | 170 observer.aborted_count() |
169 ? InkDropAnimationEndedReason::PRE_EMPTED | 171 ? InkDropAnimationEndedReason::PRE_EMPTED |
170 : InkDropAnimationEndedReason::SUCCESS); | 172 : InkDropAnimationEndedReason::SUCCESS); |
171 } | 173 } |
172 return true; | 174 return true; |
173 } | 175 } |
174 | 176 |
175 } // namespace views | 177 } // namespace views |
OLD | NEW |