Index: cc/trees/layer_tree_host.cc |
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc |
index d93e3d5e032e80c8cf353b672338904f832a16f2..3b404d1990432e4f4429901465e19ab10521530e 100644 |
--- a/cc/trees/layer_tree_host.cc |
+++ b/cc/trees/layer_tree_host.cc |
@@ -42,6 +42,7 @@ |
namespace { |
static int s_num_layer_tree_instances; |
+const size_t kMaxQueuedSwapPromiseSize = 100; |
jamesr
2013/11/12 03:15:04
where does this number come from?
Yufeng Shen (Slow to review)
2013/11/13 21:05:04
see comments below.
|
} |
namespace cc { |
@@ -398,6 +399,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
sync_tree->SetLatencyInfo(latency_info_); |
latency_info_.Clear(); |
+ sync_tree->TakeSwapPromise(&swap_promise_list_); |
+ |
host_impl->SetViewportSize(device_viewport_size_); |
host_impl->SetOverdrawBottomHeight(overdraw_bottom_height_); |
host_impl->SetDeviceScaleFactor(device_scale_factor_); |
@@ -1290,4 +1293,33 @@ bool LayerTreeHost::ScheduleMicroBenchmark( |
benchmark_name, value.Pass(), callback); |
} |
+void LayerTreeHost::QueueSwapPromise(const SwapPromise& swap_promise) { |
+ if (proxy_->HasImplThread()) { |
+ DCHECK(proxy_->CommitRequested() || proxy_->BeginMainFrameRequested()); |
+ } |
+ if (swap_promise_list_.size() > kMaxQueuedSwapPromiseSize) { |
+ NOTREACHED() << "LayerTreeHost::swap_promise_list overflows"; |
jamesr
2013/11/12 03:15:04
i don't understand this. why have this limit?
doe
Yufeng Shen (Slow to review)
2013/11/13 21:05:04
If SwapPromise is supposed to be used by different
|
+ swap_promise_list_.clear(); |
+ } |
+ swap_promise_list_.push_back(swap_promise); |
+} |
+ |
+bool LayerTreeHost::HasQueuedSwapPromise() { |
+ return !swap_promise_list_.empty(); |
+} |
+ |
+void LayerTreeHost::FinishSwapPromise() { |
+ for (size_t i = 0; i < swap_promise_list_.size(); i++) { |
+ swap_promise_list_[i].did_swap_callback.Run(); |
+ } |
+ swap_promise_list_.clear(); |
+} |
+ |
+void LayerTreeHost::BreakSwapPromise(const std::string& msg) { |
+ for (size_t i = 0; i < swap_promise_list_.size(); i++) { |
+ swap_promise_list_[i].swap_aborted_callback.Run(msg); |
+ } |
+ swap_promise_list_.clear(); |
+} |
+ |
} // namespace cc |