OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/flood_fill_ink_drop_ripple.h" | 5 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 void FloodFillInkDropRipple::AnimateToTransform( | 293 void FloodFillInkDropRipple::AnimateToTransform( |
294 const gfx::Transform& transform, | 294 const gfx::Transform& transform, |
295 base::TimeDelta duration, | 295 base::TimeDelta duration, |
296 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 296 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
297 gfx::Tween::Type tween, | 297 gfx::Tween::Type tween, |
298 ui::LayerAnimationObserver* animation_observer) { | 298 ui::LayerAnimationObserver* animation_observer) { |
299 ui::LayerAnimator* animator = painted_layer_.GetAnimator(); | 299 ui::LayerAnimator* animator = painted_layer_.GetAnimator(); |
300 ui::ScopedLayerAnimationSettings animation(animator); | 300 ui::ScopedLayerAnimationSettings animation(animator); |
301 animation.SetPreemptionStrategy(preemption_strategy); | 301 animation.SetPreemptionStrategy(preemption_strategy); |
302 animation.SetTweenType(tween); | 302 animation.SetTweenType(tween); |
303 ui::LayerAnimationElement* element = | 303 |
| 304 std::unique_ptr<ui::LayerAnimationElement> element = |
304 ui::LayerAnimationElement::CreateTransformElement(transform, duration); | 305 ui::LayerAnimationElement::CreateTransformElement(transform, duration); |
| 306 |
305 ui::LayerAnimationSequence* sequence = | 307 ui::LayerAnimationSequence* sequence = |
306 new ui::LayerAnimationSequence(element); | 308 new ui::LayerAnimationSequence(std::move(element)); |
307 | 309 |
308 if (animation_observer) | 310 if (animation_observer) |
309 sequence->AddObserver(animation_observer); | 311 sequence->AddObserver(animation_observer); |
310 | 312 |
311 animator->StartAnimation(sequence); | 313 animator->StartAnimation(sequence); |
312 } | 314 } |
313 | 315 |
314 void FloodFillInkDropRipple::SetOpacity(float opacity) { | 316 void FloodFillInkDropRipple::SetOpacity(float opacity) { |
315 root_layer_.SetOpacity(opacity); | 317 root_layer_.SetOpacity(opacity); |
316 } | 318 } |
317 | 319 |
318 void FloodFillInkDropRipple::AnimateToOpacity( | 320 void FloodFillInkDropRipple::AnimateToOpacity( |
319 float opacity, | 321 float opacity, |
320 base::TimeDelta duration, | 322 base::TimeDelta duration, |
321 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 323 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
322 gfx::Tween::Type tween, | 324 gfx::Tween::Type tween, |
323 ui::LayerAnimationObserver* animation_observer) { | 325 ui::LayerAnimationObserver* animation_observer) { |
324 ui::LayerAnimator* animator = root_layer_.GetAnimator(); | 326 ui::LayerAnimator* animator = root_layer_.GetAnimator(); |
325 ui::ScopedLayerAnimationSettings animation_settings(animator); | 327 ui::ScopedLayerAnimationSettings animation_settings(animator); |
326 animation_settings.SetPreemptionStrategy(preemption_strategy); | 328 animation_settings.SetPreemptionStrategy(preemption_strategy); |
327 animation_settings.SetTweenType(tween); | 329 animation_settings.SetTweenType(tween); |
328 ui::LayerAnimationElement* animation_element = | 330 std::unique_ptr<ui::LayerAnimationElement> animation_element = |
329 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); | 331 ui::LayerAnimationElement::CreateOpacityElement(opacity, duration); |
330 ui::LayerAnimationSequence* animation_sequence = | 332 ui::LayerAnimationSequence* animation_sequence = |
331 new ui::LayerAnimationSequence(animation_element); | 333 new ui::LayerAnimationSequence(std::move(animation_element)); |
332 | 334 |
333 if (animation_observer) | 335 if (animation_observer) |
334 animation_sequence->AddObserver(animation_observer); | 336 animation_sequence->AddObserver(animation_observer); |
335 | 337 |
336 animator->StartAnimation(animation_sequence); | 338 animator->StartAnimation(animation_sequence); |
337 } | 339 } |
338 | 340 |
339 gfx::Transform FloodFillInkDropRipple::CalculateTransform( | 341 gfx::Transform FloodFillInkDropRipple::CalculateTransform( |
340 float target_radius) const { | 342 float target_radius) const { |
341 const float target_scale = target_radius / circle_layer_delegate_.radius(); | 343 const float target_scale = target_radius / circle_layer_delegate_.radius(); |
(...skipping 24 matching lines...) Expand all Loading... |
366 (bounds.bottom_right() - point).Length(); | 368 (bounds.bottom_right() - point).Length(); |
367 | 369 |
368 float largest_distance = | 370 float largest_distance = |
369 std::max(distance_to_top_left, distance_to_top_right); | 371 std::max(distance_to_top_left, distance_to_top_right); |
370 largest_distance = std::max(largest_distance, distance_to_bottom_left); | 372 largest_distance = std::max(largest_distance, distance_to_bottom_left); |
371 largest_distance = std::max(largest_distance, distance_to_bottom_right); | 373 largest_distance = std::max(largest_distance, distance_to_bottom_right); |
372 return largest_distance; | 374 return largest_distance; |
373 } | 375 } |
374 | 376 |
375 } // namespace views | 377 } // namespace views |
OLD | NEW |