| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/debug/trace_event_argument.h" | 13 #include "base/debug/trace_event_argument.h" |
| 14 #include "base/debug/trace_event_synthetic_delay.h" | 14 #include "base/debug/trace_event_synthetic_delay.h" |
| 15 #include "cc/base/swap_promise.h" | 15 #include "cc/base/swap_promise.h" |
| 16 #include "cc/debug/benchmark_instrumentation.h" | 16 #include "cc/debug/benchmark_instrumentation.h" |
| 17 #include "cc/debug/devtools_instrumentation.h" | 17 #include "cc/debug/devtools_instrumentation.h" |
| 18 #include "cc/input/input_handler.h" | 18 #include "cc/input/input_handler.h" |
| 19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
| 20 #include "cc/output/output_surface.h" | 20 #include "cc/output/output_surface.h" |
| 21 #include "cc/quads/draw_quad.h" | 21 #include "cc/quads/draw_quad.h" |
| 22 #include "cc/resources/prioritized_resource_manager.h" | 22 #include "cc/resources/prioritized_resource_manager.h" |
| 23 #include "cc/scheduler/delay_based_time_source.h" | 23 #include "cc/scheduler/delay_based_time_source.h" |
| 24 #include "cc/scheduler/scheduler.h" | 24 #include "cc/scheduler/scheduler.h" |
| 25 #include "cc/trees/blocking_task_runner.h" | 25 #include "cc/trees/blocking_task_runner.h" |
| 26 #include "cc/trees/layer_tree_host.h" | 26 #include "cc/trees/layer_tree_host.h" |
| 27 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
| 28 #include "cc/trees/scoped_swap_promise_checker.h" |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" | 29 #include "gpu/command_buffer/client/gles2_interface.h" |
| 29 #include "ui/gfx/frame_time.h" | 30 #include "ui/gfx/frame_time.h" |
| 30 | 31 |
| 31 namespace cc { | 32 namespace cc { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // Measured in seconds. | 36 // Measured in seconds. |
| 36 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 37 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 37 | 38 |
| 38 unsigned int nextBeginFrameId = 0; | 39 unsigned int nextBeginFrameId = 0; |
| 39 | 40 |
| 40 class SwapPromiseChecker { | |
| 41 public: | |
| 42 explicit SwapPromiseChecker(LayerTreeHost* layer_tree_host) | |
| 43 : layer_tree_host_(layer_tree_host) {} | |
| 44 | |
| 45 ~SwapPromiseChecker() { | |
| 46 layer_tree_host_->BreakSwapPromises(SwapPromise::COMMIT_FAILS); | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 LayerTreeHost* layer_tree_host_; | |
| 51 }; | |
| 52 | |
| 53 } // namespace | 41 } // namespace |
| 54 | 42 |
| 55 struct ThreadProxy::CommitPendingRequest { | 43 struct ThreadProxy::CommitPendingRequest { |
| 56 CompletionEvent completion; | 44 CompletionEvent completion; |
| 57 bool commit_pending; | 45 bool commit_pending; |
| 58 }; | 46 }; |
| 59 | 47 |
| 60 struct ThreadProxy::SchedulerStateRequest { | 48 struct ThreadProxy::SchedulerStateRequest { |
| 61 CompletionEvent completion; | 49 CompletionEvent completion; |
| 62 scoped_ptr<base::Value> state; | 50 scoped_ptr<base::Value> state; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } | 447 } |
| 460 | 448 |
| 461 void ThreadProxy::SetNextCommitWaitsForActivation() { | 449 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 462 DCHECK(IsMainThread()); | 450 DCHECK(IsMainThread()); |
| 463 DCHECK(!blocked_main().main_thread_inside_commit); | 451 DCHECK(!blocked_main().main_thread_inside_commit); |
| 464 blocked_main().commit_waits_for_activation = true; | 452 blocked_main().commit_waits_for_activation = true; |
| 465 } | 453 } |
| 466 | 454 |
| 467 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 455 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 468 DCHECK(IsMainThread()); | 456 DCHECK(IsMainThread()); |
| 469 DCHECK_NE(main().defer_commits, defer_commits); | 457 if (main().defer_commits == defer_commits) |
| 458 return; |
| 459 |
| 470 main().defer_commits = defer_commits; | 460 main().defer_commits = defer_commits; |
| 471 | |
| 472 if (main().defer_commits) | 461 if (main().defer_commits) |
| 473 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 462 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| 474 else | 463 else |
| 475 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 464 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| 476 | 465 |
| 477 if (!main().defer_commits && main().pending_deferred_commit) { | 466 if (!main().defer_commits && main().pending_deferred_commit) { |
| 478 Proxy::MainThreadTaskRunner()->PostTask( | 467 Proxy::MainThreadTaskRunner()->PostTask( |
| 479 FROM_HERE, | 468 FROM_HERE, |
| 480 base::Bind(&ThreadProxy::BeginMainFrame, | 469 base::Bind(&ThreadProxy::BeginMainFrame, |
| 481 main_thread_weak_ptr_, | 470 main_thread_weak_ptr_, |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 730 |
| 742 if (main().defer_commits) { | 731 if (main().defer_commits) { |
| 743 main().pending_deferred_commit = begin_main_frame_state.Pass(); | 732 main().pending_deferred_commit = begin_main_frame_state.Pass(); |
| 744 layer_tree_host()->DidDeferCommit(); | 733 layer_tree_host()->DidDeferCommit(); |
| 745 TRACE_EVENT_INSTANT0( | 734 TRACE_EVENT_INSTANT0( |
| 746 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); | 735 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); |
| 747 return; | 736 return; |
| 748 } | 737 } |
| 749 | 738 |
| 750 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 739 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 751 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's | 740 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
| 752 // swap promises. | 741 // remaining swap promises. |
| 753 SwapPromiseChecker swap_promise_checker(layer_tree_host()); | 742 ScopedSwapPromiseChecker swap_promise_checker(layer_tree_host()); |
| 754 | 743 |
| 755 main().commit_requested = false; | 744 main().commit_requested = false; |
| 756 main().commit_request_sent_to_impl_thread = false; | 745 main().commit_request_sent_to_impl_thread = false; |
| 757 main().animate_requested = false; | 746 main().animate_requested = false; |
| 758 | 747 |
| 759 if (!layer_tree_host()->visible()) { | 748 if (!layer_tree_host()->visible()) { |
| 760 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 749 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
| 761 bool did_handle = false; | 750 bool did_handle = false; |
| 762 Proxy::ImplThreadTaskRunner()->PostTask( | 751 Proxy::ImplThreadTaskRunner()->PostTask( |
| 763 FROM_HERE, | 752 FROM_HERE, |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1402 |
| 1414 impl().timing_history.DidActivateSyncTree(); | 1403 impl().timing_history.DidActivateSyncTree(); |
| 1415 } | 1404 } |
| 1416 | 1405 |
| 1417 void ThreadProxy::DidManageTiles() { | 1406 void ThreadProxy::DidManageTiles() { |
| 1418 DCHECK(IsImplThread()); | 1407 DCHECK(IsImplThread()); |
| 1419 impl().scheduler->DidManageTiles(); | 1408 impl().scheduler->DidManageTiles(); |
| 1420 } | 1409 } |
| 1421 | 1410 |
| 1422 } // namespace cc | 1411 } // namespace cc |
| OLD | NEW |