| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 57 DCHECK(task_runner_provider_); | 57 DCHECK(task_runner_provider_); |
| 58 DCHECK(task_runner_provider_->IsMainThread()); | 58 DCHECK(task_runner_provider_->IsMainThread()); |
| 59 DCHECK(layer_tree_host); | 59 DCHECK(layer_tree_host); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SingleThreadProxy::Start() { | 62 void SingleThreadProxy::Start() { |
| 63 DebugScopedSetImplThread impl(task_runner_provider_); | 63 DebugScopedSetImplThread impl(task_runner_provider_); |
| 64 | 64 |
| 65 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); | 65 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); |
| 66 DCHECK(settings.single_thread_proxy_scheduler || |
| 67 !settings.enable_checker_imaging) |
| 68 << "Checker-imaging is not supported in synchronous single threaded mode"; |
| 66 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { | 69 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { |
| 67 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); | 70 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); |
| 68 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); | 71 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); |
| 69 | 72 |
| 70 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 73 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
| 71 new CompositorTimingHistory( | 74 new CompositorTimingHistory( |
| 72 scheduler_settings.using_synchronous_renderer_compositor, | 75 scheduler_settings.using_synchronous_renderer_compositor, |
| 73 CompositorTimingHistory::BROWSER_UMA, | 76 CompositorTimingHistory::BROWSER_UMA, |
| 74 layer_tree_host_->rendering_stats_instrumentation())); | 77 layer_tree_host_->rendering_stats_instrumentation())); |
| 75 scheduler_on_impl_thread_.reset( | 78 scheduler_on_impl_thread_.reset( |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); | 421 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); |
| 419 layer_tree_host_->DidReceiveCompositorFrameAck(); | 422 layer_tree_host_->DidReceiveCompositorFrameAck(); |
| 420 } | 423 } |
| 421 | 424 |
| 422 void SingleThreadProxy::OnDrawForCompositorFrameSink( | 425 void SingleThreadProxy::OnDrawForCompositorFrameSink( |
| 423 bool resourceless_software_draw) { | 426 bool resourceless_software_draw) { |
| 424 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 427 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
| 425 } | 428 } |
| 426 | 429 |
| 427 void SingleThreadProxy::NeedsImplSideInvalidation() { | 430 void SingleThreadProxy::NeedsImplSideInvalidation() { |
| 428 // TODO(khushalsagar): Plumb this to the scheduler when | 431 DCHECK(scheduler_on_impl_thread_); |
| 429 // https://codereview.chromium.org/2659123004/ lands. See crbug.com/686267. | 432 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); |
| 430 NOTIMPLEMENTED(); | |
| 431 } | 433 } |
| 432 | 434 |
| 433 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 435 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
| 434 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 436 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
| 435 DCHECK(task_runner_provider_->IsMainThread()); | 437 DCHECK(task_runner_provider_->IsMainThread()); |
| 436 #if DCHECK_IS_ON() | 438 #if DCHECK_IS_ON() |
| 437 DCHECK(!inside_impl_frame_); | 439 DCHECK(!inside_impl_frame_); |
| 438 #endif | 440 #endif |
| 439 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 441 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
| 440 | 442 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 // fall on the next. Doing it asynchronously instead matches the semantics of | 599 // fall on the next. Doing it asynchronously instead matches the semantics of |
| 598 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a | 600 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a |
| 599 // synchronous commit. | 601 // synchronous commit. |
| 600 DCHECK(inside_impl_frame_) | 602 DCHECK(inside_impl_frame_) |
| 601 << "BeginMainFrame should only be sent inside a BeginImplFrame"; | 603 << "BeginMainFrame should only be sent inside a BeginImplFrame"; |
| 602 #endif | 604 #endif |
| 603 | 605 |
| 604 task_runner_provider_->MainThreadTaskRunner()->PostTask( | 606 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
| 605 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, | 607 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, |
| 606 weak_factory_.GetWeakPtr(), begin_frame_args)); | 608 weak_factory_.GetWeakPtr(), begin_frame_args)); |
| 609 layer_tree_host_impl_->DidSendBeginMainFrame(); |
| 607 } | 610 } |
| 608 | 611 |
| 609 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 612 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 610 layer_tree_host_->BeginMainFrameNotExpectedSoon(); | 613 layer_tree_host_->BeginMainFrameNotExpectedSoon(); |
| 611 } | 614 } |
| 612 | 615 |
| 613 void SingleThreadProxy::BeginMainFrame(const BeginFrameArgs& begin_frame_args) { | 616 void SingleThreadProxy::BeginMainFrame(const BeginFrameArgs& begin_frame_args) { |
| 614 if (scheduler_on_impl_thread_) { | 617 if (scheduler_on_impl_thread_) { |
| 615 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted( | 618 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted( |
| 616 base::TimeTicks::Now()); | 619 base::TimeTicks::Now()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); | 728 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); |
| 726 DebugScopedSetImplThread impl(task_runner_provider_); | 729 DebugScopedSetImplThread impl(task_runner_provider_); |
| 727 layer_tree_host_impl_->PrepareTiles(); | 730 layer_tree_host_impl_->PrepareTiles(); |
| 728 } | 731 } |
| 729 | 732 |
| 730 void SingleThreadProxy::ScheduledActionInvalidateCompositorFrameSink() { | 733 void SingleThreadProxy::ScheduledActionInvalidateCompositorFrameSink() { |
| 731 NOTREACHED(); | 734 NOTREACHED(); |
| 732 } | 735 } |
| 733 | 736 |
| 734 void SingleThreadProxy::ScheduledActionPerformImplSideInvalidation() { | 737 void SingleThreadProxy::ScheduledActionPerformImplSideInvalidation() { |
| 735 NOTIMPLEMENTED(); | 738 DCHECK(scheduler_on_impl_thread_); |
| 739 |
| 740 DebugScopedSetImplThread impl(task_runner_provider_); |
| 741 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( |
| 742 task_runner_provider_->blocking_main_thread_task_runner())); |
| 743 layer_tree_host_impl_->InvalidateContentOnImplSide(); |
| 744 |
| 745 // Invalidations go directly to the active tree, so we synchronously call |
| 746 // NotifyReadyToActivate to update the scheduler and LTHI state correctly. |
| 747 // Since in single-threaded mode the scheduler will wait for a ready to draw |
| 748 // signal from LTHI, the draw will remain blocked till the invalidated tiles |
| 749 // are ready. |
| 750 NotifyReadyToActivate(); |
| 736 } | 751 } |
| 737 | 752 |
| 738 void SingleThreadProxy::UpdateBrowserControlsState( | 753 void SingleThreadProxy::UpdateBrowserControlsState( |
| 739 BrowserControlsState constraints, | 754 BrowserControlsState constraints, |
| 740 BrowserControlsState current, | 755 BrowserControlsState current, |
| 741 bool animate) { | 756 bool animate) { |
| 742 NOTREACHED() << "Browser Controls are used only in threaded mode"; | 757 NOTREACHED() << "Browser Controls are used only in threaded mode"; |
| 743 } | 758 } |
| 744 | 759 |
| 745 void SingleThreadProxy::DidFinishImplFrame() { | 760 void SingleThreadProxy::DidFinishImplFrame() { |
| 746 layer_tree_host_impl_->DidFinishImplFrame(); | 761 layer_tree_host_impl_->DidFinishImplFrame(); |
| 747 #if DCHECK_IS_ON() | 762 #if DCHECK_IS_ON() |
| 748 DCHECK(inside_impl_frame_) | 763 DCHECK(inside_impl_frame_) |
| 749 << "DidFinishImplFrame called while not inside an impl frame!"; | 764 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 750 inside_impl_frame_ = false; | 765 inside_impl_frame_ = false; |
| 751 #endif | 766 #endif |
| 752 } | 767 } |
| 753 | 768 |
| 754 } // namespace cc | 769 } // namespace cc |
| OLD | NEW |