1 // Copyright 2017 Samsung Electronics. 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.
5 #ifndef EVENT_RESAMPLER
6 #define EVENT_RESAMPLER
11 #include "ui/gfx/geometry/point_f.h"
12 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
14 #define MAX_TOUCH_COUNT 2
22 class RenderWidgetHostViewEfl;
24 class EventResamplerClient {
26 // Forward resampled touch event.
27 virtual void ForwardTouchEvent(ui::TouchEvent*) {}
29 // Forward resampled gesture event.
30 virtual void ForwardGestureEvent(const blink::WebGestureEvent&) {}
32 virtual void OnAnimatorCallback() {}
34 // Return number of touch point.
35 virtual unsigned TouchPointCount() const { return 0; }
38 class EventResampler {
40 explicit EventResampler(EventResamplerClient* client);
43 bool HandleTouchMoveEvent(ui::TouchEvent event);
44 bool HandleGestureEvent(blink::WebGestureEvent& event);
45 bool HasActiveAnimator();
48 static Eina_Bool VsyncAnimatorCallback(void* data);
50 void ResampleTouchMove(int id);
51 void ResampleScrollUpdate();
52 void ResamplePinchUpdate();
53 void NotifyAnimatorCallback();
55 void ClearTouchMoveEventQueue();
56 bool CanDeleteAnimator();
58 EventResamplerClient* client_;
60 Ecore_Animator* vsync_animator_;
61 bool has_pending_touch_move_event_[MAX_TOUCH_COUNT];
62 bool has_pending_scroll_event_;
63 bool has_pending_pinch_event_;
65 // To process without delay if event isn't processed in last callback.
66 bool is_scroll_processed_in_last_callback_;
67 bool is_pinch_processed_in_last_callback_;
69 std::queue<ui::TouchEvent> touch_move_event_queue_[MAX_TOUCH_COUNT];
70 blink::WebGestureEvent last_scroll_update_event_;
71 blink::WebGestureEvent last_pinch_update_event_;
73 gfx::PointF pending_scroll_delta_;
74 float pending_pinch_scale_;
79 #endif // EVENT_RESAMPLER