| 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/square_ink_drop_ripple.h" | 5 #include "ui/views/animation/square_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 "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 namespace views { | 164 namespace views { |
| 165 | 165 |
| 166 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size, | 166 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size, |
| 167 int large_corner_radius, | 167 int large_corner_radius, |
| 168 const gfx::Size& small_size, | 168 const gfx::Size& small_size, |
| 169 int small_corner_radius, | 169 int small_corner_radius, |
| 170 const gfx::Point& center_point, | 170 const gfx::Point& center_point, |
| 171 SkColor color, | 171 SkColor color, |
| 172 float visible_opacity) | 172 float visible_opacity) |
| 173 : SquareInkDropRipple(large_size, | |
| 174 large_corner_radius, | |
| 175 small_size, | |
| 176 small_corner_radius, | |
| 177 center_point, | |
| 178 center_point, | |
| 179 color, | |
| 180 visible_opacity) {} | |
| 181 | |
| 182 SquareInkDropRipple::SquareInkDropRipple(const gfx::Size& large_size, | |
| 183 int large_corner_radius, | |
| 184 const gfx::Size& small_size, | |
| 185 int small_corner_radius, | |
| 186 const gfx::Point& initial_center_point, | |
| 187 const gfx::Point& target_center_point, | |
| 188 SkColor color, | |
| 189 float visible_opacity) | |
| 190 : activated_shape_(ROUNDED_RECT), | 173 : activated_shape_(ROUNDED_RECT), |
| 191 visible_opacity_(visible_opacity), | 174 visible_opacity_(visible_opacity), |
| 192 target_center_point_(target_center_point), | |
| 193 large_size_(large_size), | 175 large_size_(large_size), |
| 194 large_corner_radius_(large_corner_radius), | 176 large_corner_radius_(large_corner_radius), |
| 195 small_size_(small_size), | 177 small_size_(small_size), |
| 196 small_corner_radius_(small_corner_radius), | 178 small_corner_radius_(small_corner_radius), |
| 197 circle_layer_delegate_(new CircleLayerDelegate( | 179 circle_layer_delegate_(new CircleLayerDelegate( |
| 198 color, | 180 color, |
| 199 std::min(large_size_.width(), large_size_.height()) / 2)), | 181 std::min(large_size_.width(), large_size_.height()) / 2)), |
| 200 rect_layer_delegate_( | 182 rect_layer_delegate_( |
| 201 new RectangleLayerDelegate(color, gfx::SizeF(large_size_))), | 183 new RectangleLayerDelegate(color, gfx::SizeF(large_size_))), |
| 202 root_layer_(ui::LAYER_NOT_DRAWN) { | 184 root_layer_(ui::LAYER_NOT_DRAWN) { |
| 203 root_layer_.set_name("SquareInkDropRipple:ROOT_LAYER"); | 185 root_layer_.set_name("SquareInkDropRipple:ROOT_LAYER"); |
| 204 | 186 |
| 205 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) | 187 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) |
| 206 AddPaintLayer(static_cast<PaintedShape>(i)); | 188 AddPaintLayer(static_cast<PaintedShape>(i)); |
| 207 | 189 |
| 208 root_layer_.SetMasksToBounds(false); | 190 root_layer_.SetMasksToBounds(false); |
| 209 root_layer_.SetBounds(gfx::Rect(large_size_)); | 191 root_layer_.SetBounds(gfx::Rect(large_size_)); |
| 210 | 192 |
| 211 gfx::Transform transform; | 193 gfx::Transform transform; |
| 212 transform.Translate(initial_center_point.x(), initial_center_point.y()); | 194 transform.Translate(center_point.x(), center_point.y()); |
| 213 root_layer_.SetTransform(transform); | 195 root_layer_.SetTransform(transform); |
| 214 | 196 |
| 215 SetStateToHidden(); | 197 SetStateToHidden(); |
| 216 } | 198 } |
| 217 | 199 |
| 218 SquareInkDropRipple::~SquareInkDropRipple() { | 200 SquareInkDropRipple::~SquareInkDropRipple() { |
| 219 // Explicitly aborting all the animations ensures all callbacks are invoked | 201 // Explicitly aborting all the animations ensures all callbacks are invoked |
| 220 // while this instance still exists. | 202 // while this instance still exists. |
| 221 AbortAllAnimations(); | 203 AbortAllAnimations(); |
| 222 } | 204 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 gfx::Tween::EASE_IN, animation_observer); | 272 gfx::Tween::EASE_IN, animation_observer); |
| 291 AnimateToOpacity(visible_opacity_, | 273 AnimateToOpacity(visible_opacity_, |
| 292 GetAnimationDuration(ACTION_PENDING_TRANSFORM), | 274 GetAnimationDuration(ACTION_PENDING_TRANSFORM), |
| 293 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 275 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 294 gfx::Tween::EASE_IN, animation_observer); | 276 gfx::Tween::EASE_IN, animation_observer); |
| 295 CalculateCircleTransforms(large_size_, &transforms); | 277 CalculateCircleTransforms(large_size_, &transforms); |
| 296 AnimateToTransforms(transforms, | 278 AnimateToTransforms(transforms, |
| 297 GetAnimationDuration(ACTION_PENDING_TRANSFORM), | 279 GetAnimationDuration(ACTION_PENDING_TRANSFORM), |
| 298 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 280 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 299 gfx::Tween::EASE_IN_OUT, animation_observer); | 281 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 300 AnimateCenterPoint(target_center_point_, | |
| 301 GetAnimationDuration(ACTION_PENDING_TRANSFORM), | |
| 302 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | |
| 303 gfx::Tween::EASE_IN, animation_observer); | |
| 304 break; | 282 break; |
| 305 case InkDropState::ACTION_TRIGGERED: { | 283 case InkDropState::ACTION_TRIGGERED: { |
| 306 DCHECK(old_ink_drop_state == InkDropState::HIDDEN || | 284 DCHECK(old_ink_drop_state == InkDropState::HIDDEN || |
| 307 old_ink_drop_state == InkDropState::ACTION_PENDING) | 285 old_ink_drop_state == InkDropState::ACTION_PENDING) |
| 308 << " old_ink_drop_state=" << ToString(old_ink_drop_state); | 286 << " old_ink_drop_state=" << ToString(old_ink_drop_state); |
| 309 if (old_ink_drop_state == InkDropState::HIDDEN) { | 287 if (old_ink_drop_state == InkDropState::HIDDEN) { |
| 310 AnimateStateChange(old_ink_drop_state, InkDropState::ACTION_PENDING, | 288 AnimateStateChange(old_ink_drop_state, InkDropState::ACTION_PENDING, |
| 311 animation_observer); | 289 animation_observer); |
| 312 } | 290 } |
| 313 AnimateToOpacity(kHiddenOpacity, | 291 AnimateToOpacity(kHiddenOpacity, |
| 314 GetAnimationDuration(ACTION_TRIGGERED_FADE_OUT), | 292 GetAnimationDuration(ACTION_TRIGGERED_FADE_OUT), |
| 315 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, | 293 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| 316 gfx::Tween::EASE_IN_OUT, animation_observer); | 294 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 317 gfx::Size s = ScaleToRoundedSize(large_size_, kQuickActionBurstScale); | 295 gfx::Size s = ScaleToRoundedSize(large_size_, kQuickActionBurstScale); |
| 318 CalculateCircleTransforms(s, &transforms); | 296 CalculateCircleTransforms(s, &transforms); |
| 319 AnimateToTransforms(transforms, | 297 AnimateToTransforms(transforms, |
| 320 GetAnimationDuration(ACTION_TRIGGERED_TRANSFORM), | 298 GetAnimationDuration(ACTION_TRIGGERED_TRANSFORM), |
| 321 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, | 299 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| 322 gfx::Tween::EASE_IN_OUT, animation_observer); | 300 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 323 AnimateCenterPoint(target_center_point_, | |
| 324 GetAnimationDuration(ACTION_TRIGGERED_TRANSFORM), | |
| 325 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, | |
| 326 gfx::Tween::EASE_IN, animation_observer); | |
| 327 break; | 301 break; |
| 328 } | 302 } |
| 329 case InkDropState::ALTERNATE_ACTION_PENDING: | 303 case InkDropState::ALTERNATE_ACTION_PENDING: |
| 330 DCHECK_EQ(InkDropState::ACTION_PENDING, old_ink_drop_state) | 304 DCHECK_EQ(InkDropState::ACTION_PENDING, old_ink_drop_state) |
| 331 << " old_ink_drop_state=" << ToString(old_ink_drop_state); | 305 << " old_ink_drop_state=" << ToString(old_ink_drop_state); |
| 332 AnimateToOpacity(visible_opacity_, | 306 AnimateToOpacity(visible_opacity_, |
| 333 GetAnimationDuration(ALTERNATE_ACTION_PENDING), | 307 GetAnimationDuration(ALTERNATE_ACTION_PENDING), |
| 334 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 308 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 335 gfx::Tween::EASE_IN, animation_observer); | 309 gfx::Tween::EASE_IN, animation_observer); |
| 336 CalculateRectTransforms(small_size_, small_corner_radius_, &transforms); | 310 CalculateRectTransforms(small_size_, small_corner_radius_, &transforms); |
| 337 AnimateToTransforms(transforms, | 311 AnimateToTransforms(transforms, |
| 338 GetAnimationDuration(ALTERNATE_ACTION_PENDING), | 312 GetAnimationDuration(ALTERNATE_ACTION_PENDING), |
| 339 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 313 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 340 gfx::Tween::EASE_IN_OUT, animation_observer); | 314 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 341 AnimateCenterPoint(target_center_point_, | |
| 342 GetAnimationDuration(ALTERNATE_ACTION_PENDING), | |
| 343 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | |
| 344 gfx::Tween::EASE_IN, animation_observer); | |
| 345 break; | 315 break; |
| 346 case InkDropState::ALTERNATE_ACTION_TRIGGERED: { | 316 case InkDropState::ALTERNATE_ACTION_TRIGGERED: { |
| 347 DCHECK_EQ(InkDropState::ALTERNATE_ACTION_PENDING, old_ink_drop_state) | 317 DCHECK_EQ(InkDropState::ALTERNATE_ACTION_PENDING, old_ink_drop_state) |
| 348 << " old_ink_drop_state=" << ToString(old_ink_drop_state); | 318 << " old_ink_drop_state=" << ToString(old_ink_drop_state); |
| 349 base::TimeDelta visible_duration = | 319 base::TimeDelta visible_duration = |
| 350 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM) - | 320 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM) - |
| 351 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_FADE_OUT); | 321 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_FADE_OUT); |
| 352 AnimateToOpacity(visible_opacity_, visible_duration, | 322 AnimateToOpacity(visible_opacity_, visible_duration, |
| 353 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 323 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 354 gfx::Tween::EASE_IN_OUT, animation_observer); | 324 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 355 AnimateToOpacity(kHiddenOpacity, GetAnimationDuration( | 325 AnimateToOpacity(kHiddenOpacity, GetAnimationDuration( |
| 356 ALTERNATE_ACTION_TRIGGERED_FADE_OUT), | 326 ALTERNATE_ACTION_TRIGGERED_FADE_OUT), |
| 357 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, | 327 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| 358 gfx::Tween::EASE_IN_OUT, animation_observer); | 328 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 359 CalculateRectTransforms(large_size_, large_corner_radius_, &transforms); | 329 CalculateRectTransforms(large_size_, large_corner_radius_, &transforms); |
| 360 AnimateToTransforms(transforms, GetAnimationDuration( | 330 AnimateToTransforms(transforms, GetAnimationDuration( |
| 361 ALTERNATE_ACTION_TRIGGERED_TRANSFORM), | 331 ALTERNATE_ACTION_TRIGGERED_TRANSFORM), |
| 362 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 332 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 363 gfx::Tween::EASE_IN_OUT, animation_observer); | 333 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 364 AnimateCenterPoint( | |
| 365 target_center_point_, | |
| 366 GetAnimationDuration(ALTERNATE_ACTION_TRIGGERED_TRANSFORM), | |
| 367 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | |
| 368 gfx::Tween::EASE_IN, animation_observer); | |
| 369 break; | 334 break; |
| 370 } | 335 } |
| 371 case InkDropState::ACTIVATED: { | 336 case InkDropState::ACTIVATED: { |
| 372 // Animate the opacity so that it cancels any opacity animations already | 337 // Animate the opacity so that it cancels any opacity animations already |
| 373 // in progress. | 338 // in progress. |
| 374 AnimateToOpacity(visible_opacity_, base::TimeDelta(), | 339 AnimateToOpacity(visible_opacity_, base::TimeDelta(), |
| 375 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 340 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 376 gfx::Tween::EASE_IN_OUT, animation_observer); | 341 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 377 | 342 |
| 378 ui::LayerAnimator::PreemptionStrategy rect_transform_preemption_strategy = | 343 ui::LayerAnimator::PreemptionStrategy rect_transform_preemption_strategy = |
| 379 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET; | 344 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET; |
| 380 if (old_ink_drop_state == InkDropState::HIDDEN) { | 345 if (old_ink_drop_state == InkDropState::HIDDEN) { |
| 381 rect_transform_preemption_strategy = | 346 rect_transform_preemption_strategy = |
| 382 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION; | 347 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION; |
| 383 CalculateCircleTransforms(large_size_, &transforms); | 348 CalculateCircleTransforms(large_size_, &transforms); |
| 384 AnimateToTransforms( | 349 AnimateToTransforms( |
| 385 transforms, GetAnimationDuration(ACTIVATED_CIRCLE_TRANSFORM), | 350 transforms, GetAnimationDuration(ACTIVATED_CIRCLE_TRANSFORM), |
| 386 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 351 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 387 gfx::Tween::EASE_IN_OUT, animation_observer); | 352 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 388 AnimateCenterPoint(target_center_point_, | |
| 389 GetAnimationDuration(ACTIVATED_CIRCLE_TRANSFORM), | |
| 390 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | |
| 391 gfx::Tween::EASE_IN, animation_observer); | |
| 392 } else if (old_ink_drop_state == InkDropState::ACTION_PENDING) { | 353 } else if (old_ink_drop_state == InkDropState::ACTION_PENDING) { |
| 393 rect_transform_preemption_strategy = | 354 rect_transform_preemption_strategy = |
| 394 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION; | 355 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION; |
| 395 } | 356 } |
| 396 | 357 |
| 397 GetActivatedTargetTransforms(&transforms); | 358 GetActivatedTargetTransforms(&transforms); |
| 398 AnimateToTransforms(transforms, | 359 AnimateToTransforms(transforms, |
| 399 GetAnimationDuration(ACTIVATED_RECT_TRANSFORM), | 360 GetAnimationDuration(ACTIVATED_RECT_TRANSFORM), |
| 400 rect_transform_preemption_strategy, | 361 rect_transform_preemption_strategy, |
| 401 gfx::Tween::EASE_IN_OUT, animation_observer); | 362 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 402 AnimateCenterPoint(target_center_point_, | |
| 403 GetAnimationDuration(ACTIVATED_RECT_TRANSFORM), | |
| 404 rect_transform_preemption_strategy, | |
| 405 gfx::Tween::EASE_IN, animation_observer); | |
| 406 break; | 363 break; |
| 407 } | 364 } |
| 408 case InkDropState::DEACTIVATED: { | 365 case InkDropState::DEACTIVATED: { |
| 409 base::TimeDelta visible_duration = | 366 base::TimeDelta visible_duration = |
| 410 GetAnimationDuration(DEACTIVATED_TRANSFORM) - | 367 GetAnimationDuration(DEACTIVATED_TRANSFORM) - |
| 411 GetAnimationDuration(DEACTIVATED_FADE_OUT); | 368 GetAnimationDuration(DEACTIVATED_FADE_OUT); |
| 412 AnimateToOpacity(visible_opacity_, visible_duration, | 369 AnimateToOpacity(visible_opacity_, visible_duration, |
| 413 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 370 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 414 gfx::Tween::EASE_IN_OUT, animation_observer); | 371 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 415 AnimateToOpacity(kHiddenOpacity, | 372 AnimateToOpacity(kHiddenOpacity, |
| 416 GetAnimationDuration(DEACTIVATED_FADE_OUT), | 373 GetAnimationDuration(DEACTIVATED_FADE_OUT), |
| 417 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, | 374 ui::LayerAnimator::ENQUEUE_NEW_ANIMATION, |
| 418 gfx::Tween::EASE_IN_OUT, animation_observer); | 375 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 419 GetDeactivatedTargetTransforms(&transforms); | 376 GetDeactivatedTargetTransforms(&transforms); |
| 420 AnimateToTransforms(transforms, | 377 AnimateToTransforms(transforms, |
| 421 GetAnimationDuration(DEACTIVATED_TRANSFORM), | 378 GetAnimationDuration(DEACTIVATED_TRANSFORM), |
| 422 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | 379 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, |
| 423 gfx::Tween::EASE_IN_OUT, animation_observer); | 380 gfx::Tween::EASE_IN_OUT, animation_observer); |
| 424 AnimateCenterPoint(target_center_point_, | |
| 425 GetAnimationDuration(DEACTIVATED_TRANSFORM), | |
| 426 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET, | |
| 427 gfx::Tween::EASE_IN, animation_observer); | |
| 428 break; | 381 break; |
| 429 } | 382 } |
| 430 } | 383 } |
| 431 } | 384 } |
| 432 | 385 |
| 433 void SquareInkDropRipple::SetStateToHidden() { | 386 void SquareInkDropRipple::SetStateToHidden() { |
| 434 InkDropTransforms transforms; | 387 InkDropTransforms transforms; |
| 435 // Use non-zero size to avoid visual anomalies. | 388 // Use non-zero size to avoid visual anomalies. |
| 436 CalculateCircleTransforms(gfx::Size(1, 1), &transforms); | 389 CalculateCircleTransforms(gfx::Size(1, 1), &transforms); |
| 437 SetTransforms(transforms); | 390 SetTransforms(transforms); |
| 438 root_layer_.SetOpacity(InkDropRipple::kHiddenOpacity); | 391 root_layer_.SetOpacity(InkDropRipple::kHiddenOpacity); |
| 439 root_layer_.SetVisible(false); | 392 root_layer_.SetVisible(false); |
| 440 } | 393 } |
| 441 | 394 |
| 442 void SquareInkDropRipple::AbortAllAnimations() { | 395 void SquareInkDropRipple::AbortAllAnimations() { |
| 443 root_layer_.GetAnimator()->AbortAllAnimations(); | 396 root_layer_.GetAnimator()->AbortAllAnimations(); |
| 444 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) | 397 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) |
| 445 painted_layers_[i]->GetAnimator()->AbortAllAnimations(); | 398 painted_layers_[i]->GetAnimator()->AbortAllAnimations(); |
| 446 } | 399 } |
| 447 | 400 |
| 448 void SquareInkDropRipple::AnimateCenterPoint( | |
| 449 const gfx::Point& center_point, | |
| 450 base::TimeDelta duration, | |
| 451 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | |
| 452 gfx::Tween::Type tween, | |
| 453 ui::LayerAnimationObserver* observer) { | |
| 454 ui::LayerAnimator* animator = root_layer_.GetAnimator(); | |
| 455 ui::ScopedLayerAnimationSettings animation(animator); | |
| 456 animation.SetPreemptionStrategy(preemption_strategy); | |
| 457 animation.SetTweenType(tween); | |
| 458 gfx::Transform transform; | |
| 459 transform.Translate(target_center_point_.x(), target_center_point_.y()); | |
| 460 std::unique_ptr<ui::LayerAnimationElement> element = | |
| 461 ui::LayerAnimationElement::CreateTransformElement(transform, duration); | |
| 462 ui::LayerAnimationSequence* sequence = | |
| 463 new ui::LayerAnimationSequence(std::move(element)); | |
| 464 | |
| 465 if (observer) | |
| 466 sequence->AddObserver(observer); | |
| 467 | |
| 468 animator->StartAnimation(sequence); | |
| 469 } | |
| 470 | |
| 471 void SquareInkDropRipple::AnimateToTransforms( | 401 void SquareInkDropRipple::AnimateToTransforms( |
| 472 const InkDropTransforms transforms, | 402 const InkDropTransforms transforms, |
| 473 base::TimeDelta duration, | 403 base::TimeDelta duration, |
| 474 ui::LayerAnimator::PreemptionStrategy preemption_strategy, | 404 ui::LayerAnimator::PreemptionStrategy preemption_strategy, |
| 475 gfx::Tween::Type tween, | 405 gfx::Tween::Type tween, |
| 476 ui::LayerAnimationObserver* animation_observer) { | 406 ui::LayerAnimationObserver* animation_observer) { |
| 477 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { | 407 for (int i = 0; i < PAINTED_SHAPE_COUNT; ++i) { |
| 478 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); | 408 ui::LayerAnimator* animator = painted_layers_[i]->GetAnimator(); |
| 479 ui::ScopedLayerAnimationSettings animation(animator); | 409 ui::ScopedLayerAnimationSettings animation(animator); |
| 480 animation.SetPreemptionStrategy(preemption_strategy); | 410 animation.SetPreemptionStrategy(preemption_strategy); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 layer->set_delegate(delegate); | 575 layer->set_delegate(delegate); |
| 646 layer->SetVisible(true); | 576 layer->SetVisible(true); |
| 647 layer->SetOpacity(1.0); | 577 layer->SetOpacity(1.0); |
| 648 layer->SetMasksToBounds(false); | 578 layer->SetMasksToBounds(false); |
| 649 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); | 579 layer->set_name("PAINTED_SHAPE_COUNT:" + ToLayerName(painted_shape)); |
| 650 | 580 |
| 651 painted_layers_[painted_shape].reset(layer); | 581 painted_layers_[painted_shape].reset(layer); |
| 652 } | 582 } |
| 653 | 583 |
| 654 } // namespace views | 584 } // namespace views |
| OLD | NEW |