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/horizontally_aligned_touch_noise_fil
ter.h" | 5 #include "ui/events/ozone/evdev/touch_noise/horizontally_aligned_touch_noise_fil
ter.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // The maximum horizontal distance between touches considered aligned. | 18 // The maximum horizontal distance between touches considered aligned. |
19 int kMaxDistance = 3; | 19 int kMaxDistance = 3; |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 void HorizontallyAlignedTouchNoiseFilter::Filter( | 23 void HorizontallyAlignedTouchNoiseFilter::Filter( |
24 const std::vector<InProgressTouchEvdev>& touches, | 24 const std::vector<InProgressTouchEvdev>& touches, |
25 base::TimeDelta time, | 25 base::TimeTicks time, |
26 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) { | 26 std::bitset<kNumTouchEvdevSlots>* slots_with_noise) { |
27 for (const InProgressTouchEvdev& touch : touches) { | 27 for (const InProgressTouchEvdev& touch : touches) { |
28 // Only consider new touches. | 28 // Only consider new touches. |
29 if (!touch.touching || touch.was_touching) | 29 if (!touch.touching || touch.was_touching) |
30 continue; | 30 continue; |
31 | 31 |
32 // Check if within kMaxDistance of an existing touch. | 32 // Check if within kMaxDistance of an existing touch. |
33 for (const InProgressTouchEvdev& other_touch : touches) { | 33 for (const InProgressTouchEvdev& other_touch : touches) { |
34 if (touch.slot == other_touch.slot || !other_touch.touching) | 34 if (touch.slot == other_touch.slot || !other_touch.touching) |
35 continue; | 35 continue; |
(...skipping 11 matching lines...) Expand all Loading... |
47 touch.tracking_id, time.ToInternalValue(), | 47 touch.tracking_id, time.ToInternalValue(), |
48 touch.x, touch.y, other_touch.tracking_id, | 48 touch.x, touch.y, other_touch.tracking_id, |
49 other_touch.x, other_touch.y); | 49 other_touch.x, other_touch.y); |
50 slots_with_noise->set(touch.slot); | 50 slots_with_noise->set(touch.slot); |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 } // namespace ui | 56 } // namespace ui |
OLD | NEW |