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

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

Issue 1076443002: Removed obsolete float_util.h as VS2013 supports standards well enough. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed mistake in value converter. Created 5 years, 8 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
« no previous file with comments | « media/blink/websourcebuffer_impl.cc ('k') | ui/gfx/range/range_f.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scale_gesture_detector.h" 5 #include "ui/events/gesture_detection/scale_gesture_detector.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8
8 #include <cmath> 9 #include <cmath>
9 10
10 #include "base/float_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "ui/events/gesture_detection/motion_event.h" 12 #include "ui/events/gesture_detection/motion_event.h"
13 #include "ui/events/gesture_detection/scale_gesture_listeners.h" 13 #include "ui/events/gesture_detection/scale_gesture_listeners.h"
14 14
15 using base::TimeDelta; 15 using base::TimeDelta;
16 using base::TimeTicks; 16 using base::TimeTicks;
17 17
18 namespace ui { 18 namespace ui {
19 namespace { 19 namespace {
20 20
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 void ScaleGestureDetector::AddTouchHistory(const MotionEvent& ev) { 279 void ScaleGestureDetector::AddTouchHistory(const MotionEvent& ev) {
280 const base::TimeTicks current_time = ev.GetEventTime(); 280 const base::TimeTicks current_time = ev.GetEventTime();
281 DCHECK(!current_time.is_null()); 281 DCHECK(!current_time.is_null());
282 const int count = static_cast<int>(ev.GetPointerCount()); 282 const int count = static_cast<int>(ev.GetPointerCount());
283 bool accept = touch_history_last_accepted_time_.is_null() || 283 bool accept = touch_history_last_accepted_time_.is_null() ||
284 (current_time - touch_history_last_accepted_time_) >= 284 (current_time - touch_history_last_accepted_time_) >=
285 base::TimeDelta::FromMilliseconds(kTouchStabilizeTimeMs); 285 base::TimeDelta::FromMilliseconds(kTouchStabilizeTimeMs);
286 float total = 0; 286 float total = 0;
287 int sample_count = 0; 287 int sample_count = 0;
288 for (int i = 0; i < count; i++) { 288 for (int i = 0; i < count; i++) {
289 const bool has_last_accepted = !base::IsNaN(touch_history_last_accepted_); 289 const bool has_last_accepted = !std::isnan(touch_history_last_accepted_);
290 const int history_size = static_cast<int>(ev.GetHistorySize()); 290 const int history_size = static_cast<int>(ev.GetHistorySize());
291 const int pointersample_count = history_size + 1; 291 const int pointersample_count = history_size + 1;
292 for (int h = 0; h < pointersample_count; h++) { 292 for (int h = 0; h < pointersample_count; h++) {
293 float major; 293 float major;
294 if (h < history_size) { 294 if (h < history_size) {
295 major = ev.GetHistoricalTouchMajor(i, h); 295 major = ev.GetHistoricalTouchMajor(i, h);
296 } else { 296 } else {
297 major = ev.GetTouchMajor(i); 297 major = ev.GetTouchMajor(i);
298 } 298 }
299 if (major < touch_min_major_) 299 if (major < touch_min_major_)
300 major = touch_min_major_; 300 major = touch_min_major_;
301 if (major > touch_max_major_) 301 if (major > touch_max_major_)
302 major = touch_max_major_; 302 major = touch_max_major_;
303 total += major; 303 total += major;
304 304
305 if (base::IsNaN(touch_upper_) || major > touch_upper_) { 305 if (std::isnan(touch_upper_) || major > touch_upper_) {
306 touch_upper_ = major; 306 touch_upper_ = major;
307 } 307 }
308 if (base::IsNaN(touch_lower_) || major < touch_lower_) { 308 if (std::isnan(touch_lower_) || major < touch_lower_) {
309 touch_lower_ = major; 309 touch_lower_ = major;
310 } 310 }
311 311
312 if (has_last_accepted) { 312 if (has_last_accepted) {
313 const float major_delta = major - touch_history_last_accepted_; 313 const float major_delta = major - touch_history_last_accepted_;
314 const int direction_sig = 314 const int direction_sig =
315 major_delta > 0 ? 1 : (major_delta < 0 ? -1 : 0); 315 major_delta > 0 ? 1 : (major_delta < 0 ? -1 : 0);
316 if (direction_sig != touch_history_direction_ || 316 if (direction_sig != touch_history_direction_ ||
317 (direction_sig == 0 && touch_history_direction_ == 0)) { 317 (direction_sig == 0 && touch_history_direction_ == 0)) {
318 touch_history_direction_ = direction_sig; 318 touch_history_direction_ = direction_sig;
(...skipping 27 matching lines...) Expand all
346 touch_history_last_accepted_time_ = base::TimeTicks(); 346 touch_history_last_accepted_time_ = base::TimeTicks();
347 } 347 }
348 348
349 void ScaleGestureDetector::ResetScaleWithSpan(float span) { 349 void ScaleGestureDetector::ResetScaleWithSpan(float span) {
350 in_progress_ = false; 350 in_progress_ = false;
351 initial_span_ = span; 351 initial_span_ = span;
352 double_tap_mode_ = DOUBLE_TAP_MODE_NONE; 352 double_tap_mode_ = DOUBLE_TAP_MODE_NONE;
353 } 353 }
354 354
355 } // namespace ui 355 } // namespace ui
OLDNEW
« no previous file with comments | « media/blink/websourcebuffer_impl.cc ('k') | ui/gfx/range/range_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698