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 animate_requested_ = true; |
| 185 DebugScopedSetImplThread impl(this); |
| 186 if (scheduler_on_impl_thread_) |
| 187 scheduler_on_impl_thread_->SetNeedsCommit(); |
182 } | 188 } |
183 | 189 |
184 void SingleThreadProxy::SetNeedsUpdateLayers() { | 190 void SingleThreadProxy::SetNeedsUpdateLayers() { |
185 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 191 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
186 DCHECK(Proxy::IsMainThread()); | 192 DCHECK(Proxy::IsMainThread()); |
187 SetNeedsCommit(); | 193 SetNeedsCommit(); |
188 } | 194 } |
189 | 195 |
190 void SingleThreadProxy::DoAnimate() { | 196 void SingleThreadProxy::DoAnimate() { |
191 // Don't animate if there is no root layer. | 197 // Don't animate if there is no root layer. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 timing_history_.DidCommit(); | 334 timing_history_.DidCommit(); |
329 | 335 |
330 next_frame_is_newly_committed_frame_ = true; | 336 next_frame_is_newly_committed_frame_ = true; |
331 } | 337 } |
332 | 338 |
333 void SingleThreadProxy::SetNeedsCommit() { | 339 void SingleThreadProxy::SetNeedsCommit() { |
334 DCHECK(Proxy::IsMainThread()); | 340 DCHECK(Proxy::IsMainThread()); |
335 client_->ScheduleComposite(); | 341 client_->ScheduleComposite(); |
336 if (commit_requested_) | 342 if (commit_requested_) |
337 return; | 343 return; |
| 344 commit_requested_ = true; |
338 DebugScopedSetImplThread impl(this); | 345 DebugScopedSetImplThread impl(this); |
339 if (scheduler_on_impl_thread_) | 346 if (scheduler_on_impl_thread_) |
340 scheduler_on_impl_thread_->SetNeedsCommit(); | 347 scheduler_on_impl_thread_->SetNeedsCommit(); |
341 commit_requested_ = true; | |
342 } | 348 } |
343 | 349 |
344 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 350 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
345 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 351 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); |
346 DCHECK(Proxy::IsMainThread()); | 352 DCHECK(Proxy::IsMainThread()); |
347 DebugScopedSetImplThread impl(this); | 353 DebugScopedSetImplThread impl(this); |
348 client_->ScheduleComposite(); | 354 client_->ScheduleComposite(); |
349 SetNeedsRedrawRectOnImplThread(damage_rect); | 355 SetNeedsRedrawRectOnImplThread(damage_rect); |
350 } | 356 } |
351 | 357 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 base::Bind(&SingleThreadProxy::BeginMainFrame, | 808 base::Bind(&SingleThreadProxy::BeginMainFrame, |
803 weak_factory_.GetWeakPtr())); | 809 weak_factory_.GetWeakPtr())); |
804 } | 810 } |
805 | 811 |
806 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 812 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
807 layer_tree_host_->BeginMainFrameNotExpectedSoon(); | 813 layer_tree_host_->BeginMainFrameNotExpectedSoon(); |
808 } | 814 } |
809 | 815 |
810 void SingleThreadProxy::BeginMainFrame() { | 816 void SingleThreadProxy::BeginMainFrame() { |
811 commit_requested_ = false; | 817 commit_requested_ = false; |
| 818 animate_requested_ = false; |
812 | 819 |
813 if (defer_commits_) { | 820 if (defer_commits_) { |
814 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 821 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
815 TRACE_EVENT_SCOPE_THREAD); | 822 TRACE_EVENT_SCOPE_THREAD); |
816 BeginMainFrameAbortedOnImplThread( | 823 BeginMainFrameAbortedOnImplThread( |
817 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); | 824 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
818 return; | 825 return; |
819 } | 826 } |
820 | 827 |
821 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous | 828 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous |
822 // commit. | 829 // commit. |
823 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); | 830 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); |
824 | 831 |
825 if (!layer_tree_host_->visible()) { | 832 if (!layer_tree_host_->visible()) { |
826 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 833 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
827 BeginMainFrameAbortedOnImplThread( | 834 BeginMainFrameAbortedOnImplThread( |
828 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); | 835 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
829 return; | 836 return; |
830 } | 837 } |
831 | 838 |
832 if (layer_tree_host_->output_surface_lost()) { | 839 if (layer_tree_host_->output_surface_lost()) { |
833 TRACE_EVENT_INSTANT0( | 840 TRACE_EVENT_INSTANT0( |
834 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); | 841 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); |
835 BeginMainFrameAbortedOnImplThread( | 842 BeginMainFrameAbortedOnImplThread( |
836 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); | 843 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); |
837 return; | 844 return; |
838 } | 845 } |
839 | 846 |
840 // Prevent new commits from being requested inside DoBeginMainFrame. | 847 // Prevent new commits from being requested inside DoBeginMainFrame. |
| 848 // Note: We do not want to prevent SetNeedsAnimate from requesting |
| 849 // a commit here. |
841 commit_requested_ = true; | 850 commit_requested_ = true; |
842 | 851 |
843 const BeginFrameArgs& begin_frame_args = | 852 const BeginFrameArgs& begin_frame_args = |
844 layer_tree_host_impl_->CurrentBeginFrameArgs(); | 853 layer_tree_host_impl_->CurrentBeginFrameArgs(); |
845 DoBeginMainFrame(begin_frame_args); | 854 DoBeginMainFrame(begin_frame_args); |
846 } | 855 } |
847 | 856 |
848 void SingleThreadProxy::DoBeginMainFrame( | 857 void SingleThreadProxy::DoBeginMainFrame( |
849 const BeginFrameArgs& begin_frame_args) { | 858 const BeginFrameArgs& begin_frame_args) { |
850 layer_tree_host_->WillBeginMainFrame(); | 859 layer_tree_host_->WillBeginMainFrame(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 969 |
961 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 970 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
962 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 971 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
963 } | 972 } |
964 | 973 |
965 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 974 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
966 layer_tree_host_->SendBeginFramesToChildren(args); | 975 layer_tree_host_->SendBeginFramesToChildren(args); |
967 } | 976 } |
968 | 977 |
969 } // namespace cc | 978 } // namespace cc |
OLD | NEW |