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

Side by Side Diff: ui/base/gestures/gesture_sequence.cc

Issue 11299276: Bound the maximum touchscreen fling velocity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/gestures/gesture_sequence.h" 5 #include "ui/base/gestures/gesture_sequence.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const unsigned last_coefficient = 289 const unsigned last_coefficient =
290 GestureConfiguration::NumAccelParams - 1; 290 GestureConfiguration::NumAccelParams - 1;
291 float normalized_velocity = fabs(velocity * kFlingCurveNormalization); 291 float normalized_velocity = fabs(velocity * kFlingCurveNormalization);
292 float nu = 0.0f, x = 1.f; 292 float nu = 0.0f, x = 1.f;
293 293
294 for (int i = last_coefficient ; i >= 0; i--) { 294 for (int i = last_coefficient ; i >= 0; i--) {
295 float a = GestureConfiguration::fling_acceleration_curve_coefficients(i); 295 float a = GestureConfiguration::fling_acceleration_curve_coefficients(i);
296 nu += x * a; 296 nu += x * a;
297 x *= normalized_velocity; 297 x *= normalized_velocity;
298 } 298 }
299 return nu * velocity; 299 fprintf(stderr, ">>> velo %f\n", nu * velocity);
300 fprintf(stderr, ">>> capped velo %f\n", std::max(nu * velocity,
301 GestureConfiguration::fling_velocity_cap()));
302 if (velocity < 0.f)
303 return std::max(nu * velocity, -GestureConfiguration::fling_velocity_cap());
304 else
305 return std::min(nu * velocity, GestureConfiguration::fling_velocity_cap());
300 } 306 }
301 307
302 } // namespace 308 } // namespace
303 309
304 //////////////////////////////////////////////////////////////////////////////// 310 ////////////////////////////////////////////////////////////////////////////////
305 // GestureSequence Public: 311 // GestureSequence Public:
306 312
307 GestureSequence::GestureSequence(GestureEventHelper* helper) 313 GestureSequence::GestureSequence(GestureEventHelper* helper)
308 : state_(GS_NO_GESTURE), 314 : state_(GS_NO_GESTURE),
309 flags_(0), 315 flags_(0),
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 return; 1128 return;
1123 1129
1124 // Since long press timer has been started, there should be a non-NULL point. 1130 // Since long press timer has been started, there should be a non-NULL point.
1125 const GesturePoint* point = GetPointByPointId(0); 1131 const GesturePoint* point = GetPointByPointId(0);
1126 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), 1132 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(),
1127 event.location())) 1133 event.location()))
1128 GetLongPressTimer()->Stop(); 1134 GetLongPressTimer()->Stop();
1129 } 1135 }
1130 1136
1131 } // namespace ui 1137 } // namespace ui
OLDNEW
« ui/base/gestures/gesture_configuration.cc ('K') | « ui/base/gestures/gesture_configuration.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698