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

Unified Diff: ui/base/animation/multi_animation.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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/base/animation/multi_animation.h ('k') | ui/base/animation/multi_animation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/animation/multi_animation.cc
diff --git a/ui/base/animation/multi_animation.cc b/ui/base/animation/multi_animation.cc
deleted file mode 100644
index 2e9e4772db634bde00d53ae24abec7130ef16acc..0000000000000000000000000000000000000000
--- a/ui/base/animation/multi_animation.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/animation/multi_animation.h"
-
-#include "base/logging.h"
-#include "ui/base/animation/animation_delegate.h"
-
-namespace ui {
-
-// Default interval, in ms.
-static const int kDefaultTimerInterval = 20;
-
-static int TotalTime(const MultiAnimation::Parts& parts) {
- int time_ms = 0;
- for (size_t i = 0; i < parts.size(); ++i) {
- DCHECK(parts[i].end_time_ms - parts[i].start_time_ms >= parts[i].time_ms);
- time_ms += parts[i].time_ms;
- }
- return time_ms;
-}
-
-MultiAnimation::MultiAnimation(const Parts& parts,
- base::TimeDelta timer_interval)
- : Animation(timer_interval),
- parts_(parts),
- cycle_time_ms_(TotalTime(parts)),
- current_value_(0),
- current_part_index_(0),
- continuous_(true) {
- DCHECK(!parts_.empty());
-}
-
-MultiAnimation::~MultiAnimation() {}
-
-// static.
-base::TimeDelta MultiAnimation::GetDefaultTimerInterval() {
- return base::TimeDelta::FromMilliseconds(kDefaultTimerInterval);
-}
-
-double MultiAnimation::GetCurrentValue() const {
- return current_value_;
-}
-
-void MultiAnimation::Step(base::TimeTicks time_now) {
- double last_value = current_value_;
- size_t last_index = current_part_index_;
-
- int delta = static_cast<int>((time_now - start_time()).InMilliseconds());
- if (delta >= cycle_time_ms_ && !continuous_) {
- current_part_index_ = parts_.size() - 1;
- current_value_ = Tween::CalculateValue(parts_[current_part_index_].type, 1);
- Stop();
- return;
- }
- delta %= cycle_time_ms_;
- const Part& part = GetPart(&delta, &current_part_index_);
- double percent = static_cast<double>(delta + part.start_time_ms) /
- static_cast<double>(part.end_time_ms);
- DCHECK(percent <= 1);
- current_value_ = Tween::CalculateValue(part.type, percent);
-
- if ((current_value_ != last_value || current_part_index_ != last_index) &&
- delegate()) {
- delegate()->AnimationProgressed(this);
- }
-}
-
-void MultiAnimation::SetStartTime(base::TimeTicks start_time) {
- Animation::SetStartTime(start_time);
- current_value_ = 0;
- current_part_index_ = 0;
-}
-
-const MultiAnimation::Part& MultiAnimation::GetPart(int* time_ms,
- size_t* part_index) {
- DCHECK(*time_ms < cycle_time_ms_);
-
- for (size_t i = 0; i < parts_.size(); ++i) {
- if (*time_ms < parts_[i].time_ms) {
- *part_index = i;
- return parts_[i];
- }
-
- *time_ms -= parts_[i].time_ms;
- }
- NOTREACHED();
- *time_ms = 0;
- *part_index = 0;
- return parts_[0];
-}
-
-} // namespace ui
« no previous file with comments | « ui/base/animation/multi_animation.h ('k') | ui/base/animation/multi_animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698