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

Unified Diff: ui/compositor/layer_animator.cc

Issue 311783002: Revert r274404 and r274409: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | ui/compositor/layer_animator_collection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_animator.cc
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index 39585a7c946e5a7656d46f02739826e1754e8a69..ce2b0ff364d9d7b5150ba90fa8879c5f8f46cc04 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -14,7 +14,7 @@
#include "ui/compositor/layer_animation_delegate.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
-#include "ui/compositor/layer_animator_collection.h"
+#include "ui/gfx/animation/animation_container.h"
#include "ui/gfx/frame_time.h"
#define SAFE_INVOKE_VOID(function, running_anim, ...) \
@@ -31,9 +31,22 @@
namespace ui {
+class LayerAnimator;
+
namespace {
const int kDefaultTransitionDurationMs = 120;
+const int kTimerIntervalMs = 10;
+
+// Returns the AnimationContainer we're added to.
+gfx::AnimationContainer* GetAnimationContainer() {
+ static gfx::AnimationContainer* container = NULL;
+ if (!container) {
+ container = new gfx::AnimationContainer();
+ container->AddRef();
+ }
+ return container;
+}
} // namespace
@@ -111,17 +124,7 @@ base::TimeDelta LayerAnimator::GetTransitionDuration() const {
}
void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
- if (delegate_ && is_started_) {
- LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
- if (collection)
- collection->StopAnimator(this);
- }
delegate_ = delegate;
- if (delegate_ && is_started_) {
- LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
- if (collection)
- collection->StartAnimator(this);
- }
}
void LayerAnimator::StartAnimation(LayerAnimationSequence* animation) {
@@ -178,9 +181,8 @@ void LayerAnimator::StartTogether(
adding_animations_ = true;
if (!is_animating()) {
- LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
- if (collection && collection->HasActiveAnimators())
- last_step_time_ = collection->last_tick_time();
+ if (GetAnimationContainer()->is_running())
+ last_step_time_ = GetAnimationContainer()->last_tick_time();
else
last_step_time_ = gfx::FrameTime::Now();
}
@@ -341,20 +343,6 @@ void LayerAnimator::OnThreadedAnimationStarted(
}
}
-void LayerAnimator::AddToCollection(LayerAnimatorCollection* collection) {
- if (is_animating() && !is_started_) {
- collection->StartAnimator(this);
- is_started_ = true;
- }
-}
-
-void LayerAnimator::RemoveFromCollection(LayerAnimatorCollection* collection) {
- if (is_animating() && is_started_) {
- collection->StopAnimator(this);
- is_started_ = false;
- }
-}
-
// LayerAnimator protected -----------------------------------------------------
void LayerAnimator::ProgressAnimation(LayerAnimationSequence* sequence,
@@ -407,6 +395,14 @@ void LayerAnimator::Step(base::TimeTicks now) {
}
}
+void LayerAnimator::SetStartTime(base::TimeTicks start_time) {
+ // Do nothing.
+}
+
+base::TimeDelta LayerAnimator::GetTimerInterval() const {
+ return base::TimeDelta::FromMilliseconds(kTimerIntervalMs);
+}
+
void LayerAnimator::StopAnimatingInternal(bool abort) {
scoped_refptr<LayerAnimator> retain(this);
while (is_animating()) {
@@ -435,16 +431,12 @@ void LayerAnimator::UpdateAnimationState() {
return;
const bool should_start = is_animating();
- LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
- if (collection) {
- if (should_start && !is_started_)
- collection->StartAnimator(this);
- else if (!should_start && is_started_)
- collection->StopAnimator(this);
- is_started_ = should_start;
- } else {
- is_started_ = false;
- }
+ if (should_start && !is_started_)
+ GetAnimationContainer()->Start(this);
+ else if (!should_start && is_started_)
+ GetAnimationContainer()->Stop(this);
+
+ is_started_ = should_start;
}
LayerAnimationSequence* LayerAnimator::RemoveAnimation(
@@ -761,15 +753,14 @@ bool LayerAnimator::StartSequenceImmediately(LayerAnimationSequence* sequence) {
// a resolution that can be as bad as 15ms. If this causes glitches in the
// animations, this can be switched to HighResNow() (animation uses Now()
// internally).
- // All LayerAnimators share the same LayerAnimatorCollection. Use the
+ // All LayerAnimators share the same AnimationContainer. Use the
// last_tick_time() from there to ensure animations started during the same
// event complete at the same time.
base::TimeTicks start_time;
- LayerAnimatorCollection* collection = GetLayerAnimatorCollection();
if (is_animating() || adding_animations_)
start_time = last_step_time_;
- else if (collection && collection->HasActiveAnimators())
- start_time = collection->last_tick_time();
+ else if (GetAnimationContainer()->is_running())
+ start_time = GetAnimationContainer()->last_tick_time();
else
start_time = gfx::FrameTime::Now();
@@ -848,10 +839,6 @@ void LayerAnimator::PurgeDeletedAnimations() {
}
}
-LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
- return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
-}
-
LayerAnimator::RunningAnimation::RunningAnimation(
const base::WeakPtr<LayerAnimationSequence>& sequence)
: sequence_(sequence) {
« no previous file with comments | « ui/compositor/layer_animator.h ('k') | ui/compositor/layer_animator_collection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698