Chromium Code Reviews| Index: ui/compositor/compositor.cc |
| diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc |
| index 603bf487ed24351e78771d66954301522a63d3cb..ab3d9dfaff14001703362d34cda42fd117fd5188 100644 |
| --- a/ui/compositor/compositor.cc |
| +++ b/ui/compositor/compositor.cc |
| @@ -88,7 +88,7 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, |
| draw_on_compositing_end_(false), |
| swap_state_(SWAP_NONE), |
| layer_animator_collection_(this), |
| - schedule_draw_factory_(this) { |
| + weak_ptr_factory_(this) { |
| root_web_layer_ = cc::Layer::Create(); |
| CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| @@ -183,7 +183,7 @@ void Compositor::ScheduleDraw() { |
| defer_draw_scheduling_ = true; |
| task_runner_->PostTask( |
| FROM_HERE, |
| - base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr())); |
| + base::Bind(&Compositor::Draw, weak_ptr_factory_.GetWeakPtr())); |
| } |
| } |
| @@ -290,8 +290,23 @@ bool Compositor::HasObserver(CompositorObserver* observer) { |
| } |
| void Compositor::Animate(base::TimeTicks frame_begin_time) { |
| - layer_animator_collection_.Progress(frame_begin_time); |
| - if (layer_animator_collection_.HasActiveAnimators()) |
| + bool should_animate = false; |
| + std::set<AnimationFrameTask*> tasks = rafs_; |
| + for (std::set<AnimationFrameTask*>::iterator i = tasks.begin(); |
| + i != tasks.end(); |
| + ++i) { |
| + AnimationFrameTask* task = *i; |
| + if (!rafs_.count(task)) |
| + continue; |
| + if (task->Progress(frame_begin_time) == ANIMATION_FRAME_TASK_CONTINUE) { |
| + CHECK(rafs_.count(task)); |
|
piman
2014/07/31 01:17:03
nit: DCHECK
|
| + should_animate = true; |
| + } else { |
| + DCHECK(!rafs_.count(task)); |
| + } |
| + } |
|
piman
2014/07/31 01:17:03
maybe it's naive, but why wouldn't the standard Ob
|
| + |
| + if (should_animate) |
| host_->SetNeedsAnimate(); |
| } |
| @@ -360,10 +375,6 @@ void Compositor::DidAbortSwapBuffers() { |
| OnCompositingAborted(this)); |
| } |
| -void Compositor::ScheduleAnimationForLayerCollection() { |
| - host_->SetNeedsAnimate(); |
| -} |
| - |
| const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { |
| return host_->debug_state(); |
| } |
| @@ -417,4 +428,21 @@ void Compositor::NotifyEnd() { |
| OnCompositingEnded(this)); |
| } |
| +scoped_ptr<ScopedAnimationFrameTask> Compositor::RequestAnimationFrameTask( |
| + AnimationFrameTask* task) { |
| + CHECK(!rafs_.count(task)); |
| + rafs_.insert(task); |
| + host_->SetNeedsAnimate(); |
| + return make_scoped_ptr(new ScopedAnimationFrameTask( |
| + task, |
| + base::Bind(&Compositor::RemoveAnimationFrameTask, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + task))); |
| +} |
| + |
| +void Compositor::RemoveAnimationFrameTask(AnimationFrameTask* task) { |
| + CHECK(rafs_.count(task)); |
| + rafs_.erase(task); |
| +} |
| + |
| } // namespace ui |