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 caa380ec8623f26c387539b3067298a87da5a698..12c6dda1f5f0da5160a89215d4897e61ef0241e0 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -503,6 +503,11 @@ LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
} |
+void LayerTreeHostImpl::QueueScrollUpdateLatencyInfo( |
+ const ui::LatencyInfo& latency_info) { |
+ scroll_update_latency_infos_.push_back(latency_info); |
+} |
+ |
void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
LayerImpl* root_draw_layer, |
const LayerImplList& render_surface_layer_list) { |
@@ -2462,6 +2467,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(); |
@@ -2763,6 +2773,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); |
+ std::swap(scroll_info->latency_infos, scroll_update_latency_infos_); |
return scroll_info.Pass(); |
} |
@@ -3139,6 +3150,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()); |