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_abort_remaining_swap_promises.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::SchedulerStateRequest { | 43 struct ThreadProxy::SchedulerStateRequest { |
56 CompletionEvent completion; | 44 CompletionEvent completion; |
57 scoped_ptr<base::Value> state; | 45 scoped_ptr<base::Value> state; |
58 }; | 46 }; |
59 | 47 |
60 scoped_ptr<Proxy> ThreadProxy::Create( | 48 scoped_ptr<Proxy> ThreadProxy::Create( |
61 LayerTreeHost* layer_tree_host, | 49 LayerTreeHost* layer_tree_host, |
62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 434 } |
447 | 435 |
448 void ThreadProxy::SetNextCommitWaitsForActivation() { | 436 void ThreadProxy::SetNextCommitWaitsForActivation() { |
449 DCHECK(IsMainThread()); | 437 DCHECK(IsMainThread()); |
450 DCHECK(!blocked_main().main_thread_inside_commit); | 438 DCHECK(!blocked_main().main_thread_inside_commit); |
451 blocked_main().commit_waits_for_activation = true; | 439 blocked_main().commit_waits_for_activation = true; |
452 } | 440 } |
453 | 441 |
454 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 442 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
455 DCHECK(IsMainThread()); | 443 DCHECK(IsMainThread()); |
456 DCHECK_NE(main().defer_commits, defer_commits); | 444 if (main().defer_commits == defer_commits) |
| 445 return; |
| 446 |
457 main().defer_commits = defer_commits; | 447 main().defer_commits = defer_commits; |
458 | |
459 if (main().defer_commits) | 448 if (main().defer_commits) |
460 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 449 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
461 else | 450 else |
462 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 451 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
463 | 452 |
464 if (!main().defer_commits && main().pending_deferred_commit) { | 453 if (!main().defer_commits && main().pending_deferred_commit) { |
465 Proxy::MainThreadTaskRunner()->PostTask( | 454 Proxy::MainThreadTaskRunner()->PostTask( |
466 FROM_HERE, | 455 FROM_HERE, |
467 base::Bind(&ThreadProxy::BeginMainFrame, | 456 base::Bind(&ThreadProxy::BeginMainFrame, |
468 main_thread_weak_ptr_, | 457 main_thread_weak_ptr_, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 717 |
729 if (main().defer_commits) { | 718 if (main().defer_commits) { |
730 main().pending_deferred_commit = begin_main_frame_state.Pass(); | 719 main().pending_deferred_commit = begin_main_frame_state.Pass(); |
731 layer_tree_host()->DidDeferCommit(); | 720 layer_tree_host()->DidDeferCommit(); |
732 TRACE_EVENT_INSTANT0( | 721 TRACE_EVENT_INSTANT0( |
733 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); | 722 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); |
734 return; | 723 return; |
735 } | 724 } |
736 | 725 |
737 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 726 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
738 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's | 727 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
739 // swap promises. | 728 // remaining swap promises. |
740 SwapPromiseChecker swap_promise_checker(layer_tree_host()); | 729 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); |
741 | 730 |
742 main().commit_requested = false; | 731 main().commit_requested = false; |
743 main().commit_request_sent_to_impl_thread = false; | 732 main().commit_request_sent_to_impl_thread = false; |
744 main().animate_requested = false; | 733 main().animate_requested = false; |
745 | 734 |
746 if (!layer_tree_host()->visible()) { | 735 if (!layer_tree_host()->visible()) { |
747 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); | 736 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); |
748 bool did_handle = false; | 737 bool did_handle = false; |
749 Proxy::ImplThreadTaskRunner()->PostTask( | 738 Proxy::ImplThreadTaskRunner()->PostTask( |
750 FROM_HERE, | 739 FROM_HERE, |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1390 |
1402 impl().timing_history.DidActivateSyncTree(); | 1391 impl().timing_history.DidActivateSyncTree(); |
1403 } | 1392 } |
1404 | 1393 |
1405 void ThreadProxy::DidManageTiles() { | 1394 void ThreadProxy::DidManageTiles() { |
1406 DCHECK(IsImplThread()); | 1395 DCHECK(IsImplThread()); |
1407 impl().scheduler->DidManageTiles(); | 1396 impl().scheduler->DidManageTiles(); |
1408 } | 1397 } |
1409 | 1398 |
1410 } // namespace cc | 1399 } // namespace cc |
OLD | NEW |