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

Side by Side Diff: ui/events/gesture_detection/gesture_event_data_packet.cc

Issue 407563002: Allow any number of gestures to be constructed per touch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/gesture_detection/gesture_event_data_packet.h ('k') | no next file » | 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 #include "ui/events/gesture_detection/gesture_event_data_packet.h" 5 #include "ui/events/gesture_detection/gesture_event_data_packet.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/gesture_detection/motion_event.h" 8 #include "ui/events/gesture_detection/motion_event.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 15 matching lines...) Expand all
26 case ui::MotionEvent::ACTION_POINTER_UP: 26 case ui::MotionEvent::ACTION_POINTER_UP:
27 return GestureEventDataPacket::TOUCH_END; 27 return GestureEventDataPacket::TOUCH_END;
28 }; 28 };
29 NOTREACHED() << "Invalid ui::MotionEvent action: " << event.GetAction(); 29 NOTREACHED() << "Invalid ui::MotionEvent action: " << event.GetAction();
30 return GestureEventDataPacket::INVALID; 30 return GestureEventDataPacket::INVALID;
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 GestureEventDataPacket::GestureEventDataPacket() 35 GestureEventDataPacket::GestureEventDataPacket()
36 : gesture_count_(0), gesture_source_(UNDEFINED) { 36 : gesture_source_(UNDEFINED) {
37 } 37 }
38 38
39 GestureEventDataPacket::GestureEventDataPacket( 39 GestureEventDataPacket::GestureEventDataPacket(
40 base::TimeTicks timestamp, 40 base::TimeTicks timestamp,
41 GestureSource source, 41 GestureSource source,
42 const gfx::PointF& touch_location, 42 const gfx::PointF& touch_location,
43 const gfx::PointF& raw_touch_location) 43 const gfx::PointF& raw_touch_location)
44 : timestamp_(timestamp), 44 : timestamp_(timestamp),
45 gesture_count_(0),
46 touch_location_(touch_location), 45 touch_location_(touch_location),
47 raw_touch_location_(raw_touch_location), 46 raw_touch_location_(raw_touch_location),
48 gesture_source_(source) { 47 gesture_source_(source) {
49 DCHECK_NE(gesture_source_, UNDEFINED); 48 DCHECK_NE(gesture_source_, UNDEFINED);
50 } 49 }
51 50
52 GestureEventDataPacket::GestureEventDataPacket( 51 GestureEventDataPacket::GestureEventDataPacket(
53 const GestureEventDataPacket& other) 52 const GestureEventDataPacket& other)
54 : timestamp_(other.timestamp_), 53 : timestamp_(other.timestamp_),
55 gesture_count_(other.gesture_count_), 54 gestures_(other.gestures_),
56 touch_location_(other.touch_location_), 55 touch_location_(other.touch_location_),
57 raw_touch_location_(other.raw_touch_location_), 56 raw_touch_location_(other.raw_touch_location_),
58 gesture_source_(other.gesture_source_) { 57 gesture_source_(other.gesture_source_) {
59 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_);
60 } 58 }
61 59
62 GestureEventDataPacket::~GestureEventDataPacket() { 60 GestureEventDataPacket::~GestureEventDataPacket() {
63 } 61 }
64 62
65 GestureEventDataPacket& GestureEventDataPacket::operator=( 63 GestureEventDataPacket& GestureEventDataPacket::operator=(
66 const GestureEventDataPacket& other) { 64 const GestureEventDataPacket& other) {
67 timestamp_ = other.timestamp_; 65 timestamp_ = other.timestamp_;
68 gesture_count_ = other.gesture_count_;
69 gesture_source_ = other.gesture_source_; 66 gesture_source_ = other.gesture_source_;
70 touch_location_ = other.touch_location_; 67 touch_location_ = other.touch_location_;
71 raw_touch_location_ = other.raw_touch_location_; 68 raw_touch_location_ = other.raw_touch_location_;
72 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); 69 gestures_ = other.gestures_;
73 return *this; 70 return *this;
74 } 71 }
75 72
76 void GestureEventDataPacket::Push(const GestureEventData& gesture) { 73 void GestureEventDataPacket::Push(const GestureEventData& gesture) {
77 DCHECK_NE(ET_UNKNOWN, gesture.type()); 74 DCHECK_NE(ET_UNKNOWN, gesture.type());
78 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch)); 75 gestures_.push_back(gesture);
79 gestures_[gesture_count_++] = gesture;
80 } 76 }
81 77
82 GestureEventDataPacket GestureEventDataPacket::FromTouch( 78 GestureEventDataPacket GestureEventDataPacket::FromTouch(
83 const ui::MotionEvent& touch) { 79 const ui::MotionEvent& touch) {
84 return GestureEventDataPacket(touch.GetEventTime(), 80 return GestureEventDataPacket(touch.GetEventTime(),
85 ToGestureSource(touch), 81 ToGestureSource(touch),
86 gfx::PointF(touch.GetX(), touch.GetY()), 82 gfx::PointF(touch.GetX(), touch.GetY()),
87 gfx::PointF(touch.GetRawX(), touch.GetRawY())); 83 gfx::PointF(touch.GetRawX(), touch.GetRawY()));
88 } 84 }
89 85
90 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout( 86 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout(
91 const GestureEventData& gesture) { 87 const GestureEventData& gesture) {
92 GestureEventDataPacket packet(gesture.time, 88 GestureEventDataPacket packet(gesture.time,
93 TOUCH_TIMEOUT, 89 TOUCH_TIMEOUT,
94 gfx::PointF(gesture.x, gesture.y), 90 gfx::PointF(gesture.x, gesture.y),
95 gfx::PointF(gesture.raw_x, gesture.raw_y)); 91 gfx::PointF(gesture.raw_x, gesture.raw_y));
96 packet.Push(gesture); 92 packet.Push(gesture);
97 return packet; 93 return packet;
98 } 94 }
99 95
100 } // namespace ui 96 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_event_data_packet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698