Index: cc/trees/single_thread_proxy.cc |
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc |
index ce67d341b5b3e169f27d911eb629ca69af0b18ce..2fcd0426e3e6404d100b72d1fbf3bc9f25beeba5 100644 |
--- a/cc/trees/single_thread_proxy.cc |
+++ b/cc/trees/single_thread_proxy.cc |
@@ -25,23 +25,21 @@ namespace cc { |
scoped_ptr<Proxy> SingleThreadProxy::Create( |
LayerTreeHost* layer_tree_host, |
LayerTreeHostSingleThreadClient* client, |
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ TaskRunnerProvider* task_runner_provider, |
scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
- return make_scoped_ptr(new SingleThreadProxy( |
- layer_tree_host, |
- client, |
- main_task_runner, |
- external_begin_frame_source.Pass())); |
+ return make_scoped_ptr( |
+ new SingleThreadProxy(layer_tree_host, client, task_runner_provider, |
+ external_begin_frame_source.Pass())); |
} |
SingleThreadProxy::SingleThreadProxy( |
LayerTreeHost* layer_tree_host, |
LayerTreeHostSingleThreadClient* client, |
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ TaskRunnerProvider* task_runner_provider, |
scoped_ptr<BeginFrameSource> external_begin_frame_source) |
- : Proxy(main_task_runner, NULL), |
- layer_tree_host_(layer_tree_host), |
+ : layer_tree_host_(layer_tree_host), |
client_(client), |
+ task_runner_provider_(task_runner_provider), |
external_begin_frame_source_(external_begin_frame_source.Pass()), |
next_frame_is_newly_committed_frame_(false), |
#if DCHECK_IS_ON() |
@@ -55,7 +53,8 @@ SingleThreadProxy::SingleThreadProxy( |
output_surface_creation_requested_(false), |
weak_factory_(this) { |
TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
DCHECK(layer_tree_host); |
if (layer_tree_host->settings().single_thread_proxy_scheduler && |
@@ -71,34 +70,34 @@ SingleThreadProxy::SingleThreadProxy( |
scheduler_on_impl_thread_ = Scheduler::Create( |
this, scheduler_settings, layer_tree_host_->id(), |
- MainThreadTaskRunner(), external_begin_frame_source_.get(), |
- compositor_timing_history.Pass()); |
+ task_runner_provider_->MainThreadTaskRunner(), |
+ external_begin_frame_source_.get(), compositor_timing_history.Pass()); |
} |
} |
void SingleThreadProxy::Start() { |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
} |
SingleThreadProxy::~SingleThreadProxy() { |
TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
// Make sure Stop() got called or never Started. |
DCHECK(!layer_tree_host_impl_); |
} |
void SingleThreadProxy::FinishAllRendering() { |
TRACE_EVENT0("cc", "SingleThreadProxy::FinishAllRendering"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
{ |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->FinishAllRendering(); |
} |
} |
bool SingleThreadProxy::IsStarted() const { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
return layer_tree_host_impl_; |
} |
@@ -110,7 +109,7 @@ bool SingleThreadProxy::CommitToActiveTree() const { |
void SingleThreadProxy::SetVisible(bool visible) { |
TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->SetVisible(visible); |
@@ -121,13 +120,13 @@ void SingleThreadProxy::SetVisible(bool visible) { |
void SingleThreadProxy::SetThrottleFrameProduction(bool throttle) { |
TRACE_EVENT1("cc", "SingleThreadProxy::SetThrottleFrameProduction", |
"throttle", throttle); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetThrottleFrameProduction(throttle); |
} |
void SingleThreadProxy::RequestNewOutputSurface() { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
DCHECK(layer_tree_host_->output_surface_lost()); |
output_surface_creation_callback_.Cancel(); |
if (output_surface_creation_requested_) |
@@ -146,15 +145,15 @@ void SingleThreadProxy::ReleaseOutputSurface() { |
} |
void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
DCHECK(layer_tree_host_->output_surface_lost()); |
DCHECK(output_surface_creation_requested_); |
renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
bool success; |
{ |
- DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
success = layer_tree_host_impl_->InitializeRenderer(output_surface); |
} |
@@ -173,32 +172,32 @@ void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
} |
const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
DCHECK(!layer_tree_host_->output_surface_lost()); |
return renderer_capabilities_for_main_thread_; |
} |
void SingleThreadProxy::SetNeedsAnimate() { |
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
client_->ScheduleAnimation(); |
if (animate_requested_) |
return; |
animate_requested_ = true; |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
} |
void SingleThreadProxy::SetNeedsUpdateLayers() { |
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
SetNeedsCommit(); |
} |
void SingleThreadProxy::DoCommit() { |
TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is |
// fixed. |
@@ -215,14 +214,14 @@ void SingleThreadProxy::DoCommit() { |
tracked_objects::ScopedTracker tracking_profile2( |
FROM_HERE_WITH_EXPLICIT_FUNCTION( |
"461509 SingleThreadProxy::DoCommit2")); |
- DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
// This CapturePostTasks should be destroyed before CommitComplete() is |
// called since that goes out to the embedder, and we want the embedder |
// to receive its callbacks before that. |
commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( |
- blocking_main_thread_task_runner())); |
+ task_runner_provider_->blocking_main_thread_task_runner())); |
layer_tree_host_impl_->BeginCommit(); |
@@ -276,7 +275,7 @@ void SingleThreadProxy::CommitComplete() { |
<< "Activation is expected to have synchronously occurred by now."; |
DCHECK(commit_blocking_task_runner_); |
- DebugScopedSetMainThread main(this); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
commit_blocking_task_runner_.reset(); |
layer_tree_host_->CommitComplete(); |
layer_tree_host_->DidBeginMainFrame(); |
@@ -285,31 +284,31 @@ void SingleThreadProxy::CommitComplete() { |
} |
void SingleThreadProxy::SetNeedsCommit() { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
client_->ScheduleComposite(); |
if (commit_requested_) |
return; |
commit_requested_ = true; |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
} |
void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); |
- DCHECK(Proxy::IsMainThread()); |
- DebugScopedSetImplThread impl(this); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
client_->ScheduleComposite(); |
SetNeedsRedrawRectOnImplThread(damage_rect); |
} |
void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
// Activation always forced in commit, so nothing to do. |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
} |
void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
// Deferring commits only makes sense if there's a scheduler. |
if (!scheduler_on_impl_thread_) |
return; |
@@ -326,12 +325,12 @@ void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
} |
bool SingleThreadProxy::CommitRequested() const { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
return commit_requested_; |
} |
bool SingleThreadProxy::BeginMainFrameRequested() const { |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
// If there is no scheduler, then there can be no pending begin frame, |
// as all frames are all manually initiated by the embedder of cc. |
if (!scheduler_on_impl_thread_) |
@@ -341,13 +340,13 @@ bool SingleThreadProxy::BeginMainFrameRequested() const { |
void SingleThreadProxy::Stop() { |
TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
{ |
- DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
BlockingTaskRunner::CapturePostTasks blocked( |
- blocking_main_thread_task_runner()); |
+ task_runner_provider_->blocking_main_thread_task_runner()); |
scheduler_on_impl_thread_ = nullptr; |
layer_tree_host_impl_ = nullptr; |
} |
@@ -362,21 +361,21 @@ void SingleThreadProxy::OnResourcelessSoftareDrawStateChanged( |
void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
TRACE_EVENT1( |
"cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
- DCHECK(Proxy::IsImplThread()); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->SetCanDraw(can_draw); |
} |
void SingleThreadProxy::NotifyReadyToActivate() { |
TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->NotifyReadyToActivate(); |
} |
void SingleThreadProxy::NotifyReadyToDraw() { |
TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->NotifyReadyToDraw(); |
} |
@@ -423,8 +422,8 @@ void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
scoped_ptr<AnimationEventsVector> events) { |
TRACE_EVENT0( |
"cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
- DCHECK(Proxy::IsImplThread()); |
- DebugScopedSetMainThread main(this); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
layer_tree_host_->SetAnimationEvents(events.Pass()); |
} |
@@ -438,13 +437,13 @@ void SingleThreadProxy::DidActivateSyncTree() { |
} |
void SingleThreadProxy::WillPrepareTiles() { |
- DCHECK(Proxy::IsImplThread()); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->WillPrepareTiles(); |
} |
void SingleThreadProxy::DidPrepareTiles() { |
- DCHECK(Proxy::IsImplThread()); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
if (scheduler_on_impl_thread_) |
scheduler_on_impl_thread_->DidPrepareTiles(); |
} |
@@ -454,7 +453,7 @@ void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
} |
void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
- DCHECK(IsImplThread()); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
renderer_capabilities_for_main_thread_ = |
layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); |
} |
@@ -462,7 +461,7 @@ void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
{ |
- DebugScopedSetMainThread main(this); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
// This must happen before we notify the scheduler as it may try to recreate |
// the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
layer_tree_host_->DidLoseOutputSurface(); |
@@ -516,7 +515,7 @@ void SingleThreadProxy::PostFrameTimingEventsOnImplThread( |
void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
- DCHECK(Proxy::IsMainThread()); |
+ DCHECK(task_runner_provider_->IsMainThread()); |
#if DCHECK_IS_ON() |
DCHECK(!inside_impl_frame_); |
#endif |
@@ -536,7 +535,7 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
// Start the impl frame. |
{ |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
WillBeginImplFrame(begin_frame_args); |
} |
@@ -554,7 +553,7 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
// Finish the impl frame. |
{ |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->ActivateSyncTree(); |
DCHECK( |
!layer_tree_host_impl_->active_tree()->needs_update_draw_properties()); |
@@ -581,7 +580,7 @@ bool SingleThreadProxy::SupportsImplScrolling() const { |
} |
bool SingleThreadProxy::ShouldComposite() const { |
- DCHECK(Proxy::IsImplThread()); |
+ DCHECK(task_runner_provider_->IsImplThread()); |
return layer_tree_host_impl_->visible() && |
layer_tree_host_impl_->CanDraw(); |
} |
@@ -592,7 +591,7 @@ void SingleThreadProxy::ScheduleRequestNewOutputSurface() { |
output_surface_creation_callback_.Reset( |
base::Bind(&SingleThreadProxy::RequestNewOutputSurface, |
weak_factory_.GetWeakPtr())); |
- MainThreadTaskRunner()->PostTask( |
+ task_runner_provider_->MainThreadTaskRunner()->PostTask( |
FROM_HERE, output_surface_creation_callback_.callback()); |
} |
} |
@@ -604,7 +603,7 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
DrawResult draw_result; |
bool draw_frame; |
{ |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
base::AutoReset<bool> mark_inside(&inside_draw_, true); |
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
@@ -659,7 +658,7 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
} |
if (draw_frame) { |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
// This CapturePostTasks should be destroyed before |
// DidCommitAndDrawFrame() is called since that goes out to the |
@@ -669,10 +668,10 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
// the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
// there as the main thread is not blocked, so any posted tasks inside |
// the swap buffers will execute first. |
- DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
+ DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
BlockingTaskRunner::CapturePostTasks blocked( |
- blocking_main_thread_task_runner()); |
+ task_runner_provider_->blocking_main_thread_task_runner()); |
// TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
// is fixed. |
tracked_objects::ScopedTracker tracking_profile8( |
@@ -692,7 +691,7 @@ DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
void SingleThreadProxy::DidCommitAndDrawFrame() { |
if (next_frame_is_newly_committed_frame_) { |
- DebugScopedSetMainThread main(this); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
next_frame_is_newly_committed_frame_ = false; |
layer_tree_host_->DidCommitAndDrawFrame(); |
} |
@@ -742,7 +741,7 @@ void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |
const BeginFrameArgs& begin_frame_args = |
layer_tree_host_impl_->CurrentBeginFrameArgs(); |
- MainThreadTaskRunner()->PostTask( |
+ task_runner_provider_->MainThreadTaskRunner()->PostTask( |
FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, |
weak_factory_.GetWeakPtr(), begin_frame_args)); |
} |
@@ -813,7 +812,7 @@ void SingleThreadProxy::DoBeginMainFrame( |
void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( |
CommitEarlyOutReason reason) { |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
DCHECK(scheduler_on_impl_thread_->CommitPending()); |
DCHECK(!layer_tree_host_impl_->pending_tree()); |
@@ -822,7 +821,7 @@ void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( |
} |
DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
LayerTreeHostImpl::FrameData frame; |
return DoComposite(&frame); |
} |
@@ -833,29 +832,29 @@ DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { |
} |
void SingleThreadProxy::ScheduledActionCommit() { |
- DebugScopedSetMainThread main(this); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
DoCommit(); |
} |
void SingleThreadProxy::ScheduledActionAnimate() { |
TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->Animate(); |
} |
void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->ActivateSyncTree(); |
} |
void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
- DebugScopedSetMainThread main(this); |
+ DebugScopedSetMainThread main(task_runner_provider_); |
DCHECK(scheduler_on_impl_thread_); |
// If possible, create the output surface in a post task. Synchronously |
// creating the output surface makes tests more awkward since this differs |
// from the ThreadProxy behavior. However, sometimes there is no |
// task runner. |
- if (Proxy::MainThreadTaskRunner()) { |
+ if (task_runner_provider_->MainThreadTaskRunner()) { |
ScheduleRequestNewOutputSurface(); |
} else { |
RequestNewOutputSurface(); |
@@ -864,7 +863,7 @@ void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
void SingleThreadProxy::ScheduledActionPrepareTiles() { |
TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); |
- DebugScopedSetImplThread impl(this); |
+ DebugScopedSetImplThread impl(task_runner_provider_); |
layer_tree_host_impl_->PrepareTiles(); |
} |