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

Unified Diff: ui/views/animation/ink_drop_animation_controller_impl.cc

Issue 1373983002: Enhanced the InkDropRippleImpl to create/destroy InkDropAnimations as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed merge with master. Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/animation/ink_drop_animation_controller_impl.cc
diff --git a/ui/views/animation/ink_drop_animation_controller_impl.cc b/ui/views/animation/ink_drop_animation_controller_impl.cc
index 0b014bd8b5caf3cd853f0a190cde8323dc713873..74d681d8d637422bd900240fac416aa68d3a33d2 100644
--- a/ui/views/animation/ink_drop_animation_controller_impl.cc
+++ b/ui/views/animation/ink_drop_animation_controller_impl.cc
@@ -14,11 +14,9 @@ InkDropAnimationControllerImpl::InkDropAnimationControllerImpl(
: ink_drop_host_(ink_drop_host) {}
InkDropAnimationControllerImpl::~InkDropAnimationControllerImpl() {
- if (ink_drop_animation_) {
- // TODO(bruthig): Change this to be called when the ink drop becomes hidden.
- // See www.crbug.com/522175.
- ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
- }
+ // Explicitly destroy the InkDropAnimation so that this still exists if
+ // views::InkDropAnimationObserver methods are called on this.
+ DestroyInkDropAnimation();
}
InkDropState InkDropAnimationControllerImpl::GetInkDropState() const {
@@ -27,10 +25,11 @@ InkDropState InkDropAnimationControllerImpl::GetInkDropState() const {
return ink_drop_animation_->ink_drop_state();
}
-void InkDropAnimationControllerImpl::AnimateToState(InkDropState state) {
+void InkDropAnimationControllerImpl::AnimateToState(
+ InkDropState ink_drop_state) {
if (!ink_drop_animation_)
CreateInkDropAnimation();
- ink_drop_animation_->AnimateToState(state);
+ ink_drop_animation_->AnimateToState(ink_drop_state);
}
gfx::Size InkDropAnimationControllerImpl::GetInkDropLargeSize() const {
@@ -61,19 +60,48 @@ void InkDropAnimationControllerImpl::SetInkDropCenter(
}
void InkDropAnimationControllerImpl::CreateInkDropAnimation() {
- if (ink_drop_animation_)
- ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
+ DestroyInkDropAnimation();
- // TODO(bruthig): It will be expensive to maintain InkDropAnimation instances
- // when they are not actually being used. Consider creating InkDropAnimations
- // on an as-needed basis and if construction is also expensive then consider
- // creating an InkDropAnimationPool. See www.crbug.com/522175.
ink_drop_animation_.reset(new InkDropAnimation(
ink_drop_large_size_, ink_drop_large_corner_radius_, ink_drop_small_size_,
ink_drop_small_corner_radius_));
+ ink_drop_animation_->AddObserver(this);
ink_drop_animation_->SetCenterPoint(ink_drop_center_);
ink_drop_host_->AddInkDropLayer(ink_drop_animation_->root_layer());
}
+void InkDropAnimationControllerImpl::DestroyInkDropAnimation() {
+ if (!ink_drop_animation_)
+ return;
+ ink_drop_host_->RemoveInkDropLayer(ink_drop_animation_->root_layer());
+ ink_drop_animation_->RemoveObserver(this);
+ ink_drop_animation_.reset();
+}
+
+void InkDropAnimationControllerImpl::InkDropAnimationStarted(
+ InkDropState ink_drop_state) {}
+
+void InkDropAnimationControllerImpl::InkDropAnimationEnded(
+ InkDropState ink_drop_state,
+ InkDropAnimationEndedReason reason) {
+ if (reason != SUCCESS)
+ return;
+ switch (ink_drop_state) {
+ case views::InkDropState::QUICK_ACTION:
+ case views::InkDropState::SLOW_ACTION:
+ case views::InkDropState::DEACTIVATED:
+ ink_drop_animation_->AnimateToState(views::InkDropState::HIDDEN);
+ break;
+ case views::InkDropState::HIDDEN:
+ // TODO(bruthig): Investigate whether creating and destroying
+ // InkDropAnimations is expensive and consider creating an
+ // InkDropAnimationPool. See www.crbug.com/522175.
+ DestroyInkDropAnimation();
+ break;
+ default:
+ break;
+ }
+}
+
} // namespace views
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_impl.h ('k') | ui/views/animation/ink_drop_animation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698