Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 63 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 63 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 64 : Proxy(main_task_runner, impl_task_runner), | 64 : Proxy(main_task_runner, impl_task_runner), |
| 65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), |
| 66 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | 66 main_thread_or_blocked_vars_unsafe_(layer_tree_host), |
| 67 compositor_thread_vars_unsafe_( | 67 compositor_thread_vars_unsafe_( |
| 68 this, | 68 this, |
| 69 layer_tree_host->id(), | 69 layer_tree_host->id(), |
| 70 layer_tree_host->rendering_stats_instrumentation(), | 70 layer_tree_host->rendering_stats_instrumentation(), |
| 71 external_begin_frame_source.Pass()) { | 71 external_begin_frame_source.Pass()), |
| 72 blocked_main_commit_state_vars_unsafe_(nullptr) { | |
| 72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 73 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 73 DCHECK(IsMainThread()); | 74 DCHECK(IsMainThread()); |
| 74 DCHECK(this->layer_tree_host()); | 75 DCHECK(this->layer_tree_host()); |
| 75 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once | 76 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once |
| 76 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to | 77 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to |
| 77 // ProxyMain#SetChannel. | 78 // ProxyMain#SetChannel. |
| 78 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); | 79 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); |
| 79 } | 80 } |
| 80 | 81 |
| 81 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 82 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
| 82 int layer_tree_host_id) | 83 int layer_tree_host_id) |
| 83 : layer_tree_host_id(layer_tree_host_id), | 84 : layer_tree_host_id(layer_tree_host_id), |
| 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), | 85 max_requested_pipeline_stage(NO_PIPELINE_STAGE), |
| 85 current_pipeline_stage(NO_PIPELINE_STAGE), | 86 current_pipeline_stage(NO_PIPELINE_STAGE), |
| 86 final_pipeline_stage(NO_PIPELINE_STAGE), | 87 final_pipeline_stage(NO_PIPELINE_STAGE), |
| 87 started(false), | 88 started(false), |
| 88 prepare_tiles_pending(false), | 89 prepare_tiles_pending(false), |
| 89 defer_commits(false), | 90 defer_commits(false), |
| 91 commit_waits_for_activation(false), | |
| 90 weak_factory(proxy) {} | 92 weak_factory(proxy) {} |
| 91 | 93 |
| 92 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} | 94 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} |
| 93 | 95 |
| 94 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread( | 96 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread( |
| 95 LayerTreeHost* host) | 97 LayerTreeHost* host) |
| 96 : layer_tree_host(host), | 98 : layer_tree_host(host) {} |
| 97 commit_waits_for_activation(false), | |
| 98 main_thread_inside_commit(false) {} | |
| 99 | 99 |
| 100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} | 100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} |
| 101 | 101 |
| 102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( | 102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( |
| 103 ThreadProxy* proxy, | 103 ThreadProxy* proxy, |
| 104 int layer_tree_host_id, | 104 int layer_tree_host_id, |
| 105 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 105 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 106 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 106 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 107 : layer_tree_host_id(layer_tree_host_id), | 107 : layer_tree_host_id(layer_tree_host_id), |
| 108 commit_completion_event(NULL), | 108 commit_completion_event(nullptr), |
| 109 completion_event_for_commit_held_on_tree_activation(NULL), | 109 completion_event_for_commit_held_on_tree_activation(nullptr), |
| 110 next_frame_is_newly_committed_frame(false), | 110 next_frame_is_newly_committed_frame(false), |
| 111 inside_draw(false), | 111 inside_draw(false), |
| 112 input_throttled_until_commit(false), | 112 input_throttled_until_commit(false), |
| 113 smoothness_priority_expiration_notifier( | 113 smoothness_priority_expiration_notifier( |
| 114 proxy->ImplThreadTaskRunner(), | 114 proxy->ImplThreadTaskRunner(), |
| 115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 116 base::TimeDelta::FromMilliseconds( | 116 base::TimeDelta::FromMilliseconds( |
| 117 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 117 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 118 external_begin_frame_source(external_begin_frame_source.Pass()), | 118 external_begin_frame_source(external_begin_frame_source.Pass()), |
| 119 rendering_stats_instrumentation(rendering_stats_instrumentation), | 119 rendering_stats_instrumentation(rendering_stats_instrumentation), |
| 120 weak_factory(proxy) { | 120 weak_factory(proxy) {} |
| 121 } | |
| 122 | 121 |
| 123 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 122 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 124 | 123 |
| 125 ThreadProxy::~ThreadProxy() { | 124 ThreadProxy::~ThreadProxy() { |
| 126 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 125 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
| 127 DCHECK(IsMainThread()); | 126 DCHECK(IsMainThread()); |
| 128 DCHECK(!main().started); | 127 DCHECK(!main().started); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { | 130 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { |
| 132 threaded_channel_ = threaded_channel.Pass(); | 131 threaded_channel_ = threaded_channel.Pass(); |
| 133 main().channel_main = threaded_channel_.get(); | 132 main().channel_main = threaded_channel_.get(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 void ThreadProxy::FinishAllRendering() { | 135 void ThreadProxy::FinishAllRendering() { |
| 137 DCHECK(Proxy::IsMainThread()); | 136 DCHECK(Proxy::IsMainThread()); |
| 138 DCHECK(!main().defer_commits); | 137 DCHECK(!main().defer_commits); |
| 139 | 138 |
| 140 // Make sure all GL drawing is finished on the impl thread. | 139 // Make sure all GL drawing is finished on the impl thread. |
| 141 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 140 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 142 CompletionEvent completion; | 141 CompletionEvent completion; |
| 143 Proxy::ImplThreadTaskRunner()->PostTask( | 142 main().channel_main->FinishAllRenderingOnImpl(&completion); |
| 144 FROM_HERE, | |
| 145 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread, | |
| 146 impl_thread_weak_ptr_, | |
| 147 &completion)); | |
| 148 completion.Wait(); | 143 completion.Wait(); |
| 149 } | 144 } |
| 150 | 145 |
| 151 bool ThreadProxy::IsStarted() const { | 146 bool ThreadProxy::IsStarted() const { |
| 152 DCHECK(Proxy::IsMainThread()); | 147 DCHECK(Proxy::IsMainThread()); |
| 153 return main().started; | 148 return main().started; |
| 154 } | 149 } |
| 155 | 150 |
| 156 bool ThreadProxy::CommitToActiveTree() const { | 151 bool ThreadProxy::CommitToActiveTree() const { |
| 157 // With ThreadProxy, we use a pending tree and activate it once it's ready to | 152 // With ThreadProxy, we use a pending tree and activate it once it's ready to |
| 158 // draw to allow input to modify the active tree and draw during raster. | 153 // draw to allow input to modify the active tree and draw during raster. |
| 159 return false; | 154 return false; |
| 160 } | 155 } |
| 161 | 156 |
| 162 void ThreadProxy::SetVisible(bool visible) { | 157 void ThreadProxy::SetVisible(bool visible) { |
| 163 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); | 158 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); |
| 164 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 159 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 165 | 160 |
| 166 CompletionEvent completion; | 161 CompletionEvent completion; |
| 167 Proxy::ImplThreadTaskRunner()->PostTask( | 162 main().channel_main->SetVisibleOnImpl(&completion, visible); |
| 168 FROM_HERE, | |
| 169 base::Bind(&ThreadProxy::SetVisibleOnImplThread, | |
| 170 impl_thread_weak_ptr_, | |
| 171 &completion, | |
| 172 visible)); | |
| 173 completion.Wait(); | 163 completion.Wait(); |
| 174 } | 164 } |
| 175 | 165 |
| 176 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 166 void ThreadProxy::SetVisibleOnImpl(CompletionEvent* completion, bool visible) { |
| 177 bool visible) { | |
| 178 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); | 167 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); |
| 179 impl().layer_tree_host_impl->SetVisible(visible); | 168 impl().layer_tree_host_impl->SetVisible(visible); |
| 180 impl().scheduler->SetVisible(visible); | 169 impl().scheduler->SetVisible(visible); |
| 181 completion->Signal(); | 170 completion->Signal(); |
| 182 } | 171 } |
| 183 | 172 |
| 184 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { | 173 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { |
| 185 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", | 174 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", |
| 186 throttle); | 175 throttle); |
| 187 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); | 176 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 198 DCHECK(IsMainThread()); | 187 DCHECK(IsMainThread()); |
| 199 layer_tree_host()->DidLoseOutputSurface(); | 188 layer_tree_host()->DidLoseOutputSurface(); |
| 200 } | 189 } |
| 201 | 190 |
| 202 void ThreadProxy::RequestNewOutputSurface() { | 191 void ThreadProxy::RequestNewOutputSurface() { |
| 203 DCHECK(IsMainThread()); | 192 DCHECK(IsMainThread()); |
| 204 layer_tree_host()->RequestNewOutputSurface(); | 193 layer_tree_host()->RequestNewOutputSurface(); |
| 205 } | 194 } |
| 206 | 195 |
| 207 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 196 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| 208 Proxy::ImplThreadTaskRunner()->PostTask( | 197 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); |
| 209 FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, | |
| 210 impl_thread_weak_ptr_, output_surface)); | |
| 211 } | 198 } |
| 212 | 199 |
| 213 void ThreadProxy::ReleaseOutputSurface() { | 200 void ThreadProxy::ReleaseOutputSurface() { |
| 214 DCHECK(IsMainThread()); | 201 DCHECK(IsMainThread()); |
| 215 DCHECK(layer_tree_host()->output_surface_lost()); | 202 DCHECK(layer_tree_host()->output_surface_lost()); |
| 216 | 203 |
| 217 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 204 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 218 CompletionEvent completion; | 205 CompletionEvent completion; |
| 219 Proxy::ImplThreadTaskRunner()->PostTask( | 206 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); |
| 220 FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread, | |
| 221 impl_thread_weak_ptr_, &completion)); | |
| 222 completion.Wait(); | 207 completion.Wait(); |
| 223 } | 208 } |
| 224 | 209 |
| 225 void ThreadProxy::DidInitializeOutputSurface( | 210 void ThreadProxy::DidInitializeOutputSurface( |
| 226 bool success, | 211 bool success, |
| 227 const RendererCapabilities& capabilities) { | 212 const RendererCapabilities& capabilities) { |
| 228 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); | 213 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); |
| 229 DCHECK(IsMainThread()); | 214 DCHECK(IsMainThread()); |
| 230 | 215 |
| 231 if (!success) { | 216 if (!success) { |
| 232 layer_tree_host()->DidFailToInitializeOutputSurface(); | 217 layer_tree_host()->DidFailToInitializeOutputSurface(); |
| 233 return; | 218 return; |
| 234 } | 219 } |
| 235 main().renderer_capabilities_main_thread_copy = capabilities; | 220 main().renderer_capabilities_main_thread_copy = capabilities; |
| 236 layer_tree_host()->DidInitializeOutputSurface(); | 221 layer_tree_host()->DidInitializeOutputSurface(); |
| 237 } | 222 } |
| 238 | 223 |
| 239 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( | 224 void ThreadProxy::SetRendererCapabilitiesMainCopy( |
| 240 const RendererCapabilities& capabilities) { | 225 const RendererCapabilities& capabilities) { |
| 241 main().renderer_capabilities_main_thread_copy = capabilities; | 226 main().renderer_capabilities_main_thread_copy = capabilities; |
| 242 } | 227 } |
| 243 | 228 |
| 244 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( | 229 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( |
| 245 CommitPipelineStage required_stage) { | 230 CommitPipelineStage required_stage) { |
| 246 DCHECK(IsMainThread()); | 231 DCHECK(IsMainThread()); |
| 247 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); | 232 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); |
| 248 bool already_posted = | 233 bool already_posted = |
| 249 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; | 234 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; |
| 250 main().max_requested_pipeline_stage = | 235 main().max_requested_pipeline_stage = |
| 251 std::max(main().max_requested_pipeline_stage, required_stage); | 236 std::max(main().max_requested_pipeline_stage, required_stage); |
| 252 if (already_posted) | 237 if (already_posted) |
| 253 return false; | 238 return false; |
| 254 Proxy::ImplThreadTaskRunner()->PostTask( | 239 main().channel_main->SetNeedsCommitOnImpl(); |
| 255 FROM_HERE, | |
| 256 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, | |
| 257 impl_thread_weak_ptr_)); | |
| 258 return true; | 240 return true; |
| 259 } | 241 } |
| 260 | 242 |
| 243 void ThreadProxy::SetNeedsCommitOnImpl() { | |
| 244 SetNeedsCommitOnImplThread(); | |
| 245 } | |
| 246 | |
| 261 void ThreadProxy::DidCompletePageScaleAnimation() { | 247 void ThreadProxy::DidCompletePageScaleAnimation() { |
| 262 DCHECK(IsMainThread()); | 248 DCHECK(IsMainThread()); |
| 263 layer_tree_host()->DidCompletePageScaleAnimation(); | 249 layer_tree_host()->DidCompletePageScaleAnimation(); |
| 264 } | 250 } |
| 265 | 251 |
| 266 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { | 252 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { |
| 267 DCHECK(IsMainThread()); | 253 DCHECK(IsMainThread()); |
| 268 DCHECK(!layer_tree_host()->output_surface_lost()); | 254 DCHECK(!layer_tree_host()->output_surface_lost()); |
| 269 return main().renderer_capabilities_main_thread_copy; | 255 return main().renderer_capabilities_main_thread_copy; |
| 270 } | 256 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 return; | 288 return; |
| 303 } | 289 } |
| 304 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { | 290 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { |
| 305 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", | 291 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", |
| 306 TRACE_EVENT_SCOPE_THREAD); | 292 TRACE_EVENT_SCOPE_THREAD); |
| 307 } | 293 } |
| 308 } | 294 } |
| 309 | 295 |
| 310 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 296 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
| 311 DCHECK(IsImplThread()); | 297 DCHECK(IsImplThread()); |
| 312 Proxy::MainThreadTaskRunner()->PostTask( | 298 impl().channel_impl->SetRendererCapabilitiesMainCopy( |
| 313 FROM_HERE, | 299 impl() |
| 314 base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, | 300 .layer_tree_host_impl->GetRendererCapabilities() |
| 315 main_thread_weak_ptr_, | 301 .MainThreadCapabilities()); |
| 316 impl() | |
| 317 .layer_tree_host_impl->GetRendererCapabilities() | |
| 318 .MainThreadCapabilities())); | |
| 319 } | 302 } |
| 320 | 303 |
| 321 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 304 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 322 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 305 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 323 DCHECK(IsImplThread()); | 306 DCHECK(IsImplThread()); |
| 324 Proxy::MainThreadTaskRunner()->PostTask( | 307 impl().channel_impl->DidLoseOutputSurface(); |
| 325 FROM_HERE, | |
| 326 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); | |
| 327 impl().scheduler->DidLoseOutputSurface(); | 308 impl().scheduler->DidLoseOutputSurface(); |
| 328 } | 309 } |
| 329 | 310 |
| 330 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 311 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 331 base::TimeDelta interval) { | 312 base::TimeDelta interval) { |
| 332 impl().scheduler->CommitVSyncParameters(timebase, interval); | 313 impl().scheduler->CommitVSyncParameters(timebase, interval); |
| 333 } | 314 } |
| 334 | 315 |
| 335 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 316 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 336 impl().scheduler->SetEstimatedParentDrawTime(draw_time); | 317 impl().scheduler->SetEstimatedParentDrawTime(draw_time); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 // In tests the layer tree is destroyed after the scheduler is. | 377 // In tests the layer tree is destroyed after the scheduler is. |
| 397 if (impl().scheduler) | 378 if (impl().scheduler) |
| 398 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); | 379 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); |
| 399 } | 380 } |
| 400 | 381 |
| 401 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 382 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 402 scoped_ptr<AnimationEventsVector> events) { | 383 scoped_ptr<AnimationEventsVector> events) { |
| 403 TRACE_EVENT0("cc", | 384 TRACE_EVENT0("cc", |
| 404 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 385 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| 405 DCHECK(IsImplThread()); | 386 DCHECK(IsImplThread()); |
| 406 Proxy::MainThreadTaskRunner()->PostTask( | 387 impl().channel_impl->SetAnimationEvents(events.Pass()); |
| 407 FROM_HERE, | |
| 408 base::Bind(&ThreadProxy::SetAnimationEvents, | |
| 409 main_thread_weak_ptr_, | |
| 410 base::Passed(&events))); | |
| 411 } | 388 } |
| 412 | 389 |
| 413 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } | 390 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } |
| 414 | 391 |
| 415 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 392 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
| 416 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); | 393 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); |
| 417 DCHECK(IsMainThread()); | 394 DCHECK(IsMainThread()); |
| 418 Proxy::ImplThreadTaskRunner()->PostTask( | 395 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); |
| 419 FROM_HERE, | 396 } |
| 420 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, | 397 |
| 421 impl_thread_weak_ptr_, | 398 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { |
| 422 damage_rect)); | 399 DCHECK(IsImplThread()); |
| 400 SetNeedsRedrawRectOnImplThread(damage_rect); | |
| 423 } | 401 } |
| 424 | 402 |
| 425 void ThreadProxy::SetNextCommitWaitsForActivation() { | 403 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 426 DCHECK(IsMainThread()); | 404 DCHECK(IsMainThread()); |
| 427 DCHECK(!blocked_main().main_thread_inside_commit); | 405 main().commit_waits_for_activation = true; |
| 428 blocked_main().commit_waits_for_activation = true; | |
| 429 } | 406 } |
| 430 | 407 |
| 431 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 408 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 432 DCHECK(IsMainThread()); | 409 DCHECK(IsMainThread()); |
| 433 if (main().defer_commits == defer_commits) | 410 if (main().defer_commits == defer_commits) |
| 434 return; | 411 return; |
| 435 | 412 |
| 436 main().defer_commits = defer_commits; | 413 main().defer_commits = defer_commits; |
| 437 if (main().defer_commits) | 414 if (main().defer_commits) |
| 438 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 415 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| 439 else | 416 else |
| 440 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 417 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| 441 | 418 |
| 442 Proxy::ImplThreadTaskRunner()->PostTask( | 419 main().channel_main->SetDeferCommitsOnImpl(defer_commits); |
| 443 FROM_HERE, | |
| 444 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread, | |
| 445 impl_thread_weak_ptr_, | |
| 446 defer_commits)); | |
| 447 } | 420 } |
| 448 | 421 |
| 449 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { | 422 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) { |
| 450 DCHECK(IsImplThread()); | 423 DCHECK(IsImplThread()); |
| 451 impl().scheduler->SetDeferCommits(defer_commits); | 424 impl().scheduler->SetDeferCommits(defer_commits); |
| 452 } | 425 } |
| 453 | 426 |
| 454 bool ThreadProxy::CommitRequested() const { | 427 bool ThreadProxy::CommitRequested() const { |
| 455 DCHECK(IsMainThread()); | 428 DCHECK(IsMainThread()); |
| 456 // TODO(skyostil): Split this into something like CommitRequested() and | 429 // TODO(skyostil): Split this into something like CommitRequested() and |
| 457 // CommitInProgress(). | 430 // CommitInProgress(). |
| 458 return main().current_pipeline_stage != NO_PIPELINE_STAGE || | 431 return main().current_pipeline_stage != NO_PIPELINE_STAGE || |
| 459 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; | 432 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 482 } | 455 } |
| 483 | 456 |
| 484 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { | 457 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
| 485 DCHECK(IsImplThread()); | 458 DCHECK(IsImplThread()); |
| 486 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); | 459 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); |
| 487 SetNeedsRedrawOnImplThread(); | 460 SetNeedsRedrawOnImplThread(); |
| 488 } | 461 } |
| 489 | 462 |
| 490 void ThreadProxy::MainThreadHasStoppedFlinging() { | 463 void ThreadProxy::MainThreadHasStoppedFlinging() { |
| 491 DCHECK(IsMainThread()); | 464 DCHECK(IsMainThread()); |
| 492 Proxy::ImplThreadTaskRunner()->PostTask( | 465 main().channel_main->MainThreadHasStoppedFlingingOnImpl(); |
| 493 FROM_HERE, | |
| 494 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, | |
| 495 impl_thread_weak_ptr_)); | |
| 496 } | 466 } |
| 497 | 467 |
| 498 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { | 468 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { |
| 499 DCHECK(IsImplThread()); | 469 DCHECK(IsImplThread()); |
| 500 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); | 470 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); |
| 501 } | 471 } |
| 502 | 472 |
| 503 void ThreadProxy::NotifyInputThrottledUntilCommit() { | 473 void ThreadProxy::NotifyInputThrottledUntilCommit() { |
| 504 DCHECK(IsMainThread()); | 474 DCHECK(IsMainThread()); |
| 505 Proxy::ImplThreadTaskRunner()->PostTask( | 475 main().channel_main->SetInputThrottledUntilCommitOnImpl(true); |
| 506 FROM_HERE, | |
| 507 base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread, | |
| 508 impl_thread_weak_ptr_, | |
| 509 true)); | |
| 510 } | 476 } |
| 511 | 477 |
| 512 void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { | 478 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| 513 DCHECK(IsImplThread()); | 479 DCHECK(IsImplThread()); |
| 514 if (is_throttled == impl().input_throttled_until_commit) | 480 if (is_throttled == impl().input_throttled_until_commit) |
| 515 return; | 481 return; |
| 516 impl().input_throttled_until_commit = is_throttled; | 482 impl().input_throttled_until_commit = is_throttled; |
| 517 RenewTreePriority(); | 483 RenewTreePriority(); |
| 518 } | 484 } |
| 519 | 485 |
| 520 LayerTreeHost* ThreadProxy::layer_tree_host() { | 486 LayerTreeHost* ThreadProxy::layer_tree_host() { |
| 521 return blocked_main().layer_tree_host; | 487 return blocked_main().layer_tree_host; |
| 522 } | 488 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 538 DCHECK(IsMainThread() || IsMainThreadBlocked()); | 504 DCHECK(IsMainThread() || IsMainThreadBlocked()); |
| 539 return main_thread_or_blocked_vars_unsafe_; | 505 return main_thread_or_blocked_vars_unsafe_; |
| 540 } | 506 } |
| 541 | 507 |
| 542 const ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main() | 508 const ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main() |
| 543 const { | 509 const { |
| 544 DCHECK(IsMainThread() || IsMainThreadBlocked()); | 510 DCHECK(IsMainThread() || IsMainThreadBlocked()); |
| 545 return main_thread_or_blocked_vars_unsafe_; | 511 return main_thread_or_blocked_vars_unsafe_; |
| 546 } | 512 } |
| 547 | 513 |
| 514 const BlockedMainCommitState* ThreadProxy::blocked_commit_state() const { | |
|
vmpstr
2015/10/19 18:08:07
Can this be moved into a separate patch? Let's jus
Khushal
2015/10/20 11:58:26
Sounds good, will handle this in the next patch.
| |
| 515 DCHECK(IsImplThread() && IsMainThreadBlocked() && | |
| 516 impl().commit_completion_event); | |
| 517 return blocked_main_commit_state_vars_unsafe_; | |
| 518 } | |
| 519 | |
| 520 void ThreadProxy::set_blocked_commit_state( | |
| 521 BlockedMainCommitState* blocked_main_commit_state) { | |
| 522 DCHECK(IsImplThread() && IsMainThreadBlocked() && | |
| 523 impl().commit_completion_event); | |
| 524 blocked_main_commit_state_vars_unsafe_ = blocked_main_commit_state; | |
| 525 } | |
| 526 | |
| 548 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { | 527 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { |
| 549 DCHECK(IsImplThread()); | 528 DCHECK(IsImplThread()); |
| 550 return compositor_thread_vars_unsafe_; | 529 return compositor_thread_vars_unsafe_; |
| 551 } | 530 } |
| 552 | 531 |
| 553 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { | 532 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { |
| 554 DCHECK(IsImplThread()); | 533 DCHECK(IsImplThread()); |
| 555 return compositor_thread_vars_unsafe_; | 534 return compositor_thread_vars_unsafe_; |
| 556 } | 535 } |
| 557 | 536 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 578 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 557 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
| 579 DCHECK(IsMainThread()); | 558 DCHECK(IsMainThread()); |
| 580 DCHECK(main().started); | 559 DCHECK(main().started); |
| 581 | 560 |
| 582 // Synchronously finishes pending GL operations and deletes the impl. | 561 // Synchronously finishes pending GL operations and deletes the impl. |
| 583 // The two steps are done as separate post tasks, so that tasks posted | 562 // The two steps are done as separate post tasks, so that tasks posted |
| 584 // by the GL implementation due to the Finish can be executed by the | 563 // by the GL implementation due to the Finish can be executed by the |
| 585 // renderer before shutting it down. | 564 // renderer before shutting it down. |
| 586 { | 565 { |
| 587 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 566 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 588 | |
| 589 CompletionEvent completion; | 567 CompletionEvent completion; |
| 590 Proxy::ImplThreadTaskRunner()->PostTask( | 568 main().channel_main->FinishGLOnImpl(&completion); |
| 591 FROM_HERE, | |
| 592 base::Bind(&ThreadProxy::FinishGLOnImplThread, | |
| 593 impl_thread_weak_ptr_, | |
| 594 &completion)); | |
| 595 completion.Wait(); | 569 completion.Wait(); |
| 596 } | 570 } |
| 597 { | 571 { |
| 598 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 572 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 599 | 573 |
| 600 CompletionEvent completion; | 574 CompletionEvent completion; |
| 601 Proxy::ImplThreadTaskRunner()->PostTask( | 575 Proxy::ImplThreadTaskRunner()->PostTask( |
| 602 FROM_HERE, | 576 FROM_HERE, |
| 603 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | 577 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, |
| 604 impl_thread_weak_ptr_, | 578 impl_thread_weak_ptr_, |
| 605 &completion)); | 579 &completion)); |
| 606 completion.Wait(); | 580 completion.Wait(); |
| 607 } | 581 } |
| 608 | 582 |
| 609 main().weak_factory.InvalidateWeakPtrs(); | 583 main().weak_factory.InvalidateWeakPtrs(); |
| 610 blocked_main().layer_tree_host = NULL; | 584 blocked_main().layer_tree_host = NULL; |
| 611 main().started = false; | 585 main().started = false; |
| 612 } | 586 } |
| 613 | 587 |
| 614 bool ThreadProxy::SupportsImplScrolling() const { | 588 bool ThreadProxy::SupportsImplScrolling() const { |
| 615 return true; | 589 return true; |
| 616 } | 590 } |
| 617 | 591 |
| 618 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { | 592 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
| 619 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 593 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 620 DCHECK(IsImplThread()); | 594 DCHECK(IsImplThread()); |
| 621 impl().layer_tree_host_impl->FinishAllRendering(); | 595 impl().layer_tree_host_impl->FinishAllRendering(); |
| 622 completion->Signal(); | 596 completion->Signal(); |
| 623 } | 597 } |
| 624 | 598 |
| 625 void ThreadProxy::ScheduledActionSendBeginMainFrame() { | 599 void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 626 unsigned int begin_frame_id = nextBeginFrameId++; | 600 unsigned int begin_frame_id = nextBeginFrameId++; |
| 627 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 601 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 628 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 602 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
| 629 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 603 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 630 new BeginMainFrameAndCommitState); | 604 new BeginMainFrameAndCommitState); |
| 631 begin_main_frame_state->begin_frame_id = begin_frame_id; | 605 begin_main_frame_state->begin_frame_id = begin_frame_id; |
| 632 begin_main_frame_state->begin_frame_args = | 606 begin_main_frame_state->begin_frame_args = |
| 633 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); | 607 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); |
| 634 begin_main_frame_state->scroll_info = | 608 begin_main_frame_state->scroll_info = |
| 635 impl().layer_tree_host_impl->ProcessScrollDeltas(); | 609 impl().layer_tree_host_impl->ProcessScrollDeltas(); |
| 636 begin_main_frame_state->memory_allocation_limit_bytes = | 610 begin_main_frame_state->memory_allocation_limit_bytes = |
| 637 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); | 611 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); |
| 638 begin_main_frame_state->evicted_ui_resources = | 612 begin_main_frame_state->evicted_ui_resources = |
| 639 impl().layer_tree_host_impl->EvictedUIResourcesExist(); | 613 impl().layer_tree_host_impl->EvictedUIResourcesExist(); |
| 640 // TODO(vmpstr): This needs to be fixed if | 614 // TODO(vmpstr): This needs to be fixed if |
| 641 // main_frame_before_activation_enabled is set, since we might run this code | 615 // main_frame_before_activation_enabled is set, since we might run this code |
| 642 // twice before recording a duration. crbug.com/469824 | 616 // twice before recording a duration. crbug.com/469824 |
| 643 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; | 617 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; |
| 644 Proxy::MainThreadTaskRunner()->PostTask( | 618 impl().channel_impl->BeginMainFrame(begin_main_frame_state.Pass()); |
| 645 FROM_HERE, | |
| 646 base::Bind(&ThreadProxy::BeginMainFrame, | |
| 647 main_thread_weak_ptr_, | |
| 648 base::Passed(&begin_main_frame_state))); | |
| 649 devtools_instrumentation::DidRequestMainThreadFrame( | 619 devtools_instrumentation::DidRequestMainThreadFrame( |
| 650 impl().layer_tree_host_id); | 620 impl().layer_tree_host_id); |
| 651 } | 621 } |
| 652 | 622 |
| 653 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 623 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 654 Proxy::MainThreadTaskRunner()->PostTask( | 624 impl().channel_impl->BeginMainFrameNotExpectedSoon(); |
| 655 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, | |
| 656 main_thread_weak_ptr_)); | |
| 657 } | 625 } |
| 658 | 626 |
| 659 void ThreadProxy::BeginMainFrame( | 627 void ThreadProxy::BeginMainFrame( |
| 660 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 628 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 661 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 629 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 662 benchmark_instrumentation::kDoBeginFrame, | 630 benchmark_instrumentation::kDoBeginFrame, |
| 663 begin_main_frame_state->begin_frame_id); | 631 begin_main_frame_state->begin_frame_id); |
| 664 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 632 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 665 DCHECK(IsMainThread()); | 633 DCHECK(IsMainThread()); |
| 666 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); | 634 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); |
| 667 | 635 |
| 668 if (main().defer_commits) { | 636 if (main().defer_commits) { |
| 669 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 637 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| 670 TRACE_EVENT_SCOPE_THREAD); | 638 TRACE_EVENT_SCOPE_THREAD); |
| 671 Proxy::ImplThreadTaskRunner()->PostTask( | 639 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 672 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 640 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 673 impl_thread_weak_ptr_, | |
| 674 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT)); | |
| 675 return; | 641 return; |
| 676 } | 642 } |
| 677 | 643 |
| 678 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 644 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 679 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the | 645 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
| 680 // remaining swap promises. | 646 // remaining swap promises. |
| 681 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); | 647 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); |
| 682 | 648 |
| 683 main().final_pipeline_stage = main().max_requested_pipeline_stage; | 649 main().final_pipeline_stage = main().max_requested_pipeline_stage; |
| 684 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; | 650 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; |
| 685 | 651 |
| 686 if (!layer_tree_host()->visible()) { | 652 if (!layer_tree_host()->visible()) { |
| 687 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 653 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 688 Proxy::ImplThreadTaskRunner()->PostTask( | 654 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 689 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 655 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 690 impl_thread_weak_ptr_, | |
| 691 CommitEarlyOutReason::ABORTED_NOT_VISIBLE)); | |
| 692 return; | 656 return; |
| 693 } | 657 } |
| 694 | 658 |
| 695 if (layer_tree_host()->output_surface_lost()) { | 659 if (layer_tree_host()->output_surface_lost()) { |
| 696 TRACE_EVENT_INSTANT0( | 660 TRACE_EVENT_INSTANT0( |
| 697 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 661 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 698 Proxy::ImplThreadTaskRunner()->PostTask( | 662 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 699 FROM_HERE, | 663 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); |
| 700 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | |
| 701 impl_thread_weak_ptr_, | |
| 702 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST)); | |
| 703 return; | 664 return; |
| 704 } | 665 } |
| 705 | 666 |
| 706 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; | 667 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; |
| 707 | 668 |
| 708 layer_tree_host()->ApplyScrollAndScale( | 669 layer_tree_host()->ApplyScrollAndScale( |
| 709 begin_main_frame_state->scroll_info.get()); | 670 begin_main_frame_state->scroll_info.get()); |
| 710 | 671 |
| 711 layer_tree_host()->WillBeginMainFrame(); | 672 layer_tree_host()->WillBeginMainFrame(); |
| 712 | 673 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 731 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; | 692 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; |
| 732 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); | 693 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); |
| 733 | 694 |
| 734 layer_tree_host()->WillCommit(); | 695 layer_tree_host()->WillCommit(); |
| 735 devtools_instrumentation::ScopedCommitTrace commit_task( | 696 devtools_instrumentation::ScopedCommitTrace commit_task( |
| 736 layer_tree_host()->id()); | 697 layer_tree_host()->id()); |
| 737 | 698 |
| 738 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; | 699 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; |
| 739 if (!updated && can_cancel_this_commit) { | 700 if (!updated && can_cancel_this_commit) { |
| 740 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 701 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
| 741 Proxy::ImplThreadTaskRunner()->PostTask( | 702 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 742 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 703 CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 743 impl_thread_weak_ptr_, | |
| 744 CommitEarlyOutReason::FINISHED_NO_UPDATES)); | |
| 745 | 704 |
| 746 // Although the commit is internally aborted, this is because it has been | 705 // Although the commit is internally aborted, this is because it has been |
| 747 // detected to be a no-op. From the perspective of an embedder, this commit | 706 // detected to be a no-op. From the perspective of an embedder, this commit |
| 748 // went through, and input should no longer be throttled, etc. | 707 // went through, and input should no longer be throttled, etc. |
| 749 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 708 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 750 layer_tree_host()->CommitComplete(); | 709 layer_tree_host()->CommitComplete(); |
| 751 layer_tree_host()->DidBeginMainFrame(); | 710 layer_tree_host()->DidBeginMainFrame(); |
| 752 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); | 711 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); |
| 753 return; | 712 return; |
| 754 } | 713 } |
| 755 | 714 |
| 756 // Notify the impl thread that the main thread is ready to commit. This will | 715 // Notify the impl thread that the main thread is ready to commit. This will |
| 757 // begin the commit process, which is blocking from the main thread's | 716 // begin the commit process, which is blocking from the main thread's |
| 758 // point of view, but asynchronously performed on the impl thread, | 717 // point of view, but asynchronously performed on the impl thread, |
| 759 // coordinated by the Scheduler. | 718 // coordinated by the Scheduler. |
| 760 { | 719 { |
| 761 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); | 720 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
| 762 | 721 |
| 763 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 722 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 764 | 723 |
| 765 // This CapturePostTasks should be destroyed before CommitComplete() is | 724 // This CapturePostTasks should be destroyed before CommitComplete() is |
| 766 // called since that goes out to the embedder, and we want the embedder | 725 // called since that goes out to the embedder, and we want the embedder |
| 767 // to receive its callbacks before that. | 726 // to receive its callbacks before that. |
| 768 BlockingTaskRunner::CapturePostTasks blocked( | 727 BlockingTaskRunner::CapturePostTasks blocked( |
| 769 blocking_main_thread_task_runner()); | 728 blocking_main_thread_task_runner()); |
| 770 | 729 |
| 771 CompletionEvent completion; | 730 CompletionEvent completion; |
| 772 Proxy::ImplThreadTaskRunner()->PostTask( | 731 BlockedMainCommitState blocked_main_commit_state; |
| 773 FROM_HERE, base::Bind(&ThreadProxy::StartCommitOnImplThread, | 732 blocked_main_commit_state.layer_tree_host = layer_tree_host(); |
| 774 impl_thread_weak_ptr_, &completion)); | 733 blocked_main_commit_state.commit_waits_for_activation = |
| 734 &main().commit_waits_for_activation; | |
| 735 main().channel_main->StartCommitOnImpl(&completion, | |
| 736 &blocked_main_commit_state); | |
| 775 completion.Wait(); | 737 completion.Wait(); |
| 776 } | 738 } |
| 777 | 739 |
| 778 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 740 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 779 layer_tree_host()->CommitComplete(); | 741 layer_tree_host()->CommitComplete(); |
| 780 layer_tree_host()->DidBeginMainFrame(); | 742 layer_tree_host()->DidBeginMainFrame(); |
| 781 } | 743 } |
| 782 | 744 |
| 783 void ThreadProxy::BeginMainFrameNotExpectedSoon() { | 745 void ThreadProxy::BeginMainFrameNotExpectedSoon() { |
| 784 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); | 746 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); |
| 785 DCHECK(IsMainThread()); | 747 DCHECK(IsMainThread()); |
| 786 layer_tree_host()->BeginMainFrameNotExpectedSoon(); | 748 layer_tree_host()->BeginMainFrameNotExpectedSoon(); |
| 787 } | 749 } |
| 788 | 750 |
| 789 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion) { | 751 void ThreadProxy::StartCommitOnImpl( |
| 752 CompletionEvent* completion, | |
| 753 BlockedMainCommitState* blocked_main_commit_state) { | |
| 790 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 754 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
| 791 DCHECK(!impl().commit_completion_event); | 755 DCHECK(!impl().commit_completion_event); |
| 792 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 756 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
| 793 DCHECK(impl().scheduler); | 757 DCHECK(impl().scheduler); |
| 794 DCHECK(impl().scheduler->CommitPending()); | 758 DCHECK(impl().scheduler->CommitPending()); |
| 795 | 759 |
| 796 if (!impl().layer_tree_host_impl) { | 760 if (!impl().layer_tree_host_impl) { |
| 797 TRACE_EVENT_INSTANT0( | 761 TRACE_EVENT_INSTANT0( |
| 798 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); | 762 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); |
| 799 completion->Signal(); | |
|
vmpstr
2015/10/19 18:08:07
We can keep the completion logic as is for now and
Khushal
2015/10/20 11:58:26
Sounds good. I've added the methods we discussed t
| |
| 800 return; | 763 return; |
| 801 } | 764 } |
| 802 | 765 |
| 803 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 766 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
| 804 // But, we can avoid a PostTask in here. | 767 // But, we can avoid a PostTask in here. |
| 805 impl().scheduler->NotifyBeginMainFrameStarted(); | 768 impl().scheduler->NotifyBeginMainFrameStarted(); |
| 806 impl().commit_completion_event = completion; | 769 impl().commit_completion_event = completion; |
| 770 DCHECK(!blocked_commit_state()); | |
| 771 set_blocked_commit_state(blocked_main_commit_state); | |
| 807 impl().scheduler->NotifyReadyToCommit(); | 772 impl().scheduler->NotifyReadyToCommit(); |
| 808 } | 773 } |
| 809 | 774 |
| 810 void ThreadProxy::BeginMainFrameAbortedOnImplThread( | 775 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { |
| 811 CommitEarlyOutReason reason) { | |
| 812 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 776 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
| 813 CommitEarlyOutReasonToString(reason)); | 777 CommitEarlyOutReasonToString(reason)); |
| 814 DCHECK(IsImplThread()); | 778 DCHECK(IsImplThread()); |
| 815 DCHECK(impl().scheduler); | 779 DCHECK(impl().scheduler); |
| 816 DCHECK(impl().scheduler->CommitPending()); | 780 DCHECK(impl().scheduler->CommitPending()); |
| 817 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 781 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| 818 | 782 |
| 819 if (CommitEarlyOutHandledCommit(reason)) { | 783 if (CommitEarlyOutHandledCommit(reason)) { |
| 820 SetInputThrottledUntilCommitOnImplThread(false); | 784 SetInputThrottledUntilCommitOnImpl(false); |
| 821 impl().last_processed_begin_main_frame_args = | 785 impl().last_processed_begin_main_frame_args = |
| 822 impl().last_begin_main_frame_args; | 786 impl().last_begin_main_frame_args; |
| 823 } | 787 } |
| 824 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); | 788 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); |
| 825 impl().scheduler->BeginMainFrameAborted(reason); | 789 impl().scheduler->BeginMainFrameAborted(reason); |
| 826 } | 790 } |
| 827 | 791 |
| 828 void ThreadProxy::ScheduledActionAnimate() { | 792 void ThreadProxy::ScheduledActionAnimate() { |
| 829 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 793 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
| 830 DCHECK(IsImplThread()); | 794 DCHECK(IsImplThread()); |
| 831 | 795 |
| 832 impl().layer_tree_host_impl->Animate(); | 796 impl().layer_tree_host_impl->Animate(); |
| 833 } | 797 } |
| 834 | 798 |
| 835 void ThreadProxy::ScheduledActionCommit() { | 799 void ThreadProxy::ScheduledActionCommit() { |
| 836 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 800 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
| 837 DCHECK(IsImplThread()); | 801 DCHECK(IsImplThread()); |
| 838 DCHECK(IsMainThreadBlocked()); | 802 DCHECK(IsMainThreadBlocked()); |
| 839 DCHECK(impl().commit_completion_event); | 803 DCHECK(impl().commit_completion_event); |
| 804 DCHECK(blocked_commit_state()); | |
| 840 | 805 |
| 841 blocked_main().main_thread_inside_commit = true; | |
| 842 impl().layer_tree_host_impl->BeginCommit(); | 806 impl().layer_tree_host_impl->BeginCommit(); |
| 843 layer_tree_host()->FinishCommitOnImplThread( | 807 blocked_commit_state()->layer_tree_host->FinishCommitOnImplThread( |
| 844 impl().layer_tree_host_impl.get()); | 808 impl().layer_tree_host_impl.get()); |
| 845 blocked_main().main_thread_inside_commit = false; | |
| 846 | 809 |
| 847 bool hold_commit = blocked_main().commit_waits_for_activation; | 810 bool hold_commit = *(blocked_commit_state()->commit_waits_for_activation); |
| 848 blocked_main().commit_waits_for_activation = false; | 811 *(blocked_commit_state()->commit_waits_for_activation) = false; |
| 849 | 812 |
| 850 if (hold_commit) { | 813 if (hold_commit) { |
| 851 // For some layer types in impl-side painting, the commit is held until | 814 // For some layer types in impl-side painting, the commit is held until |
| 852 // the sync tree is activated. It's also possible that the | 815 // the sync tree is activated. It's also possible that the |
| 853 // sync tree has already activated if there was no work to be done. | 816 // sync tree has already activated if there was no work to be done. |
| 854 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 817 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
| 855 impl().completion_event_for_commit_held_on_tree_activation = | 818 impl().completion_event_for_commit_held_on_tree_activation = |
| 856 impl().commit_completion_event; | 819 impl().commit_completion_event; |
| 857 impl().commit_completion_event = NULL; | 820 set_blocked_commit_state(nullptr); |
| 821 impl().commit_completion_event = nullptr; | |
| 858 } else { | 822 } else { |
| 823 set_blocked_commit_state(nullptr); | |
| 859 impl().commit_completion_event->Signal(); | 824 impl().commit_completion_event->Signal(); |
| 860 impl().commit_completion_event = NULL; | 825 impl().commit_completion_event = nullptr; |
| 861 } | 826 } |
| 862 | 827 |
| 863 impl().scheduler->DidCommit(); | 828 impl().scheduler->DidCommit(); |
| 864 | 829 |
| 865 // Delay this step until afer the main thread has been released as it's | 830 // Delay this step until afer the main thread has been released as it's |
| 866 // often a good bit of work to update the tree and prepare the new frame. | 831 // often a good bit of work to update the tree and prepare the new frame. |
| 867 impl().layer_tree_host_impl->CommitComplete(); | 832 impl().layer_tree_host_impl->CommitComplete(); |
| 868 | 833 |
| 869 SetInputThrottledUntilCommitOnImplThread(false); | 834 SetInputThrottledUntilCommitOnImpl(false); |
| 870 | 835 |
| 871 impl().next_frame_is_newly_committed_frame = true; | 836 impl().next_frame_is_newly_committed_frame = true; |
| 872 } | 837 } |
| 873 | 838 |
| 874 void ThreadProxy::ScheduledActionActivateSyncTree() { | 839 void ThreadProxy::ScheduledActionActivateSyncTree() { |
| 875 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); | 840 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); |
| 876 DCHECK(IsImplThread()); | 841 DCHECK(IsImplThread()); |
| 877 impl().layer_tree_host_impl->ActivateSyncTree(); | 842 impl().layer_tree_host_impl->ActivateSyncTree(); |
| 878 } | 843 } |
| 879 | 844 |
| 880 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 845 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 881 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); | 846 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); |
| 882 DCHECK(IsImplThread()); | 847 DCHECK(IsImplThread()); |
| 883 Proxy::MainThreadTaskRunner()->PostTask( | 848 impl().channel_impl->RequestNewOutputSurface(); |
| 884 FROM_HERE, | |
| 885 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_)); | |
| 886 } | 849 } |
| 887 | 850 |
| 888 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 851 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 889 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 852 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 890 DrawResult result; | 853 DrawResult result; |
| 891 | 854 |
| 892 DCHECK(IsImplThread()); | 855 DCHECK(IsImplThread()); |
| 893 DCHECK(impl().layer_tree_host_impl.get()); | 856 DCHECK(impl().layer_tree_host_impl.get()); |
| 894 | 857 |
| 895 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 858 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 | 894 |
| 932 bool start_ready_animations = draw_frame; | 895 bool start_ready_animations = draw_frame; |
| 933 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 896 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
| 934 | 897 |
| 935 if (draw_frame) | 898 if (draw_frame) |
| 936 impl().layer_tree_host_impl->SwapBuffers(frame); | 899 impl().layer_tree_host_impl->SwapBuffers(frame); |
| 937 | 900 |
| 938 // Tell the main thread that the the newly-commited frame was drawn. | 901 // Tell the main thread that the the newly-commited frame was drawn. |
| 939 if (impl().next_frame_is_newly_committed_frame) { | 902 if (impl().next_frame_is_newly_committed_frame) { |
| 940 impl().next_frame_is_newly_committed_frame = false; | 903 impl().next_frame_is_newly_committed_frame = false; |
| 941 Proxy::MainThreadTaskRunner()->PostTask( | 904 impl().channel_impl->DidCommitAndDrawFrame(); |
| 942 FROM_HERE, | |
| 943 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | |
| 944 } | 905 } |
| 945 | 906 |
| 946 DCHECK_NE(INVALID_RESULT, result); | 907 DCHECK_NE(INVALID_RESULT, result); |
| 947 return result; | 908 return result; |
| 948 } | 909 } |
| 949 | 910 |
| 950 void ThreadProxy::ScheduledActionPrepareTiles() { | 911 void ThreadProxy::ScheduledActionPrepareTiles() { |
| 951 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); | 912 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); |
| 952 impl().layer_tree_host_impl->PrepareTiles(); | 913 impl().layer_tree_host_impl->PrepareTiles(); |
| 953 } | 914 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 this, scheduler_settings, impl().layer_tree_host_id, | 988 this, scheduler_settings, impl().layer_tree_host_id, |
| 1028 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), | 989 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), |
| 1029 compositor_timing_history.Pass()); | 990 compositor_timing_history.Pass()); |
| 1030 | 991 |
| 1031 DCHECK_EQ(impl().scheduler->visible(), | 992 DCHECK_EQ(impl().scheduler->visible(), |
| 1032 impl().layer_tree_host_impl->visible()); | 993 impl().layer_tree_host_impl->visible()); |
| 1033 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 994 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| 1034 completion->Signal(); | 995 completion->Signal(); |
| 1035 } | 996 } |
| 1036 | 997 |
| 1037 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 998 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { |
| 1038 OutputSurface* output_surface) { | |
| 1039 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); | 999 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| 1040 DCHECK(IsImplThread()); | 1000 DCHECK(IsImplThread()); |
| 1041 | 1001 |
| 1042 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); | 1002 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| 1043 bool success = host_impl->InitializeRenderer(output_surface); | 1003 bool success = host_impl->InitializeRenderer(output_surface); |
| 1044 RendererCapabilities capabilities; | 1004 RendererCapabilities capabilities; |
| 1045 if (success) { | 1005 if (success) { |
| 1046 capabilities = | 1006 capabilities = |
| 1047 host_impl->GetRendererCapabilities().MainThreadCapabilities(); | 1007 host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| 1048 } | 1008 } |
| 1049 | 1009 |
| 1050 Proxy::MainThreadTaskRunner()->PostTask( | 1010 impl().channel_impl->DidInitializeOutputSurface(success, capabilities); |
| 1051 FROM_HERE, | |
| 1052 base::Bind(&ThreadProxy::DidInitializeOutputSurface, | |
| 1053 main_thread_weak_ptr_, | |
| 1054 success, | |
| 1055 capabilities)); | |
| 1056 | 1011 |
| 1057 if (success) | 1012 if (success) |
| 1058 impl().scheduler->DidCreateAndInitializeOutputSurface(); | 1013 impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| 1059 } | 1014 } |
| 1060 | 1015 |
| 1061 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( | 1016 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) { |
| 1062 CompletionEvent* completion) { | |
| 1063 DCHECK(IsImplThread()); | 1017 DCHECK(IsImplThread()); |
| 1064 | 1018 |
| 1065 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call | 1019 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call |
| 1066 // LayerTreeHost::DidLoseOutputSurface since it already knows. | 1020 // LayerTreeHost::DidLoseOutputSurface since it already knows. |
| 1067 impl().scheduler->DidLoseOutputSurface(); | 1021 impl().scheduler->DidLoseOutputSurface(); |
| 1068 impl().layer_tree_host_impl->ReleaseOutputSurface(); | 1022 impl().layer_tree_host_impl->ReleaseOutputSurface(); |
| 1069 completion->Signal(); | 1023 completion->Signal(); |
| 1070 } | 1024 } |
| 1071 | 1025 |
| 1072 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | 1026 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) { |
| 1073 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 1027 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1074 DCHECK(IsImplThread()); | 1028 DCHECK(IsImplThread()); |
| 1075 if (impl().layer_tree_host_impl->output_surface()) { | 1029 if (impl().layer_tree_host_impl->output_surface()) { |
| 1076 ContextProvider* context_provider = | 1030 ContextProvider* context_provider = |
| 1077 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1031 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1078 if (context_provider) | 1032 if (context_provider) |
| 1079 context_provider->ContextGL()->Finish(); | 1033 context_provider->ContextGL()->Finish(); |
| 1080 } | 1034 } |
| 1081 completion->Signal(); | 1035 completion->Signal(); |
| 1082 } | 1036 } |
| 1083 | 1037 |
| 1084 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1038 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1085 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1039 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1086 DCHECK(IsImplThread()); | 1040 DCHECK(IsImplThread()); |
| 1087 DCHECK(IsMainThreadBlocked()); | 1041 DCHECK(IsMainThreadBlocked()); |
| 1088 impl().scheduler = nullptr; | 1042 impl().scheduler = nullptr; |
| 1089 impl().external_begin_frame_source = nullptr; | 1043 impl().external_begin_frame_source = nullptr; |
| 1090 impl().layer_tree_host_impl = nullptr; | 1044 impl().layer_tree_host_impl = nullptr; |
| 1091 impl().weak_factory.InvalidateWeakPtrs(); | 1045 impl().weak_factory.InvalidateWeakPtrs(); |
| 1092 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 1046 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
| 1093 // holding while still on the compositor thread. This also ensures any | 1047 // holding while still on the compositor thread. This also ensures any |
| 1094 // callbacks holding a ThreadProxy pointer are cancelled. | 1048 // callbacks holding a ThreadProxy pointer are cancelled. |
| 1095 impl().smoothness_priority_expiration_notifier.Shutdown(); | 1049 impl().smoothness_priority_expiration_notifier.Shutdown(); |
| 1096 completion->Signal(); | 1050 completion->Signal(); |
| 1097 } | 1051 } |
| 1098 | 1052 |
| 1099 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() | |
| 1100 : memory_allocation_limit_bytes(0), | |
| 1101 evicted_ui_resources(false) {} | |
| 1102 | |
| 1103 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} | |
| 1104 | |
| 1105 bool ThreadProxy::MainFrameWillHappenForTesting() { | 1053 bool ThreadProxy::MainFrameWillHappenForTesting() { |
| 1106 DCHECK(IsMainThread()); | 1054 DCHECK(IsMainThread()); |
| 1107 CompletionEvent completion; | |
| 1108 bool main_frame_will_happen = false; | 1055 bool main_frame_will_happen = false; |
| 1109 { | 1056 { |
| 1110 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 1057 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 1111 Proxy::ImplThreadTaskRunner()->PostTask( | 1058 CompletionEvent completion; |
| 1112 FROM_HERE, | 1059 main().channel_main->MainFrameWillHappenOnImplForTesting( |
| 1113 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, | 1060 &completion, &main_frame_will_happen); |
| 1114 impl_thread_weak_ptr_, | |
| 1115 &completion, | |
| 1116 &main_frame_will_happen)); | |
| 1117 completion.Wait(); | 1061 completion.Wait(); |
| 1118 } | 1062 } |
| 1119 return main_frame_will_happen; | 1063 return main_frame_will_happen; |
| 1120 } | 1064 } |
| 1121 | 1065 |
| 1122 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 1066 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 1123 NOTREACHED() << "Only used by SingleThreadProxy"; | 1067 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 1124 } | 1068 } |
| 1125 | 1069 |
| 1126 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( | 1070 void ThreadProxy::MainFrameWillHappenOnImplForTesting( |
| 1127 CompletionEvent* completion, | 1071 CompletionEvent* completion, |
| 1128 bool* main_frame_will_happen) { | 1072 bool* main_frame_will_happen) { |
| 1129 DCHECK(IsImplThread()); | 1073 DCHECK(IsImplThread()); |
| 1130 if (impl().layer_tree_host_impl->output_surface()) { | 1074 if (impl().layer_tree_host_impl->output_surface()) { |
| 1131 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); | 1075 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); |
| 1132 } else { | 1076 } else { |
| 1133 *main_frame_will_happen = false; | 1077 *main_frame_will_happen = false; |
| 1134 } | 1078 } |
| 1135 completion->Signal(); | 1079 completion->Signal(); |
| 1136 } | 1080 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1192 } | 1136 } |
| 1193 | 1137 |
| 1194 void ThreadProxy::DidActivateSyncTree() { | 1138 void ThreadProxy::DidActivateSyncTree() { |
| 1195 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); | 1139 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); |
| 1196 DCHECK(IsImplThread()); | 1140 DCHECK(IsImplThread()); |
| 1197 | 1141 |
| 1198 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1142 if (impl().completion_event_for_commit_held_on_tree_activation) { |
| 1199 TRACE_EVENT_INSTANT0( | 1143 TRACE_EVENT_INSTANT0( |
| 1200 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1144 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
| 1201 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1145 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
| 1202 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1146 impl().completion_event_for_commit_held_on_tree_activation = nullptr; |
| 1203 } | 1147 } |
| 1204 | 1148 |
| 1205 impl().last_processed_begin_main_frame_args = | 1149 impl().last_processed_begin_main_frame_args = |
| 1206 impl().last_begin_main_frame_args; | 1150 impl().last_begin_main_frame_args; |
| 1207 } | 1151 } |
| 1208 | 1152 |
| 1209 void ThreadProxy::WillPrepareTiles() { | 1153 void ThreadProxy::WillPrepareTiles() { |
| 1210 DCHECK(IsImplThread()); | 1154 DCHECK(IsImplThread()); |
| 1211 impl().scheduler->WillPrepareTiles(); | 1155 impl().scheduler->WillPrepareTiles(); |
| 1212 } | 1156 } |
| 1213 | 1157 |
| 1214 void ThreadProxy::DidPrepareTiles() { | 1158 void ThreadProxy::DidPrepareTiles() { |
| 1215 DCHECK(IsImplThread()); | 1159 DCHECK(IsImplThread()); |
| 1216 impl().scheduler->DidPrepareTiles(); | 1160 impl().scheduler->DidPrepareTiles(); |
| 1217 } | 1161 } |
| 1218 | 1162 |
| 1219 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1163 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1220 DCHECK(IsImplThread()); | 1164 DCHECK(IsImplThread()); |
| 1221 Proxy::MainThreadTaskRunner()->PostTask( | 1165 impl().channel_impl->DidCompletePageScaleAnimation(); |
| 1222 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | |
| 1223 main_thread_weak_ptr_)); | |
| 1224 } | 1166 } |
| 1225 | 1167 |
| 1226 void ThreadProxy::OnDrawForOutputSurface() { | 1168 void ThreadProxy::OnDrawForOutputSurface() { |
| 1227 DCHECK(IsImplThread()); | 1169 DCHECK(IsImplThread()); |
| 1228 impl().scheduler->OnDrawForOutputSurface(); | 1170 impl().scheduler->OnDrawForOutputSurface(); |
| 1229 } | 1171 } |
| 1230 | 1172 |
| 1231 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, | 1173 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, |
| 1232 TopControlsState current, | 1174 TopControlsState current, |
| 1233 bool animate) { | 1175 bool animate) { |
| 1234 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, | 1176 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, |
| 1235 animate); | 1177 animate); |
| 1236 } | 1178 } |
| 1237 | 1179 |
| 1238 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, | 1180 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, |
| 1239 TopControlsState current, | 1181 TopControlsState current, |
| 1240 bool animate) { | 1182 bool animate) { |
| 1241 DCHECK(IsImplThread()); | 1183 DCHECK(IsImplThread()); |
| 1242 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( | 1184 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( |
| 1243 constraints, current, animate); | 1185 constraints, current, animate); |
| 1244 } | 1186 } |
| 1245 | 1187 |
| 1246 void ThreadProxy::PostFrameTimingEventsOnImplThread( | 1188 void ThreadProxy::PostFrameTimingEventsOnImplThread( |
| 1247 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1189 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1248 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1190 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1249 DCHECK(IsImplThread()); | 1191 DCHECK(IsImplThread()); |
| 1250 Proxy::MainThreadTaskRunner()->PostTask( | 1192 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), |
| 1251 FROM_HERE, | 1193 main_frame_events.Pass()); |
| 1252 base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_, | |
| 1253 base::Passed(composite_events.Pass()), | |
| 1254 base::Passed(main_frame_events.Pass()))); | |
| 1255 } | 1194 } |
| 1256 | 1195 |
| 1257 void ThreadProxy::PostFrameTimingEvents( | 1196 void ThreadProxy::PostFrameTimingEventsOnMain( |
| 1258 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1197 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1259 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1198 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1260 DCHECK(IsMainThread()); | 1199 DCHECK(IsMainThread()); |
| 1261 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), | 1200 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), |
| 1262 main_frame_events.Pass()); | 1201 main_frame_events.Pass()); |
| 1263 } | 1202 } |
| 1264 | 1203 |
| 1265 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1204 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
| 1266 return main_thread_weak_ptr_; | 1205 return main_thread_weak_ptr_; |
| 1267 } | 1206 } |
| 1268 | 1207 |
| 1269 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1208 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
| 1270 return impl_thread_weak_ptr_; | 1209 return impl_thread_weak_ptr_; |
| 1271 } | 1210 } |
| 1272 | 1211 |
| 1273 } // namespace cc | 1212 } // namespace cc |
| OLD | NEW |