| 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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (scheduler_on_impl_thread_) | 413 if (scheduler_on_impl_thread_) |
| 414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); | 414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
| 415 compositor_frame_sink_lost_ = true; | 415 compositor_frame_sink_lost_ = true; |
| 416 } | 416 } |
| 417 | 417 |
| 418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 419 if (scheduler_on_impl_thread_) | 419 if (scheduler_on_impl_thread_) |
| 420 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 420 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 423 void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() { |
| 424 TRACE_EVENT0("cc,benchmark", | 424 TRACE_EVENT0("cc,benchmark", |
| 425 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 425 "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread"); |
| 426 if (scheduler_on_impl_thread_) | 426 if (scheduler_on_impl_thread_) |
| 427 scheduler_on_impl_thread_->DidSwapBuffersComplete(); | 427 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); |
| 428 layer_tree_host_->DidCompleteSwapBuffers(); | 428 layer_tree_host_->DidReceiveCompositorFrameAck(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 void SingleThreadProxy::OnDrawForCompositorFrameSink( | 431 void SingleThreadProxy::OnDrawForCompositorFrameSink( |
| 432 bool resourceless_software_draw) { | 432 bool resourceless_software_draw) { |
| 433 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 433 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
| 434 } | 434 } |
| 435 | 435 |
| 436 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 436 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
| 437 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 437 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
| 438 DCHECK(task_runner_provider_->IsMainThread()); | 438 DCHECK(task_runner_provider_->IsMainThread()); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // the swap buffers will execute first. | 543 // the swap buffers will execute first. |
| 544 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 544 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 545 BlockingTaskRunner::CapturePostTasks blocked( | 545 BlockingTaskRunner::CapturePostTasks blocked( |
| 546 task_runner_provider_->blocking_main_thread_task_runner()); | 546 task_runner_provider_->blocking_main_thread_task_runner()); |
| 547 | 547 |
| 548 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); | 548 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); |
| 549 draw_frame = draw_result == DRAW_SUCCESS; | 549 draw_frame = draw_result == DRAW_SUCCESS; |
| 550 if (draw_frame) { | 550 if (draw_frame) { |
| 551 if (layer_tree_host_impl_->DrawLayers(frame)) { | 551 if (layer_tree_host_impl_->DrawLayers(frame)) { |
| 552 if (scheduler_on_impl_thread_) | 552 if (scheduler_on_impl_thread_) |
| 553 scheduler_on_impl_thread_->DidSwapBuffers(); | 553 // Drawing implies we submitted a frame to the CompositorFrameSink. |
| 554 scheduler_on_impl_thread_->DidSubmitCompositorFrame(); |
| 554 client_->DidPostSwapBuffers(); | 555 client_->DidPostSwapBuffers(); |
| 555 } | 556 } |
| 556 } | 557 } |
| 557 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 558 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
| 558 | 559 |
| 559 bool start_ready_animations = draw_frame; | 560 bool start_ready_animations = draw_frame; |
| 560 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 561 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 561 } | 562 } |
| 562 DidCommitAndDrawFrame(); | 563 DidCommitAndDrawFrame(); |
| 563 | 564 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 DebugScopedSetImplThread impl(task_runner_provider_); | 682 DebugScopedSetImplThread impl(task_runner_provider_); |
| 682 DCHECK(scheduler_on_impl_thread_->CommitPending()); | 683 DCHECK(scheduler_on_impl_thread_->CommitPending()); |
| 683 DCHECK(!layer_tree_host_impl_->pending_tree()); | 684 DCHECK(!layer_tree_host_impl_->pending_tree()); |
| 684 | 685 |
| 685 std::vector<std::unique_ptr<SwapPromise>> empty_swap_promises; | 686 std::vector<std::unique_ptr<SwapPromise>> empty_swap_promises; |
| 686 layer_tree_host_impl_->BeginMainFrameAborted(reason, | 687 layer_tree_host_impl_->BeginMainFrameAborted(reason, |
| 687 std::move(empty_swap_promises)); | 688 std::move(empty_swap_promises)); |
| 688 scheduler_on_impl_thread_->BeginMainFrameAborted(reason); | 689 scheduler_on_impl_thread_->BeginMainFrameAborted(reason); |
| 689 } | 690 } |
| 690 | 691 |
| 691 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { | 692 DrawResult SingleThreadProxy::ScheduledActionDrawIfPossible() { |
| 692 DebugScopedSetImplThread impl(task_runner_provider_); | 693 DebugScopedSetImplThread impl(task_runner_provider_); |
| 693 LayerTreeHostImpl::FrameData frame; | 694 LayerTreeHostImpl::FrameData frame; |
| 694 return DoComposite(&frame); | 695 return DoComposite(&frame); |
| 695 } | 696 } |
| 696 | 697 |
| 697 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { | 698 DrawResult SingleThreadProxy::ScheduledActionDrawForced() { |
| 698 NOTREACHED(); | 699 NOTREACHED(); |
| 699 return INVALID_RESULT; | 700 return INVALID_RESULT; |
| 700 } | 701 } |
| 701 | 702 |
| 702 void SingleThreadProxy::ScheduledActionCommit() { | 703 void SingleThreadProxy::ScheduledActionCommit() { |
| 703 DebugScopedSetMainThread main(task_runner_provider_); | 704 DebugScopedSetMainThread main(task_runner_provider_); |
| 704 DoCommit(); | 705 DoCommit(); |
| 705 } | 706 } |
| 706 | 707 |
| 707 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 708 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 void SingleThreadProxy::DidFinishImplFrame() { | 743 void SingleThreadProxy::DidFinishImplFrame() { |
| 743 layer_tree_host_impl_->DidFinishImplFrame(); | 744 layer_tree_host_impl_->DidFinishImplFrame(); |
| 744 #if DCHECK_IS_ON() | 745 #if DCHECK_IS_ON() |
| 745 DCHECK(inside_impl_frame_) | 746 DCHECK(inside_impl_frame_) |
| 746 << "DidFinishImplFrame called while not inside an impl frame!"; | 747 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 747 inside_impl_frame_ = false; | 748 inside_impl_frame_ = false; |
| 748 #endif | 749 #endif |
| 749 } | 750 } |
| 750 | 751 |
| 751 } // namespace cc | 752 } // namespace cc |
| OLD | NEW |