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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "cc/base/swap_promise.h" |
13 #include "cc/debug/benchmark_instrumentation.h" | 14 #include "cc/debug/benchmark_instrumentation.h" |
14 #include "cc/input/input_handler.h" | 15 #include "cc/input/input_handler.h" |
15 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
16 #include "cc/output/output_surface.h" | 17 #include "cc/output/output_surface.h" |
17 #include "cc/quads/draw_quad.h" | 18 #include "cc/quads/draw_quad.h" |
18 #include "cc/resources/prioritized_resource_manager.h" | 19 #include "cc/resources/prioritized_resource_manager.h" |
19 #include "cc/scheduler/delay_based_time_source.h" | 20 #include "cc/scheduler/delay_based_time_source.h" |
20 #include "cc/scheduler/frame_rate_controller.h" | 21 #include "cc/scheduler/frame_rate_controller.h" |
21 #include "cc/scheduler/scheduler.h" | 22 #include "cc/scheduler/scheduler.h" |
22 #include "cc/trees/blocking_task_runner.h" | 23 #include "cc/trees/blocking_task_runner.h" |
23 #include "cc/trees/layer_tree_host.h" | 24 #include "cc/trees/layer_tree_host.h" |
24 #include "cc/trees/layer_tree_impl.h" | 25 #include "cc/trees/layer_tree_impl.h" |
25 #include "ui/gfx/frame_time.h" | 26 #include "ui/gfx/frame_time.h" |
26 | 27 |
| 28 namespace { |
| 29 |
27 // Measured in seconds. | 30 // Measured in seconds. |
28 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 31 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
29 | 32 |
30 const size_t kDurationHistorySize = 60; | 33 const size_t kDurationHistorySize = 60; |
31 const double kCommitAndActivationDurationEstimationPercentile = 50.0; | 34 const double kCommitAndActivationDurationEstimationPercentile = 50.0; |
32 const double kDrawDurationEstimationPercentile = 100.0; | 35 const double kDrawDurationEstimationPercentile = 100.0; |
33 const int kDrawDurationEstimatePaddingInMicroseconds = 0; | 36 const int kDrawDurationEstimatePaddingInMicroseconds = 0; |
34 | 37 |
| 38 class SwapPromiseChecker { |
| 39 public: |
| 40 explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host) |
| 41 : layer_tree_host_(layer_tree_host) {} |
| 42 |
| 43 ~SwapPromiseChecker() { |
| 44 layer_tree_host_->BreakSwapPromises(cc::SwapPromise::COMMIT_FAILS); |
| 45 } |
| 46 |
| 47 private: |
| 48 cc::LayerTreeHost* layer_tree_host_; |
| 49 }; |
| 50 |
| 51 } // namespace |
| 52 |
35 namespace cc { | 53 namespace cc { |
36 | 54 |
37 struct ThreadProxy::ReadbackRequest { | 55 struct ThreadProxy::ReadbackRequest { |
38 CompletionEvent completion; | 56 CompletionEvent completion; |
39 bool success; | 57 bool success; |
40 void* pixels; | 58 void* pixels; |
41 gfx::Rect rect; | 59 gfx::Rect rect; |
42 }; | 60 }; |
43 | 61 |
44 struct ThreadProxy::CommitPendingRequest { | 62 struct ThreadProxy::CommitPendingRequest { |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 if (!layer_tree_host_) | 741 if (!layer_tree_host_) |
724 return; | 742 return; |
725 | 743 |
726 if (defer_commits_) { | 744 if (defer_commits_) { |
727 pending_deferred_commit_ = begin_main_frame_state.Pass(); | 745 pending_deferred_commit_ = begin_main_frame_state.Pass(); |
728 layer_tree_host_->DidDeferCommit(); | 746 layer_tree_host_->DidDeferCommit(); |
729 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 747 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
730 return; | 748 return; |
731 } | 749 } |
732 | 750 |
| 751 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
| 752 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's |
| 753 // swap promises. |
| 754 SwapPromiseChecker swap_promise_checker(layer_tree_host_); |
| 755 |
733 // Do not notify the impl thread of commit requests that occur during | 756 // Do not notify the impl thread of commit requests that occur during |
734 // the apply/animate/layout part of the BeginMainFrameAndCommit process since | 757 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
735 // those commit requests will get painted immediately. Once we have done | 758 // those commit requests will get painted immediately. Once we have done |
736 // the paint, commit_requested_ will be set to false to allow new commit | 759 // the paint, commit_requested_ will be set to false to allow new commit |
737 // requests to be scheduled. | 760 // requests to be scheduled. |
738 commit_requested_ = true; | 761 commit_requested_ = true; |
739 commit_request_sent_to_impl_thread_ = true; | 762 commit_request_sent_to_impl_thread_ = true; |
740 | 763 |
741 // On the other hand, the AnimationRequested flag needs to be cleared | 764 // On the other hand, the AnimationRequested flag needs to be cleared |
742 // here so that any animation requests generated by the apply or animate | 765 // here so that any animation requests generated by the apply or animate |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 commit_to_activate_duration_history_.InsertSample( | 1613 commit_to_activate_duration_history_.InsertSample( |
1591 base::TimeTicks::HighResNow() - commit_complete_time_); | 1614 base::TimeTicks::HighResNow() - commit_complete_time_); |
1592 } | 1615 } |
1593 | 1616 |
1594 void ThreadProxy::DidManageTiles() { | 1617 void ThreadProxy::DidManageTiles() { |
1595 DCHECK(IsImplThread()); | 1618 DCHECK(IsImplThread()); |
1596 scheduler_on_impl_thread_->DidManageTiles(); | 1619 scheduler_on_impl_thread_->DidManageTiles(); |
1597 } | 1620 } |
1598 | 1621 |
1599 } // namespace cc | 1622 } // namespace cc |
OLD | NEW |