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

Unified Diff: ui/compositor/animation_frame_task.h

Issue 427103002: compositor: Add rAF-like functionality for the UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months 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: ui/compositor/animation_frame_task.h
diff --git a/ui/compositor/animation_frame_task.h b/ui/compositor/animation_frame_task.h
new file mode 100644
index 0000000000000000000000000000000000000000..95c7f4473af019d3e40a2f0f61b6f83ceb75e203
--- /dev/null
+++ b/ui/compositor/animation_frame_task.h
@@ -0,0 +1,61 @@
+// 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 UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_
+#define UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "ui/compositor/compositor_export.h"
+
+namespace ui {
+
+enum AnimationFrameTaskStatus {
+ ANIMATION_FRAME_TASK_CONTINUE,
+ ANIMATION_FRAME_TASK_END,
+};
+
+class COMPOSITOR_EXPORT AnimationFrameTask {
+ public:
+ virtual ~AnimationFrameTask() {}
+
+ // Updates the task. Returns ANIMATION_FRAME_TASK_CONTINUE if the task has not
+ // completed, and should be triggered again at the next tick. Returns
+ // ANIMATION_FRAME_TASK_END if the task is complete. When returning
+ // ANIMATION_FRAME_TASK_END, the corresponding ScopedAnimationFrameTask handle
+ // for the task must be destroyed.
+ virtual AnimationFrameTaskStatus Progress(base::TimeTicks timestamp) = 0;
+};
+
+// A handle for an AnimationFrameTask. Destroying this handle removes the task
+// from the compositor. This handle can be destroyed at any time.
+class COMPOSITOR_EXPORT ScopedAnimationFrameTask {
+ public:
+ ScopedAnimationFrameTask(AnimationFrameTask* task,
+ const base::Closure& destroy_callback);
+ ~ScopedAnimationFrameTask();
+
+ private:
+ AnimationFrameTask* task_;
+ base::Closure destroy_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedAnimationFrameTask);
+};
+
+class COMPOSITOR_EXPORT AnimationFrameTaskProvider {
+ public:
+ virtual ~AnimationFrameTaskProvider() {}
+
+ // Adds |task| to the set of tasks that should be run at each animation
+ // step. Note that there is no guaranteed order among the tasks in the set.
+ // Destroying the returned handle removes the task from the set. Note that the
+ // caller must ensure that |task| outlives the returned handle.
+ virtual scoped_ptr<ScopedAnimationFrameTask> RequestAnimationFrameTask(
piman 2014/07/31 01:17:03 I would prefer if ScopedAnimationFrameTask was not
+ AnimationFrameTask* task) = 0;
+};
+
+} // namespace ui
+
+#endif // UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_

Powered by Google App Engine
This is Rietveld 408576698