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

Side by Side Diff: services/view_manager/scheduled_animation_group.h

Issue 772893004: Adds constants and runner for animations (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Merge Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
6 #define SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "mojo/services/public/interfaces/view_manager/animations.mojom.h"
13 #include "ui/gfx/animation/tween.h"
14 #include "ui/gfx/transform.h"
15
16 namespace mojo {
17 namespace service {
18
19 class ServerView;
20
21 struct ScheduledAnimationValue {
22 ScheduledAnimationValue();
23 ~ScheduledAnimationValue();
24
25 float float_value;
26 gfx::Transform transform;
27 };
28
29 struct ScheduledAnimationElement {
30 ScheduledAnimationElement();
31 ~ScheduledAnimationElement();
32
33 AnimationProperty property;
34 base::TimeDelta duration;
35 gfx::Tween::Type tween_type;
36 bool is_start_valid;
37 ScheduledAnimationValue start_value;
38 ScheduledAnimationValue target_value;
39 // Start time is based on scheduled time and relative to any other elements
40 // in the sequence.
41 base::TimeTicks start_time;
42 };
43
44 struct ScheduledAnimationSequence {
45 ScheduledAnimationSequence();
46 ~ScheduledAnimationSequence();
47
48 bool run_until_stopped;
49 std::vector<ScheduledAnimationElement> elements;
50
51 // Sum of the duration of all elements. This does not take into account
52 // |cycle_count|.
53 base::TimeDelta duration;
54
55 // The following values are updated as the animation progresses.
56
57 // Number of cycles remaining. This is only used if |run_until_stopped| is
58 // false.
59 uint32_t cycle_count;
60
61 // Index into |elements| of the element currently animating.
62 size_t current_index;
63 };
64
65 // Corresponds to a mojo::AnimationGroup and is responsible for running the
66 // actual animation.
67 class ScheduledAnimationGroup {
68 public:
69 ~ScheduledAnimationGroup();
70
71 // Returns a new ScheduledAnimationGroup from the supplied parameters, or
72 // null if |transport_group| isn't valid.
73 static scoped_ptr<ScheduledAnimationGroup> Create(
74 ServerView* view,
75 base::TimeTicks now,
76 uint32_t id,
77 const AnimationGroup& transport_group);
78
79 uint32_t id() const { return id_; }
80
81 // Gets the start value for any elements that don't have an explicit start.
82 // value.
83 void ObtainStartValues();
84
85 // Sets the values of any properties that are not in |other| to their final
86 // value.
87 void SetValuesToTargetValuesForPropertiesNotIn(
88 const ScheduledAnimationGroup& other);
89
90 // Advances the group. |time| is the current time. Returns true if the group
91 // is done (nothing left to animate).
92 bool Tick(base::TimeTicks time);
93
94 private:
95 ScheduledAnimationGroup(ServerView* view,
96 uint32_t id,
97 base::TimeTicks time_scheduled);
98
99 ServerView* view_;
100 const uint32_t id_;
101 base::TimeTicks time_scheduled_;
102 std::vector<ScheduledAnimationSequence> sequences_;
103
104 DISALLOW_COPY_AND_ASSIGN(ScheduledAnimationGroup);
105 };
106
107 } // namespace service
108 } // namespace mojo
109
110 #endif // SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
OLDNEW
« no previous file with comments | « services/view_manager/animation_runner_unittest.cc ('k') | services/view_manager/scheduled_animation_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698