Chromium Code Reviews| 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_ |