Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: ui/events/blink/input_handler_proxy.h

Issue 2429953002: Implement compositor thread VSync aligned event queue (Closed)
Patch Set: dtapuska&enne's review: Call |Now()| once per loop; Chromium style; Remove parameterized test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/blink/event_with_callback.cc ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ 5 #ifndef UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
6 #define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ 6 #define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "cc/input/input_handler.h" 12 #include "cc/input/input_handler.h"
13 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 13 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" 14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
15 #include "third_party/WebKit/public/platform/WebGestureEvent.h" 15 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
16 #include "third_party/WebKit/public/platform/WebInputEvent.h" 16 #include "third_party/WebKit/public/platform/WebInputEvent.h"
17 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h" 17 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h"
18 #include "ui/events/blink/blink_features.h"
18 #include "ui/events/blink/input_scroll_elasticity_controller.h" 19 #include "ui/events/blink/input_scroll_elasticity_controller.h"
19 #include "ui/events/blink/scoped_web_input_event.h" 20 #include "ui/events/blink/scoped_web_input_event.h"
20 #include "ui/events/blink/synchronous_input_handler_proxy.h" 21 #include "ui/events/blink/synchronous_input_handler_proxy.h"
21 22
23 namespace base {
24 class TickClock;
25 }
26
22 namespace ui { 27 namespace ui {
23 28
24 namespace test { 29 namespace test {
25 class InputHandlerProxyTest; 30 class InputHandlerProxyTest;
31 class InputHandlerProxyEventQueueTest;
26 } 32 }
27 33
34 class CompositorThreadEventQueue;
35 class EventWithCallback;
28 class InputHandlerProxyClient; 36 class InputHandlerProxyClient;
29 class InputScrollElasticityController; 37 class InputScrollElasticityController;
30 class SynchronousInputHandler; 38 class SynchronousInputHandler;
31 class SynchronousInputHandlerProxy; 39 class SynchronousInputHandlerProxy;
32 struct DidOverscrollParams; 40 struct DidOverscrollParams;
33 41
34 // This class is a proxy between the blink web input events for a WebWidget and 42 // This class is a proxy between the blink web input events for a WebWidget and
35 // the compositor's input handling logic. InputHandlerProxy instances live 43 // the compositor's input handling logic. InputHandlerProxy instances live
36 // entirely on the compositor thread. Each InputHandler instance handles input 44 // entirely on the compositor thread. Each InputHandler instance handles input
37 // events intended for a specific WebWidget. 45 // events intended for a specific WebWidget.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void Animate(base::TimeTicks time) override; 82 void Animate(base::TimeTicks time) override;
75 void MainThreadHasStoppedFlinging() override; 83 void MainThreadHasStoppedFlinging() override;
76 void ReconcileElasticOverscrollAndRootScroll() override; 84 void ReconcileElasticOverscrollAndRootScroll() override;
77 void UpdateRootLayerStateForSynchronousInputHandler( 85 void UpdateRootLayerStateForSynchronousInputHandler(
78 const gfx::ScrollOffset& total_scroll_offset, 86 const gfx::ScrollOffset& total_scroll_offset,
79 const gfx::ScrollOffset& max_scroll_offset, 87 const gfx::ScrollOffset& max_scroll_offset,
80 const gfx::SizeF& scrollable_size, 88 const gfx::SizeF& scrollable_size,
81 float page_scale_factor, 89 float page_scale_factor,
82 float min_page_scale_factor, 90 float min_page_scale_factor,
83 float max_page_scale_factor) override; 91 float max_page_scale_factor) override;
92 void DeliverInputForBeginFrame() override;
84 93
85 // SynchronousInputHandlerProxy implementation. 94 // SynchronousInputHandlerProxy implementation.
86 void SetOnlySynchronouslyAnimateRootFlings( 95 void SetOnlySynchronouslyAnimateRootFlings(
87 SynchronousInputHandler* synchronous_input_handler) override; 96 SynchronousInputHandler* synchronous_input_handler) override;
88 void SynchronouslyAnimate(base::TimeTicks time) override; 97 void SynchronouslyAnimate(base::TimeTicks time) override;
89 void SynchronouslySetRootScrollOffset( 98 void SynchronouslySetRootScrollOffset(
90 const gfx::ScrollOffset& root_offset) override; 99 const gfx::ScrollOffset& root_offset) override;
91 void SynchronouslyZoomBy(float magnify_delta, 100 void SynchronouslyZoomBy(float magnify_delta,
92 const gfx::Point& anchor) override; 101 const gfx::Point& anchor) override;
93 102
94 // blink::WebGestureCurveTarget implementation. 103 // blink::WebGestureCurveTarget implementation.
95 bool scrollBy(const blink::WebFloatSize& offset, 104 bool scrollBy(const blink::WebFloatSize& offset,
96 const blink::WebFloatSize& velocity) override; 105 const blink::WebFloatSize& velocity) override;
97 106
98 bool gesture_scroll_on_impl_thread_for_testing() const { 107 bool gesture_scroll_on_impl_thread_for_testing() const {
99 return gesture_scroll_on_impl_thread_; 108 return gesture_scroll_on_impl_thread_;
100 } 109 }
101 110
102 protected: 111 protected:
103 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device, 112 void RecordMainThreadScrollingReasons(blink::WebGestureDevice device,
104 uint32_t reasons); 113 uint32_t reasons);
105 114
106 private: 115 private:
107 friend class test::InputHandlerProxyTest; 116 friend class test::InputHandlerProxyTest;
117 friend class test::InputHandlerProxyEventQueueTest;
118
119 void DispatchSingleInputEvent(std::unique_ptr<EventWithCallback>,
120 const base::TimeTicks);
121 void DispatchQueuedInputEvents();
108 122
109 // Helper functions for handling more complicated input events. 123 // Helper functions for handling more complicated input events.
110 EventDisposition HandleMouseWheel( 124 EventDisposition HandleMouseWheel(
111 const blink::WebMouseWheelEvent& event); 125 const blink::WebMouseWheelEvent& event);
112 EventDisposition ScrollByMouseWheel( 126 EventDisposition ScrollByMouseWheel(
113 const blink::WebMouseWheelEvent& event, 127 const blink::WebMouseWheelEvent& event,
114 cc::EventListenerProperties listener_properties); 128 cc::EventListenerProperties listener_properties);
115 EventDisposition HandleGestureScrollBegin( 129 EventDisposition HandleGestureScrollBegin(
116 const blink::WebGestureEvent& event); 130 const blink::WebGestureEvent& event);
117 EventDisposition HandleGestureScrollUpdate( 131 EventDisposition HandleGestureScrollUpdate(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool bundle_overscroll_params_with_ack); 170 bool bundle_overscroll_params_with_ack);
157 171
158 // Whether to use a smooth scroll animation for this event. 172 // Whether to use a smooth scroll animation for this event.
159 bool ShouldAnimate(bool has_precise_scroll_deltas) const; 173 bool ShouldAnimate(bool has_precise_scroll_deltas) const;
160 174
161 // Update the elastic overscroll controller with |gesture_event|. 175 // Update the elastic overscroll controller with |gesture_event|.
162 void HandleScrollElasticityOverscroll( 176 void HandleScrollElasticityOverscroll(
163 const blink::WebGestureEvent& gesture_event, 177 const blink::WebGestureEvent& gesture_event,
164 const cc::InputHandlerScrollResult& scroll_result); 178 const cc::InputHandlerScrollResult& scroll_result);
165 179
180 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
181
166 std::unique_ptr<blink::WebGestureCurve> fling_curve_; 182 std::unique_ptr<blink::WebGestureCurve> fling_curve_;
167 // Parameters for the active fling animation, stored in case we need to 183 // Parameters for the active fling animation, stored in case we need to
168 // transfer it out later. 184 // transfer it out later.
169 blink::WebActiveWheelFlingParameters fling_parameters_; 185 blink::WebActiveWheelFlingParameters fling_parameters_;
170 186
171 InputHandlerProxyClient* client_; 187 InputHandlerProxyClient* client_;
172 cc::InputHandler* input_handler_; 188 cc::InputHandler* input_handler_;
173 189
174 // Time at which an active fling should expire due to a deferred cancellation 190 // Time at which an active fling should expire due to a deferred cancellation
175 // event. A call to |Animate()| after this time will end the fling. 191 // event. A call to |Animate()| after this time will end the fling.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 int32_t touch_start_result_; 238 int32_t touch_start_result_;
223 239
224 base::TimeTicks last_fling_animate_time_; 240 base::TimeTicks last_fling_animate_time_;
225 241
226 // Used to record overscroll notifications while an event is being 242 // Used to record overscroll notifications while an event is being
227 // dispatched. If the event causes overscroll, the overscroll metadata can be 243 // dispatched. If the event causes overscroll, the overscroll metadata can be
228 // bundled in the event ack, saving an IPC. Note that we must continue 244 // bundled in the event ack, saving an IPC. Note that we must continue
229 // supporting overscroll IPC notifications due to fling animation updates. 245 // supporting overscroll IPC notifications due to fling animation updates.
230 std::unique_ptr<DidOverscrollParams> current_overscroll_params_; 246 std::unique_ptr<DidOverscrollParams> current_overscroll_params_;
231 247
248 std::unique_ptr<CompositorThreadEventQueue> compositor_event_queue_;
249 bool has_ongoing_compositor_scroll_pinch_;
250
251 std::unique_ptr<base::TickClock> tick_clock_;
252
232 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); 253 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy);
233 }; 254 };
234 255
235 } // namespace ui 256 } // namespace ui
236 257
237 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_ 258 #endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
OLDNEW
« no previous file with comments | « ui/events/blink/event_with_callback.cc ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698