| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 threaded_channel_ = threaded_channel.Pass(); | 131 threaded_channel_ = threaded_channel.Pass(); |
| 132 main().channel_main = threaded_channel_.get(); | 132 main().channel_main = threaded_channel_.get(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ThreadProxy::FinishAllRendering() { | 135 void ThreadProxy::FinishAllRendering() { |
| 136 DCHECK(Proxy::IsMainThread()); | 136 DCHECK(Proxy::IsMainThread()); |
| 137 DCHECK(!main().defer_commits); | 137 DCHECK(!main().defer_commits); |
| 138 | 138 |
| 139 // Make sure all GL drawing is finished on the impl thread. | 139 // Make sure all GL drawing is finished on the impl thread. |
| 140 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 140 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 141 CompletionEvent completion; | 141 main().channel_main->FinishAllRenderingOnImpl(); |
| 142 Proxy::ImplThreadTaskRunner()->PostTask( | |
| 143 FROM_HERE, | |
| 144 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread, | |
| 145 impl_thread_weak_ptr_, | |
| 146 &completion)); | |
| 147 completion.Wait(); | |
| 148 } | 142 } |
| 149 | 143 |
| 150 bool ThreadProxy::IsStarted() const { | 144 bool ThreadProxy::IsStarted() const { |
| 151 DCHECK(Proxy::IsMainThread()); | 145 DCHECK(Proxy::IsMainThread()); |
| 152 return main().started; | 146 return main().started; |
| 153 } | 147 } |
| 154 | 148 |
| 155 bool ThreadProxy::CommitToActiveTree() const { | 149 bool ThreadProxy::CommitToActiveTree() const { |
| 156 // With ThreadProxy, we use a pending tree and activate it once it's ready to | 150 // With ThreadProxy, we use a pending tree and activate it once it's ready to |
| 157 // draw to allow input to modify the active tree and draw during raster. | 151 // draw to allow input to modify the active tree and draw during raster. |
| 158 return false; | 152 return false; |
| 159 } | 153 } |
| 160 | 154 |
| 161 void ThreadProxy::SetLayerTreeHostClientReady() { | 155 void ThreadProxy::SetLayerTreeHostClientReady() { |
| 162 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); | 156 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); |
| 163 main().channel_main->SetLayerTreeHostClientReadyOnImpl(); | 157 main().channel_main->SetLayerTreeHostClientReadyOnImpl(); |
| 164 } | 158 } |
| 165 | 159 |
| 166 void ThreadProxy::SetLayerTreeHostClientReadyOnImpl() { | 160 void ThreadProxy::SetLayerTreeHostClientReadyOnImpl() { |
| 167 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReadyOnImplThread"); | 161 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReadyOnImplThread"); |
| 168 impl().scheduler->SetCanStart(); | 162 impl().scheduler->SetCanStart(); |
| 169 } | 163 } |
| 170 | 164 |
| 171 void ThreadProxy::SetVisible(bool visible) { | 165 void ThreadProxy::SetVisible(bool visible) { |
| 172 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); | 166 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); |
| 173 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 167 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 174 | 168 |
| 175 CompletionEvent completion; | 169 main().channel_main->SetVisibleOnImpl(visible); |
| 176 Proxy::ImplThreadTaskRunner()->PostTask( | |
| 177 FROM_HERE, | |
| 178 base::Bind(&ThreadProxy::SetVisibleOnImplThread, | |
| 179 impl_thread_weak_ptr_, | |
| 180 &completion, | |
| 181 visible)); | |
| 182 completion.Wait(); | |
| 183 } | 170 } |
| 184 | 171 |
| 185 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 172 void ThreadProxy::SetVisibleOnImpl(bool visible) { |
| 186 bool visible) { | |
| 187 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); | 173 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); |
| 188 impl().layer_tree_host_impl->SetVisible(visible); | 174 impl().layer_tree_host_impl->SetVisible(visible); |
| 189 impl().scheduler->SetVisible(visible); | 175 impl().scheduler->SetVisible(visible); |
| 190 completion->Signal(); | |
| 191 } | 176 } |
| 192 | 177 |
| 193 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { | 178 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { |
| 194 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", | 179 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", |
| 195 throttle); | 180 throttle); |
| 196 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); | 181 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); |
| 197 } | 182 } |
| 198 | 183 |
| 199 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { | 184 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { |
| 200 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", | 185 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", |
| 201 "throttle", throttle); | 186 "throttle", throttle); |
| 202 impl().scheduler->SetThrottleFrameProduction(throttle); | 187 impl().scheduler->SetThrottleFrameProduction(throttle); |
| 203 } | 188 } |
| 204 | 189 |
| 205 void ThreadProxy::DidLoseOutputSurface() { | 190 void ThreadProxy::DidLoseOutputSurface() { |
| 206 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 191 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
| 207 DCHECK(IsMainThread()); | 192 DCHECK(IsMainThread()); |
| 208 layer_tree_host()->DidLoseOutputSurface(); | 193 layer_tree_host()->DidLoseOutputSurface(); |
| 209 } | 194 } |
| 210 | 195 |
| 211 void ThreadProxy::RequestNewOutputSurface() { | 196 void ThreadProxy::RequestNewOutputSurface() { |
| 212 DCHECK(IsMainThread()); | 197 DCHECK(IsMainThread()); |
| 213 layer_tree_host()->RequestNewOutputSurface(); | 198 layer_tree_host()->RequestNewOutputSurface(); |
| 214 } | 199 } |
| 215 | 200 |
| 216 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 201 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| 217 Proxy::ImplThreadTaskRunner()->PostTask( | 202 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); |
| 218 FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread, | |
| 219 impl_thread_weak_ptr_, output_surface)); | |
| 220 } | 203 } |
| 221 | 204 |
| 222 void ThreadProxy::ReleaseOutputSurface() { | 205 void ThreadProxy::ReleaseOutputSurface() { |
| 223 DCHECK(IsMainThread()); | 206 DCHECK(IsMainThread()); |
| 224 DCHECK(layer_tree_host()->output_surface_lost()); | 207 DCHECK(layer_tree_host()->output_surface_lost()); |
| 225 | 208 |
| 226 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 209 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 227 CompletionEvent completion; | 210 main().channel_main->ReleaseOutputSurfaceOnImpl(); |
| 228 Proxy::ImplThreadTaskRunner()->PostTask( | |
| 229 FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread, | |
| 230 impl_thread_weak_ptr_, &completion)); | |
| 231 completion.Wait(); | |
| 232 } | 211 } |
| 233 | 212 |
| 234 void ThreadProxy::DidInitializeOutputSurface( | 213 void ThreadProxy::DidInitializeOutputSurface( |
| 235 bool success, | 214 bool success, |
| 236 const RendererCapabilities& capabilities) { | 215 const RendererCapabilities& capabilities) { |
| 237 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); | 216 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); |
| 238 DCHECK(IsMainThread()); | 217 DCHECK(IsMainThread()); |
| 239 | 218 |
| 240 if (!success) { | 219 if (!success) { |
| 241 layer_tree_host()->DidFailToInitializeOutputSurface(); | 220 layer_tree_host()->DidFailToInitializeOutputSurface(); |
| 242 return; | 221 return; |
| 243 } | 222 } |
| 244 main().renderer_capabilities_main_thread_copy = capabilities; | 223 main().renderer_capabilities_main_thread_copy = capabilities; |
| 245 layer_tree_host()->DidInitializeOutputSurface(); | 224 layer_tree_host()->DidInitializeOutputSurface(); |
| 246 } | 225 } |
| 247 | 226 |
| 248 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( | 227 void ThreadProxy::SetRendererCapabilitiesMainCopy( |
| 249 const RendererCapabilities& capabilities) { | 228 const RendererCapabilities& capabilities) { |
| 250 main().renderer_capabilities_main_thread_copy = capabilities; | 229 main().renderer_capabilities_main_thread_copy = capabilities; |
| 251 } | 230 } |
| 252 | 231 |
| 253 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( | 232 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( |
| 254 CommitPipelineStage required_stage) { | 233 CommitPipelineStage required_stage) { |
| 255 DCHECK(IsMainThread()); | 234 DCHECK(IsMainThread()); |
| 256 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); | 235 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); |
| 257 bool already_posted = | 236 bool already_posted = |
| 258 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; | 237 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return; | 290 return; |
| 312 } | 291 } |
| 313 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { | 292 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { |
| 314 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", | 293 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", |
| 315 TRACE_EVENT_SCOPE_THREAD); | 294 TRACE_EVENT_SCOPE_THREAD); |
| 316 } | 295 } |
| 317 } | 296 } |
| 318 | 297 |
| 319 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 298 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
| 320 DCHECK(IsImplThread()); | 299 DCHECK(IsImplThread()); |
| 321 Proxy::MainThreadTaskRunner()->PostTask( | 300 impl().channel_impl->SetRendererCapabilitiesMainCopy( |
| 322 FROM_HERE, | 301 impl() |
| 323 base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, | 302 .layer_tree_host_impl->GetRendererCapabilities() |
| 324 main_thread_weak_ptr_, | 303 .MainThreadCapabilities()); |
| 325 impl() | |
| 326 .layer_tree_host_impl->GetRendererCapabilities() | |
| 327 .MainThreadCapabilities())); | |
| 328 } | 304 } |
| 329 | 305 |
| 330 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 306 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 331 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 307 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 332 DCHECK(IsImplThread()); | 308 DCHECK(IsImplThread()); |
| 333 Proxy::MainThreadTaskRunner()->PostTask( | 309 impl().channel_impl->DidLoseOutputSurface(); |
| 334 FROM_HERE, | |
| 335 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); | |
| 336 impl().scheduler->DidLoseOutputSurface(); | 310 impl().scheduler->DidLoseOutputSurface(); |
| 337 } | 311 } |
| 338 | 312 |
| 339 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 313 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 340 base::TimeDelta interval) { | 314 base::TimeDelta interval) { |
| 341 impl().scheduler->CommitVSyncParameters(timebase, interval); | 315 impl().scheduler->CommitVSyncParameters(timebase, interval); |
| 342 } | 316 } |
| 343 | 317 |
| 344 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 318 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 345 impl().scheduler->SetEstimatedParentDrawTime(draw_time); | 319 impl().scheduler->SetEstimatedParentDrawTime(draw_time); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // In tests the layer tree is destroyed after the scheduler is. | 379 // In tests the layer tree is destroyed after the scheduler is. |
| 406 if (impl().scheduler) | 380 if (impl().scheduler) |
| 407 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); | 381 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); |
| 408 } | 382 } |
| 409 | 383 |
| 410 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 384 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 411 scoped_ptr<AnimationEventsVector> events) { | 385 scoped_ptr<AnimationEventsVector> events) { |
| 412 TRACE_EVENT0("cc", | 386 TRACE_EVENT0("cc", |
| 413 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 387 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| 414 DCHECK(IsImplThread()); | 388 DCHECK(IsImplThread()); |
| 415 Proxy::MainThreadTaskRunner()->PostTask( | 389 impl().channel_impl->SetAnimationEvents(events.Pass()); |
| 416 FROM_HERE, | |
| 417 base::Bind(&ThreadProxy::SetAnimationEvents, | |
| 418 main_thread_weak_ptr_, | |
| 419 base::Passed(&events))); | |
| 420 } | 390 } |
| 421 | 391 |
| 422 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } | 392 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } |
| 423 | 393 |
| 424 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 394 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
| 425 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); | 395 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); |
| 426 DCHECK(IsMainThread()); | 396 DCHECK(IsMainThread()); |
| 427 Proxy::ImplThreadTaskRunner()->PostTask( | 397 Proxy::ImplThreadTaskRunner()->PostTask( |
| 428 FROM_HERE, | 398 FROM_HERE, |
| 429 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, | 399 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 441 DCHECK(IsMainThread()); | 411 DCHECK(IsMainThread()); |
| 442 if (main().defer_commits == defer_commits) | 412 if (main().defer_commits == defer_commits) |
| 443 return; | 413 return; |
| 444 | 414 |
| 445 main().defer_commits = defer_commits; | 415 main().defer_commits = defer_commits; |
| 446 if (main().defer_commits) | 416 if (main().defer_commits) |
| 447 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 417 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| 448 else | 418 else |
| 449 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 419 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| 450 | 420 |
| 451 Proxy::ImplThreadTaskRunner()->PostTask( | 421 main().channel_main->SetDeferCommitsOnImpl(defer_commits); |
| 452 FROM_HERE, | |
| 453 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread, | |
| 454 impl_thread_weak_ptr_, | |
| 455 defer_commits)); | |
| 456 } | 422 } |
| 457 | 423 |
| 458 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { | 424 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) { |
| 459 DCHECK(IsImplThread()); | 425 DCHECK(IsImplThread()); |
| 460 impl().scheduler->SetDeferCommits(defer_commits); | 426 impl().scheduler->SetDeferCommits(defer_commits); |
| 461 } | 427 } |
| 462 | 428 |
| 463 bool ThreadProxy::CommitRequested() const { | 429 bool ThreadProxy::CommitRequested() const { |
| 464 DCHECK(IsMainThread()); | 430 DCHECK(IsMainThread()); |
| 465 // TODO(skyostil): Split this into something like CommitRequested() and | 431 // TODO(skyostil): Split this into something like CommitRequested() and |
| 466 // CommitInProgress(). | 432 // CommitInProgress(). |
| 467 return main().current_pipeline_stage != NO_PIPELINE_STAGE || | 433 return main().current_pipeline_stage != NO_PIPELINE_STAGE || |
| 468 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; | 434 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 491 } | 457 } |
| 492 | 458 |
| 493 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { | 459 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
| 494 DCHECK(IsImplThread()); | 460 DCHECK(IsImplThread()); |
| 495 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); | 461 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); |
| 496 SetNeedsRedrawOnImplThread(); | 462 SetNeedsRedrawOnImplThread(); |
| 497 } | 463 } |
| 498 | 464 |
| 499 void ThreadProxy::MainThreadHasStoppedFlinging() { | 465 void ThreadProxy::MainThreadHasStoppedFlinging() { |
| 500 DCHECK(IsMainThread()); | 466 DCHECK(IsMainThread()); |
| 501 Proxy::ImplThreadTaskRunner()->PostTask( | 467 main().channel_main->MainThreadHasStoppedFlingingOnImpl(); |
| 502 FROM_HERE, | |
| 503 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, | |
| 504 impl_thread_weak_ptr_)); | |
| 505 } | 468 } |
| 506 | 469 |
| 507 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { | 470 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { |
| 508 DCHECK(IsImplThread()); | 471 DCHECK(IsImplThread()); |
| 509 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); | 472 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); |
| 510 } | 473 } |
| 511 | 474 |
| 512 void ThreadProxy::NotifyInputThrottledUntilCommit() { | 475 void ThreadProxy::NotifyInputThrottledUntilCommit() { |
| 513 DCHECK(IsMainThread()); | 476 DCHECK(IsMainThread()); |
| 514 Proxy::ImplThreadTaskRunner()->PostTask( | 477 main().channel_main->SetInputThrottledUntilCommitOnImpl(true); |
| 515 FROM_HERE, | |
| 516 base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread, | |
| 517 impl_thread_weak_ptr_, | |
| 518 true)); | |
| 519 } | 478 } |
| 520 | 479 |
| 521 void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { | 480 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| 522 DCHECK(IsImplThread()); | 481 DCHECK(IsImplThread()); |
| 523 if (is_throttled == impl().input_throttled_until_commit) | 482 if (is_throttled == impl().input_throttled_until_commit) |
| 524 return; | 483 return; |
| 525 impl().input_throttled_until_commit = is_throttled; | 484 impl().input_throttled_until_commit = is_throttled; |
| 526 RenewTreePriority(); | 485 RenewTreePriority(); |
| 527 } | 486 } |
| 528 | 487 |
| 529 LayerTreeHost* ThreadProxy::layer_tree_host() { | 488 LayerTreeHost* ThreadProxy::layer_tree_host() { |
| 530 return blocked_main().layer_tree_host; | 489 return blocked_main().layer_tree_host; |
| 531 } | 490 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 546 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
| 588 DCHECK(IsMainThread()); | 547 DCHECK(IsMainThread()); |
| 589 DCHECK(main().started); | 548 DCHECK(main().started); |
| 590 | 549 |
| 591 // Synchronously finishes pending GL operations and deletes the impl. | 550 // Synchronously finishes pending GL operations and deletes the impl. |
| 592 // The two steps are done as separate post tasks, so that tasks posted | 551 // The two steps are done as separate post tasks, so that tasks posted |
| 593 // by the GL implementation due to the Finish can be executed by the | 552 // by the GL implementation due to the Finish can be executed by the |
| 594 // renderer before shutting it down. | 553 // renderer before shutting it down. |
| 595 { | 554 { |
| 596 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 555 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 597 | 556 main().channel_main->FinishGLOnImpl(); |
| 598 CompletionEvent completion; | |
| 599 Proxy::ImplThreadTaskRunner()->PostTask( | |
| 600 FROM_HERE, | |
| 601 base::Bind(&ThreadProxy::FinishGLOnImplThread, | |
| 602 impl_thread_weak_ptr_, | |
| 603 &completion)); | |
| 604 completion.Wait(); | |
| 605 } | 557 } |
| 606 { | 558 { |
| 607 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 559 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 608 | 560 |
| 609 CompletionEvent completion; | 561 CompletionEvent completion; |
| 610 Proxy::ImplThreadTaskRunner()->PostTask( | 562 Proxy::ImplThreadTaskRunner()->PostTask( |
| 611 FROM_HERE, | 563 FROM_HERE, |
| 612 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | 564 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, |
| 613 impl_thread_weak_ptr_, | 565 impl_thread_weak_ptr_, |
| 614 &completion)); | 566 &completion)); |
| 615 completion.Wait(); | 567 completion.Wait(); |
| 616 } | 568 } |
| 617 | 569 |
| 618 main().weak_factory.InvalidateWeakPtrs(); | 570 main().weak_factory.InvalidateWeakPtrs(); |
| 619 blocked_main().layer_tree_host = NULL; | 571 blocked_main().layer_tree_host = NULL; |
| 620 main().started = false; | 572 main().started = false; |
| 621 } | 573 } |
| 622 | 574 |
| 623 bool ThreadProxy::SupportsImplScrolling() const { | 575 bool ThreadProxy::SupportsImplScrolling() const { |
| 624 return true; | 576 return true; |
| 625 } | 577 } |
| 626 | 578 |
| 627 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { | 579 void ThreadProxy::FinishAllRenderingOnImpl() { |
| 628 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 580 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 629 DCHECK(IsImplThread()); | 581 DCHECK(IsImplThread()); |
| 630 impl().layer_tree_host_impl->FinishAllRendering(); | 582 impl().layer_tree_host_impl->FinishAllRendering(); |
| 631 completion->Signal(); | |
| 632 } | 583 } |
| 633 | 584 |
| 634 void ThreadProxy::ScheduledActionSendBeginMainFrame() { | 585 void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 635 unsigned int begin_frame_id = nextBeginFrameId++; | 586 unsigned int begin_frame_id = nextBeginFrameId++; |
| 636 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 587 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 637 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 588 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
| 638 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 589 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 639 new BeginMainFrameAndCommitState); | 590 new BeginMainFrameAndCommitState); |
| 640 begin_main_frame_state->begin_frame_id = begin_frame_id; | 591 begin_main_frame_state->begin_frame_id = begin_frame_id; |
| 641 begin_main_frame_state->begin_frame_args = | 592 begin_main_frame_state->begin_frame_args = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 653 Proxy::MainThreadTaskRunner()->PostTask( | 604 Proxy::MainThreadTaskRunner()->PostTask( |
| 654 FROM_HERE, | 605 FROM_HERE, |
| 655 base::Bind(&ThreadProxy::BeginMainFrame, | 606 base::Bind(&ThreadProxy::BeginMainFrame, |
| 656 main_thread_weak_ptr_, | 607 main_thread_weak_ptr_, |
| 657 base::Passed(&begin_main_frame_state))); | 608 base::Passed(&begin_main_frame_state))); |
| 658 devtools_instrumentation::DidRequestMainThreadFrame( | 609 devtools_instrumentation::DidRequestMainThreadFrame( |
| 659 impl().layer_tree_host_id); | 610 impl().layer_tree_host_id); |
| 660 } | 611 } |
| 661 | 612 |
| 662 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 613 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 663 Proxy::MainThreadTaskRunner()->PostTask( | 614 impl().channel_impl->BeginMainFrameNotExpectedSoon(); |
| 664 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon, | |
| 665 main_thread_weak_ptr_)); | |
| 666 } | 615 } |
| 667 | 616 |
| 668 void ThreadProxy::BeginMainFrame( | 617 void ThreadProxy::BeginMainFrame( |
| 669 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 618 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 670 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 619 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 671 benchmark_instrumentation::kDoBeginFrame, | 620 benchmark_instrumentation::kDoBeginFrame, |
| 672 begin_main_frame_state->begin_frame_id); | 621 begin_main_frame_state->begin_frame_id); |
| 673 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 622 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 674 DCHECK(IsMainThread()); | 623 DCHECK(IsMainThread()); |
| 675 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); | 624 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 void ThreadProxy::BeginMainFrameAbortedOnImplThread( | 768 void ThreadProxy::BeginMainFrameAbortedOnImplThread( |
| 820 CommitEarlyOutReason reason) { | 769 CommitEarlyOutReason reason) { |
| 821 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 770 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
| 822 CommitEarlyOutReasonToString(reason)); | 771 CommitEarlyOutReasonToString(reason)); |
| 823 DCHECK(IsImplThread()); | 772 DCHECK(IsImplThread()); |
| 824 DCHECK(impl().scheduler); | 773 DCHECK(impl().scheduler); |
| 825 DCHECK(impl().scheduler->CommitPending()); | 774 DCHECK(impl().scheduler->CommitPending()); |
| 826 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 775 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| 827 | 776 |
| 828 if (CommitEarlyOutHandledCommit(reason)) { | 777 if (CommitEarlyOutHandledCommit(reason)) { |
| 829 SetInputThrottledUntilCommitOnImplThread(false); | 778 SetInputThrottledUntilCommitOnImpl(false); |
| 830 impl().last_processed_begin_main_frame_args = | 779 impl().last_processed_begin_main_frame_args = |
| 831 impl().last_begin_main_frame_args; | 780 impl().last_begin_main_frame_args; |
| 832 } | 781 } |
| 833 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); | 782 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); |
| 834 impl().scheduler->BeginMainFrameAborted(reason); | 783 impl().scheduler->BeginMainFrameAborted(reason); |
| 835 } | 784 } |
| 836 | 785 |
| 837 void ThreadProxy::ScheduledActionAnimate() { | 786 void ThreadProxy::ScheduledActionAnimate() { |
| 838 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 787 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
| 839 DCHECK(IsImplThread()); | 788 DCHECK(IsImplThread()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 868 impl().commit_completion_event->Signal(); | 817 impl().commit_completion_event->Signal(); |
| 869 impl().commit_completion_event = NULL; | 818 impl().commit_completion_event = NULL; |
| 870 } | 819 } |
| 871 | 820 |
| 872 impl().scheduler->DidCommit(); | 821 impl().scheduler->DidCommit(); |
| 873 | 822 |
| 874 // Delay this step until afer the main thread has been released as it's | 823 // Delay this step until afer the main thread has been released as it's |
| 875 // often a good bit of work to update the tree and prepare the new frame. | 824 // often a good bit of work to update the tree and prepare the new frame. |
| 876 impl().layer_tree_host_impl->CommitComplete(); | 825 impl().layer_tree_host_impl->CommitComplete(); |
| 877 | 826 |
| 878 SetInputThrottledUntilCommitOnImplThread(false); | 827 SetInputThrottledUntilCommitOnImpl(false); |
| 879 | 828 |
| 880 impl().next_frame_is_newly_committed_frame = true; | 829 impl().next_frame_is_newly_committed_frame = true; |
| 881 } | 830 } |
| 882 | 831 |
| 883 void ThreadProxy::ScheduledActionActivateSyncTree() { | 832 void ThreadProxy::ScheduledActionActivateSyncTree() { |
| 884 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); | 833 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); |
| 885 DCHECK(IsImplThread()); | 834 DCHECK(IsImplThread()); |
| 886 impl().layer_tree_host_impl->ActivateSyncTree(); | 835 impl().layer_tree_host_impl->ActivateSyncTree(); |
| 887 } | 836 } |
| 888 | 837 |
| 889 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 838 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 890 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); | 839 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); |
| 891 DCHECK(IsImplThread()); | 840 DCHECK(IsImplThread()); |
| 892 Proxy::MainThreadTaskRunner()->PostTask( | 841 impl().channel_impl->RequestNewOutputSurface(); |
| 893 FROM_HERE, | |
| 894 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_)); | |
| 895 } | 842 } |
| 896 | 843 |
| 897 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 844 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 898 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 845 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 899 DrawResult result; | 846 DrawResult result; |
| 900 | 847 |
| 901 DCHECK(IsImplThread()); | 848 DCHECK(IsImplThread()); |
| 902 DCHECK(impl().layer_tree_host_impl.get()); | 849 DCHECK(impl().layer_tree_host_impl.get()); |
| 903 | 850 |
| 904 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 851 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 887 |
| 941 bool start_ready_animations = draw_frame; | 888 bool start_ready_animations = draw_frame; |
| 942 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); | 889 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); |
| 943 | 890 |
| 944 if (draw_frame) | 891 if (draw_frame) |
| 945 impl().layer_tree_host_impl->SwapBuffers(frame); | 892 impl().layer_tree_host_impl->SwapBuffers(frame); |
| 946 | 893 |
| 947 // Tell the main thread that the the newly-commited frame was drawn. | 894 // Tell the main thread that the the newly-commited frame was drawn. |
| 948 if (impl().next_frame_is_newly_committed_frame) { | 895 if (impl().next_frame_is_newly_committed_frame) { |
| 949 impl().next_frame_is_newly_committed_frame = false; | 896 impl().next_frame_is_newly_committed_frame = false; |
| 950 Proxy::MainThreadTaskRunner()->PostTask( | 897 impl().channel_impl->DidCommitAndDrawFrame(); |
| 951 FROM_HERE, | |
| 952 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | |
| 953 } | 898 } |
| 954 | 899 |
| 955 DCHECK_NE(INVALID_RESULT, result); | 900 DCHECK_NE(INVALID_RESULT, result); |
| 956 return result; | 901 return result; |
| 957 } | 902 } |
| 958 | 903 |
| 959 void ThreadProxy::ScheduledActionPrepareTiles() { | 904 void ThreadProxy::ScheduledActionPrepareTiles() { |
| 960 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); | 905 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); |
| 961 impl().layer_tree_host_impl->PrepareTiles(); | 906 impl().layer_tree_host_impl->PrepareTiles(); |
| 962 } | 907 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, | 977 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, |
| 1033 impl().rendering_stats_instrumentation)); | 978 impl().rendering_stats_instrumentation)); |
| 1034 | 979 |
| 1035 impl().scheduler = Scheduler::Create( | 980 impl().scheduler = Scheduler::Create( |
| 1036 this, scheduler_settings, impl().layer_tree_host_id, | 981 this, scheduler_settings, impl().layer_tree_host_id, |
| 1037 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), | 982 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), |
| 1038 compositor_timing_history.Pass()); | 983 compositor_timing_history.Pass()); |
| 1039 | 984 |
| 1040 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); | 985 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); |
| 1041 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 986 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| 987 threaded_channel_->InitImplThreadWeakPtr(); |
| 1042 completion->Signal(); | 988 completion->Signal(); |
| 1043 } | 989 } |
| 1044 | 990 |
| 1045 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 991 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { |
| 1046 OutputSurface* output_surface) { | |
| 1047 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); | 992 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| 1048 DCHECK(IsImplThread()); | 993 DCHECK(IsImplThread()); |
| 1049 | 994 |
| 1050 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); | 995 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| 1051 bool success = host_impl->InitializeRenderer(output_surface); | 996 bool success = host_impl->InitializeRenderer(output_surface); |
| 1052 RendererCapabilities capabilities; | 997 RendererCapabilities capabilities; |
| 1053 if (success) { | 998 if (success) { |
| 1054 capabilities = | 999 capabilities = |
| 1055 host_impl->GetRendererCapabilities().MainThreadCapabilities(); | 1000 host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| 1056 } | 1001 } |
| 1057 | 1002 |
| 1058 Proxy::MainThreadTaskRunner()->PostTask( | 1003 impl().channel_impl->DidInitializeOutputSurface(success, capabilities); |
| 1059 FROM_HERE, | |
| 1060 base::Bind(&ThreadProxy::DidInitializeOutputSurface, | |
| 1061 main_thread_weak_ptr_, | |
| 1062 success, | |
| 1063 capabilities)); | |
| 1064 | 1004 |
| 1065 if (success) | 1005 if (success) |
| 1066 impl().scheduler->DidCreateAndInitializeOutputSurface(); | 1006 impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| 1067 } | 1007 } |
| 1068 | 1008 |
| 1069 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( | 1009 void ThreadProxy::ReleaseOutputSurfaceOnImpl() { |
| 1070 CompletionEvent* completion) { | |
| 1071 DCHECK(IsImplThread()); | 1010 DCHECK(IsImplThread()); |
| 1072 | 1011 |
| 1073 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call | 1012 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call |
| 1074 // LayerTreeHost::DidLoseOutputSurface since it already knows. | 1013 // LayerTreeHost::DidLoseOutputSurface since it already knows. |
| 1075 impl().scheduler->DidLoseOutputSurface(); | 1014 impl().scheduler->DidLoseOutputSurface(); |
| 1076 impl().layer_tree_host_impl->ReleaseOutputSurface(); | 1015 impl().layer_tree_host_impl->ReleaseOutputSurface(); |
| 1077 completion->Signal(); | |
| 1078 } | 1016 } |
| 1079 | 1017 |
| 1080 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | 1018 void ThreadProxy::FinishGLOnImpl() { |
| 1081 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 1019 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1082 DCHECK(IsImplThread()); | 1020 DCHECK(IsImplThread()); |
| 1083 if (impl().layer_tree_host_impl->output_surface()) { | 1021 if (impl().layer_tree_host_impl->output_surface()) { |
| 1084 ContextProvider* context_provider = | 1022 ContextProvider* context_provider = |
| 1085 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1023 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1086 if (context_provider) | 1024 if (context_provider) |
| 1087 context_provider->ContextGL()->Finish(); | 1025 context_provider->ContextGL()->Finish(); |
| 1088 } | 1026 } |
| 1089 completion->Signal(); | |
| 1090 } | 1027 } |
| 1091 | 1028 |
| 1092 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1029 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1093 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1030 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1094 DCHECK(IsImplThread()); | 1031 DCHECK(IsImplThread()); |
| 1095 DCHECK(IsMainThreadBlocked()); | 1032 DCHECK(IsMainThreadBlocked()); |
| 1096 impl().scheduler = nullptr; | 1033 impl().scheduler = nullptr; |
| 1097 impl().external_begin_frame_source = nullptr; | 1034 impl().external_begin_frame_source = nullptr; |
| 1098 impl().layer_tree_host_impl = nullptr; | 1035 impl().layer_tree_host_impl = nullptr; |
| 1099 impl().weak_factory.InvalidateWeakPtrs(); | 1036 impl().weak_factory.InvalidateWeakPtrs(); |
| 1037 threaded_channel_->InvalidateImplThreadWeakPtr(); |
| 1100 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 1038 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
| 1101 // holding while still on the compositor thread. This also ensures any | 1039 // holding while still on the compositor thread. This also ensures any |
| 1102 // callbacks holding a ThreadProxy pointer are cancelled. | 1040 // callbacks holding a ThreadProxy pointer are cancelled. |
| 1103 impl().smoothness_priority_expiration_notifier.Shutdown(); | 1041 impl().smoothness_priority_expiration_notifier.Shutdown(); |
| 1104 completion->Signal(); | 1042 completion->Signal(); |
| 1105 } | 1043 } |
| 1106 | 1044 |
| 1107 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() | 1045 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() |
| 1108 : memory_allocation_limit_bytes(0), | 1046 : memory_allocation_limit_bytes(0), |
| 1109 evicted_ui_resources(false) {} | 1047 evicted_ui_resources(false) {} |
| 1110 | 1048 |
| 1111 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} | 1049 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} |
| 1112 | 1050 |
| 1113 bool ThreadProxy::MainFrameWillHappenForTesting() { | 1051 bool ThreadProxy::MainFrameWillHappenForTesting() { |
| 1114 DCHECK(IsMainThread()); | 1052 DCHECK(IsMainThread()); |
| 1115 CompletionEvent completion; | |
| 1116 bool main_frame_will_happen = false; | 1053 bool main_frame_will_happen = false; |
| 1117 { | 1054 { |
| 1118 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 1055 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 1119 Proxy::ImplThreadTaskRunner()->PostTask( | 1056 main().channel_main->MainFrameWillHappenOnImplForTesting( |
| 1120 FROM_HERE, | 1057 &main_frame_will_happen); |
| 1121 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, | |
| 1122 impl_thread_weak_ptr_, | |
| 1123 &completion, | |
| 1124 &main_frame_will_happen)); | |
| 1125 completion.Wait(); | |
| 1126 } | 1058 } |
| 1127 return main_frame_will_happen; | 1059 return main_frame_will_happen; |
| 1128 } | 1060 } |
| 1129 | 1061 |
| 1130 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 1062 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 1131 NOTREACHED() << "Only used by SingleThreadProxy"; | 1063 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 1132 } | 1064 } |
| 1133 | 1065 |
| 1134 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( | 1066 void ThreadProxy::MainFrameWillHappenOnImplForTesting( |
| 1135 CompletionEvent* completion, | |
| 1136 bool* main_frame_will_happen) { | 1067 bool* main_frame_will_happen) { |
| 1137 DCHECK(IsImplThread()); | 1068 DCHECK(IsImplThread()); |
| 1138 if (impl().layer_tree_host_impl->output_surface()) { | 1069 if (impl().layer_tree_host_impl->output_surface()) { |
| 1139 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); | 1070 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); |
| 1140 } else { | 1071 } else { |
| 1141 *main_frame_will_happen = false; | 1072 *main_frame_will_happen = false; |
| 1142 } | 1073 } |
| 1143 completion->Signal(); | |
| 1144 } | 1074 } |
| 1145 | 1075 |
| 1146 void ThreadProxy::RenewTreePriority() { | 1076 void ThreadProxy::RenewTreePriority() { |
| 1147 DCHECK(IsImplThread()); | 1077 DCHECK(IsImplThread()); |
| 1148 bool smoothness_takes_priority = | 1078 bool smoothness_takes_priority = |
| 1149 impl().layer_tree_host_impl->pinch_gesture_active() || | 1079 impl().layer_tree_host_impl->pinch_gesture_active() || |
| 1150 impl().layer_tree_host_impl->page_scale_animation_active() || | 1080 impl().layer_tree_host_impl->page_scale_animation_active() || |
| 1151 impl().layer_tree_host_impl->IsActivelyScrolling(); | 1081 impl().layer_tree_host_impl->IsActivelyScrolling(); |
| 1152 | 1082 |
| 1153 // Schedule expiration if smoothness currently takes priority. | 1083 // Schedule expiration if smoothness currently takes priority. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 impl().scheduler->WillPrepareTiles(); | 1149 impl().scheduler->WillPrepareTiles(); |
| 1220 } | 1150 } |
| 1221 | 1151 |
| 1222 void ThreadProxy::DidPrepareTiles() { | 1152 void ThreadProxy::DidPrepareTiles() { |
| 1223 DCHECK(IsImplThread()); | 1153 DCHECK(IsImplThread()); |
| 1224 impl().scheduler->DidPrepareTiles(); | 1154 impl().scheduler->DidPrepareTiles(); |
| 1225 } | 1155 } |
| 1226 | 1156 |
| 1227 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1157 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1228 DCHECK(IsImplThread()); | 1158 DCHECK(IsImplThread()); |
| 1229 Proxy::MainThreadTaskRunner()->PostTask( | 1159 impl().channel_impl->DidCompletePageScaleAnimation(); |
| 1230 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | |
| 1231 main_thread_weak_ptr_)); | |
| 1232 } | 1160 } |
| 1233 | 1161 |
| 1234 void ThreadProxy::OnDrawForOutputSurface() { | 1162 void ThreadProxy::OnDrawForOutputSurface() { |
| 1235 DCHECK(IsImplThread()); | 1163 DCHECK(IsImplThread()); |
| 1236 impl().scheduler->OnDrawForOutputSurface(); | 1164 impl().scheduler->OnDrawForOutputSurface(); |
| 1237 } | 1165 } |
| 1238 | 1166 |
| 1239 void ThreadProxy::PostFrameTimingEventsOnImplThread( | 1167 void ThreadProxy::PostFrameTimingEventsOnImplThread( |
| 1240 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1168 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1241 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1169 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1242 DCHECK(IsImplThread()); | 1170 DCHECK(IsImplThread()); |
| 1243 Proxy::MainThreadTaskRunner()->PostTask( | 1171 impl().channel_impl->PostFrameTimingEventsToMain(composite_events.Pass(), |
| 1244 FROM_HERE, | 1172 main_frame_events.Pass()); |
| 1245 base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_, | |
| 1246 base::Passed(composite_events.Pass()), | |
| 1247 base::Passed(main_frame_events.Pass()))); | |
| 1248 } | 1173 } |
| 1249 | 1174 |
| 1250 void ThreadProxy::PostFrameTimingEvents( | 1175 void ThreadProxy::PostFrameTimingEventsToMain( |
| 1251 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1176 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1252 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1177 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1253 DCHECK(IsMainThread()); | 1178 DCHECK(IsMainThread()); |
| 1254 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), | 1179 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), |
| 1255 main_frame_events.Pass()); | 1180 main_frame_events.Pass()); |
| 1256 } | 1181 } |
| 1257 | 1182 |
| 1258 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1183 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
| 1259 return main_thread_weak_ptr_; | 1184 return main_thread_weak_ptr_; |
| 1260 } | 1185 } |
| 1261 | 1186 |
| 1262 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1187 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
| 1263 return impl_thread_weak_ptr_; | 1188 return impl_thread_weak_ptr_; |
| 1264 } | 1189 } |
| 1265 | 1190 |
| 1266 } // namespace cc | 1191 } // namespace cc |
| OLD | NEW |