| 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 #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 18 matching lines...) Expand all Loading... |
| 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_count_(0), gesture_source_(UNDEFINED) {} |
| 37 | 37 |
| 38 GestureEventDataPacket::GestureEventDataPacket(base::TimeTicks timestamp, | 38 GestureEventDataPacket::GestureEventDataPacket(base::TimeTicks timestamp, |
| 39 GestureSource source) | 39 GestureSource source, |
| 40 : timestamp_(timestamp), gesture_count_(0), gesture_source_(source) { | 40 gfx::PointF touch_location) |
| 41 : timestamp_(timestamp), |
| 42 gesture_count_(0), |
| 43 touch_location_(touch_location), |
| 44 gesture_source_(source) { |
| 41 DCHECK_NE(gesture_source_, UNDEFINED); | 45 DCHECK_NE(gesture_source_, UNDEFINED); |
| 42 } | 46 } |
| 43 | 47 |
| 44 GestureEventDataPacket::GestureEventDataPacket( | 48 GestureEventDataPacket::GestureEventDataPacket( |
| 45 const GestureEventDataPacket& other) | 49 const GestureEventDataPacket& other) |
| 46 : timestamp_(other.timestamp_), | 50 : timestamp_(other.timestamp_), |
| 47 gesture_count_(other.gesture_count_), | 51 gesture_count_(other.gesture_count_), |
| 52 touch_location_(other.touch_location_), |
| 48 gesture_source_(other.gesture_source_) { | 53 gesture_source_(other.gesture_source_) { |
| 49 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); | 54 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); |
| 50 } | 55 } |
| 51 | 56 |
| 52 GestureEventDataPacket::~GestureEventDataPacket() {} | 57 GestureEventDataPacket::~GestureEventDataPacket() {} |
| 53 | 58 |
| 54 GestureEventDataPacket& GestureEventDataPacket::operator=( | 59 GestureEventDataPacket& GestureEventDataPacket::operator=( |
| 55 const GestureEventDataPacket& other) { | 60 const GestureEventDataPacket& other) { |
| 56 timestamp_ = other.timestamp_; | 61 timestamp_ = other.timestamp_; |
| 57 gesture_count_ = other.gesture_count_; | 62 gesture_count_ = other.gesture_count_; |
| 58 gesture_source_ = other.gesture_source_; | 63 gesture_source_ = other.gesture_source_; |
| 64 touch_location_ = other.touch_location_; |
| 59 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); | 65 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); |
| 60 return *this; | 66 return *this; |
| 61 } | 67 } |
| 62 | 68 |
| 63 void GestureEventDataPacket::Push(const GestureEventData& gesture) { | 69 void GestureEventDataPacket::Push(const GestureEventData& gesture) { |
| 64 DCHECK_NE(ET_UNKNOWN, gesture.type); | 70 DCHECK_NE(ET_UNKNOWN, gesture.type); |
| 65 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch)); | 71 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch)); |
| 66 gestures_[gesture_count_++] = gesture; | 72 gestures_[gesture_count_++] = gesture; |
| 67 } | 73 } |
| 68 | 74 |
| 69 GestureEventDataPacket GestureEventDataPacket::FromTouch( | 75 GestureEventDataPacket GestureEventDataPacket::FromTouch( |
| 70 const ui::MotionEvent& touch) { | 76 const ui::MotionEvent& touch) { |
| 71 return GestureEventDataPacket(touch.GetEventTime(), ToGestureSource(touch)); | 77 return GestureEventDataPacket(touch.GetEventTime(), |
| 78 ToGestureSource(touch), |
| 79 gfx::PointF(touch.GetX(), touch.GetY())); |
| 72 } | 80 } |
| 73 | 81 |
| 74 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout( | 82 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout( |
| 75 const GestureEventData& gesture) { | 83 const GestureEventData& gesture) { |
| 76 GestureEventDataPacket packet(gesture.time, TOUCH_TIMEOUT); | 84 GestureEventDataPacket packet( |
| 85 gesture.time, TOUCH_TIMEOUT, gfx::PointF(gesture.x, gesture.y)); |
| 77 packet.Push(gesture); | 86 packet.Push(gesture); |
| 78 return packet; | 87 return packet; |
| 79 } | 88 } |
| 80 | 89 |
| 81 } // namespace ui | 90 } // namespace ui |
| OLD | NEW |