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/gestures/motion_event_aura.h" | 5 #include "ui/events/gestures/motion_event_aura.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/events/gestures/gesture_configuration.h" | 8 #include "ui/events/gestures/gesture_configuration.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 MotionEventAura::MotionEventAura() | 12 MotionEventAura::MotionEventAura() |
13 : pointer_count_(0), cached_action_index_(-1) { | 13 : pointer_count_(0), cached_action_index_(-1) { |
14 } | 14 } |
15 | 15 |
16 MotionEventAura::MotionEventAura( | 16 MotionEventAura::MotionEventAura(size_t pointer_count, |
17 size_t pointer_count, | 17 const base::TimeTicks& last_touch_time, |
18 const base::TimeTicks& last_touch_time, | 18 Action cached_action, |
19 Action cached_action, | 19 int cached_action_index, |
20 int cached_action_index, | 20 const PointData (&active_touches)[10/*TODO*/]) |
21 const PointData (&active_touches)[GestureSequence::kMaxGesturePoints]) | |
22 : pointer_count_(pointer_count), | 21 : pointer_count_(pointer_count), |
23 last_touch_time_(last_touch_time), | 22 last_touch_time_(last_touch_time), |
24 cached_action_(cached_action), | 23 cached_action_(cached_action), |
25 cached_action_index_(cached_action_index) { | 24 cached_action_index_(cached_action_index) { |
26 DCHECK(pointer_count_); | 25 DCHECK(pointer_count_); |
27 for (size_t i = 0; i < pointer_count; ++i) | 26 for (size_t i = 0; i < pointer_count; ++i) |
28 active_touches_[i] = active_touches[i]; | 27 active_touches_[i] = active_touches[i]; |
29 } | 28 } |
30 | 29 |
31 MotionEventAura::~MotionEventAura() {} | 30 MotionEventAura::~MotionEventAura() {} |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 source_device_id(0), | 173 source_device_id(0), |
175 major_radius(0) { | 174 major_radius(0) { |
176 } | 175 } |
177 | 176 |
178 int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { | 177 int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { |
179 DCHECK_LT(pointer_index, pointer_count_); | 178 DCHECK_LT(pointer_index, pointer_count_); |
180 return active_touches_[pointer_index].source_device_id; | 179 return active_touches_[pointer_index].source_device_id; |
181 } | 180 } |
182 | 181 |
183 void MotionEventAura::AddTouch(const TouchEvent& touch) { | 182 void MotionEventAura::AddTouch(const TouchEvent& touch) { |
184 if (pointer_count_ == static_cast<size_t>(GestureSequence::kMaxGesturePoints)) | 183 if (pointer_count_ == MotionEvent::MAX_TOUCH_POINT_COUNT) |
185 return; | 184 return; |
186 | 185 |
187 active_touches_[pointer_count_] = GetPointDataFromTouchEvent(touch); | 186 active_touches_[pointer_count_] = GetPointDataFromTouchEvent(touch); |
188 pointer_count_++; | 187 pointer_count_++; |
189 } | 188 } |
190 | 189 |
191 | 190 |
192 void MotionEventAura::UpdateTouch(const TouchEvent& touch) { | 191 void MotionEventAura::UpdateTouch(const TouchEvent& touch) { |
193 active_touches_[GetIndexFromId(touch.touch_id())] = | 192 active_touches_[GetIndexFromId(touch.touch_id())] = |
194 GetPointDataFromTouchEvent(touch); | 193 GetPointDataFromTouchEvent(touch); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 size_t MotionEventAura::GetIndexFromId(int id) const { | 230 size_t MotionEventAura::GetIndexFromId(int id) const { |
232 for (size_t i = 0; i < pointer_count_; ++i) { | 231 for (size_t i = 0; i < pointer_count_; ++i) { |
233 if (active_touches_[i].touch_id == id) | 232 if (active_touches_[i].touch_id == id) |
234 return i; | 233 return i; |
235 } | 234 } |
236 NOTREACHED(); | 235 NOTREACHED(); |
237 return 0; | 236 return 0; |
238 } | 237 } |
239 | 238 |
240 } // namespace ui | 239 } // namespace ui |
OLD | NEW |