Chromium Code Reviews| 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 #include <vector> | |
| 8 | 9 |
| 9 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.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 if (layer_tree_host_->HasQueuedSwapPromise()) | |
| 45 layer_tree_host_->BreakSwapPromise("COMMIT ABORTED"); | |
| 46 } | |
| 47 | |
| 48 private: | |
| 49 cc::LayerTreeHost* layer_tree_host_; | |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 35 namespace cc { | 54 namespace cc { |
| 36 | 55 |
| 37 struct ThreadProxy::ReadbackRequest { | 56 struct ThreadProxy::ReadbackRequest { |
| 38 CompletionEvent completion; | 57 CompletionEvent completion; |
| 39 bool success; | 58 bool success; |
| 40 void* pixels; | 59 void* pixels; |
| 41 gfx::Rect rect; | 60 gfx::Rect rect; |
| 42 }; | 61 }; |
| 43 | 62 |
| 44 struct ThreadProxy::CommitPendingRequest { | 63 struct ThreadProxy::CommitPendingRequest { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 if (!layer_tree_host_) | 742 if (!layer_tree_host_) |
| 724 return; | 743 return; |
| 725 | 744 |
| 726 if (defer_commits_) { | 745 if (defer_commits_) { |
| 727 pending_deferred_commit_ = begin_main_frame_state.Pass(); | 746 pending_deferred_commit_ = begin_main_frame_state.Pass(); |
| 728 layer_tree_host_->DidDeferCommit(); | 747 layer_tree_host_->DidDeferCommit(); |
| 729 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 748 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 730 return; | 749 return; |
| 731 } | 750 } |
| 732 | 751 |
| 752 // If the commit finishes, LTH will transfer its swap promises to LTI. | |
| 753 // The dtor of SwapPromiseChecker will check LTH's swap promises, and | |
| 754 // call the swap aborted callback of the swap promises if the commit | |
| 755 // ever aborts. | |
| 756 SwapPromiseChecker swap_promise_checker(layer_tree_host_); | |
|
jamesr
2013/11/12 03:15:04
it looks like this will invoke the aborted callbac
Yufeng Shen (Slow to review)
2013/11/13 21:05:04
See comments below.
| |
| 757 | |
| 733 // Do not notify the impl thread of commit requests that occur during | 758 // Do not notify the impl thread of commit requests that occur during |
| 734 // the apply/animate/layout part of the BeginMainFrameAndCommit process since | 759 // the apply/animate/layout part of the BeginMainFrameAndCommit process since |
| 735 // those commit requests will get painted immediately. Once we have done | 760 // 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 | 761 // the paint, commit_requested_ will be set to false to allow new commit |
| 737 // requests to be scheduled. | 762 // requests to be scheduled. |
| 738 commit_requested_ = true; | 763 commit_requested_ = true; |
| 739 commit_request_sent_to_impl_thread_ = true; | 764 commit_request_sent_to_impl_thread_ = true; |
| 740 | 765 |
| 741 // On the other hand, the AnimationRequested flag needs to be cleared | 766 // On the other hand, the AnimationRequested flag needs to be cleared |
| 742 // here so that any animation requests generated by the apply or animate | 767 // here so that any animation requests generated by the apply or animate |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, | 1127 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, |
| 1103 readback_request_on_impl_thread_->rect); | 1128 readback_request_on_impl_thread_->rect); |
| 1104 result.did_readback = true; | 1129 result.did_readback = true; |
| 1105 } | 1130 } |
| 1106 readback_request_on_impl_thread_->success = result.did_readback; | 1131 readback_request_on_impl_thread_->success = result.did_readback; |
| 1107 readback_request_on_impl_thread_->completion.Signal(); | 1132 readback_request_on_impl_thread_->completion.Signal(); |
| 1108 readback_request_on_impl_thread_ = NULL; | 1133 readback_request_on_impl_thread_ = NULL; |
| 1109 } else if (draw_frame) { | 1134 } else if (draw_frame) { |
| 1110 DCHECK(swap_requested); | 1135 DCHECK(swap_requested); |
| 1111 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame); | 1136 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame); |
| 1137 if (result.did_swap) | |
| 1138 layer_tree_host_impl_->active_tree()->FinishSwapPromise(); | |
| 1139 else | |
| 1140 layer_tree_host_impl_->active_tree()->BreakSwapPromise("DID NOT SWAP"); | |
|
jamesr
2013/11/12 03:15:04
whereas these calls will invoke callbacks from the
Yufeng Shen (Slow to review)
2013/11/13 21:05:04
Right. I have in the new patch set changed the in
| |
| 1112 | 1141 |
| 1113 // We don't know if we have incomplete tiles if we didn't actually swap. | 1142 // We don't know if we have incomplete tiles if we didn't actually swap. |
| 1114 if (result.did_swap) { | 1143 if (result.did_swap) { |
| 1115 DCHECK(!frame.has_no_damage); | 1144 DCHECK(!frame.has_no_damage); |
| 1116 SetSwapUsedIncompleteTileOnImplThread(frame.contains_incomplete_tile); | 1145 SetSwapUsedIncompleteTileOnImplThread(frame.contains_incomplete_tile); |
| 1117 } | 1146 } |
| 1118 } | 1147 } |
| 1119 | 1148 |
| 1120 // Tell the main thread that the the newly-commited frame was drawn. | 1149 // Tell the main thread that the the newly-commited frame was drawn. |
| 1121 if (next_frame_is_newly_committed_frame_on_impl_thread_) { | 1150 if (next_frame_is_newly_committed_frame_on_impl_thread_) { |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1585 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1614 completion_event_for_commit_held_on_tree_activation_ = NULL; |
| 1586 } | 1615 } |
| 1587 | 1616 |
| 1588 UpdateBackgroundAnimateTicking(); | 1617 UpdateBackgroundAnimateTicking(); |
| 1589 | 1618 |
| 1590 commit_to_activate_duration_history_.InsertSample( | 1619 commit_to_activate_duration_history_.InsertSample( |
| 1591 base::TimeTicks::HighResNow() - commit_complete_time_); | 1620 base::TimeTicks::HighResNow() - commit_complete_time_); |
| 1592 } | 1621 } |
| 1593 | 1622 |
| 1594 } // namespace cc | 1623 } // namespace cc |
| OLD | NEW |