Index: cc/trees/layer_tree_host_impl.cc |
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
index 13f8b502a3717a298d710a363d6a3363c54ef210..c652ee349c08f45496171088920356b5e386a92d 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -15,6 +15,7 @@ |
#include "base/strings/stringprintf.h" |
#include "cc/animation/scrollbar_animation_controller.h" |
#include "cc/animation/timing_function.h" |
+#include "cc/base/latency_info_swap_promise.h" |
#include "cc/base/latency_info_swap_promise_monitor.h" |
#include "cc/base/math_util.h" |
#include "cc/base/util.h" |
@@ -500,6 +501,24 @@ LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
} |
+void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( |
+ scoped_ptr<LatencyInfoSwapPromise> swap_promise) { |
+ if (swap_promises_for_main_thread_scroll_update_.size() > |
+ kMaxQueuedSwapPromiseNumber) { |
+ BreakSwapPromisesForMainThreadScrollUpdate( |
+ SwapPromise::SWAP_PROMISE_LIST_OVERFLOW); |
+ } |
+ swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); |
+} |
+ |
+void LayerTreeHostImpl::BreakSwapPromisesForMainThreadScrollUpdate( |
+ SwapPromise::DidNotSwapReason reason) { |
+ for (size_t i = 0; i < swap_promises_for_main_thread_scroll_update_.size(); |
+ i++) |
+ swap_promises_for_main_thread_scroll_update_[i]->DidNotSwap(reason); |
+ swap_promises_for_main_thread_scroll_update_.clear(); |
+} |
+ |
void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
LayerImpl* root_draw_layer, |
const LayerImplList& render_surface_layer_list) { |
@@ -2468,6 +2487,11 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point, |
bool did_scroll_content = did_scroll_x || did_scroll_y; |
if (did_scroll_content) { |
+ // If we are scrolling with an active scroll handler, forward latency |
+ // tracking information to the main thread so the delay introduced by the |
+ // handler is accounted for. |
+ if (scroll_affects_scroll_handler()) |
+ NotifySwapPromiseMonitorsOfForwardingToMainThread(); |
client_->SetNeedsCommitOnImplThread(); |
SetNeedsRedraw(); |
client_->RenewTreePriority(); |
@@ -2769,6 +2793,7 @@ scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
+ scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
return scroll_info.Pass(); |
} |
@@ -3145,6 +3170,12 @@ void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
(*it)->OnSetNeedsRedrawOnImpl(); |
} |
+void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { |
+ std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
+ for (; it != swap_promise_monitor_.end(); it++) |
+ (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); |
+} |
+ |
void LayerTreeHostImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { |
DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == |
picture_layers_.end()); |