Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 60513007: Add SwapPromise support to LayerTreeHost and LayerTreeImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rework SwapPromise() interface to have virtual DidSwap() & DidNotSwap() interface Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 if (layer_tree_host_->HasQueuedSwapPromise())
danakj 2013/11/13 23:23:35 Do you even need this? You could just always call
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
45 layer_tree_host_->BreakSwapPromise(cc::SwapPromise::COMMIT_FAILS);
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
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.
danakj 2013/11/13 23:22:09 Spell out LayerTreeHost and LayerTreeImpl
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
753 // The dtor of SwapPromiseChecker will check LTH's swap promises, and
danakj 2013/11/13 23:22:09 destructor check the LayerTreeHost's swap promise
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
754 // break those swap promises if the commit ever aborts.
755 SwapPromiseChecker swap_promise_checker(layer_tree_host_);
756
733 // Do not notify the impl thread of commit requests that occur during 757 // Do not notify the impl thread of commit requests that occur during
734 // the apply/animate/layout part of the BeginMainFrameAndCommit process since 758 // the apply/animate/layout part of the BeginMainFrameAndCommit process since
735 // those commit requests will get painted immediately. Once we have done 759 // 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 760 // the paint, commit_requested_ will be set to false to allow new commit
737 // requests to be scheduled. 761 // requests to be scheduled.
738 commit_requested_ = true; 762 commit_requested_ = true;
739 commit_request_sent_to_impl_thread_ = true; 763 commit_request_sent_to_impl_thread_ = true;
740 764
741 // On the other hand, the AnimationRequested flag needs to be cleared 765 // On the other hand, the AnimationRequested flag needs to be cleared
742 // here so that any animation requests generated by the apply or animate 766 // here so that any animation requests generated by the apply or animate
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, 1126 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels,
1103 readback_request_on_impl_thread_->rect); 1127 readback_request_on_impl_thread_->rect);
1104 result.did_readback = true; 1128 result.did_readback = true;
1105 } 1129 }
1106 readback_request_on_impl_thread_->success = result.did_readback; 1130 readback_request_on_impl_thread_->success = result.did_readback;
1107 readback_request_on_impl_thread_->completion.Signal(); 1131 readback_request_on_impl_thread_->completion.Signal();
1108 readback_request_on_impl_thread_ = NULL; 1132 readback_request_on_impl_thread_ = NULL;
1109 } else if (draw_frame) { 1133 } else if (draw_frame) {
1110 DCHECK(swap_requested); 1134 DCHECK(swap_requested);
1111 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame); 1135 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame);
1136 if (result.did_swap)
1137 layer_tree_host_impl_->active_tree()->FinishSwapPromise();
1138 else
1139 layer_tree_host_impl_->active_tree()->BreakSwapPromise(
1140 SwapPromise::SWAP_FAILS);
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void ThreadProxy::DidManageTiles() { 1623 void ThreadProxy::DidManageTiles() {
1595 DCHECK(IsImplThread()); 1624 DCHECK(IsImplThread());
1596 scheduler_on_impl_thread_->DidManageTiles(); 1625 scheduler_on_impl_thread_->DidManageTiles();
1597 } 1626 }
1598 1627
1599 } // namespace cc 1628 } // namespace cc
OLDNEW
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/single_thread_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698