12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CC_ANIMATION_ANIMATION_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CC_ANIMATION_ANIMATION_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h"
10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/time/time.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/cc_export.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc {
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class AnimationCurve;
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// An Animation contains all the state required to play an AnimationCurve.
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Specifically, the affected property, the run state (paused, finished, etc.),
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// loop count, last pause time, and the total time spent paused.
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class CC_EXPORT Animation {
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Animations begin in the 'WaitingForTargetAvailability' state. An Animation
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // waiting for target availibility will run as soon as its target property
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // is free (and all the animations animating with it are also able to run).
25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // When this time arrives, the controller will move the animation into the
26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Starting state, and then into the Running state. Running animations may
27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // toggle between Running and Paused, and may be stopped by moving into either
28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // the Aborted or Finished states. A Finished animation was allowed to run to
29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // completion, but an Aborted animation was not.
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum RunState {
31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    WaitingForTargetAvailability = 0,
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    WaitingForDeletion,
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Starting,
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Running,
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Paused,
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Finished,
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Aborted,
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // This sentinel must be last.
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    RunStateEnumSize
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum TargetProperty {
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Transform = 0,
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    Opacity,
454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    Filter,
46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    ScrollOffset,
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BackgroundColor,
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // This sentinel must be last.
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    TargetPropertyEnumSize
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  enum Direction { Normal, Reverse, Alternate, AlternateReverse };
53010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  enum FillMode {
551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    FillModeNone,
561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    FillModeForwards,
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    FillModeBackwards,
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    FillModeBoth
591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  };
601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static scoped_ptr<Animation> Create(scoped_ptr<AnimationCurve> curve,
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      int animation_id,
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      int group_id,
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      TargetProperty target_property);
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~Animation();
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int id() const { return id_; }
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int group() const { return group_; }
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TargetProperty target_property() const { return target_property_; }
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  RunState run_state() const { return run_state_; }
73cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void SetRunState(RunState run_state, base::TimeTicks monotonic_time);
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // This is the number of times that the animation will play. If this
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // value is zero the animation will not play. If it is negative, then
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the animation will loop indefinitely.
786e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  double iterations() const { return iterations_; }
796e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void set_iterations(double n) { iterations_ = n; }
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  double iteration_start() const { return iteration_start_; }
821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void set_iteration_start(double iteration_start) {
831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    iteration_start_ = iteration_start;
841320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  }
851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
86cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeTicks start_time() const { return start_time_; }
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
88cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void set_start_time(base::TimeTicks monotonic_time) {
89cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    start_time_ = monotonic_time;
90cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
91cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  bool has_set_start_time() const { return !start_time_.is_null(); }
92cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
93cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeDelta time_offset() const { return time_offset_; }
94cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void set_time_offset(base::TimeDelta monotonic_time) {
95cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    time_offset_ = monotonic_time;
96cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  }
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
98cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void Suspend(base::TimeTicks monotonic_time);
99cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void Resume(base::TimeTicks monotonic_time);
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
101010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  Direction direction() { return direction_; }
102010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  void set_direction(Direction direction) { direction_ = direction; }
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  FillMode fill_mode() { return fill_mode_; }
1051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void set_fill_mode(FillMode fill_mode) { fill_mode_ = fill_mode; }
1061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
10703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  double playback_rate() { return playback_rate_; }
10803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  void set_playback_rate(double playback_rate) {
10903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    playback_rate_ = playback_rate;
11003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  }
11103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
112cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  bool IsFinishedAt(base::TimeTicks monotonic_time) const;
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_finished() const {
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return run_state_ == Finished ||
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        run_state_ == Aborted ||
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        run_state_ == WaitingForDeletion;
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool InEffect(base::TimeTicks monotonic_time) const;
1201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AnimationCurve* curve() { return curve_.get(); }
1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const AnimationCurve* curve() const { return curve_.get(); }
1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If this is true, even if the animation is running, it will not be tickable
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // until it is given a start time. This is true for animations running on the
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // main thread.
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool needs_synchronized_start_time() const {
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return needs_synchronized_start_time_;
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void set_needs_synchronized_start_time(bool needs_synchronized_start_time) {
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    needs_synchronized_start_time_ = needs_synchronized_start_time;
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // This is true for animations running on the main thread when the Finished
135c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // event sent by the corresponding impl animation has been received.
136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool received_finished_event() const {
137c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return received_finished_event_;
138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void set_received_finished_event(bool received_finished_event) {
140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    received_finished_event_ = received_finished_event;
141c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Takes the given absolute time, and using the start time and the number
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // of iterations, returns the relative time in the current iteration.
145cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  double TrimTimeToCurrentIteration(base::TimeTicks monotonic_time) const;
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
147c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  scoped_ptr<Animation> CloneAndInitialize(RunState initial_run_state) const;
148cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_controlling_instance() const { return is_controlling_instance_; }
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void PushPropertiesTo(Animation* other) const;
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void set_is_impl_only(bool is_impl_only) { is_impl_only_ = is_impl_only; }
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_impl_only() const { return is_impl_only_; }
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1565c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  void set_affects_active_observers(bool affects_active_observers) {
1575c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    affects_active_observers_ = affects_active_observers;
1585c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  }
1595c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  bool affects_active_observers() const { return affects_active_observers_; }
1605c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
1615c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  void set_affects_pending_observers(bool affects_pending_observers) {
1625c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    affects_pending_observers_ = affects_pending_observers;
1635c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  }
1645c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  bool affects_pending_observers() const { return affects_pending_observers_; }
1655c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Animation(scoped_ptr<AnimationCurve> curve,
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            int animation_id,
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            int group_id,
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            TargetProperty target_property);
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  double ConvertToActiveTime(base::TimeTicks monotonic_time) const;
1731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<AnimationCurve> curve_;
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // IDs are not necessarily unique.
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int id_;
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Animations that must be run together are called 'grouped' and have the same
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // group id. Grouped animations are guaranteed to start at the same time and
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // no other animations may animate any of the group's target properties until
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // all animations in the group have finished animating. Note: an active
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // animation's group id and target property uniquely identify that animation.
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int group_;
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TargetProperty target_property_;
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  RunState run_state_;
1886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  double iterations_;
1891320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  double iteration_start_;
190cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeTicks start_time_;
191010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  Direction direction_;
19203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  double playback_rate_;
1931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  FillMode fill_mode_;
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The time offset effectively pushes the start of the animation back in time.
1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // This is used for resuming paused animations -- an animation is added with a
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // non-zero time offset, causing the animation to skip ahead to the desired
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // point in time.
199cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeDelta time_offset_;
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool needs_synchronized_start_time_;
202c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool received_finished_event_;
2032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // When an animation is suspended, it behaves as if it is paused and it also
2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // ignores all run state changes until it is resumed. This is used for testing
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // purposes.
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool suspended_;
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // These are used in TrimTimeToCurrentIteration to account for time
2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // spent while paused. This is not included in AnimationState since it
2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // there is absolutely no need for clients of this controller to know
2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // about these values.
213cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeTicks pause_time_;
214cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  base::TimeDelta total_paused_time_;
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Animations lead dual lives. An active animation will be conceptually owned
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // by two controllers, one on the impl thread and one on the main. In reality,
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // there will be two separate Animation instances for the same animation. They
2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // will have the same group id and the same target property (these two values
2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // uniquely identify an animation). The instance on the impl thread is the
2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // instance that ultimately controls the values of the animating layer and so
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // we will refer to it as the 'controlling instance'.
2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_controlling_instance_;
2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_impl_only_;
2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // When pushed from a main-thread controller to a compositor-thread
2285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // controller, an animation will initially only affect pending observers
2295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // (corresponding to layers in the pending tree). Animations that only
2305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // affect pending observers are able to reach the Starting state and tick
2315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // pending observers, but cannot proceed any further and do not tick active
2325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // observers. After activation, such animations affect both kinds of observers
2335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // and are able to proceed past the Starting state. When the removal of
2345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // an animation is pushed from a main-thread controller to a
2355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // compositor-thread controller, this initially only makes the animation
2365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // stop affecting pending observers. After activation, such animations no
2375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // longer affect any observers, and are deleted.
2385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  bool affects_active_observers_;
2395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  bool affects_pending_observers_;
2405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(Animation);
2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace cc
2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CC_ANIMATION_ANIMATION_H_
247