| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ozone/evdev/touch_noise/far_apart_taps_touch_noise_filter.h" | 5 #include "ui/events/ozone/evdev/touch_noise/far_apart_taps_touch_noise_filter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 int Distance2(int x1, int y1, int x2, int y2) { | 36 int Distance2(int x1, int y1, int x2, int y2) { |
| 37 int offset_x = x2 - x1; | 37 int offset_x = x2 - x1; |
| 38 int offset_y = y2 - y1; | 38 int offset_y = y2 - y1; |
| 39 return offset_x * offset_x + offset_y * offset_y; | 39 return offset_x * offset_x + offset_y * offset_y; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 void FarApartTapsTouchNoiseFilter::Filter( | 44 void FarApartTapsTouchNoiseFilter::Filter( |
| 45 const std::vector<InProgressTouchEvdev>& touches, | 45 const std::vector<InProgressTouchEvdev>& touches, |
| 46 base::TimeDelta time, | 46 base::TimeTicks time, |
| 47 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) { | 47 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) { |
| 48 // Remove old taps. | 48 // Remove old taps. |
| 49 base::TimeDelta tap_cutoff = | 49 base::TimeTicks tap_cutoff = |
| 50 time - base::TimeDelta::FromMilliseconds(kMaxTapDeltaMs); | 50 time - base::TimeDelta::FromMilliseconds(kMaxTapDeltaMs); |
| 51 for (size_t i = 0; i < arraysize(tracked_taps_); ++i) { | 51 for (size_t i = 0; i < arraysize(tracked_taps_); ++i) { |
| 52 if (tracked_taps_[i].start < tap_cutoff) | 52 if (tracked_taps_[i].start < tap_cutoff) |
| 53 tracked_taps_[i].Invalidate(); | 53 tracked_taps_[i].Invalidate(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 for (const InProgressTouchEvdev& touch : touches) { | 56 for (const InProgressTouchEvdev& touch : touches) { |
| 57 // Only look at slots with active touches. | 57 // Only look at slots with active touches. |
| 58 if (!touch.touching && !touch.was_touching) | 58 if (!touch.touching && !touch.was_touching) |
| 59 continue; | 59 continue; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 slots_with_noise->set(slot); | 100 slots_with_noise->set(slot); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 if (!touch.touching) | 104 if (!touch.touching) |
| 105 tracked_taps_[slot].Invalidate(); | 105 tracked_taps_[slot].Invalidate(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace ui | 109 } // namespace ui |
| OLD | NEW |