| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 main_thread_inside_commit(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 DCHECK(!blocked_main().main_thread_inside_commit); |
| 428 blocked_main().commit_waits_for_activation = true; | 406 blocked_main().commit_waits_for_activation = true; |
| 429 } | 407 } |
| 430 | 408 |
| 431 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 409 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 432 DCHECK(IsMainThread()); | 410 DCHECK(IsMainThread()); |
| 433 if (main().defer_commits == defer_commits) | 411 if (main().defer_commits == defer_commits) |
| 434 return; | 412 return; |
| 435 | 413 |
| 436 main().defer_commits = defer_commits; | 414 main().defer_commits = defer_commits; |
| 437 if (main().defer_commits) | 415 if (main().defer_commits) |
| 438 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 416 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| 439 else | 417 else |
| 440 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 418 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| 441 | 419 |
| 442 Proxy::ImplThreadTaskRunner()->PostTask( | 420 main().channel_main->SetDeferCommitsOnImpl(defer_commits); |
| 443 FROM_HERE, | |
| 444 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread, | |
| 445 impl_thread_weak_ptr_, | |
| 446 defer_commits)); | |
| 447 } | 421 } |
| 448 | 422 |
| 449 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { | 423 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) const { |
| 450 DCHECK(IsImplThread()); | 424 DCHECK(IsImplThread()); |
| 451 impl().scheduler->SetDeferCommits(defer_commits); | 425 impl().scheduler->SetDeferCommits(defer_commits); |
| 452 } | 426 } |
| 453 | 427 |
| 454 bool ThreadProxy::CommitRequested() const { | 428 bool ThreadProxy::CommitRequested() const { |
| 455 DCHECK(IsMainThread()); | 429 DCHECK(IsMainThread()); |
| 456 // TODO(skyostil): Split this into something like CommitRequested() and | 430 // TODO(skyostil): Split this into something like CommitRequested() and |
| 457 // CommitInProgress(). | 431 // CommitInProgress(). |
| 458 return main().current_pipeline_stage != NO_PIPELINE_STAGE || | 432 return main().current_pipeline_stage != NO_PIPELINE_STAGE || |
| 459 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; | 433 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 482 } | 456 } |
| 483 | 457 |
| 484 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { | 458 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
| 485 DCHECK(IsImplThread()); | 459 DCHECK(IsImplThread()); |
| 486 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); | 460 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); |
| 487 SetNeedsRedrawOnImplThread(); | 461 SetNeedsRedrawOnImplThread(); |
| 488 } | 462 } |
| 489 | 463 |
| 490 void ThreadProxy::MainThreadHasStoppedFlinging() { | 464 void ThreadProxy::MainThreadHasStoppedFlinging() { |
| 491 DCHECK(IsMainThread()); | 465 DCHECK(IsMainThread()); |
| 492 Proxy::ImplThreadTaskRunner()->PostTask( | 466 main().channel_main->MainThreadHasStoppedFlingingOnImpl(); |
| 493 FROM_HERE, | |
| 494 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, | |
| 495 impl_thread_weak_ptr_)); | |
| 496 } | 467 } |
| 497 | 468 |
| 498 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { | 469 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { |
| 499 DCHECK(IsImplThread()); | 470 DCHECK(IsImplThread()); |
| 500 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); | 471 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); |
| 501 } | 472 } |
| 502 | 473 |
| 503 void ThreadProxy::NotifyInputThrottledUntilCommit() { | 474 void ThreadProxy::NotifyInputThrottledUntilCommit() { |
| 504 DCHECK(IsMainThread()); | 475 DCHECK(IsMainThread()); |
| 505 Proxy::ImplThreadTaskRunner()->PostTask( | 476 main().channel_main->SetInputThrottledUntilCommitOnImpl(true); |
| 506 FROM_HERE, | |
| 507 base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread, | |
| 508 impl_thread_weak_ptr_, | |
| 509 true)); | |
| 510 } | 477 } |
| 511 | 478 |
| 512 void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { | 479 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| 513 DCHECK(IsImplThread()); | 480 DCHECK(IsImplThread()); |
| 514 if (is_throttled == impl().input_throttled_until_commit) | 481 if (is_throttled == impl().input_throttled_until_commit) |
| 515 return; | 482 return; |
| 516 impl().input_throttled_until_commit = is_throttled; | 483 impl().input_throttled_until_commit = is_throttled; |
| 517 RenewTreePriority(); | 484 RenewTreePriority(); |
| 518 } | 485 } |
| 519 | 486 |
| 520 LayerTreeHost* ThreadProxy::layer_tree_host() { | 487 LayerTreeHost* ThreadProxy::layer_tree_host() { |
| 521 return blocked_main().layer_tree_host; | 488 return blocked_main().layer_tree_host; |
| 522 } | 489 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 545 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
| 579 DCHECK(IsMainThread()); | 546 DCHECK(IsMainThread()); |
| 580 DCHECK(main().started); | 547 DCHECK(main().started); |
| 581 | 548 |
| 582 // Synchronously finishes pending GL operations and deletes the impl. | 549 // Synchronously finishes pending GL operations and deletes the impl. |
| 583 // The two steps are done as separate post tasks, so that tasks posted | 550 // 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 | 551 // by the GL implementation due to the Finish can be executed by the |
| 585 // renderer before shutting it down. | 552 // renderer before shutting it down. |
| 586 { | 553 { |
| 587 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 554 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 588 | |
| 589 CompletionEvent completion; | 555 CompletionEvent completion; |
| 590 Proxy::ImplThreadTaskRunner()->PostTask( | 556 main().channel_main->FinishGLOnImpl(&completion); |
| 591 FROM_HERE, | |
| 592 base::Bind(&ThreadProxy::FinishGLOnImplThread, | |
| 593 impl_thread_weak_ptr_, | |
| 594 &completion)); | |
| 595 completion.Wait(); | 557 completion.Wait(); |
| 596 } | 558 } |
| 597 { | 559 { |
| 598 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 560 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 599 | 561 |
| 600 CompletionEvent completion; | 562 CompletionEvent completion; |
| 601 Proxy::ImplThreadTaskRunner()->PostTask( | 563 Proxy::ImplThreadTaskRunner()->PostTask( |
| 602 FROM_HERE, | 564 FROM_HERE, |
| 603 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | 565 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, |
| 604 impl_thread_weak_ptr_, | 566 impl_thread_weak_ptr_, |
| 605 &completion)); | 567 &completion)); |
| 606 completion.Wait(); | 568 completion.Wait(); |
| 607 } | 569 } |
| 608 | 570 |
| 609 main().weak_factory.InvalidateWeakPtrs(); | 571 main().weak_factory.InvalidateWeakPtrs(); |
| 610 blocked_main().layer_tree_host = NULL; | 572 blocked_main().layer_tree_host = NULL; |
| 611 main().started = false; | 573 main().started = false; |
| 612 } | 574 } |
| 613 | 575 |
| 614 bool ThreadProxy::SupportsImplScrolling() const { | 576 bool ThreadProxy::SupportsImplScrolling() const { |
| 615 return true; | 577 return true; |
| 616 } | 578 } |
| 617 | 579 |
| 618 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { | 580 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
| 619 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 581 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 620 DCHECK(IsImplThread()); | 582 DCHECK(IsImplThread()); |
| 621 impl().layer_tree_host_impl->FinishAllRendering(); | 583 impl().layer_tree_host_impl->FinishAllRendering(); |
| 622 completion->Signal(); | 584 completion->Signal(); |
| 623 } | 585 } |
| 624 | 586 |
| 625 void ThreadProxy::ScheduledActionSendBeginMainFrame() { | 587 void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 626 unsigned int begin_frame_id = nextBeginFrameId++; | 588 unsigned int begin_frame_id = nextBeginFrameId++; |
| 627 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 589 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 628 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 590 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
| 629 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 591 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 630 new BeginMainFrameAndCommitState); | 592 new BeginMainFrameAndCommitState); |
| 631 begin_main_frame_state->begin_frame_id = begin_frame_id; | 593 begin_main_frame_state->begin_frame_id = begin_frame_id; |
| 632 begin_main_frame_state->begin_frame_args = | 594 begin_main_frame_state->begin_frame_args = |
| 633 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); | 595 impl().layer_tree_host_impl->CurrentBeginFrameArgs(); |
| 634 begin_main_frame_state->scroll_info = | 596 begin_main_frame_state->scroll_info = |
| 635 impl().layer_tree_host_impl->ProcessScrollDeltas(); | 597 impl().layer_tree_host_impl->ProcessScrollDeltas(); |
| 636 begin_main_frame_state->memory_allocation_limit_bytes = | 598 begin_main_frame_state->memory_allocation_limit_bytes = |
| 637 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); | 599 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); |
| 638 begin_main_frame_state->evicted_ui_resources = | 600 begin_main_frame_state->evicted_ui_resources = |
| 639 impl().layer_tree_host_impl->EvictedUIResourcesExist(); | 601 impl().layer_tree_host_impl->EvictedUIResourcesExist(); |
| 640 // TODO(vmpstr): This needs to be fixed if | 602 // TODO(vmpstr): This needs to be fixed if |
| 641 // main_frame_before_activation_enabled is set, since we might run this code | 603 // main_frame_before_activation_enabled is set, since we might run this code |
| 642 // twice before recording a duration. crbug.com/469824 | 604 // twice before recording a duration. crbug.com/469824 |
| 643 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; | 605 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; |
| 644 Proxy::MainThreadTaskRunner()->PostTask( | 606 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( | 607 devtools_instrumentation::DidRequestMainThreadFrame( |
| 650 impl().layer_tree_host_id); | 608 impl().layer_tree_host_id); |
| 651 } | 609 } |
| 652 | 610 |
| 653 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 611 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 654 Proxy::MainThreadTaskRunner()->PostTask( | 612 impl().channel_impl->BeginMainFrameNotExpectedSoon(); |
| 655 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, | |
| 656 main_thread_weak_ptr_)); | |
| 657 } | 613 } |
| 658 | 614 |
| 659 void ThreadProxy::BeginMainFrame( | 615 void ThreadProxy::BeginMainFrame( |
| 660 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 616 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 661 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 617 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 662 benchmark_instrumentation::kDoBeginFrame, | 618 benchmark_instrumentation::kDoBeginFrame, |
| 663 begin_main_frame_state->begin_frame_id); | 619 begin_main_frame_state->begin_frame_id); |
| 664 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 620 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 665 DCHECK(IsMainThread()); | 621 DCHECK(IsMainThread()); |
| 666 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); | 622 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); |
| 667 | 623 |
| 668 if (main().defer_commits) { | 624 if (main().defer_commits) { |
| 669 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 625 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| 670 TRACE_EVENT_SCOPE_THREAD); | 626 TRACE_EVENT_SCOPE_THREAD); |
| 671 Proxy::ImplThreadTaskRunner()->PostTask( | 627 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 672 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 628 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 673 impl_thread_weak_ptr_, | |
| 674 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT)); | |
| 675 return; | 629 return; |
| 676 } | 630 } |
| 677 | 631 |
| 678 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 632 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 679 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the | 633 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
| 680 // remaining swap promises. | 634 // remaining swap promises. |
| 681 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); | 635 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); |
| 682 | 636 |
| 683 main().final_pipeline_stage = main().max_requested_pipeline_stage; | 637 main().final_pipeline_stage = main().max_requested_pipeline_stage; |
| 684 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; | 638 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; |
| 685 | 639 |
| 686 if (!layer_tree_host()->visible()) { | 640 if (!layer_tree_host()->visible()) { |
| 687 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 641 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 688 Proxy::ImplThreadTaskRunner()->PostTask( | 642 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 689 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 643 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 690 impl_thread_weak_ptr_, | |
| 691 CommitEarlyOutReason::ABORTED_NOT_VISIBLE)); | |
| 692 return; | 644 return; |
| 693 } | 645 } |
| 694 | 646 |
| 695 if (layer_tree_host()->output_surface_lost()) { | 647 if (layer_tree_host()->output_surface_lost()) { |
| 696 TRACE_EVENT_INSTANT0( | 648 TRACE_EVENT_INSTANT0( |
| 697 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 649 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 698 Proxy::ImplThreadTaskRunner()->PostTask( | 650 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 699 FROM_HERE, | 651 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); |
| 700 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | |
| 701 impl_thread_weak_ptr_, | |
| 702 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST)); | |
| 703 return; | 652 return; |
| 704 } | 653 } |
| 705 | 654 |
| 706 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; | 655 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; |
| 707 | 656 |
| 708 layer_tree_host()->ApplyScrollAndScale( | 657 layer_tree_host()->ApplyScrollAndScale( |
| 709 begin_main_frame_state->scroll_info.get()); | 658 begin_main_frame_state->scroll_info.get()); |
| 710 | 659 |
| 711 layer_tree_host()->WillBeginMainFrame(); | 660 layer_tree_host()->WillBeginMainFrame(); |
| 712 | 661 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 731 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; | 680 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; |
| 732 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); | 681 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); |
| 733 | 682 |
| 734 layer_tree_host()->WillCommit(); | 683 layer_tree_host()->WillCommit(); |
| 735 devtools_instrumentation::ScopedCommitTrace commit_task( | 684 devtools_instrumentation::ScopedCommitTrace commit_task( |
| 736 layer_tree_host()->id()); | 685 layer_tree_host()->id()); |
| 737 | 686 |
| 738 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; | 687 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; |
| 739 if (!updated && can_cancel_this_commit) { | 688 if (!updated && can_cancel_this_commit) { |
| 740 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 689 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
| 741 Proxy::ImplThreadTaskRunner()->PostTask( | 690 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 742 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 691 CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 743 impl_thread_weak_ptr_, | |
| 744 CommitEarlyOutReason::FINISHED_NO_UPDATES)); | |
| 745 | 692 |
| 746 // Although the commit is internally aborted, this is because it has been | 693 // 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 | 694 // 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. | 695 // went through, and input should no longer be throttled, etc. |
| 749 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 696 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 750 layer_tree_host()->CommitComplete(); | 697 layer_tree_host()->CommitComplete(); |
| 751 layer_tree_host()->DidBeginMainFrame(); | 698 layer_tree_host()->DidBeginMainFrame(); |
| 752 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); | 699 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); |
| 753 return; | 700 return; |
| 754 } | 701 } |
| 755 | 702 |
| 756 // Notify the impl thread that the main thread is ready to commit. This will | 703 // 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 | 704 // begin the commit process, which is blocking from the main thread's |
| 758 // point of view, but asynchronously performed on the impl thread, | 705 // point of view, but asynchronously performed on the impl thread, |
| 759 // coordinated by the Scheduler. | 706 // coordinated by the Scheduler. |
| 760 { | 707 { |
| 761 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); | 708 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
| 762 | 709 |
| 763 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 710 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 764 | 711 |
| 765 // This CapturePostTasks should be destroyed before CommitComplete() is | 712 // This CapturePostTasks should be destroyed before CommitComplete() is |
| 766 // called since that goes out to the embedder, and we want the embedder | 713 // called since that goes out to the embedder, and we want the embedder |
| 767 // to receive its callbacks before that. | 714 // to receive its callbacks before that. |
| 768 BlockingTaskRunner::CapturePostTasks blocked( | 715 BlockingTaskRunner::CapturePostTasks blocked( |
| 769 blocking_main_thread_task_runner()); | 716 blocking_main_thread_task_runner()); |
| 770 | 717 |
| 771 CompletionEvent completion; | 718 CompletionEvent completion; |
| 772 Proxy::ImplThreadTaskRunner()->PostTask( | 719 main().channel_main->StartCommitOnImpl(&completion); |
| 773 FROM_HERE, base::Bind(&ThreadProxy::StartCommitOnImplThread, | |
| 774 impl_thread_weak_ptr_, &completion)); | |
| 775 completion.Wait(); | 720 completion.Wait(); |
| 776 } | 721 } |
| 777 | 722 |
| 778 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 723 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 779 layer_tree_host()->CommitComplete(); | 724 layer_tree_host()->CommitComplete(); |
| 780 layer_tree_host()->DidBeginMainFrame(); | 725 layer_tree_host()->DidBeginMainFrame(); |
| 781 } | 726 } |
| 782 | 727 |
| 783 void ThreadProxy::BeginMainFrameNotExpectedSoon() { | 728 void ThreadProxy::BeginMainFrameNotExpectedSoon() { |
| 784 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); | 729 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); |
| 785 DCHECK(IsMainThread()); | 730 DCHECK(IsMainThread()); |
| 786 layer_tree_host()->BeginMainFrameNotExpectedSoon(); | 731 layer_tree_host()->BeginMainFrameNotExpectedSoon(); |
| 787 } | 732 } |
| 788 | 733 |
| 789 void ThreadProxy::StartCommitOnImplThread(CompletionEvent* completion) { | 734 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion) { |
| 790 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 735 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
| 791 DCHECK(!impl().commit_completion_event); | 736 DCHECK(!impl().commit_completion_event); |
| 792 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 737 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
| 793 DCHECK(impl().scheduler); | 738 DCHECK(impl().scheduler); |
| 794 DCHECK(impl().scheduler->CommitPending()); | 739 DCHECK(impl().scheduler->CommitPending()); |
| 795 | 740 |
| 796 if (!impl().layer_tree_host_impl) { | 741 if (!impl().layer_tree_host_impl) { |
| 797 TRACE_EVENT_INSTANT0( | 742 TRACE_EVENT_INSTANT0( |
| 798 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); | 743 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); |
| 799 completion->Signal(); | 744 completion->Signal(); |
| 800 return; | 745 return; |
| 801 } | 746 } |
| 802 | 747 |
| 803 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 748 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
| 804 // But, we can avoid a PostTask in here. | 749 // But, we can avoid a PostTask in here. |
| 805 impl().scheduler->NotifyBeginMainFrameStarted(); | 750 impl().scheduler->NotifyBeginMainFrameStarted(); |
| 806 impl().commit_completion_event = completion; | 751 impl().commit_completion_event = completion; |
| 807 impl().scheduler->NotifyReadyToCommit(); | 752 impl().scheduler->NotifyReadyToCommit(); |
| 808 } | 753 } |
| 809 | 754 |
| 810 void ThreadProxy::BeginMainFrameAbortedOnImplThread( | 755 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { |
| 811 CommitEarlyOutReason reason) { | |
| 812 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 756 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
| 813 CommitEarlyOutReasonToString(reason)); | 757 CommitEarlyOutReasonToString(reason)); |
| 814 DCHECK(IsImplThread()); | 758 DCHECK(IsImplThread()); |
| 815 DCHECK(impl().scheduler); | 759 DCHECK(impl().scheduler); |
| 816 DCHECK(impl().scheduler->CommitPending()); | 760 DCHECK(impl().scheduler->CommitPending()); |
| 817 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 761 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| 818 | 762 |
| 819 if (CommitEarlyOutHandledCommit(reason)) { | 763 if (CommitEarlyOutHandledCommit(reason)) { |
| 820 SetInputThrottledUntilCommitOnImplThread(false); | 764 SetInputThrottledUntilCommitOnImpl(false); |
| 821 impl().last_processed_begin_main_frame_args = | 765 impl().last_processed_begin_main_frame_args = |
| 822 impl().last_begin_main_frame_args; | 766 impl().last_begin_main_frame_args; |
| 823 } | 767 } |
| 824 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); | 768 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); |
| 825 impl().scheduler->BeginMainFrameAborted(reason); | 769 impl().scheduler->BeginMainFrameAborted(reason); |
| 826 } | 770 } |
| 827 | 771 |
| 828 void ThreadProxy::ScheduledActionAnimate() { | 772 void ThreadProxy::ScheduledActionAnimate() { |
| 829 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 773 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
| 830 DCHECK(IsImplThread()); | 774 DCHECK(IsImplThread()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 847 bool hold_commit = blocked_main().commit_waits_for_activation; | 791 bool hold_commit = blocked_main().commit_waits_for_activation; |
| 848 blocked_main().commit_waits_for_activation = false; | 792 blocked_main().commit_waits_for_activation = false; |
| 849 | 793 |
| 850 if (hold_commit) { | 794 if (hold_commit) { |
| 851 // For some layer types in impl-side painting, the commit is held until | 795 // 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 | 796 // 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. | 797 // sync tree has already activated if there was no work to be done. |
| 854 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); | 798 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); |
| 855 impl().completion_event_for_commit_held_on_tree_activation = | 799 impl().completion_event_for_commit_held_on_tree_activation = |
| 856 impl().commit_completion_event; | 800 impl().commit_completion_event; |
| 857 impl().commit_completion_event = NULL; | 801 impl().commit_completion_event = nullptr; |
| 858 } else { | 802 } else { |
| 859 impl().commit_completion_event->Signal(); | 803 impl().commit_completion_event->Signal(); |
| 860 impl().commit_completion_event = NULL; | 804 impl().commit_completion_event = nullptr; |
| 861 } | 805 } |
| 862 | 806 |
| 863 impl().scheduler->DidCommit(); | 807 impl().scheduler->DidCommit(); |
| 864 | 808 |
| 865 // Delay this step until afer the main thread has been released as it's | 809 // 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. | 810 // often a good bit of work to update the tree and prepare the new frame. |
| 867 impl().layer_tree_host_impl->CommitComplete(); | 811 impl().layer_tree_host_impl->CommitComplete(); |
| 868 | 812 |
| 869 SetInputThrottledUntilCommitOnImplThread(false); | 813 SetInputThrottledUntilCommitOnImpl(false); |
| 870 | 814 |
| 871 impl().next_frame_is_newly_committed_frame = true; | 815 impl().next_frame_is_newly_committed_frame = true; |
| 872 } | 816 } |
| 873 | 817 |
| 874 void ThreadProxy::ScheduledActionActivateSyncTree() { | 818 void ThreadProxy::ScheduledActionActivateSyncTree() { |
| 875 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); | 819 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); |
| 876 DCHECK(IsImplThread()); | 820 DCHECK(IsImplThread()); |
| 877 impl().layer_tree_host_impl->ActivateSyncTree(); | 821 impl().layer_tree_host_impl->ActivateSyncTree(); |
| 878 } | 822 } |
| 879 | 823 |
| 880 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 824 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 881 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); | 825 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); |
| 882 DCHECK(IsImplThread()); | 826 DCHECK(IsImplThread()); |
| 883 Proxy::MainThreadTaskRunner()->PostTask( | 827 impl().channel_impl->RequestNewOutputSurface(); |
| 884 FROM_HERE, | |
| 885 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_)); | |
| 886 } | 828 } |
| 887 | 829 |
| 888 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 830 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 889 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 831 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 890 DrawResult result; | 832 DrawResult result; |
| 891 | 833 |
| 892 DCHECK(IsImplThread()); | 834 DCHECK(IsImplThread()); |
| 893 DCHECK(impl().layer_tree_host_impl.get()); | 835 DCHECK(impl().layer_tree_host_impl.get()); |
| 894 | 836 |
| 895 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 837 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 | 873 |
| 932 bool start_ready_animations = draw_frame; | 874 bool start_ready_animations = draw_frame; |
| 933 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 875 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
| 934 | 876 |
| 935 if (draw_frame) | 877 if (draw_frame) |
| 936 impl().layer_tree_host_impl->SwapBuffers(frame); | 878 impl().layer_tree_host_impl->SwapBuffers(frame); |
| 937 | 879 |
| 938 // Tell the main thread that the the newly-commited frame was drawn. | 880 // Tell the main thread that the the newly-commited frame was drawn. |
| 939 if (impl().next_frame_is_newly_committed_frame) { | 881 if (impl().next_frame_is_newly_committed_frame) { |
| 940 impl().next_frame_is_newly_committed_frame = false; | 882 impl().next_frame_is_newly_committed_frame = false; |
| 941 Proxy::MainThreadTaskRunner()->PostTask( | 883 impl().channel_impl->DidCommitAndDrawFrame(); |
| 942 FROM_HERE, | |
| 943 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | |
| 944 } | 884 } |
| 945 | 885 |
| 946 DCHECK_NE(INVALID_RESULT, result); | 886 DCHECK_NE(INVALID_RESULT, result); |
| 947 return result; | 887 return result; |
| 948 } | 888 } |
| 949 | 889 |
| 950 void ThreadProxy::ScheduledActionPrepareTiles() { | 890 void ThreadProxy::ScheduledActionPrepareTiles() { |
| 951 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); | 891 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); |
| 952 impl().layer_tree_host_impl->PrepareTiles(); | 892 impl().layer_tree_host_impl->PrepareTiles(); |
| 953 } | 893 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 this, scheduler_settings, impl().layer_tree_host_id, | 967 this, scheduler_settings, impl().layer_tree_host_id, |
| 1028 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), | 968 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), |
| 1029 compositor_timing_history.Pass()); | 969 compositor_timing_history.Pass()); |
| 1030 | 970 |
| 1031 DCHECK_EQ(impl().scheduler->visible(), | 971 DCHECK_EQ(impl().scheduler->visible(), |
| 1032 impl().layer_tree_host_impl->visible()); | 972 impl().layer_tree_host_impl->visible()); |
| 1033 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 973 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| 1034 completion->Signal(); | 974 completion->Signal(); |
| 1035 } | 975 } |
| 1036 | 976 |
| 1037 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 977 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { |
| 1038 OutputSurface* output_surface) { | |
| 1039 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); | 978 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| 1040 DCHECK(IsImplThread()); | 979 DCHECK(IsImplThread()); |
| 1041 | 980 |
| 1042 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); | 981 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| 1043 bool success = host_impl->InitializeRenderer(output_surface); | 982 bool success = host_impl->InitializeRenderer(output_surface); |
| 1044 RendererCapabilities capabilities; | 983 RendererCapabilities capabilities; |
| 1045 if (success) { | 984 if (success) { |
| 1046 capabilities = | 985 capabilities = |
| 1047 host_impl->GetRendererCapabilities().MainThreadCapabilities(); | 986 host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| 1048 } | 987 } |
| 1049 | 988 |
| 1050 Proxy::MainThreadTaskRunner()->PostTask( | 989 impl().channel_impl->DidInitializeOutputSurface(success, capabilities); |
| 1051 FROM_HERE, | |
| 1052 base::Bind(&ThreadProxy::DidInitializeOutputSurface, | |
| 1053 main_thread_weak_ptr_, | |
| 1054 success, | |
| 1055 capabilities)); | |
| 1056 | 990 |
| 1057 if (success) | 991 if (success) |
| 1058 impl().scheduler->DidCreateAndInitializeOutputSurface(); | 992 impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| 1059 } | 993 } |
| 1060 | 994 |
| 1061 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( | 995 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) { |
| 1062 CompletionEvent* completion) { | |
| 1063 DCHECK(IsImplThread()); | 996 DCHECK(IsImplThread()); |
| 1064 | 997 |
| 1065 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call | 998 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call |
| 1066 // LayerTreeHost::DidLoseOutputSurface since it already knows. | 999 // LayerTreeHost::DidLoseOutputSurface since it already knows. |
| 1067 impl().scheduler->DidLoseOutputSurface(); | 1000 impl().scheduler->DidLoseOutputSurface(); |
| 1068 impl().layer_tree_host_impl->ReleaseOutputSurface(); | 1001 impl().layer_tree_host_impl->ReleaseOutputSurface(); |
| 1069 completion->Signal(); | 1002 completion->Signal(); |
| 1070 } | 1003 } |
| 1071 | 1004 |
| 1072 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | 1005 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) { |
| 1073 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 1006 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1074 DCHECK(IsImplThread()); | 1007 DCHECK(IsImplThread()); |
| 1075 if (impl().layer_tree_host_impl->output_surface()) { | 1008 if (impl().layer_tree_host_impl->output_surface()) { |
| 1076 ContextProvider* context_provider = | 1009 ContextProvider* context_provider = |
| 1077 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1010 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1078 if (context_provider) | 1011 if (context_provider) |
| 1079 context_provider->ContextGL()->Finish(); | 1012 context_provider->ContextGL()->Finish(); |
| 1080 } | 1013 } |
| 1081 completion->Signal(); | 1014 completion->Signal(); |
| 1082 } | 1015 } |
| 1083 | 1016 |
| 1084 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1017 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1085 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1018 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1086 DCHECK(IsImplThread()); | 1019 DCHECK(IsImplThread()); |
| 1087 DCHECK(IsMainThreadBlocked()); | 1020 DCHECK(IsMainThreadBlocked()); |
| 1088 impl().scheduler = nullptr; | 1021 impl().scheduler = nullptr; |
| 1089 impl().external_begin_frame_source = nullptr; | 1022 impl().external_begin_frame_source = nullptr; |
| 1090 impl().layer_tree_host_impl = nullptr; | 1023 impl().layer_tree_host_impl = nullptr; |
| 1091 impl().weak_factory.InvalidateWeakPtrs(); | 1024 impl().weak_factory.InvalidateWeakPtrs(); |
| 1092 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 1025 // 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 | 1026 // holding while still on the compositor thread. This also ensures any |
| 1094 // callbacks holding a ThreadProxy pointer are cancelled. | 1027 // callbacks holding a ThreadProxy pointer are cancelled. |
| 1095 impl().smoothness_priority_expiration_notifier.Shutdown(); | 1028 impl().smoothness_priority_expiration_notifier.Shutdown(); |
| 1096 completion->Signal(); | 1029 completion->Signal(); |
| 1097 } | 1030 } |
| 1098 | 1031 |
| 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() { | 1032 bool ThreadProxy::MainFrameWillHappenForTesting() { |
| 1106 DCHECK(IsMainThread()); | 1033 DCHECK(IsMainThread()); |
| 1107 CompletionEvent completion; | |
| 1108 bool main_frame_will_happen = false; | 1034 bool main_frame_will_happen = false; |
| 1109 { | 1035 { |
| 1110 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 1036 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 1111 Proxy::ImplThreadTaskRunner()->PostTask( | 1037 CompletionEvent completion; |
| 1112 FROM_HERE, | 1038 main().channel_main->MainFrameWillHappenOnImplForTesting( |
| 1113 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, | 1039 &completion, &main_frame_will_happen); |
| 1114 impl_thread_weak_ptr_, | |
| 1115 &completion, | |
| 1116 &main_frame_will_happen)); | |
| 1117 completion.Wait(); | 1040 completion.Wait(); |
| 1118 } | 1041 } |
| 1119 return main_frame_will_happen; | 1042 return main_frame_will_happen; |
| 1120 } | 1043 } |
| 1121 | 1044 |
| 1122 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 1045 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 1123 NOTREACHED() << "Only used by SingleThreadProxy"; | 1046 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 1124 } | 1047 } |
| 1125 | 1048 |
| 1126 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( | 1049 void ThreadProxy::MainFrameWillHappenOnImplForTesting( |
| 1127 CompletionEvent* completion, | 1050 CompletionEvent* completion, |
| 1128 bool* main_frame_will_happen) { | 1051 bool* main_frame_will_happen) { |
| 1129 DCHECK(IsImplThread()); | 1052 DCHECK(IsImplThread()); |
| 1130 if (impl().layer_tree_host_impl->output_surface()) { | 1053 if (impl().layer_tree_host_impl->output_surface()) { |
| 1131 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); | 1054 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); |
| 1132 } else { | 1055 } else { |
| 1133 *main_frame_will_happen = false; | 1056 *main_frame_will_happen = false; |
| 1134 } | 1057 } |
| 1135 completion->Signal(); | 1058 completion->Signal(); |
| 1136 } | 1059 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 } | 1115 } |
| 1193 | 1116 |
| 1194 void ThreadProxy::DidActivateSyncTree() { | 1117 void ThreadProxy::DidActivateSyncTree() { |
| 1195 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); | 1118 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); |
| 1196 DCHECK(IsImplThread()); | 1119 DCHECK(IsImplThread()); |
| 1197 | 1120 |
| 1198 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1121 if (impl().completion_event_for_commit_held_on_tree_activation) { |
| 1199 TRACE_EVENT_INSTANT0( | 1122 TRACE_EVENT_INSTANT0( |
| 1200 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1123 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
| 1201 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1124 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
| 1202 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1125 impl().completion_event_for_commit_held_on_tree_activation = nullptr; |
| 1203 } | 1126 } |
| 1204 | 1127 |
| 1205 impl().last_processed_begin_main_frame_args = | 1128 impl().last_processed_begin_main_frame_args = |
| 1206 impl().last_begin_main_frame_args; | 1129 impl().last_begin_main_frame_args; |
| 1207 } | 1130 } |
| 1208 | 1131 |
| 1209 void ThreadProxy::WillPrepareTiles() { | 1132 void ThreadProxy::WillPrepareTiles() { |
| 1210 DCHECK(IsImplThread()); | 1133 DCHECK(IsImplThread()); |
| 1211 impl().scheduler->WillPrepareTiles(); | 1134 impl().scheduler->WillPrepareTiles(); |
| 1212 } | 1135 } |
| 1213 | 1136 |
| 1214 void ThreadProxy::DidPrepareTiles() { | 1137 void ThreadProxy::DidPrepareTiles() { |
| 1215 DCHECK(IsImplThread()); | 1138 DCHECK(IsImplThread()); |
| 1216 impl().scheduler->DidPrepareTiles(); | 1139 impl().scheduler->DidPrepareTiles(); |
| 1217 } | 1140 } |
| 1218 | 1141 |
| 1219 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1142 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1220 DCHECK(IsImplThread()); | 1143 DCHECK(IsImplThread()); |
| 1221 Proxy::MainThreadTaskRunner()->PostTask( | 1144 impl().channel_impl->DidCompletePageScaleAnimation(); |
| 1222 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | |
| 1223 main_thread_weak_ptr_)); | |
| 1224 } | 1145 } |
| 1225 | 1146 |
| 1226 void ThreadProxy::OnDrawForOutputSurface() { | 1147 void ThreadProxy::OnDrawForOutputSurface() { |
| 1227 DCHECK(IsImplThread()); | 1148 DCHECK(IsImplThread()); |
| 1228 impl().scheduler->OnDrawForOutputSurface(); | 1149 impl().scheduler->OnDrawForOutputSurface(); |
| 1229 } | 1150 } |
| 1230 | 1151 |
| 1231 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, | 1152 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, |
| 1232 TopControlsState current, | 1153 TopControlsState current, |
| 1233 bool animate) { | 1154 bool animate) { |
| 1234 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, | 1155 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, |
| 1235 animate); | 1156 animate); |
| 1236 } | 1157 } |
| 1237 | 1158 |
| 1238 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, | 1159 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, |
| 1239 TopControlsState current, | 1160 TopControlsState current, |
| 1240 bool animate) { | 1161 bool animate) { |
| 1241 DCHECK(IsImplThread()); | 1162 DCHECK(IsImplThread()); |
| 1242 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( | 1163 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( |
| 1243 constraints, current, animate); | 1164 constraints, current, animate); |
| 1244 } | 1165 } |
| 1245 | 1166 |
| 1246 void ThreadProxy::PostFrameTimingEventsOnImplThread( | 1167 void ThreadProxy::PostFrameTimingEventsOnImplThread( |
| 1247 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1168 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1248 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1169 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1249 DCHECK(IsImplThread()); | 1170 DCHECK(IsImplThread()); |
| 1250 Proxy::MainThreadTaskRunner()->PostTask( | 1171 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), |
| 1251 FROM_HERE, | 1172 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 } | 1173 } |
| 1256 | 1174 |
| 1257 void ThreadProxy::PostFrameTimingEvents( | 1175 void ThreadProxy::PostFrameTimingEventsOnMain( |
| 1258 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1176 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1259 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1177 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1260 DCHECK(IsMainThread()); | 1178 DCHECK(IsMainThread()); |
| 1261 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), | 1179 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), |
| 1262 main_frame_events.Pass()); | 1180 main_frame_events.Pass()); |
| 1263 } | 1181 } |
| 1264 | 1182 |
| 1265 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1183 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
| 1266 return main_thread_weak_ptr_; | 1184 return main_thread_weak_ptr_; |
| 1267 } | 1185 } |
| 1268 | 1186 |
| 1269 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1187 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
| 1270 return impl_thread_weak_ptr_; | 1188 return impl_thread_weak_ptr_; |
| 1271 } | 1189 } |
| 1272 | 1190 |
| 1273 } // namespace cc | 1191 } // namespace cc |
| OLD | NEW |