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

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

Issue 531133002: Revert of Completed webkit radiusX, radiusY and rotationAngle handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/motion_event_buffer.h" 5 #include "ui/events/gesture_detection/motion_event_buffer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "ui/events/gesture_detection/motion_event.h" 8 #include "ui/events/gesture_detection/motion_event.h"
9 #include "ui/events/gesture_detection/motion_event_generic.h" 9 #include "ui/events/gesture_detection/motion_event_generic.h"
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 size_t pointer_index) { 90 size_t pointer_index) {
91 PointerProperties result; 91 PointerProperties result;
92 result.id = event.GetPointerId(pointer_index); 92 result.id = event.GetPointerId(pointer_index);
93 result.tool_type = event.GetToolType(pointer_index); 93 result.tool_type = event.GetToolType(pointer_index);
94 result.x = event.GetX(pointer_index); 94 result.x = event.GetX(pointer_index);
95 result.y = event.GetY(pointer_index); 95 result.y = event.GetY(pointer_index);
96 result.raw_x = event.GetRawX(pointer_index); 96 result.raw_x = event.GetRawX(pointer_index);
97 result.raw_y = event.GetRawY(pointer_index); 97 result.raw_y = event.GetRawY(pointer_index);
98 result.pressure = event.GetPressure(pointer_index); 98 result.pressure = event.GetPressure(pointer_index);
99 result.touch_major = event.GetTouchMajor(pointer_index); 99 result.touch_major = event.GetTouchMajor(pointer_index);
100 result.touch_minor = event.GetTouchMinor(pointer_index);
101 result.orientation = event.GetOrientation(pointer_index);
102 return result; 100 return result;
103 } 101 }
104 102
105 PointerProperties ResamplePointer(const MotionEvent& event0, 103 PointerProperties ResamplePointer(const MotionEvent& event0,
106 const MotionEvent& event1, 104 const MotionEvent& event1,
107 size_t event0_pointer_index, 105 size_t event0_pointer_index,
108 size_t event1_pointer_index, 106 size_t event1_pointer_index,
109 float alpha) { 107 float alpha) {
110 DCHECK_EQ(event0.GetPointerId(event0_pointer_index), 108 DCHECK_EQ(event0.GetPointerId(event0_pointer_index),
111 event1.GetPointerId(event1_pointer_index)); 109 event1.GetPointerId(event1_pointer_index));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // recent event used as the base event, and prior events used as the history. 167 // recent event used as the base event, and prior events used as the history.
170 class CompoundMotionEvent : public ui::MotionEvent { 168 class CompoundMotionEvent : public ui::MotionEvent {
171 public: 169 public:
172 explicit CompoundMotionEvent(MotionEventVector events) 170 explicit CompoundMotionEvent(MotionEventVector events)
173 : events_(events.Pass()) { 171 : events_(events.Pass()) {
174 DCHECK_GE(events_.size(), 1U); 172 DCHECK_GE(events_.size(), 1U);
175 } 173 }
176 virtual ~CompoundMotionEvent() {} 174 virtual ~CompoundMotionEvent() {}
177 175
178 virtual int GetId() const OVERRIDE { return latest().GetId(); } 176 virtual int GetId() const OVERRIDE { return latest().GetId(); }
179
180 virtual Action GetAction() const OVERRIDE { return latest().GetAction(); } 177 virtual Action GetAction() const OVERRIDE { return latest().GetAction(); }
181
182 virtual int GetActionIndex() const OVERRIDE { 178 virtual int GetActionIndex() const OVERRIDE {
183 return latest().GetActionIndex(); 179 return latest().GetActionIndex();
184 } 180 }
185
186 virtual size_t GetPointerCount() const OVERRIDE { 181 virtual size_t GetPointerCount() const OVERRIDE {
187 return latest().GetPointerCount(); 182 return latest().GetPointerCount();
188 } 183 }
189
190 virtual int GetPointerId(size_t pointer_index) const OVERRIDE { 184 virtual int GetPointerId(size_t pointer_index) const OVERRIDE {
191 return latest().GetPointerId(pointer_index); 185 return latest().GetPointerId(pointer_index);
192 } 186 }
193
194 virtual float GetX(size_t pointer_index) const OVERRIDE { 187 virtual float GetX(size_t pointer_index) const OVERRIDE {
195 return latest().GetX(pointer_index); 188 return latest().GetX(pointer_index);
196 } 189 }
197
198 virtual float GetY(size_t pointer_index) const OVERRIDE { 190 virtual float GetY(size_t pointer_index) const OVERRIDE {
199 return latest().GetY(pointer_index); 191 return latest().GetY(pointer_index);
200 } 192 }
201
202 virtual float GetRawX(size_t pointer_index) const OVERRIDE { 193 virtual float GetRawX(size_t pointer_index) const OVERRIDE {
203 return latest().GetRawX(pointer_index); 194 return latest().GetRawX(pointer_index);
204 } 195 }
205
206 virtual float GetRawY(size_t pointer_index) const OVERRIDE { 196 virtual float GetRawY(size_t pointer_index) const OVERRIDE {
207 return latest().GetRawY(pointer_index); 197 return latest().GetRawY(pointer_index);
208 } 198 }
209
210 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE { 199 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE {
211 return latest().GetTouchMajor(pointer_index); 200 return latest().GetTouchMajor(pointer_index);
212 } 201 }
213
214 virtual float GetTouchMinor(size_t pointer_index) const OVERRIDE {
215 return latest().GetTouchMinor(pointer_index);
216 }
217
218 virtual float GetOrientation(size_t pointer_index) const OVERRIDE {
219 return latest().GetOrientation(pointer_index);
220 }
221
222 virtual float GetPressure(size_t pointer_index) const OVERRIDE { 202 virtual float GetPressure(size_t pointer_index) const OVERRIDE {
223 return latest().GetPressure(pointer_index); 203 return latest().GetPressure(pointer_index);
224 } 204 }
225
226 virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE { 205 virtual ToolType GetToolType(size_t pointer_index) const OVERRIDE {
227 return latest().GetToolType(pointer_index); 206 return latest().GetToolType(pointer_index);
228 } 207 }
229
230 virtual int GetButtonState() const OVERRIDE { 208 virtual int GetButtonState() const OVERRIDE {
231 return latest().GetButtonState(); 209 return latest().GetButtonState();
232 } 210 }
233
234 virtual base::TimeTicks GetEventTime() const OVERRIDE { 211 virtual base::TimeTicks GetEventTime() const OVERRIDE {
235 return latest().GetEventTime(); 212 return latest().GetEventTime();
236 } 213 }
237
238 virtual size_t GetHistorySize() const OVERRIDE { return events_.size() - 1; } 214 virtual size_t GetHistorySize() const OVERRIDE { return events_.size() - 1; }
239
240 virtual base::TimeTicks GetHistoricalEventTime( 215 virtual base::TimeTicks GetHistoricalEventTime(
241 size_t historical_index) const OVERRIDE { 216 size_t historical_index) const OVERRIDE {
242 DCHECK_LT(historical_index, GetHistorySize()); 217 DCHECK_LT(historical_index, GetHistorySize());
243 return events_[historical_index]->GetEventTime(); 218 return events_[historical_index]->GetEventTime();
244 } 219 }
245
246 virtual float GetHistoricalTouchMajor( 220 virtual float GetHistoricalTouchMajor(
247 size_t pointer_index, 221 size_t pointer_index,
248 size_t historical_index) const OVERRIDE { 222 size_t historical_index) const OVERRIDE {
249 DCHECK_LT(historical_index, GetHistorySize()); 223 DCHECK_LT(historical_index, GetHistorySize());
250 return events_[historical_index]->GetTouchMajor(); 224 return events_[historical_index]->GetTouchMajor();
251 } 225 }
252
253 virtual float GetHistoricalX(size_t pointer_index, 226 virtual float GetHistoricalX(size_t pointer_index,
254 size_t historical_index) const OVERRIDE { 227 size_t historical_index) const OVERRIDE {
255 DCHECK_LT(historical_index, GetHistorySize()); 228 DCHECK_LT(historical_index, GetHistorySize());
256 return events_[historical_index]->GetX(pointer_index); 229 return events_[historical_index]->GetX(pointer_index);
257 } 230 }
258
259 virtual float GetHistoricalY(size_t pointer_index, 231 virtual float GetHistoricalY(size_t pointer_index,
260 size_t historical_index) const OVERRIDE { 232 size_t historical_index) const OVERRIDE {
261 DCHECK_LT(historical_index, GetHistorySize()); 233 DCHECK_LT(historical_index, GetHistorySize());
262 return events_[historical_index]->GetY(pointer_index); 234 return events_[historical_index]->GetY(pointer_index);
263 } 235 }
264
265 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE { 236 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE {
266 MotionEventVector cloned_events; 237 MotionEventVector cloned_events;
267 cloned_events.reserve(events_.size()); 238 cloned_events.reserve(events_.size());
268 for (size_t i = 0; i < events_.size(); ++i) 239 for (size_t i = 0; i < events_.size(); ++i)
269 cloned_events.push_back(events_[i]->Clone().release()); 240 cloned_events.push_back(events_[i]->Clone().release());
270 return scoped_ptr<MotionEvent>( 241 return scoped_ptr<MotionEvent>(
271 new CompoundMotionEvent(cloned_events.Pass())); 242 new CompoundMotionEvent(cloned_events.Pass()));
272 } 243 }
273
274 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE { 244 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE {
275 return latest().Cancel(); 245 return latest().Cancel();
276 } 246 }
277 247
278 // Returns the new, resampled event, or NULL if none was created. 248 // Returns the new, resampled event, or NULL if none was created.
279 // TODO(jdduke): Revisit resampling to handle cases where alternating frames 249 // TODO(jdduke): Revisit resampling to handle cases where alternating frames
280 // are resampled or resampling is otherwise inconsistent, e.g., a 90hz input 250 // are resampled or resampling is otherwise inconsistent, e.g., a 90hz input
281 // and 60hz frame signal could phase-align such that even frames yield an 251 // and 60hz frame signal could phase-align such that even frames yield an
282 // extrapolated event and odd frames are not resampled, crbug.com/399381. 252 // extrapolated event and odd frames are not resampled, crbug.com/399381.
283 const MotionEvent* TryResample(base::TimeTicks resample_time, 253 const MotionEvent* TryResample(base::TimeTicks resample_time,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 events.weak_clear(); 423 events.weak_clear();
454 client_->ForwardMotionEvent(*event); 424 client_->ForwardMotionEvent(*event);
455 return; 425 return;
456 } 426 }
457 427
458 CompoundMotionEvent compound_event(events.Pass()); 428 CompoundMotionEvent compound_event(events.Pass());
459 client_->ForwardMotionEvent(compound_event); 429 client_->ForwardMotionEvent(compound_event);
460 } 430 }
461 431
462 } // namespace ui 432 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/motion_event.cc ('k') | ui/events/gesture_detection/motion_event_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698