| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_ |
| 6 #define BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 12 #include "ui/events/blink/input_handler_proxy.h" |
| 13 #include "ui/events/blink/input_handler_proxy_client.h" |
| 14 #include "ui/events/gesture_detection/filtered_gesture_provider.h" |
| 15 #include "ui/events/gesture_detection/motion_event.h" |
| 16 |
| 17 namespace blimp { |
| 18 |
| 19 class BlimpInputManagerClient { |
| 20 public: |
| 21 virtual void SendWebInputEvent( |
| 22 const blink::WebInputEvent& input_event) = 0; |
| 23 }; |
| 24 |
| 25 // The BlimpInputManager handles input events for a specific render widget. The |
| 26 // class processes ui::events to generate web input events which are forwarded |
| 27 // to the compositor to be handled on the compositor thread. If the event can |
| 28 // not be handled locally by the compositor, it is given to the |
| 29 // BlimpInputManagerClient to be sent to the engine. |
| 30 class BlimpInputManager : public ui::InputHandlerProxyClient, |
| 31 public ui::GestureProviderClient { |
| 32 public: |
| 33 static scoped_ptr<BlimpInputManager> Create( |
| 34 BlimpInputManagerClient* client, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 36 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
| 37 const base::WeakPtr<cc::InputHandler>& input_handler); |
| 38 |
| 39 ~BlimpInputManager(); |
| 40 |
| 41 // Called to process a ui::MotionEvent. Returns true if the event was |
| 42 // successfully processed. |
| 43 bool OnTouchEvent(const ui::MotionEvent& motion_event); |
| 44 |
| 45 private: |
| 46 BlimpInputManager( |
| 47 BlimpInputManagerClient* client, |
| 48 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 49 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
| 50 const base::WeakPtr<cc::InputHandler>& input_handler); |
| 51 |
| 52 |
| 53 // InputHandlerProxyClient implementation. Called on the compositor thread. |
| 54 void WillShutdown() override; |
| 55 void TransferActiveWheelFlingAnimation( |
| 56 const blink::WebActiveWheelFlingParameters& params) override; |
| 57 blink::WebGestureCurve* CreateFlingAnimationCurve( |
| 58 blink::WebGestureDevice device_source, |
| 59 const blink::WebFloatPoint& velocity, |
| 60 const blink::WebSize& cumulative_scroll) override; |
| 61 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 62 const gfx::Vector2dF& latest_overscroll_delta, |
| 63 const gfx::Vector2dF& current_fling_velocity, |
| 64 const gfx::PointF& causal_event_viewport_point) override; |
| 65 void DidStopFlinging() override; |
| 66 void DidAnimateForInput() override; |
| 67 |
| 68 // ui::GestureProviderClient implementation. Called on main thread. |
| 69 void OnGestureEvent(const ui::GestureEventData& gesture) override; |
| 70 |
| 71 void CreateInputHandlerProxyOnCompositorThread( |
| 72 const base::WeakPtr<cc::InputHandler>& input_handler); |
| 73 void HandleWebInputEventOnCompositorThread( |
| 74 const blink::WebInputEvent& input_event); |
| 75 void SendWebInputEvent(const blink::WebInputEvent& input_event); |
| 76 |
| 77 bool IsMainThread() const; |
| 78 bool IsCompositorThread() const; |
| 79 |
| 80 BlimpInputManagerClient* client_; |
| 81 |
| 82 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 83 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 84 |
| 85 ui::FilteredGestureProvider gesture_provider_; |
| 86 |
| 87 scoped_ptr<ui::InputHandlerProxy> input_handler_proxy_; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(BlimpInputManager); |
| 90 }; |
| 91 |
| 92 } // namespace blimp |
| 93 |
| 94 #endif // BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_ |
| OLD | NEW |