Revert "Enable by default drive search on all channels and LSP API on dev."
[chromium-blink-merge.git] / components / view_manager / scheduled_animation_group.h
blobf46abf064aee780bc01876091f114bacb04bdd86
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
6 #define COMPONENTS_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "components/view_manager/public/interfaces/animations.mojom.h"
13 #include "ui/gfx/animation/tween.h"
14 #include "ui/gfx/transform.h"
16 namespace view_manager {
18 class ServerView;
20 struct ScheduledAnimationValue {
21 ScheduledAnimationValue();
22 ~ScheduledAnimationValue();
24 float float_value;
25 gfx::Transform transform;
28 struct ScheduledAnimationElement {
29 ScheduledAnimationElement();
30 ~ScheduledAnimationElement();
32 mojo::AnimationProperty property;
33 base::TimeDelta duration;
34 gfx::Tween::Type tween_type;
35 bool is_start_valid;
36 ScheduledAnimationValue start_value;
37 ScheduledAnimationValue target_value;
38 // Start time is based on scheduled time and relative to any other elements
39 // in the sequence.
40 base::TimeTicks start_time;
43 struct ScheduledAnimationSequence {
44 ScheduledAnimationSequence();
45 ~ScheduledAnimationSequence();
47 bool run_until_stopped;
48 std::vector<ScheduledAnimationElement> elements;
50 // Sum of the duration of all elements. This does not take into account
51 // |cycle_count|.
52 base::TimeDelta duration;
54 // The following values are updated as the animation progresses.
56 // Number of cycles remaining. This is only used if |run_until_stopped| is
57 // false.
58 uint32_t cycle_count;
60 // Index into |elements| of the element currently animating.
61 size_t current_index;
64 // Corresponds to a mojo::AnimationGroup and is responsible for running the
65 // actual animation.
66 class ScheduledAnimationGroup {
67 public:
68 ~ScheduledAnimationGroup();
70 // Returns a new ScheduledAnimationGroup from the supplied parameters, or
71 // null if |transport_group| isn't valid.
72 static scoped_ptr<ScheduledAnimationGroup> Create(
73 ServerView* view,
74 base::TimeTicks now,
75 uint32_t id,
76 const mojo::AnimationGroup& transport_group);
78 uint32_t id() const { return id_; }
80 // Gets the start value for any elements that don't have an explicit start.
81 // value.
82 void ObtainStartValues();
84 // Sets the values of any properties that are not in |other| to their final
85 // value.
86 void SetValuesToTargetValuesForPropertiesNotIn(
87 const ScheduledAnimationGroup& other);
89 // Advances the group. |time| is the current time. Returns true if the group
90 // is done (nothing left to animate).
91 bool Tick(base::TimeTicks time);
93 ServerView* view() { return view_; }
95 private:
96 ScheduledAnimationGroup(ServerView* view,
97 uint32_t id,
98 base::TimeTicks time_scheduled);
100 ServerView* view_;
101 const uint32_t id_;
102 base::TimeTicks time_scheduled_;
103 std::vector<ScheduledAnimationSequence> sequences_;
105 DISALLOW_COPY_AND_ASSIGN(ScheduledAnimationGroup);
108 } // namespace view_manager
110 #endif // COMPONENTS_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_