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" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { | 261 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { |
262 // During shutdown, destroying the CompositorFrameSink may unset the | 262 // During shutdown, destroying the CompositorFrameSink may unset the |
263 // BeginFrameSource. | 263 // BeginFrameSource. |
264 if (scheduler_) { | 264 if (scheduler_) { |
265 // TODO(enne): this overrides any preexisting begin frame source. Those | 265 // TODO(enne): this overrides any preexisting begin frame source. Those |
266 // other sources will eventually be removed and this will be the only path. | 266 // other sources will eventually be removed and this will be the only path. |
267 scheduler_->SetBeginFrameSource(source); | 267 scheduler_->SetBeginFrameSource(source); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 void ProxyImpl::DidSwapBuffersCompleteOnImplThread() { | 271 void ProxyImpl::DidReceiveCompositorFrameAckOnImplThread() { |
272 TRACE_EVENT0("cc,benchmark", "ProxyImpl::DidSwapBuffersCompleteOnImplThread"); | 272 TRACE_EVENT0("cc,benchmark", |
| 273 "ProxyImpl::DidReceiveCompositorFrameAckOnImplThread"); |
273 DCHECK(IsImplThread()); | 274 DCHECK(IsImplThread()); |
274 scheduler_->DidSwapBuffersComplete(); | 275 scheduler_->DidReceiveCompositorFrameAck(); |
275 channel_impl_->DidCompleteSwapBuffers(); | 276 channel_impl_->DidReceiveCompositorFrameAck(); |
276 } | 277 } |
277 | 278 |
278 void ProxyImpl::OnCanDrawStateChanged(bool can_draw) { | 279 void ProxyImpl::OnCanDrawStateChanged(bool can_draw) { |
279 TRACE_EVENT1("cc", "ProxyImpl::OnCanDrawStateChanged", "can_draw", can_draw); | 280 TRACE_EVENT1("cc", "ProxyImpl::OnCanDrawStateChanged", "can_draw", can_draw); |
280 DCHECK(IsImplThread()); | 281 DCHECK(IsImplThread()); |
281 scheduler_->SetCanDraw(can_draw); | 282 scheduler_->SetCanDraw(can_draw); |
282 } | 283 } |
283 | 284 |
284 void ProxyImpl::NotifyReadyToActivate() { | 285 void ProxyImpl::NotifyReadyToActivate() { |
285 TRACE_EVENT0("cc", "ProxyImpl::NotifyReadyToActivate"); | 286 TRACE_EVENT0("cc", "ProxyImpl::NotifyReadyToActivate"); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 begin_main_frame_state->begin_frame_callbacks = | 442 begin_main_frame_state->begin_frame_callbacks = |
442 layer_tree_host_impl_->ProcessLayerTreeMutations(); | 443 layer_tree_host_impl_->ProcessLayerTreeMutations(); |
443 begin_main_frame_state->scroll_info = | 444 begin_main_frame_state->scroll_info = |
444 layer_tree_host_impl_->ProcessScrollDeltas(); | 445 layer_tree_host_impl_->ProcessScrollDeltas(); |
445 begin_main_frame_state->evicted_ui_resources = | 446 begin_main_frame_state->evicted_ui_resources = |
446 layer_tree_host_impl_->EvictedUIResourcesExist(); | 447 layer_tree_host_impl_->EvictedUIResourcesExist(); |
447 channel_impl_->BeginMainFrame(std::move(begin_main_frame_state)); | 448 channel_impl_->BeginMainFrame(std::move(begin_main_frame_state)); |
448 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); | 449 devtools_instrumentation::DidRequestMainThreadFrame(layer_tree_host_id_); |
449 } | 450 } |
450 | 451 |
451 DrawResult ProxyImpl::ScheduledActionDrawAndSwapIfPossible() { | 452 DrawResult ProxyImpl::ScheduledActionDrawIfPossible() { |
452 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDrawAndSwap"); | 453 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDraw"); |
453 DCHECK(IsImplThread()); | 454 DCHECK(IsImplThread()); |
454 | 455 |
455 // SchedulerStateMachine::DidDrawIfPossibleCompleted isn't set up to | 456 // The scheduler should never generate this call when it can't draw. |
456 // handle DRAW_ABORTED_CANT_DRAW. Moreover, the scheduler should | |
457 // never generate this call when it can't draw. | |
458 DCHECK(layer_tree_host_impl_->CanDraw()); | 457 DCHECK(layer_tree_host_impl_->CanDraw()); |
459 | 458 |
460 bool forced_draw = false; | 459 bool forced_draw = false; |
461 return DrawAndSwapInternal(forced_draw); | 460 return DrawInternal(forced_draw); |
462 } | 461 } |
463 | 462 |
464 DrawResult ProxyImpl::ScheduledActionDrawAndSwapForced() { | 463 DrawResult ProxyImpl::ScheduledActionDrawForced() { |
465 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDrawAndSwapForced"); | 464 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionDrawForced"); |
466 DCHECK(IsImplThread()); | 465 DCHECK(IsImplThread()); |
467 bool forced_draw = true; | 466 bool forced_draw = true; |
468 return DrawAndSwapInternal(forced_draw); | 467 return DrawInternal(forced_draw); |
469 } | 468 } |
470 | 469 |
471 void ProxyImpl::ScheduledActionCommit() { | 470 void ProxyImpl::ScheduledActionCommit() { |
472 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionCommit"); | 471 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionCommit"); |
473 DCHECK(IsImplThread()); | 472 DCHECK(IsImplThread()); |
474 DCHECK(IsMainThreadBlocked()); | 473 DCHECK(IsMainThreadBlocked()); |
475 DCHECK(commit_completion_event_); | 474 DCHECK(commit_completion_event_); |
476 | 475 |
477 layer_tree_host_impl_->BeginCommit(); | 476 layer_tree_host_impl_->BeginCommit(); |
478 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( | 477 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 DCHECK(IsImplThread()); | 530 DCHECK(IsImplThread()); |
532 DCHECK(layer_tree_host_impl_->compositor_frame_sink()); | 531 DCHECK(layer_tree_host_impl_->compositor_frame_sink()); |
533 layer_tree_host_impl_->compositor_frame_sink()->Invalidate(); | 532 layer_tree_host_impl_->compositor_frame_sink()->Invalidate(); |
534 } | 533 } |
535 | 534 |
536 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() { | 535 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() { |
537 DCHECK(IsImplThread()); | 536 DCHECK(IsImplThread()); |
538 channel_impl_->BeginMainFrameNotExpectedSoon(); | 537 channel_impl_->BeginMainFrameNotExpectedSoon(); |
539 } | 538 } |
540 | 539 |
541 DrawResult ProxyImpl::DrawAndSwapInternal(bool forced_draw) { | 540 DrawResult ProxyImpl::DrawInternal(bool forced_draw) { |
542 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 541 TRACE_EVENT_SYNTHETIC_DELAY("cc.Draw"); |
543 | 542 |
544 DCHECK(IsImplThread()); | 543 DCHECK(IsImplThread()); |
545 DCHECK(layer_tree_host_impl_.get()); | 544 DCHECK(layer_tree_host_impl_.get()); |
546 | 545 |
547 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 546 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
548 | 547 |
549 if (layer_tree_host_impl_->pending_tree()) { | 548 if (layer_tree_host_impl_->pending_tree()) { |
550 bool update_lcd_text = false; | 549 bool update_lcd_text = false; |
551 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties( | 550 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties( |
552 update_lcd_text); | 551 update_lcd_text); |
(...skipping 16 matching lines...) Expand all Loading... |
569 DrawResult result; | 568 DrawResult result; |
570 if (layer_tree_host_impl_->CanDraw()) { | 569 if (layer_tree_host_impl_->CanDraw()) { |
571 result = layer_tree_host_impl_->PrepareToDraw(&frame); | 570 result = layer_tree_host_impl_->PrepareToDraw(&frame); |
572 draw_frame = forced_draw || result == DRAW_SUCCESS; | 571 draw_frame = forced_draw || result == DRAW_SUCCESS; |
573 } else { | 572 } else { |
574 result = DRAW_ABORTED_CANT_DRAW; | 573 result = DRAW_ABORTED_CANT_DRAW; |
575 } | 574 } |
576 | 575 |
577 if (draw_frame) { | 576 if (draw_frame) { |
578 if (layer_tree_host_impl_->DrawLayers(&frame)) | 577 if (layer_tree_host_impl_->DrawLayers(&frame)) |
579 scheduler_->DidSwapBuffers(); | 578 // Drawing implies we submitted a frame to the CompositorFrameSink. |
| 579 scheduler_->DidSubmitCompositorFrame(); |
580 result = DRAW_SUCCESS; | 580 result = DRAW_SUCCESS; |
581 } else { | 581 } else { |
582 DCHECK_NE(DRAW_SUCCESS, result); | 582 DCHECK_NE(DRAW_SUCCESS, result); |
583 } | 583 } |
584 | 584 |
585 layer_tree_host_impl_->DidDrawAllLayers(frame); | 585 layer_tree_host_impl_->DidDrawAllLayers(frame); |
586 | 586 |
587 bool start_ready_animations = draw_frame; | 587 bool start_ready_animations = draw_frame; |
588 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 588 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
589 | 589 |
(...skipping 14 matching lines...) Expand all Loading... |
604 bool ProxyImpl::IsMainThreadBlocked() const { | 604 bool ProxyImpl::IsMainThreadBlocked() const { |
605 return task_runner_provider_->IsMainThreadBlocked(); | 605 return task_runner_provider_->IsMainThreadBlocked(); |
606 } | 606 } |
607 | 607 |
608 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 608 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
609 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 609 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
610 return main_thread_blocked_commit_vars_unsafe_; | 610 return main_thread_blocked_commit_vars_unsafe_; |
611 } | 611 } |
612 | 612 |
613 } // namespace cc | 613 } // namespace cc |
OLD | NEW |