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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: services/view_manager/scheduled_animation_group.h
diff --git a/services/view_manager/scheduled_animation_group.h b/services/view_manager/scheduled_animation_group.h
new file mode 100644
index 0000000000000000000000000000000000000000..990808b00d75ce39ca5936963f1da1a75a4700bf
--- /dev/null
+++ b/services/view_manager/scheduled_animation_group.h
@@ -0,0 +1,110 @@
+// Copyright 2014 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.
+
+#ifndef SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
+#define SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "mojo/services/public/interfaces/view_manager/animations.mojom.h"
+#include "ui/gfx/animation/tween.h"
+#include "ui/gfx/transform.h"
+
+namespace mojo {
+namespace service {
+
+class ServerView;
+
+struct ScheduledAnimationValue {
+ ScheduledAnimationValue();
+ ~ScheduledAnimationValue();
+
+ float float_value;
+ gfx::Transform transform;
+};
+
+struct ScheduledAnimationElement {
+ ScheduledAnimationElement();
+ ~ScheduledAnimationElement();
+
+ AnimationProperty property;
+ base::TimeDelta duration;
+ gfx::Tween::Type tween_type;
+ bool is_start_valid;
+ ScheduledAnimationValue start_value;
+ ScheduledAnimationValue target_value;
+ // Start time is based on scheduled time and relative to any other elements
+ // in the sequence.
+ base::TimeTicks start_time;
+};
+
+struct ScheduledAnimationSequence {
+ ScheduledAnimationSequence();
+ ~ScheduledAnimationSequence();
+
+ bool run_until_stopped;
+ std::vector<ScheduledAnimationElement> elements;
+
+ // Sum of the duration of all elements. This does not take into account
+ // |cycle_count|.
+ base::TimeDelta duration;
+
+ // The following values are updated as the animation progresses.
+
+ // Number of cycles remaining. This is only used if |run_until_stopped| is
+ // false.
+ uint32_t cycle_count;
+
+ // Index into |elements| of the element currently animating.
+ size_t current_index;
+};
+
+// Corresponds to a mojo::AnimationGroup and is responsible for running the
+// actual animation.
+class ScheduledAnimationGroup {
+ public:
+ ~ScheduledAnimationGroup();
+
+ // Returns a new ScheduledAnimationGroup from the supplied parameters, or
+ // null if |transport_group| isn't valid.
+ static scoped_ptr<ScheduledAnimationGroup> Create(
+ ServerView* view,
+ base::TimeTicks now,
+ uint32_t id,
+ const AnimationGroup& transport_group);
+
+ uint32_t id() const { return id_; }
+
+ // Gets the start value for any elements that don't have an explicit start.
+ // value.
+ void ObtainStartValues();
+
+ // Sets the values of any properties that are not in |other| to their final
+ // value.
+ void SetValuesToTargetValuesForPropertiesNotIn(
+ const ScheduledAnimationGroup& other);
+
+ // Advances the group. |time| is the current time. Returns true if the group
+ // is done (nothing left to animate).
+ bool Tick(base::TimeTicks time);
+
+ private:
+ ScheduledAnimationGroup(ServerView* view,
+ uint32_t id,
+ base::TimeTicks time_scheduled);
+
+ ServerView* view_;
+ const uint32_t id_;
+ base::TimeTicks time_scheduled_;
+ std::vector<ScheduledAnimationSequence> sequences_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScheduledAnimationGroup);
+};
+
+} // namespace service
+} // namespace mojo
+
+#endif // SERVICES_VIEW_MANAGER_SCHEDULED_ANIMATION_GROUP_H_
« 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