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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 has_pending_tree); | 377 has_pending_tree); |
378 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); | 378 scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); |
379 } | 379 } |
380 | 380 |
381 void ThreadProxy::SetNeedsCommitOnImplThread() { | 381 void ThreadProxy::SetNeedsCommitOnImplThread() { |
382 DCHECK(IsImplThread()); | 382 DCHECK(IsImplThread()); |
383 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 383 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
384 scheduler_on_impl_thread_->SetNeedsCommit(); | 384 scheduler_on_impl_thread_->SetNeedsCommit(); |
385 } | 385 } |
386 | 386 |
387 void ThreadProxy::SetNeedsManageTilesOnImplThread() { | |
388 if (manage_tiles_pending_) | |
389 return; | |
390 Proxy::ImplThread()->PostTask( | |
391 base::Bind(&ThreadProxy::ManageTilesOnImplThread, impl_thread_weak_ptr_)); | |
392 manage_tiles_pending_ = true; | |
393 } | |
394 | |
395 void ThreadProxy::ManageTilesOnImplThread() { | |
396 // TODO(nduca): If needed, move this into CCSchedulerStateMachine. | |
397 manage_tiles_pending_ = false; | |
398 if (layer_tree_host_impl_) | |
399 layer_tree_host_impl_->ManageTiles(); | |
400 } | |
401 | |
402 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 387 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
403 scoped_ptr<AnimationEventsVector> events, | 388 scoped_ptr<AnimationEventsVector> events, |
404 base::Time wall_clock_time) { | 389 base::Time wall_clock_time) { |
405 DCHECK(IsImplThread()); | 390 DCHECK(IsImplThread()); |
406 TRACE_EVENT0("cc", | 391 TRACE_EVENT0("cc", |
407 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 392 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
408 Proxy::MainThread()->PostTask(base::Bind(&ThreadProxy::SetAnimationEvents, | 393 Proxy::MainThread()->PostTask(base::Bind(&ThreadProxy::SetAnimationEvents, |
409 main_thread_weak_ptr_, | 394 main_thread_weak_ptr_, |
410 base::Passed(&events), | 395 base::Passed(&events), |
411 wall_clock_time)); | 396 wall_clock_time)); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // Tell the main thread that the the newly-commited frame was drawn. | 964 // Tell the main thread that the the newly-commited frame was drawn. |
980 if (next_frame_is_newly_committed_frame_on_impl_thread_) { | 965 if (next_frame_is_newly_committed_frame_on_impl_thread_) { |
981 next_frame_is_newly_committed_frame_on_impl_thread_ = false; | 966 next_frame_is_newly_committed_frame_on_impl_thread_ = false; |
982 Proxy::MainThread()->PostTask( | 967 Proxy::MainThread()->PostTask( |
983 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | 968 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
984 } | 969 } |
985 | 970 |
986 if (draw_frame) | 971 if (draw_frame) |
987 CheckOutputSurfaceStatusOnImplThread(); | 972 CheckOutputSurfaceStatusOnImplThread(); |
988 | 973 |
| 974 // Update the tile state after drawing. This prevents manage tiles from |
| 975 // being in the critical path for getting things on screen, but still |
| 976 // makes sure that tile state is updated on a semi-regular basis. |
| 977 if (layer_tree_host_impl_->settings().impl_side_painting) |
| 978 layer_tree_host_impl_->ManageTiles(); |
| 979 |
989 return result; | 980 return result; |
990 } | 981 } |
991 | 982 |
992 void ThreadProxy::AcquireLayerTextures() { | 983 void ThreadProxy::AcquireLayerTextures() { |
993 // Called when the main thread needs to modify a layer texture that is used | 984 // Called when the main thread needs to modify a layer texture that is used |
994 // directly by the compositor. | 985 // directly by the compositor. |
995 // This method will block until the next compositor draw if there is a | 986 // This method will block until the next compositor draw if there is a |
996 // previously committed frame that is still undrawn. This is necessary to | 987 // previously committed frame that is still undrawn. This is necessary to |
997 // ensure that the main thread does not monopolize access to the textures. | 988 // ensure that the main thread does not monopolize access to the textures. |
998 DCHECK(IsMainThread()); | 989 DCHECK(IsMainThread()); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 !layer_tree_host_impl_->pending_tree()) { | 1383 !layer_tree_host_impl_->pending_tree()) { |
1393 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1384 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
1394 TRACE_EVENT_SCOPE_THREAD); | 1385 TRACE_EVENT_SCOPE_THREAD); |
1395 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1386 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1396 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1387 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1397 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1388 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1398 } | 1389 } |
1399 } | 1390 } |
1400 | 1391 |
1401 } // namespace cc | 1392 } // namespace cc |
OLD | NEW |