diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 04:15:08 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 04:15:08 +0000 |
commit | b76329da0d38e599eb5f4f4581443d4f3a20feac (patch) | |
tree | 3e76cdeadb12f8f82918105ab515c28df34d585f | |
parent | 2f0d92f42bf494a62bd41309d888348f17340b6d (diff) | |
download | chromium_src-b76329da0d38e599eb5f4f4581443d4f3a20feac.zip chromium_src-b76329da0d38e599eb5f4f4581443d4f3a20feac.tar.gz chromium_src-b76329da0d38e599eb5f4f4581443d4f3a20feac.tar.bz2 |
Track LatencyInfo through impl-thread scrolling.
Extract the LatencyInfo from the input event and pass it to the LayerTreeHostImpl along with the input event.
BUG=155367
R=jamesr@chromium.org
Review URL: https://codereview.chromium.org/15899013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/input/input_handler.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/android/in_process/synchronous_input_event_filter.cc | 3 | ||||
-rw-r--r-- | content/renderer/gpu/input_event_filter.cc | 23 | ||||
-rw-r--r-- | content/renderer/gpu/input_event_filter.h | 4 | ||||
-rw-r--r-- | content/renderer/gpu/input_event_filter_unittest.cc | 5 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_manager.cc | 6 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_manager.h | 3 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_manager_client.h | 10 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_proxy.cc | 13 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_proxy.h | 3 | ||||
-rw-r--r-- | content/renderer/gpu/input_handler_proxy_unittest.cc | 4 |
14 files changed, 71 insertions, 17 deletions
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h index e4499af..89e8ec3 100644 --- a/cc/input/input_handler.h +++ b/cc/input/input_handler.h @@ -17,6 +17,8 @@ class Vector2d; class Vector2dF; } +namespace ui { struct LatencyInfo; } + namespace cc { class LayerScrollOffsetDelegate; @@ -118,6 +120,9 @@ class CC_EXPORT InputHandler { virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_point) = 0; + virtual void SetLatencyInfoForInputEvent( + const ui::LatencyInfo& latency_info) = 0; + protected: InputHandler() {} virtual ~InputHandler() {} diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 7080044..492df4d 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -385,6 +385,11 @@ bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { return false; } +void LayerTreeHostImpl::SetLatencyInfoForInputEvent( + const ui::LatencyInfo& latency_info) { + active_tree()->SetLatencyInfo(latency_info); +} + void LayerTreeHostImpl::TrackDamageForAllSurfaces( LayerImpl* root_draw_layer, const LayerImplList& render_surface_layer_list) { diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index b7ebe17..5bfbcfd 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -125,6 +125,8 @@ class CC_EXPORT LayerTreeHostImpl base::TimeDelta duration) OVERRIDE; virtual void ScheduleAnimation() OVERRIDE; virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE; + virtual void SetLatencyInfoForInputEvent(const ui::LatencyInfo& latency_info) + OVERRIDE; // TopControlsManagerClient implementation. virtual void DidChangeTopControlsPosition() OVERRIDE; diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 432af98..6180568 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -345,6 +345,8 @@ void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { pending_tree->SetCurrentlyScrollingLayer( LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0)); + pending_tree->SetLatencyInfo(latency_info_); + latency_info_.Clear(); } static void DidBecomeActiveRecursive(LayerImpl* layer) { diff --git a/content/browser/android/in_process/synchronous_input_event_filter.cc b/content/browser/android/in_process/synchronous_input_event_filter.cc index 3e0c09a..75bf352 100644 --- a/content/browser/android/in_process/synchronous_input_event_filter.cc +++ b/content/browser/android/in_process/synchronous_input_event_filter.cc @@ -5,6 +5,7 @@ #include "content/browser/android/in_process/synchronous_input_event_filter.h" #include "content/public/browser/browser_thread.h" +#include "ui/base/latency_info.h" using WebKit::WebInputEvent; @@ -25,7 +26,7 @@ InputEventAckState SynchronousInputEventFilter::HandleInputEvent( if (handler_.is_null()) return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; - return handler_.Run(routing_id, &input_event); + return handler_.Run(routing_id, &input_event, ui::LatencyInfo()); } void SynchronousInputEventFilter::SetBoundHandler(const Handler& handler) { diff --git a/content/renderer/gpu/input_event_filter.cc b/content/renderer/gpu/input_event_filter.cc index ecf47a0..0d06a1f 100644 --- a/content/renderer/gpu/input_event_filter.cc +++ b/content/renderer/gpu/input_event_filter.cc @@ -80,12 +80,15 @@ bool InputEventFilter::OnMessageReceived(const IPC::Message& message) { // static const WebInputEvent* InputEventFilter::CrackMessage( - const IPC::Message& message) { + const IPC::Message& message, + ui::LatencyInfo* latency_info) { DCHECK(message.type() == InputMsg_HandleInputEvent::ID); PickleIterator iter(message); const WebInputEvent* event = NULL; IPC::ParamTraits<IPC::WebInputEventPointer>::Read(&message, &iter, &event); + if (latency_info) + IPC::ParamTraits<ui::LatencyInfo>::Read(&message, &iter, latency_info); return event; } @@ -108,8 +111,11 @@ void InputEventFilter::ForwardToHandler(const IPC::Message& message) { return; } - InputEventAckState ack = handler_.Run(message.routing_id(), - CrackMessage(message)); + ui::LatencyInfo latency_info; + const WebInputEvent* event = CrackMessage(message, &latency_info); + + InputEventAckState ack = + handler_.Run(message.routing_id(), event, latency_info); if (ack == INPUT_EVENT_ACK_STATE_NOT_CONSUMED) { TRACE_EVENT0("input", "InputEventFilter::ForwardToHandler"); @@ -127,11 +133,12 @@ void InputEventFilter::SendACK(const IPC::Message& message, InputEventAckState ack_result) { DCHECK(target_loop_->BelongsToCurrentThread()); - io_loop_->PostTask( - FROM_HERE, - base::Bind(&InputEventFilter::SendACKOnIOThread, this, - message.routing_id(), CrackMessage(message)->type, - ack_result)); + io_loop_->PostTask(FROM_HERE, + base::Bind(&InputEventFilter::SendACKOnIOThread, + this, + message.routing_id(), + CrackMessage(message, NULL)->type, + ack_result)); } void InputEventFilter::SendACKOnIOThread( diff --git a/content/renderer/gpu/input_event_filter.h b/content/renderer/gpu/input_event_filter.h index 499003c..3638eba 100644 --- a/content/renderer/gpu/input_event_filter.h +++ b/content/renderer/gpu/input_event_filter.h @@ -54,7 +54,9 @@ class CONTENT_EXPORT InputEventFilter virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; // Expects a InputMsg_HandleInputEvent message. - static const WebKit::WebInputEvent* CrackMessage(const IPC::Message& message); + static const WebKit::WebInputEvent* CrackMessage( + const IPC::Message& message, + ui::LatencyInfo* latency_info); private: friend class IPC::ChannelProxy::MessageFilter; diff --git a/content/renderer/gpu/input_event_filter_unittest.cc b/content/renderer/gpu/input_event_filter_unittest.cc index 8f48f12..61c0002 100644 --- a/content/renderer/gpu/input_event_filter_unittest.cc +++ b/content/renderer/gpu/input_event_filter_unittest.cc @@ -46,7 +46,8 @@ class InputEventRecorder { } InputEventAckState HandleInputEvent(int routing_id, - const WebInputEvent* event) { + const WebInputEvent* event, + const ui::LatencyInfo& latency_info) { DCHECK_EQ(kTestRoutingID, routing_id); records_.push_back(Record(event)); @@ -210,7 +211,7 @@ TEST_F(InputEventFilterTest, Basic) { const IPC::Message& message = message_recorder_.message_at(i); ASSERT_EQ(InputMsg_HandleInputEvent::ID, message.type()); - const WebInputEvent* event = InputEventFilter::CrackMessage(message); + const WebInputEvent* event = InputEventFilter::CrackMessage(message, NULL); EXPECT_EQ(kEvents[i].size, event->size); EXPECT_TRUE(memcmp(&kEvents[i], event, event->size) == 0); diff --git a/content/renderer/gpu/input_handler_manager.cc b/content/renderer/gpu/input_handler_manager.cc index 37cf957..8a2683d 100644 --- a/content/renderer/gpu/input_handler_manager.cc +++ b/content/renderer/gpu/input_handler_manager.cc @@ -103,7 +103,8 @@ void InputHandlerManager::RemoveInputHandler(int routing_id) { InputEventAckState InputHandlerManager::HandleInputEvent( int routing_id, - const WebInputEvent* input_event) { + const WebInputEvent* input_event, + const ui::LatencyInfo& latency_info) { DCHECK(message_loop_proxy_->BelongsToCurrentThread()); InputHandlerMap::iterator it = input_handlers_.find(routing_id); @@ -114,8 +115,9 @@ InputEventAckState InputHandlerManager::HandleInputEvent( return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; } + InputHandlerProxy* proxy = it->second->input_handler_proxy(); return InputEventDispositionToAck( - it->second->input_handler_proxy()->HandleInputEvent(*input_event)); + proxy->HandleInputEventWithLatencyInfo(*input_event, latency_info)); } } // namespace content diff --git a/content/renderer/gpu/input_handler_manager.h b/content/renderer/gpu/input_handler_manager.h index 904db0d..02104ff 100644 --- a/content/renderer/gpu/input_handler_manager.h +++ b/content/renderer/gpu/input_handler_manager.h @@ -51,7 +51,8 @@ class InputHandlerManager { // Called from the compositor's thread. InputEventAckState HandleInputEvent(int routing_id, - const WebKit::WebInputEvent* input_event); + const WebKit::WebInputEvent* input_event, + const ui::LatencyInfo& latency_info); private: // Called from the compositor's thread. diff --git a/content/renderer/gpu/input_handler_manager_client.h b/content/renderer/gpu/input_handler_manager_client.h index deb7839..11ec084 100644 --- a/content/renderer/gpu/input_handler_manager_client.h +++ b/content/renderer/gpu/input_handler_manager_client.h @@ -9,6 +9,10 @@ #include "base/callback_forward.h" #include "content/common/content_export.h" +namespace ui { +struct LatencyInfo; +} + namespace WebKit { class WebInputEvent; } @@ -22,8 +26,10 @@ class CONTENT_EXPORT InputHandlerManagerClient { // The Manager will supply a |handler| when bound to the client. This is valid // until the manager shuts down, at which point it supplies a null |handler|. // The client should only makes calls to |handler| on the compositor thread. - typedef base::Callback<InputEventAckState( - int /*routing_id*/, const WebKit::WebInputEvent*)> Handler; + typedef base::Callback< + InputEventAckState(int /*routing_id*/, + const WebKit::WebInputEvent*, + const ui::LatencyInfo& latency_info)> Handler; // Called from the main thread. virtual void SetBoundHandler(const Handler& handler) = 0; diff --git a/content/renderer/gpu/input_handler_proxy.cc b/content/renderer/gpu/input_handler_proxy.cc index c9fdd51..6fa233a 100644 --- a/content/renderer/gpu/input_handler_proxy.cc +++ b/content/renderer/gpu/input_handler_proxy.cc @@ -9,6 +9,7 @@ #include "content/renderer/gpu/input_handler_proxy_client.h" #include "third_party/WebKit/public/platform/Platform.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "ui/base/latency_info.h" using WebKit::WebFloatPoint; using WebKit::WebFloatSize; @@ -48,6 +49,18 @@ void InputHandlerProxy::SetClient(InputHandlerProxyClient* client) { client_ = client; } +InputHandlerProxy::EventDisposition +InputHandlerProxy::HandleInputEventWithLatencyInfo( + const WebInputEvent& event, + const ui::LatencyInfo& latency_info) { + DCHECK(input_handler_); + + InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); + if (disposition != DID_NOT_HANDLE) + input_handler_->SetLatencyInfoForInputEvent(latency_info); + return disposition; +} + InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( const WebInputEvent& event) { DCHECK(client_); diff --git a/content/renderer/gpu/input_handler_proxy.h b/content/renderer/gpu/input_handler_proxy.h index 3784771..26a42f5 100644 --- a/content/renderer/gpu/input_handler_proxy.h +++ b/content/renderer/gpu/input_handler_proxy.h @@ -37,6 +37,9 @@ class CONTENT_EXPORT InputHandlerProxy DID_NOT_HANDLE, DROP_EVENT }; + EventDisposition HandleInputEventWithLatencyInfo( + const WebKit::WebInputEvent& event, + const ui::LatencyInfo& latency_info); EventDisposition HandleInputEvent(const WebKit::WebInputEvent& event); // cc::InputHandlerClient implementation. diff --git a/content/renderer/gpu/input_handler_proxy_unittest.cc b/content/renderer/gpu/input_handler_proxy_unittest.cc index 0abf803..edc2d6e 100644 --- a/content/renderer/gpu/input_handler_proxy_unittest.cc +++ b/content/renderer/gpu/input_handler_proxy_unittest.cc @@ -14,6 +14,7 @@ #include "third_party/WebKit/public/platform/WebGestureCurve.h" #include "third_party/WebKit/public/platform/WebPoint.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" +#include "ui/base/latency_info.h" using WebKit::WebActiveWheelFlingParameters; using WebKit::WebFloatPoint; @@ -50,6 +51,9 @@ class MockInputHandler : public cc::InputHandler { MOCK_METHOD0(ScrollEnd, void()); MOCK_METHOD0(FlingScrollBegin, cc::InputHandler::ScrollStatus()); + MOCK_METHOD1(SetLatencyInfoForInputEvent, + void(const ui::LatencyInfo& latency_info)); + virtual void BindToClient(cc::InputHandlerClient* client) OVERRIDE {} virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, |