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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
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 UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_
6 #define UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_
7
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "ui/compositor/compositor_export.h"
12
13 namespace ui {
14
15 enum AnimationFrameTaskStatus {
16 ANIMATION_FRAME_TASK_CONTINUE,
17 ANIMATION_FRAME_TASK_END,
18 };
19
20 class COMPOSITOR_EXPORT AnimationFrameTask {
21 public:
22 virtual ~AnimationFrameTask() {}
23
24 // Updates the task. Returns ANIMATION_FRAME_TASK_CONTINUE if the task has not
25 // completed, and should be triggered again at the next tick. Returns
26 // ANIMATION_FRAME_TASK_END if the task is complete. When returning
27 // ANIMATION_FRAME_TASK_END, the corresponding ScopedAnimationFrameTask handle
28 // for the task must be destroyed.
29 virtual AnimationFrameTaskStatus Progress(base::TimeTicks timestamp) = 0;
30 };
31
32 // A handle for an AnimationFrameTask. Destroying this handle removes the task
33 // from the compositor. This handle can be destroyed at any time.
34 class COMPOSITOR_EXPORT ScopedAnimationFrameTask {
35 public:
36 ScopedAnimationFrameTask(AnimationFrameTask* task,
37 const base::Closure& destroy_callback);
38 ~ScopedAnimationFrameTask();
39
40 private:
41 AnimationFrameTask* task_;
42 base::Closure destroy_callback_;
43
44 DISALLOW_COPY_AND_ASSIGN(ScopedAnimationFrameTask);
45 };
46
47 class COMPOSITOR_EXPORT AnimationFrameTaskProvider {
48 public:
49 virtual ~AnimationFrameTaskProvider() {}
50
51 // Adds |task| to the set of tasks that should be run at each animation
52 // step. Note that there is no guaranteed order among the tasks in the set.
53 // Destroying the returned handle removes the task from the set. Note that the
54 // caller must ensure that |task| outlives the returned handle.
55 virtual scoped_ptr<ScopedAnimationFrameTask> RequestAnimationFrameTask(
piman 2014/07/31 01:17:03 I would prefer if ScopedAnimationFrameTask was not
56 AnimationFrameTask* task) = 0;
57 };
58
59 } // namespace ui
60
61 #endif // UI_COMPOSITOR_ANIMATION_FRAME_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698