| 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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Measured in seconds. | 25 // Measured in seconds. |
| 26 const double kContextRecreationTickRate = 0.03; | 26 const double kContextRecreationTickRate = 0.03; |
| 27 | 27 |
| 28 // Measured in seconds. | 28 // Measured in seconds. |
| 29 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 29 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 30 | 30 |
| 31 // Time period in seconds from the previous vsync during which we are allowed to |
| 32 // retry tree activation and rendering. |
| 33 const double kTreeActivationGracePeriod = 0.008; |
| 34 |
| 31 } // namespace | 35 } // namespace |
| 32 | 36 |
| 33 namespace cc { | 37 namespace cc { |
| 34 | 38 |
| 35 scoped_ptr<Proxy> ThreadProxy::Create(LayerTreeHost* layer_tree_host, | 39 scoped_ptr<Proxy> ThreadProxy::Create(LayerTreeHost* layer_tree_host, |
| 36 scoped_ptr<Thread> impl_thread) { | 40 scoped_ptr<Thread> impl_thread) { |
| 37 return make_scoped_ptr( | 41 return make_scoped_ptr( |
| 38 new ThreadProxy(layer_tree_host, impl_thread.Pass())).PassAs<Proxy>(); | 42 new ThreadProxy(layer_tree_host, impl_thread.Pass())).PassAs<Proxy>(); |
| 39 } | 43 } |
| 40 | 44 |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 "ThreadProxy::ScheduledActionCheckForCompletedTileUploads"); | 846 "ThreadProxy::ScheduledActionCheckForCompletedTileUploads"); |
| 843 layer_tree_host_impl_->CheckForCompletedTileUploads(); | 847 layer_tree_host_impl_->CheckForCompletedTileUploads(); |
| 844 } | 848 } |
| 845 | 849 |
| 846 void ThreadProxy::ScheduledActionActivatePendingTreeIfNeeded() { | 850 void ThreadProxy::ScheduledActionActivatePendingTreeIfNeeded() { |
| 847 DCHECK(IsImplThread()); | 851 DCHECK(IsImplThread()); |
| 848 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivatePendingTreeIfNeeded"); | 852 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivatePendingTreeIfNeeded"); |
| 849 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | 853 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
| 850 } | 854 } |
| 851 | 855 |
| 856 void ThreadProxy::DidFinishTileRasterTasks() { |
| 857 DCHECK(IsImplThread()); |
| 858 TRACE_EVENT0("cc", "LayerTreeHostImpl::DidFinishTileRasterTasks"); |
| 859 base::TimeDelta time_since_vsync = |
| 860 base::TimeTicks::Now() - scheduler_on_impl_thread_->LastVSyncTime(); |
| 861 base::TimeDelta grace_period = |
| 862 base::TimeDelta::FromMilliseconds(kTreeActivationGracePeriod); |
| 863 if (time_since_vsync > grace_period) { |
| 864 TRACE_EVENT0("cc", "LayerTreeHostImpl::DidFinishTileRasterTasks: too late"); |
| 865 return; |
| 866 } |
| 867 if (layer_tree_host_impl_->ActivatePendingTreeIfNeeded()) |
| 868 scheduler_on_impl_thread_->VSyncTick(false); |
| 869 } |
| 870 |
| 852 void ThreadProxy::ScheduledActionBeginContextRecreation() { | 871 void ThreadProxy::ScheduledActionBeginContextRecreation() { |
| 853 DCHECK(IsImplThread()); | 872 DCHECK(IsImplThread()); |
| 854 Proxy::MainThread()->PostTask( | 873 Proxy::MainThread()->PostTask( |
| 855 base::Bind(&ThreadProxy::BeginContextRecreation, main_thread_weak_ptr_)); | 874 base::Bind(&ThreadProxy::BeginContextRecreation, main_thread_weak_ptr_)); |
| 856 } | 875 } |
| 857 | 876 |
| 858 ScheduledActionDrawAndSwapResult | 877 ScheduledActionDrawAndSwapResult |
| 859 ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { | 878 ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
| 860 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndSwap"); | 879 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndSwap"); |
| 861 | 880 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1359 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
| 1341 impl_thread_weak_ptr_), | 1360 impl_thread_weak_ptr_), |
| 1342 delay); | 1361 delay); |
| 1343 } | 1362 } |
| 1344 | 1363 |
| 1345 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1364 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
| 1346 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1365 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
| 1347 } | 1366 } |
| 1348 | 1367 |
| 1349 } // namespace cc | 1368 } // namespace cc |
| OLD | NEW |