OLD | NEW |
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_GESTURE_EVENT_DATA_PACKET_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
8 #include "ui/events/gesture_detection/gesture_detection_export.h" | 10 #include "ui/events/gesture_detection/gesture_detection_export.h" |
9 #include "ui/events/gesture_detection/gesture_event_data.h" | 11 #include "ui/events/gesture_detection/gesture_event_data.h" |
10 | 12 |
11 namespace ui { | 13 namespace ui { |
12 | 14 |
13 class MotionEvent; | 15 class MotionEvent; |
14 | 16 |
15 // Acts as a transport container for gestures created (directly or indirectly) | 17 // Acts as a transport container for gestures created (directly or indirectly) |
16 // by a touch event. | 18 // by a touch event. |
17 class GESTURE_DETECTION_EXPORT GestureEventDataPacket { | 19 class GESTURE_DETECTION_EXPORT GestureEventDataPacket { |
(...skipping 17 matching lines...) Expand all Loading... |
35 | 37 |
36 // Factory methods for creating a packet from a particular event. | 38 // Factory methods for creating a packet from a particular event. |
37 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch); | 39 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch); |
38 static GestureEventDataPacket FromTouchTimeout( | 40 static GestureEventDataPacket FromTouchTimeout( |
39 const GestureEventData& gesture); | 41 const GestureEventData& gesture); |
40 | 42 |
41 void Push(const GestureEventData& gesture); | 43 void Push(const GestureEventData& gesture); |
42 | 44 |
43 const base::TimeTicks& timestamp() const { return timestamp_; } | 45 const base::TimeTicks& timestamp() const { return timestamp_; } |
44 const GestureEventData& gesture(size_t i) const { return gestures_[i]; } | 46 const GestureEventData& gesture(size_t i) const { return gestures_[i]; } |
45 size_t gesture_count() const { return gesture_count_; } | 47 size_t gesture_count() const { return gestures_.size(); } |
46 GestureSource gesture_source() const { return gesture_source_; } | 48 GestureSource gesture_source() const { return gesture_source_; } |
47 const gfx::PointF& touch_location() const { return touch_location_; } | 49 const gfx::PointF& touch_location() const { return touch_location_; } |
48 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; } | 50 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; } |
49 | 51 |
50 private: | 52 private: |
51 GestureEventDataPacket(base::TimeTicks timestamp, | 53 GestureEventDataPacket(base::TimeTicks timestamp, |
52 GestureSource source, | 54 GestureSource source, |
53 const gfx::PointF& touch_location, | 55 const gfx::PointF& touch_location, |
54 const gfx::PointF& raw_touch_location); | 56 const gfx::PointF& raw_touch_location); |
55 | 57 |
56 enum { kMaxGesturesPerTouch = 5 }; | |
57 base::TimeTicks timestamp_; | 58 base::TimeTicks timestamp_; |
58 GestureEventData gestures_[kMaxGesturesPerTouch]; | 59 // TODO(jdduke): This vector is in general very short. Optimize? |
59 size_t gesture_count_; | 60 std::vector<GestureEventData> gestures_; |
60 gfx::PointF touch_location_; | 61 gfx::PointF touch_location_; |
61 gfx::PointF raw_touch_location_; | 62 gfx::PointF raw_touch_location_; |
62 GestureSource gesture_source_; | 63 GestureSource gesture_source_; |
63 }; | 64 }; |
64 | 65 |
65 } // namespace ui | 66 } // namespace ui |
66 | 67 |
67 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ | 68 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_ |
OLD | NEW |