Index: ui/compositor/compositor.cc |
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc |
index faa70b11adcbde045f86b358d95140f3b1639318..b7ed37373c0a1e68cdaabc57e27ac82edcf3676e 100644 |
--- a/ui/compositor/compositor.cc |
+++ b/ui/compositor/compositor.cc |
@@ -80,10 +80,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, |
num_failed_recreate_attempts_(0), |
disable_schedule_composite_(false), |
compositor_lock_(NULL), |
- defer_draw_scheduling_(false), |
- waiting_on_compositing_end_(false), |
- draw_on_compositing_end_(false), |
- swap_state_(SWAP_NONE), |
layer_animator_collection_(this), |
weak_ptr_factory_(this) { |
root_web_layer_ = cc::Layer::Create(); |
@@ -109,7 +105,8 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, |
settings.per_tile_painting_enabled = true; |
#endif |
#if defined(OS_WIN) |
- settings.disable_hi_res_timer_tasks_on_battery = true; |
+ settings.disable_hi_res_timer_tasks_on_battery = |
+ !context_factory_->DoesCreateTestContexts(); |
settings.renderer_settings.finish_rendering_on_resize = true; |
#endif |
@@ -140,7 +137,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, |
settings.impl_side_painting = IsUIImplSidePaintingEnabled(); |
settings.use_zero_copy = IsUIZeroCopyEnabled(); |
- settings.single_thread_proxy_scheduler = false; |
base::TimeTicks before_create = base::TimeTicks::Now(); |
if (compositor_thread_loop_.get()) { |
@@ -194,14 +190,7 @@ void Compositor::SetOutputSurface( |
} |
void Compositor::ScheduleDraw() { |
- if (compositor_thread_loop_.get()) { |
- host_->SetNeedsCommit(); |
- } else if (!defer_draw_scheduling_) { |
- defer_draw_scheduling_ = true; |
- task_runner_->PostTask( |
- FROM_HERE, |
- base::Bind(&Compositor::Draw, weak_ptr_factory_.GetWeakPtr())); |
- } |
+ host_->SetNeedsCommit(); |
} |
void Compositor::SetRootLayer(Layer* root_layer) { |
@@ -222,43 +211,19 @@ void Compositor::SetHostHasTransparentBackground( |
host_->set_has_transparent_background(host_has_transparent_background); |
} |
-void Compositor::Draw() { |
- DCHECK(!compositor_thread_loop_.get()); |
- |
- defer_draw_scheduling_ = false; |
- if (waiting_on_compositing_end_) { |
- draw_on_compositing_end_ = true; |
- return; |
- } |
- if (!root_layer_) |
- return; |
- |
- TRACE_EVENT_ASYNC_BEGIN0("ui", "Compositor::Draw", last_started_frame_ + 1); |
- |
- DCHECK_NE(swap_state_, SWAP_POSTED); |
- swap_state_ = SWAP_NONE; |
- |
- waiting_on_compositing_end_ = true; |
- last_started_frame_++; |
- if (!IsLocked()) { |
- // TODO(nduca): Temporary while compositor calls |
- // compositeImmediately() directly. |
- cc::BeginFrameArgs args = cc::BeginFrameArgs::Create( |
- BEGINFRAME_FROM_HERE, gfx::FrameTime::Now(), base::TimeTicks(), |
- cc::BeginFrameArgs::DefaultInterval(), cc::BeginFrameArgs::SYNCHRONOUS); |
- BeginMainFrame(args); |
- host_->Composite(args.frame_time); |
- } |
- if (swap_state_ == SWAP_NONE) |
- NotifyEnd(); |
-} |
- |
void Compositor::ScheduleFullRedraw() { |
+ // TODO(enne): Some callers (mac) call this function expecting that it |
+ // will also commit. This should probably just redraw the screen |
+ // from damage and not commit. ScheduleDraw/ScheduleRedraw need |
+ // better names. |
host_->SetNeedsRedraw(); |
+ host_->SetNeedsCommit(); |
} |
void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) { |
+ // TODO(enne): Make this not commit. See ScheduleFullRedraw. |
host_->SetNeedsRedrawRect(damage_rect); |
+ host_->SetNeedsCommit(); |
} |
void Compositor::DisableSwapUntilResize() { |
@@ -377,45 +342,28 @@ void Compositor::DidCommit() { |
} |
void Compositor::DidCommitAndDrawFrame() { |
- base::TimeTicks start_time = gfx::FrameTime::Now(); |
- FOR_EACH_OBSERVER(CompositorObserver, |
- observer_list_, |
- OnCompositingStarted(this, start_time)); |
} |
void Compositor::DidCompleteSwapBuffers() { |
+ // DidPostSwapBuffers is a SingleThreadProxy-only feature. Synthetically |
+ // generate OnCompositingStarted messages for the threaded case so that |
+ // OnCompositingStarted/OnCompositingEnded messages match. |
if (compositor_thread_loop_.get()) { |
- NotifyEnd(); |
- } else { |
- DCHECK_EQ(swap_state_, SWAP_POSTED); |
- NotifyEnd(); |
- swap_state_ = SWAP_COMPLETED; |
+ base::TimeTicks start_time = gfx::FrameTime::Now(); |
+ FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
+ OnCompositingStarted(this, start_time)); |
} |
-} |
- |
-void Compositor::ScheduleComposite() { |
- if (!disable_schedule_composite_) |
- ScheduleDraw(); |
-} |
- |
-void Compositor::ScheduleAnimation() { |
- ScheduleComposite(); |
+ FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
+ OnCompositingEnded(this)); |
} |
void Compositor::DidPostSwapBuffers() { |
- DCHECK(!compositor_thread_loop_.get()); |
- DCHECK_EQ(swap_state_, SWAP_NONE); |
- swap_state_ = SWAP_POSTED; |
+ base::TimeTicks start_time = gfx::FrameTime::Now(); |
+ FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
+ OnCompositingStarted(this, start_time)); |
} |
void Compositor::DidAbortSwapBuffers() { |
- if (!compositor_thread_loop_.get()) { |
- if (swap_state_ == SWAP_POSTED) { |
- NotifyEnd(); |
- swap_state_ = SWAP_COMPLETED; |
- } |
- } |
- |
FOR_EACH_OBSERVER(CompositorObserver, |
observer_list_, |
OnCompositingAborted(this)); |
@@ -437,8 +385,7 @@ const cc::RendererSettings& Compositor::GetRendererSettings() const { |
scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { |
if (!compositor_lock_) { |
compositor_lock_ = new CompositorLock(this); |
- if (compositor_thread_loop_.get()) |
- host_->SetDeferCommits(true); |
+ host_->SetDeferCommits(true); |
FOR_EACH_OBSERVER(CompositorObserver, |
observer_list_, |
OnCompositingLockStateChanged(this)); |
@@ -449,8 +396,7 @@ scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { |
void Compositor::UnlockCompositor() { |
DCHECK(compositor_lock_); |
compositor_lock_ = NULL; |
- if (compositor_thread_loop_.get()) |
- host_->SetDeferCommits(false); |
+ host_->SetDeferCommits(false); |
FOR_EACH_OBSERVER(CompositorObserver, |
observer_list_, |
OnCompositingLockStateChanged(this)); |
@@ -461,20 +407,4 @@ void Compositor::CancelCompositorLock() { |
compositor_lock_->CancelLock(); |
} |
-void Compositor::NotifyEnd() { |
- last_ended_frame_++; |
- TRACE_EVENT_ASYNC_END0("ui", "Compositor::Draw", last_ended_frame_); |
- waiting_on_compositing_end_ = false; |
- if (draw_on_compositing_end_) { |
- draw_on_compositing_end_ = false; |
- |
- // Call ScheduleDraw() instead of Draw() in order to allow other |
- // CompositorObservers to be notified before starting another |
- // draw cycle. |
- ScheduleDraw(); |
- } |
- FOR_EACH_OBSERVER( |
- CompositorObserver, observer_list_, OnCompositingEnded(this)); |
-} |
- |
} // namespace ui |