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

Side by Side Diff: ui/events/gestures/motion_event_impl.h

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months 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/gestures/gesture_recognizer_impl.cc ('k') | ui/events/gestures/motion_event_impl.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_GESTURE_DETECTION_UI_MOTION_EVENT_H_ 5 #ifndef UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ 6 #define UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/events/events_export.h" 13 #include "ui/events/events_export.h"
14 #include "ui/events/gesture_detection/motion_event.h" 14 #include "ui/events/gesture_detection/motion_event_generic.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 // Implementation of MotionEvent which takes a stream of ui::TouchEvents. 18 // Implementation of MotionEvent which takes a stream of ui::TouchEvents.
19 class EVENTS_EXPORT MotionEventImpl : public MotionEvent { 19 class EVENTS_EXPORT MotionEventImpl : public MotionEventGeneric {
20 public: 20 public:
21 MotionEventImpl(); 21 MotionEventImpl();
22 ~MotionEventImpl() override; 22 ~MotionEventImpl() override;
23 23
24 void OnTouch(const TouchEvent& touch); 24 // MotionEventGeneric:
25 int GetSourceDeviceId(size_t pointer_index) const override;
25 26
26 // MotionEvent implementation. 27 // Returns true iff the touch was valid.
27 int GetId() const override; 28 bool OnTouch(const TouchEvent& touch);
28 Action GetAction() const override;
29 int GetActionIndex() const override;
30 size_t GetPointerCount() const override;
31 int GetPointerId(size_t pointer_index) const override;
32 float GetX(size_t pointer_index) const override;
33 float GetY(size_t pointer_index) const override;
34 float GetRawX(size_t pointer_index) const override;
35 float GetRawY(size_t pointer_index) const override;
36 float GetTouchMajor(size_t pointer_index) const override;
37 float GetTouchMinor(size_t pointer_index) const override;
38 float GetOrientation(size_t pointer_index) const override;
39 float GetPressure(size_t pointer_index) const override;
40 ToolType GetToolType(size_t pointer_index) const override;
41 int GetButtonState() const override;
42 int GetFlags() const override;
43 base::TimeTicks GetEventTime() const override;
44
45 scoped_ptr<MotionEvent> Clone() const override;
46 scoped_ptr<MotionEvent> Cancel() const override;
47
48 int GetSourceDeviceId(size_t pointer_index) const;
49 29
50 // We can't cleanup removed touch points immediately upon receipt of a 30 // We can't cleanup removed touch points immediately upon receipt of a
51 // TouchCancel or TouchRelease, as the MotionEvent needs to be able to report 31 // TouchCancel or TouchRelease, as the MotionEvent needs to be able to report
52 // information about those touch events. Once the MotionEvent has been 32 // information about those touch events. Once the MotionEvent has been
53 // processed, we call CleanupRemovedTouchPoints to do the required 33 // processed, we call CleanupRemovedTouchPoints to do the required
54 // book-keeping. 34 // book-keeping.
55 void CleanupRemovedTouchPoints(const TouchEvent& event); 35 void CleanupRemovedTouchPoints(const TouchEvent& event);
56 36
57 private: 37 private:
58 struct PointData {
59 PointData();
60 float x;
61 float y;
62 float raw_x;
63 float raw_y;
64 int touch_id;
65 float pressure;
66 int source_device_id;
67 float touch_major;
68 float touch_minor;
69 float orientation;
70 };
71
72 MotionEventImpl(
73 size_t pointer_count,
74 const base::TimeTicks& last_touch_time,
75 Action cached_action,
76 int cached_action_index,
77 int flags,
78 const PointData (&active_touches)[MotionEvent::MAX_TOUCH_POINT_COUNT]);
79
80 static PointData GetPointDataFromTouchEvent(const TouchEvent& touch);
81 void AddTouch(const TouchEvent& touch); 38 void AddTouch(const TouchEvent& touch);
82 void UpdateTouch(const TouchEvent& touch); 39 void UpdateTouch(const TouchEvent& touch);
83 void UpdateCachedAction(const TouchEvent& touch); 40 void UpdateCachedAction(const TouchEvent& touch);
84 size_t GetIndexFromId(int id) const; 41 int GetIndexFromId(int id) const;
85
86 size_t pointer_count_;
87 base::TimeTicks last_touch_time_;
88 Action cached_action_;
89 // The index of the touch responsible for last ACTION_POINTER_DOWN or
90 // ACTION_POINTER_UP. -1 if no such action has occurred.
91 int cached_action_index_;
92 int flags_;
93
94 // We want constant time indexing by pointer_index, and fast indexing by id.
95 PointData active_touches_[MotionEvent::MAX_TOUCH_POINT_COUNT];
96 42
97 DISALLOW_COPY_AND_ASSIGN(MotionEventImpl); 43 DISALLOW_COPY_AND_ASSIGN(MotionEventImpl);
98 }; 44 };
99 45
100 } // namespace ui 46 } // namespace ui
101 47
102 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_ 48 #endif // UI_EVENTS_GESTURE_DETECTION_UI_MOTION_EVENT_H_
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_recognizer_impl.cc ('k') | ui/events/gestures/motion_event_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698