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

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

Issue 349463002: [Android] Map raw touch coordinates to global gesture locations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
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_count_(0), gesture_source_(UNDEFINED) {
37 }
37 38
38 GestureEventDataPacket::GestureEventDataPacket(base::TimeTicks timestamp, 39 GestureEventDataPacket::GestureEventDataPacket(
39 GestureSource source, 40 base::TimeTicks timestamp,
40 gfx::PointF touch_location) 41 GestureSource source,
42 const gfx::PointF& touch_location,
43 const gfx::PointF& raw_touch_location)
41 : timestamp_(timestamp), 44 : timestamp_(timestamp),
42 gesture_count_(0), 45 gesture_count_(0),
43 touch_location_(touch_location), 46 touch_location_(touch_location),
47 raw_touch_location_(raw_touch_location),
44 gesture_source_(source) { 48 gesture_source_(source) {
45 DCHECK_NE(gesture_source_, UNDEFINED); 49 DCHECK_NE(gesture_source_, UNDEFINED);
46 } 50 }
47 51
48 GestureEventDataPacket::GestureEventDataPacket( 52 GestureEventDataPacket::GestureEventDataPacket(
49 const GestureEventDataPacket& other) 53 const GestureEventDataPacket& other)
50 : timestamp_(other.timestamp_), 54 : timestamp_(other.timestamp_),
51 gesture_count_(other.gesture_count_), 55 gesture_count_(other.gesture_count_),
52 touch_location_(other.touch_location_), 56 touch_location_(other.touch_location_),
57 raw_touch_location_(other.raw_touch_location_),
53 gesture_source_(other.gesture_source_) { 58 gesture_source_(other.gesture_source_) {
54 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); 59 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_);
55 } 60 }
56 61
57 GestureEventDataPacket::~GestureEventDataPacket() {} 62 GestureEventDataPacket::~GestureEventDataPacket() {
63 }
58 64
59 GestureEventDataPacket& GestureEventDataPacket::operator=( 65 GestureEventDataPacket& GestureEventDataPacket::operator=(
60 const GestureEventDataPacket& other) { 66 const GestureEventDataPacket& other) {
61 timestamp_ = other.timestamp_; 67 timestamp_ = other.timestamp_;
62 gesture_count_ = other.gesture_count_; 68 gesture_count_ = other.gesture_count_;
63 gesture_source_ = other.gesture_source_; 69 gesture_source_ = other.gesture_source_;
64 touch_location_ = other.touch_location_; 70 touch_location_ = other.touch_location_;
71 raw_touch_location_ = other.raw_touch_location_;
65 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_); 72 std::copy(other.gestures_, other.gestures_ + other.gesture_count_, gestures_);
66 return *this; 73 return *this;
67 } 74 }
68 75
69 void GestureEventDataPacket::Push(const GestureEventData& gesture) { 76 void GestureEventDataPacket::Push(const GestureEventData& gesture) {
70 DCHECK_NE(ET_UNKNOWN, gesture.type()); 77 DCHECK_NE(ET_UNKNOWN, gesture.type());
71 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch)); 78 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch));
72 gestures_[gesture_count_++] = gesture; 79 gestures_[gesture_count_++] = gesture;
73 } 80 }
74 81
75 GestureEventDataPacket GestureEventDataPacket::FromTouch( 82 GestureEventDataPacket GestureEventDataPacket::FromTouch(
76 const ui::MotionEvent& touch) { 83 const ui::MotionEvent& touch) {
77 return GestureEventDataPacket(touch.GetEventTime(), 84 return GestureEventDataPacket(touch.GetEventTime(),
78 ToGestureSource(touch), 85 ToGestureSource(touch),
79 gfx::PointF(touch.GetX(), touch.GetY())); 86 gfx::PointF(touch.GetX(), touch.GetY()),
87 gfx::PointF(touch.GetRawX(), touch.GetRawY()));
80 } 88 }
81 89
82 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout( 90 GestureEventDataPacket GestureEventDataPacket::FromTouchTimeout(
83 const GestureEventData& gesture) { 91 const GestureEventData& gesture) {
84 GestureEventDataPacket packet( 92 GestureEventDataPacket packet(gesture.time,
85 gesture.time, TOUCH_TIMEOUT, gfx::PointF(gesture.x, gesture.y)); 93 TOUCH_TIMEOUT,
94 gfx::PointF(gesture.x, gesture.y),
95 gfx::PointF(gesture.raw_x, gesture.raw_y));
86 packet.Push(gesture); 96 packet.Push(gesture);
87 return packet; 97 return packet;
88 } 98 }
89 99
90 } // namespace ui 100 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698