| 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/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/debug/benchmark_instrumentation.h" | 10 #include "cc/debug/benchmark_instrumentation.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 LayerTreeHostSingleThreadClient* client, | 40 LayerTreeHostSingleThreadClient* client, |
| 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 42 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 42 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 43 : Proxy(main_task_runner, NULL), | 43 : Proxy(main_task_runner, NULL), |
| 44 layer_tree_host_(layer_tree_host), | 44 layer_tree_host_(layer_tree_host), |
| 45 client_(client), | 45 client_(client), |
| 46 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 46 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
| 47 next_frame_is_newly_committed_frame_(false), | 47 next_frame_is_newly_committed_frame_(false), |
| 48 inside_draw_(false), | 48 inside_draw_(false), |
| 49 defer_commits_(false), | 49 defer_commits_(false), |
| 50 animate_requested_(false), |
| 50 commit_requested_(false), | 51 commit_requested_(false), |
| 51 inside_synchronous_composite_(false), | 52 inside_synchronous_composite_(false), |
| 52 output_surface_creation_requested_(false), | 53 output_surface_creation_requested_(false), |
| 53 weak_factory_(this) { | 54 weak_factory_(this) { |
| 54 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 55 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 55 DCHECK(Proxy::IsMainThread()); | 56 DCHECK(Proxy::IsMainThread()); |
| 56 DCHECK(layer_tree_host); | 57 DCHECK(layer_tree_host); |
| 57 | 58 |
| 58 if (layer_tree_host->settings().single_thread_proxy_scheduler && | 59 if (layer_tree_host->settings().single_thread_proxy_scheduler && |
| 59 !scheduler_on_impl_thread_) { | 60 !scheduler_on_impl_thread_) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 172 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 172 DCHECK(Proxy::IsMainThread()); | 173 DCHECK(Proxy::IsMainThread()); |
| 173 DCHECK(!layer_tree_host_->output_surface_lost()); | 174 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 174 return renderer_capabilities_for_main_thread_; | 175 return renderer_capabilities_for_main_thread_; |
| 175 } | 176 } |
| 176 | 177 |
| 177 void SingleThreadProxy::SetNeedsAnimate() { | 178 void SingleThreadProxy::SetNeedsAnimate() { |
| 178 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 179 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
| 179 DCHECK(Proxy::IsMainThread()); | 180 DCHECK(Proxy::IsMainThread()); |
| 180 client_->ScheduleAnimation(); | 181 client_->ScheduleAnimation(); |
| 181 SetNeedsCommit(); | 182 if (animate_requested_) { |
| 183 return; |
| 184 } |
| 185 DebugScopedSetImplThread impl(this); |
| 186 if (scheduler_on_impl_thread_) |
| 187 scheduler_on_impl_thread_->SetNeedsCommit(); |
| 188 animate_requested_ = true; |
| 182 } | 189 } |
| 183 | 190 |
| 184 void SingleThreadProxy::SetNeedsUpdateLayers() { | 191 void SingleThreadProxy::SetNeedsUpdateLayers() { |
| 185 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 192 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
| 186 DCHECK(Proxy::IsMainThread()); | 193 DCHECK(Proxy::IsMainThread()); |
| 187 SetNeedsCommit(); | 194 SetNeedsCommit(); |
| 188 } | 195 } |
| 189 | 196 |
| 190 void SingleThreadProxy::DoAnimate() { | 197 void SingleThreadProxy::DoAnimate() { |
| 191 // Don't animate if there is no root layer. | 198 // Don't animate if there is no root layer. |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 base::Bind(&SingleThreadProxy::BeginMainFrame, | 809 base::Bind(&SingleThreadProxy::BeginMainFrame, |
| 803 weak_factory_.GetWeakPtr())); | 810 weak_factory_.GetWeakPtr())); |
| 804 } | 811 } |
| 805 | 812 |
| 806 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 813 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 807 layer_tree_host_->BeginMainFrameNotExpectedSoon(); | 814 layer_tree_host_->BeginMainFrameNotExpectedSoon(); |
| 808 } | 815 } |
| 809 | 816 |
| 810 void SingleThreadProxy::BeginMainFrame() { | 817 void SingleThreadProxy::BeginMainFrame() { |
| 811 commit_requested_ = false; | 818 commit_requested_ = false; |
| 819 animate_requested_ = false; |
| 812 | 820 |
| 813 if (defer_commits_) { | 821 if (defer_commits_) { |
| 814 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 822 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| 815 TRACE_EVENT_SCOPE_THREAD); | 823 TRACE_EVENT_SCOPE_THREAD); |
| 816 BeginMainFrameAbortedOnImplThread( | 824 BeginMainFrameAbortedOnImplThread( |
| 817 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); | 825 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 818 return; | 826 return; |
| 819 } | 827 } |
| 820 | 828 |
| 821 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous | 829 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous |
| 822 // commit. | 830 // commit. |
| 823 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); | 831 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); |
| 824 | 832 |
| 825 if (!layer_tree_host_->visible()) { | 833 if (!layer_tree_host_->visible()) { |
| 826 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 834 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 827 BeginMainFrameAbortedOnImplThread( | 835 BeginMainFrameAbortedOnImplThread( |
| 828 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); | 836 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 829 return; | 837 return; |
| 830 } | 838 } |
| 831 | 839 |
| 832 if (layer_tree_host_->output_surface_lost()) { | 840 if (layer_tree_host_->output_surface_lost()) { |
| 833 TRACE_EVENT_INSTANT0( | 841 TRACE_EVENT_INSTANT0( |
| 834 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 842 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
| 835 BeginMainFrameAbortedOnImplThread( | 843 BeginMainFrameAbortedOnImplThread( |
| 836 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); | 844 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); |
| 837 return; | 845 return; |
| 838 } | 846 } |
| 839 | 847 |
| 840 // Prevent new commits from being requested inside DoBeginMainFrame. | 848 // Prevent new commits from being requested inside DoBeginMainFrame. But don't |
| 849 // do the same for animate_requested_ because animations can request a new |
| 850 // frame inside of the commit. |
| 841 commit_requested_ = true; | 851 commit_requested_ = true; |
| 842 | 852 |
| 843 const BeginFrameArgs& begin_frame_args = | 853 const BeginFrameArgs& begin_frame_args = |
| 844 layer_tree_host_impl_->CurrentBeginFrameArgs(); | 854 layer_tree_host_impl_->CurrentBeginFrameArgs(); |
| 845 DoBeginMainFrame(begin_frame_args); | 855 DoBeginMainFrame(begin_frame_args); |
| 846 } | 856 } |
| 847 | 857 |
| 848 void SingleThreadProxy::DoBeginMainFrame( | 858 void SingleThreadProxy::DoBeginMainFrame( |
| 849 const BeginFrameArgs& begin_frame_args) { | 859 const BeginFrameArgs& begin_frame_args) { |
| 850 layer_tree_host_->WillBeginMainFrame(); | 860 layer_tree_host_->WillBeginMainFrame(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 970 |
| 961 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 971 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 962 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 972 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 963 } | 973 } |
| 964 | 974 |
| 965 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 975 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 966 layer_tree_host_->SendBeginFramesToChildren(args); | 976 layer_tree_host_->SendBeginFramesToChildren(args); |
| 967 } | 977 } |
| 968 | 978 |
| 969 } // namespace cc | 979 } // namespace cc |
| OLD | NEW |