| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proxy_impl.h" | 5 #include "cc/trees/proxy_impl.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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "base/trace_event/trace_event_synthetic_delay.h" | 14 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 15 #include "cc/debug/benchmark_instrumentation.h" | 15 #include "cc/debug/benchmark_instrumentation.h" |
| 16 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
| 17 #include "cc/input/browser_controls_offset_manager.h" | 17 #include "cc/input/browser_controls_offset_manager.h" |
| 18 #include "cc/output/compositor_frame_sink.h" | 18 #include "cc/output/compositor_frame_sink.h" |
| 19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
| 20 #include "cc/scheduler/compositor_timing_history.h" | 20 #include "cc/scheduler/compositor_timing_history.h" |
| 21 #include "cc/scheduler/delay_based_time_source.h" | 21 #include "cc/scheduler/delay_based_time_source.h" |
| 22 #include "cc/trees/layer_tree_host_in_process.h" | 22 #include "cc/trees/layer_tree_host_in_process.h" |
| 23 #include "cc/trees/layer_tree_impl.h" | 23 #include "cc/trees/layer_tree_impl.h" |
| 24 #include "cc/trees/mutator_host.h" | 24 #include "cc/trees/mutator_host.h" |
| 25 #include "cc/trees/proxy_main.h" |
| 25 #include "cc/trees/task_runner_provider.h" | 26 #include "cc/trees/task_runner_provider.h" |
| 26 #include "gpu/command_buffer/client/gles2_interface.h" | 27 #include "gpu/command_buffer/client/gles2_interface.h" |
| 27 | 28 |
| 28 namespace cc { | 29 namespace cc { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // Measured in seconds. | 33 // Measured in seconds. |
| 33 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 34 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 34 | 35 |
| 35 unsigned int nextBeginFrameId = 0; | 36 unsigned int nextBeginFrameId = 0; |
| 36 | 37 |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 ProxyImpl::ProxyImpl(ChannelImpl* channel_impl, | 40 ProxyImpl::ProxyImpl(base::WeakPtr<ProxyMain> proxy_main_weak_ptr, |
| 40 LayerTreeHostInProcess* layer_tree_host, | 41 LayerTreeHostInProcess* layer_tree_host, |
| 41 TaskRunnerProvider* task_runner_provider) | 42 TaskRunnerProvider* task_runner_provider) |
| 42 : layer_tree_host_id_(layer_tree_host->GetId()), | 43 : layer_tree_host_id_(layer_tree_host->GetId()), |
| 43 commit_completion_waits_for_activation_(false), | 44 commit_completion_waits_for_activation_(false), |
| 44 commit_completion_event_(nullptr), | 45 commit_completion_event_(nullptr), |
| 45 activation_completion_event_(nullptr), | 46 activation_completion_event_(nullptr), |
| 46 next_frame_is_newly_committed_frame_(false), | 47 next_frame_is_newly_committed_frame_(false), |
| 47 inside_draw_(false), | 48 inside_draw_(false), |
| 48 input_throttled_until_commit_(false), | 49 input_throttled_until_commit_(false), |
| 49 task_runner_provider_(task_runner_provider), | 50 task_runner_provider_(task_runner_provider), |
| 50 smoothness_priority_expiration_notifier_( | 51 smoothness_priority_expiration_notifier_( |
| 51 task_runner_provider->ImplThreadTaskRunner(), | 52 task_runner_provider->ImplThreadTaskRunner(), |
| 52 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), | 53 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), |
| 53 base::TimeDelta::FromSecondsD( | 54 base::TimeDelta::FromSecondsD( |
| 54 kSmoothnessTakesPriorityExpirationDelay)), | 55 kSmoothnessTakesPriorityExpirationDelay)), |
| 55 rendering_stats_instrumentation_( | 56 rendering_stats_instrumentation_( |
| 56 layer_tree_host->rendering_stats_instrumentation()), | 57 layer_tree_host->rendering_stats_instrumentation()), |
| 57 channel_impl_(channel_impl) { | 58 proxy_main_weak_ptr_(proxy_main_weak_ptr) { |
| 58 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); | 59 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); |
| 59 DCHECK(IsImplThread()); | 60 DCHECK(IsImplThread()); |
| 60 DCHECK(IsMainThreadBlocked()); | 61 DCHECK(IsMainThreadBlocked()); |
| 61 | 62 |
| 62 // Double checking we set this correctly since double->int truncations are | 63 // Double checking we set this correctly since double->int truncations are |
| 63 // silent and have been done mistakenly: crbug.com/568120. | 64 // silent and have been done mistakenly: crbug.com/568120. |
| 64 DCHECK(!smoothness_priority_expiration_notifier_.delay().is_zero()); | 65 DCHECK(!smoothness_priority_expiration_notifier_.delay().is_zero()); |
| 65 | 66 |
| 66 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); | 67 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); |
| 67 const LayerTreeSettings& settings = layer_tree_host->GetSettings(); | 68 const LayerTreeSettings& settings = layer_tree_host->GetSettings(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 constraints, current, animate); | 121 constraints, current, animate); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void ProxyImpl::InitializeCompositorFrameSinkOnImpl( | 124 void ProxyImpl::InitializeCompositorFrameSinkOnImpl( |
| 124 CompositorFrameSink* compositor_frame_sink) { | 125 CompositorFrameSink* compositor_frame_sink) { |
| 125 TRACE_EVENT0("cc", "ProxyImpl::InitializeCompositorFrameSinkOnImplThread"); | 126 TRACE_EVENT0("cc", "ProxyImpl::InitializeCompositorFrameSinkOnImplThread"); |
| 126 DCHECK(IsImplThread()); | 127 DCHECK(IsImplThread()); |
| 127 | 128 |
| 128 LayerTreeHostImpl* host_impl = layer_tree_host_impl_.get(); | 129 LayerTreeHostImpl* host_impl = layer_tree_host_impl_.get(); |
| 129 bool success = host_impl->InitializeRenderer(compositor_frame_sink); | 130 bool success = host_impl->InitializeRenderer(compositor_frame_sink); |
| 130 channel_impl_->DidInitializeCompositorFrameSink(success); | 131 MainThreadTaskRunner()->PostTask( |
| 132 FROM_HERE, base::Bind(&ProxyMain::DidInitializeCompositorFrameSink, |
| 133 proxy_main_weak_ptr_, success)); |
| 131 if (success) | 134 if (success) |
| 132 scheduler_->DidCreateAndInitializeCompositorFrameSink(); | 135 scheduler_->DidCreateAndInitializeCompositorFrameSink(); |
| 133 } | 136 } |
| 134 | 137 |
| 135 void ProxyImpl::MainThreadHasStoppedFlingingOnImpl() { | 138 void ProxyImpl::MainThreadHasStoppedFlingingOnImpl() { |
| 136 DCHECK(IsImplThread()); | 139 DCHECK(IsImplThread()); |
| 137 layer_tree_host_impl_->MainThreadHasStoppedFlinging(); | 140 layer_tree_host_impl_->MainThreadHasStoppedFlinging(); |
| 138 } | 141 } |
| 139 | 142 |
| 140 void ProxyImpl::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { | 143 void ProxyImpl::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 commit_completion_waits_for_activation_ = hold_commit_for_activation; | 251 commit_completion_waits_for_activation_ = hold_commit_for_activation; |
| 249 | 252 |
| 250 DCHECK(!blocked_main_commit().layer_tree_host); | 253 DCHECK(!blocked_main_commit().layer_tree_host); |
| 251 blocked_main_commit().layer_tree_host = layer_tree_host; | 254 blocked_main_commit().layer_tree_host = layer_tree_host; |
| 252 scheduler_->NotifyReadyToCommit(); | 255 scheduler_->NotifyReadyToCommit(); |
| 253 } | 256 } |
| 254 | 257 |
| 255 void ProxyImpl::DidLoseCompositorFrameSinkOnImplThread() { | 258 void ProxyImpl::DidLoseCompositorFrameSinkOnImplThread() { |
| 256 TRACE_EVENT0("cc", "ProxyImpl::DidLoseCompositorFrameSinkOnImplThread"); | 259 TRACE_EVENT0("cc", "ProxyImpl::DidLoseCompositorFrameSinkOnImplThread"); |
| 257 DCHECK(IsImplThread()); | 260 DCHECK(IsImplThread()); |
| 258 channel_impl_->DidLoseCompositorFrameSink(); | 261 MainThreadTaskRunner()->PostTask( |
| 262 FROM_HERE, |
| 263 base::Bind(&ProxyMain::DidLoseCompositorFrameSink, proxy_main_weak_ptr_)); |
| 259 scheduler_->DidLoseCompositorFrameSink(); | 264 scheduler_->DidLoseCompositorFrameSink(); |
| 260 } | 265 } |
| 261 | 266 |
| 262 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { | 267 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { |
| 263 // During shutdown, destroying the CompositorFrameSink may unset the | 268 // During shutdown, destroying the CompositorFrameSink may unset the |
| 264 // BeginFrameSource. | 269 // BeginFrameSource. |
| 265 if (scheduler_) { | 270 if (scheduler_) { |
| 266 // TODO(enne): this overrides any preexisting begin frame source. Those | 271 // TODO(enne): this overrides any preexisting begin frame source. Those |
| 267 // other sources will eventually be removed and this will be the only path. | 272 // other sources will eventually be removed and this will be the only path. |
| 268 scheduler_->SetBeginFrameSource(source); | 273 scheduler_->SetBeginFrameSource(source); |
| 269 } | 274 } |
| 270 } | 275 } |
| 271 | 276 |
| 272 void ProxyImpl::DidReceiveCompositorFrameAckOnImplThread() { | 277 void ProxyImpl::DidReceiveCompositorFrameAckOnImplThread() { |
| 273 TRACE_EVENT0("cc,benchmark", | 278 TRACE_EVENT0("cc,benchmark", |
| 274 "ProxyImpl::DidReceiveCompositorFrameAckOnImplThread"); | 279 "ProxyImpl::DidReceiveCompositorFrameAckOnImplThread"); |
| 275 DCHECK(IsImplThread()); | 280 DCHECK(IsImplThread()); |
| 276 scheduler_->DidReceiveCompositorFrameAck(); | 281 scheduler_->DidReceiveCompositorFrameAck(); |
| 277 channel_impl_->DidReceiveCompositorFrameAck(); | 282 MainThreadTaskRunner()->PostTask( |
| 283 FROM_HERE, base::Bind(&ProxyMain::DidReceiveCompositorFrameAck, |
| 284 proxy_main_weak_ptr_)); |
| 278 } | 285 } |
| 279 | 286 |
| 280 void ProxyImpl::OnCanDrawStateChanged(bool can_draw) { | 287 void ProxyImpl::OnCanDrawStateChanged(bool can_draw) { |
| 281 TRACE_EVENT1("cc", "ProxyImpl::OnCanDrawStateChanged", "can_draw", can_draw); | 288 TRACE_EVENT1("cc", "ProxyImpl::OnCanDrawStateChanged", "can_draw", can_draw); |
| 282 DCHECK(IsImplThread()); | 289 DCHECK(IsImplThread()); |
| 283 scheduler_->SetCanDraw(can_draw); | 290 scheduler_->SetCanDraw(can_draw); |
| 284 } | 291 } |
| 285 | 292 |
| 286 void ProxyImpl::NotifyReadyToActivate() { | 293 void ProxyImpl::NotifyReadyToActivate() { |
| 287 TRACE_EVENT0("cc", "ProxyImpl::NotifyReadyToActivate"); | 294 TRACE_EVENT0("cc", "ProxyImpl::NotifyReadyToActivate"); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 DCHECK(IsImplThread()); | 331 DCHECK(IsImplThread()); |
| 325 // In tests the layer tree is destroyed after the scheduler is. | 332 // In tests the layer tree is destroyed after the scheduler is. |
| 326 if (scheduler_) | 333 if (scheduler_) |
| 327 scheduler_->SetVideoNeedsBeginFrames(needs_begin_frames); | 334 scheduler_->SetVideoNeedsBeginFrames(needs_begin_frames); |
| 328 } | 335 } |
| 329 | 336 |
| 330 void ProxyImpl::PostAnimationEventsToMainThreadOnImplThread( | 337 void ProxyImpl::PostAnimationEventsToMainThreadOnImplThread( |
| 331 std::unique_ptr<MutatorEvents> events) { | 338 std::unique_ptr<MutatorEvents> events) { |
| 332 TRACE_EVENT0("cc", "ProxyImpl::PostAnimationEventsToMainThreadOnImplThread"); | 339 TRACE_EVENT0("cc", "ProxyImpl::PostAnimationEventsToMainThreadOnImplThread"); |
| 333 DCHECK(IsImplThread()); | 340 DCHECK(IsImplThread()); |
| 334 channel_impl_->SetAnimationEvents(std::move(events)); | 341 MainThreadTaskRunner()->PostTask( |
| 342 FROM_HERE, base::Bind(&ProxyMain::SetAnimationEvents, |
| 343 proxy_main_weak_ptr_, base::Passed(&events))); |
| 335 } | 344 } |
| 336 | 345 |
| 337 bool ProxyImpl::IsInsideDraw() { | 346 bool ProxyImpl::IsInsideDraw() { |
| 338 return inside_draw_; | 347 return inside_draw_; |
| 339 } | 348 } |
| 340 | 349 |
| 341 void ProxyImpl::RenewTreePriority() { | 350 void ProxyImpl::RenewTreePriority() { |
| 342 DCHECK(IsImplThread()); | 351 DCHECK(IsImplThread()); |
| 343 bool smoothness_takes_priority = | 352 bool smoothness_takes_priority = |
| 344 layer_tree_host_impl_->pinch_gesture_active() || | 353 layer_tree_host_impl_->pinch_gesture_active() || |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 scheduler_->WillPrepareTiles(); | 415 scheduler_->WillPrepareTiles(); |
| 407 } | 416 } |
| 408 | 417 |
| 409 void ProxyImpl::DidPrepareTiles() { | 418 void ProxyImpl::DidPrepareTiles() { |
| 410 DCHECK(IsImplThread()); | 419 DCHECK(IsImplThread()); |
| 411 scheduler_->DidPrepareTiles(); | 420 scheduler_->DidPrepareTiles(); |
| 412 } | 421 } |
| 413 | 422 |
| 414 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() { | 423 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() { |
| 415 DCHECK(IsImplThread()); | 424 DCHECK(IsImplThread()); |
| 416 channel_impl_->DidCompletePageScaleAnimation(); | 425 MainThreadTaskRunner()->PostTask( |
| 426 FROM_HERE, base::Bind(&ProxyMain::DidCompletePageScaleAnimation, |
| 427 proxy_main_weak_ptr_)); |
| 417 } | 428 } |
| 418 | 429 |
| 419 void ProxyImpl::OnDrawForCompositorFrameSink(bool resourceless_software_draw) { | 430 void ProxyImpl::OnDrawForCompositorFrameSink(bool resourceless_software_draw) { |
| 420 DCHECK(IsImplThread()); | 431 DCHECK(IsImplThread()); |
| 421 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 432 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 422 } | 433 } |
| 423 | 434 |
| 424 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 435 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 425 DCHECK(IsImplThread()); | 436 DCHECK(IsImplThread()); |
| 426 layer_tree_host_impl_->WillBeginImplFrame(args); | 437 layer_tree_host_impl_->WillBeginImplFrame(args); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 439 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 450 std::unique_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 440 new BeginMainFrameAndCommitState); | 451 new BeginMainFrameAndCommitState); |
| 441 begin_main_frame_state->begin_frame_id = begin_frame_id; | 452 begin_main_frame_state->begin_frame_id = begin_frame_id; |
| 442 begin_main_frame_state->begin_frame_args = args; | 453 begin_main_frame_state->begin_frame_args = args; |
| 443 begin_main_frame_state->begin_frame_callbacks = | 454 begin_main_frame_state->begin_frame_callbacks = |
| 444 layer_tree_host_impl_->ProcessLayerTreeMutations(); | 455 layer_tree_host_impl_->ProcessLayerTreeMutations(); |
| 445 begin_main_frame_state->scroll_info = | 456 begin_main_frame_state->scroll_info = |
| 446 layer_tree_host_impl_->ProcessScrollDeltas(); | 457 layer_tree_host_impl_->ProcessScrollDeltas(); |
| 447 begin_main_frame_state->evicted_ui_resources = | 458 begin_main_frame_state->evicted_ui_resources = |
| 448 layer_tree_host_impl_->EvictedUIResourcesExist(); | 459 layer_tree_host_impl_->EvictedUIResourcesExist(); |
| 449 channel_impl_->BeginMainFrame(std::move(begin_main_frame_state)); | 460 MainThreadTaskRunner()->PostTask( |
| 461 FROM_HERE, base::Bind(&ProxyMain::BeginMainFrame, proxy_main_weak_ptr_, |
| 462 base::Passed(&begin_main_frame_state))); |
| 450 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); | 463 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); |
| 451 } | 464 } |
| 452 | 465 |
| 453 DrawResult ProxyImpl::ScheduledActionDrawIfPossible() { | 466 DrawResult ProxyImpl::ScheduledActionDrawIfPossible() { |
| 454 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDraw"); | 467 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDraw"); |
| 455 DCHECK(IsImplThread()); | 468 DCHECK(IsImplThread()); |
| 456 | 469 |
| 457 // The scheduler should never generate this call when it can't draw. | 470 // The scheduler should never generate this call when it can't draw. |
| 458 DCHECK(layer_tree_host_impl_->CanDraw()); | 471 DCHECK(layer_tree_host_impl_->CanDraw()); |
| 459 | 472 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 void ProxyImpl::ScheduledActionActivateSyncTree() { | 523 void ProxyImpl::ScheduledActionActivateSyncTree() { |
| 511 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionActivateSyncTree"); | 524 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionActivateSyncTree"); |
| 512 DCHECK(IsImplThread()); | 525 DCHECK(IsImplThread()); |
| 513 layer_tree_host_impl_->ActivateSyncTree(); | 526 layer_tree_host_impl_->ActivateSyncTree(); |
| 514 } | 527 } |
| 515 | 528 |
| 516 void ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation() { | 529 void ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation() { |
| 517 TRACE_EVENT0("cc", | 530 TRACE_EVENT0("cc", |
| 518 "ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation"); | 531 "ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation"); |
| 519 DCHECK(IsImplThread()); | 532 DCHECK(IsImplThread()); |
| 520 channel_impl_->RequestNewCompositorFrameSink(); | 533 MainThreadTaskRunner()->PostTask( |
| 534 FROM_HERE, base::Bind(&ProxyMain::RequestNewCompositorFrameSink, |
| 535 proxy_main_weak_ptr_)); |
| 521 } | 536 } |
| 522 | 537 |
| 523 void ProxyImpl::ScheduledActionPrepareTiles() { | 538 void ProxyImpl::ScheduledActionPrepareTiles() { |
| 524 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionPrepareTiles"); | 539 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionPrepareTiles"); |
| 525 DCHECK(IsImplThread()); | 540 DCHECK(IsImplThread()); |
| 526 layer_tree_host_impl_->PrepareTiles(); | 541 layer_tree_host_impl_->PrepareTiles(); |
| 527 } | 542 } |
| 528 | 543 |
| 529 void ProxyImpl::ScheduledActionInvalidateCompositorFrameSink() { | 544 void ProxyImpl::ScheduledActionInvalidateCompositorFrameSink() { |
| 530 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionInvalidateCompositorFrameSink"); | 545 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionInvalidateCompositorFrameSink"); |
| 531 DCHECK(IsImplThread()); | 546 DCHECK(IsImplThread()); |
| 532 DCHECK(layer_tree_host_impl_->compositor_frame_sink()); | 547 DCHECK(layer_tree_host_impl_->compositor_frame_sink()); |
| 533 layer_tree_host_impl_->compositor_frame_sink()->Invalidate(); | 548 layer_tree_host_impl_->compositor_frame_sink()->Invalidate(); |
| 534 } | 549 } |
| 535 | 550 |
| 536 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() { | 551 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() { |
| 537 DCHECK(IsImplThread()); | 552 DCHECK(IsImplThread()); |
| 538 channel_impl_->BeginMainFrameNotExpectedSoon(); | 553 MainThreadTaskRunner()->PostTask( |
| 554 FROM_HERE, base::Bind(&ProxyMain::BeginMainFrameNotExpectedSoon, |
| 555 proxy_main_weak_ptr_)); |
| 539 } | 556 } |
| 540 | 557 |
| 541 DrawResult ProxyImpl::DrawInternal(bool forced_draw) { | 558 DrawResult ProxyImpl::DrawInternal(bool forced_draw) { |
| 542 TRACE_EVENT_SYNTHETIC_DELAY("cc.Draw"); | 559 TRACE_EVENT_SYNTHETIC_DELAY("cc.Draw"); |
| 543 | 560 |
| 544 DCHECK(IsImplThread()); | 561 DCHECK(IsImplThread()); |
| 545 DCHECK(layer_tree_host_impl_.get()); | 562 DCHECK(layer_tree_host_impl_.get()); |
| 546 | 563 |
| 547 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 564 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
| 548 | 565 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 601 } |
| 585 | 602 |
| 586 layer_tree_host_impl_->DidDrawAllLayers(frame); | 603 layer_tree_host_impl_->DidDrawAllLayers(frame); |
| 587 | 604 |
| 588 bool start_ready_animations = draw_frame; | 605 bool start_ready_animations = draw_frame; |
| 589 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 606 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 590 | 607 |
| 591 // Tell the main thread that the the newly-commited frame was drawn. | 608 // Tell the main thread that the the newly-commited frame was drawn. |
| 592 if (next_frame_is_newly_committed_frame_) { | 609 if (next_frame_is_newly_committed_frame_) { |
| 593 next_frame_is_newly_committed_frame_ = false; | 610 next_frame_is_newly_committed_frame_ = false; |
| 594 channel_impl_->DidCommitAndDrawFrame(); | 611 MainThreadTaskRunner()->PostTask( |
| 612 FROM_HERE, |
| 613 base::Bind(&ProxyMain::DidCommitAndDrawFrame, proxy_main_weak_ptr_)); |
| 595 } | 614 } |
| 596 | 615 |
| 597 DCHECK_NE(INVALID_RESULT, result); | 616 DCHECK_NE(INVALID_RESULT, result); |
| 598 return result; | 617 return result; |
| 599 } | 618 } |
| 600 | 619 |
| 601 bool ProxyImpl::IsImplThread() const { | 620 bool ProxyImpl::IsImplThread() const { |
| 602 return task_runner_provider_->IsImplThread(); | 621 return task_runner_provider_->IsImplThread(); |
| 603 } | 622 } |
| 604 | 623 |
| 605 bool ProxyImpl::IsMainThreadBlocked() const { | 624 bool ProxyImpl::IsMainThreadBlocked() const { |
| 606 return task_runner_provider_->IsMainThreadBlocked(); | 625 return task_runner_provider_->IsMainThreadBlocked(); |
| 607 } | 626 } |
| 608 | 627 |
| 609 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 628 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
| 610 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 629 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
| 611 return main_thread_blocked_commit_vars_unsafe_; | 630 return main_thread_blocked_commit_vars_unsafe_; |
| 612 } | 631 } |
| 613 | 632 |
| 633 base::SingleThreadTaskRunner* ProxyImpl::MainThreadTaskRunner() { |
| 634 return task_runner_provider_->MainThreadTaskRunner(); |
| 635 } |
| 636 |
| 614 } // namespace cc | 637 } // namespace cc |
| OLD | NEW |