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

Unified Diff: services/view_manager/animation_runner.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
« no previous file with comments | « services/view_manager/BUILD.gn ('k') | services/view_manager/animation_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/view_manager/animation_runner.h
diff --git a/services/view_manager/animation_runner.h b/services/view_manager/animation_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..24e3bde16e0fbf33c17d7ef77bb32cd4f936168d
--- /dev/null
+++ b/services/view_manager/animation_runner.h
@@ -0,0 +1,73 @@
+// 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_ANIMATION_RUNNER_H_
+#define SERVICES_VIEW_MANAGER_ANIMATION_RUNNER_H_
+
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/observer_list.h"
+#include "base/time/time.h"
+
+namespace mojo {
+
+class AnimationGroup;
+
+namespace service {
+
+class AnimationRunnerObserver;
+class ScheduledAnimationGroup;
+class ServerView;
+
+// AnimationRunner is responsible for maintaing and running a set of animations.
+// The animations are represented as a set of AnimationGroups. New animations
+// are scheduled by way of Schedule(). A |view| may only have one animation
+// running at a time. Schedule()ing a new animation implicitly cancels the
+// outstanding animation. Animations progress by way of the Tick() function.
+class AnimationRunner {
+ public:
+ explicit AnimationRunner(base::TimeTicks now);
+ ~AnimationRunner();
+
+ void AddObserver(AnimationRunnerObserver* observer);
+ void RemoveObserver(AnimationRunnerObserver* observer);
+
+ // Schedules an animation for |view|. If there is an existing animation in
+ // progress for |view| it is canceled and any properties that were animating
+ // but are no longer animating are set to their target value.
+ // Returns 0 if |transport_group| is not valid.
+ uint32_t Schedule(ServerView* view, const AnimationGroup& transport_group);
+
+ // Returns the view the animation identified by |id| was scheduled for.
+ ServerView* GetViewForAnimation(uint32_t id);
+
+ // Cancels the animation scheduled for |view|. Does nothing if there is no
+ // animation scheduled for |view|. This does not change |view|. That is, any
+ // in progress animations are stopped.
+ void CancelAnimationForView(ServerView* view);
+
+ // Advance the animations updating values appropriately.
+ void Tick(base::TimeTicks time);
+
+ // Returns true if there are animations currently scheduled.
+ bool HasAnimations() const { return !animation_map_.empty(); }
+
+ private:
+ using ViewAnimationMap =
+ base::ScopedPtrHashMap<ServerView*, ScheduledAnimationGroup>;
+
+ uint32_t next_id_;
+
+ base::TimeTicks last_tick_time_;
+
+ ObserverList<AnimationRunnerObserver> observers_;
+
+ ViewAnimationMap animation_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(AnimationRunner);
+};
+
+} // namespace service
+} // namespace mojo
+
+#endif // SERVICES_VIEW_MANAGER_ANIMATION_RUNNER_H_
« no previous file with comments | « services/view_manager/BUILD.gn ('k') | services/view_manager/animation_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698