Commit e5ba742d authored by Sean O'Brien's avatar Sean O'Brien Committed by Commit Bot

ozone: Add low pressure filter for touchscreen

To prevent poor quality touches on hana, add a filter for low pressure
touches, such as those generated by a pencil.  Finger presses are above
the chosen threshold and aren't affected.  If a contact ever exceeds the
presure threshold, all remaining events for that contact are sent.

CQ-DEPEND=CL:1093584
BUG=b:69232663
TEST=manual testing on hana with pressure filter enabled

Change-Id: Ic2d56eb656e318ee46744ef37f6055d8573a2261
Reviewed-on: https://chromium-review.googlesource.com/1096126Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Sean O'Brien <seobrien@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569415}
parent 77c1f668
......@@ -134,6 +134,7 @@ void DeriveCommandLine(const GURL& start_url,
::switches::kGpuRasterizationMSAASampleCount,
::switches::kGpuStartupDialog,
::switches::kGpuSandboxStartEarly,
::switches::kLowPressureTouchFiltering,
::switches::kNumRasterThreads,
::switches::kPpapiFlashArgs,
::switches::kPpapiFlashPath,
......
......@@ -39,6 +39,10 @@ const char kTouchCalibration[] = "touch-calibration";
// Tells Chrome to do edge touch filtering. Useful for convertible tablet.
const char kEdgeTouchFiltering[] = "edge-touch-filtering";
// Tells Chrome to do filter out low pressure touches, as from a pencil. Should
// only be used if the driver level filtering is insufficient.
const char kLowPressureTouchFiltering[] = "low-pressure-touch-filtering";
#endif
} // namespace switches
......@@ -23,6 +23,7 @@ EVENTS_BASE_EXPORT extern const char kPenDevices[];
EVENTS_BASE_EXPORT extern const char kExtraTouchNoiseFiltering[];
EVENTS_BASE_EXPORT extern const char kTouchCalibration[];
EVENTS_BASE_EXPORT extern const char kEdgeTouchFiltering[];
EVENTS_BASE_EXPORT extern const char kLowPressureTouchFiltering[];
#endif
} // namespace switches
......
......@@ -117,6 +117,8 @@ if (use_ozone) {
"evdev/touch_filter/far_apart_taps_touch_noise_filter.h",
"evdev/touch_filter/horizontally_aligned_touch_noise_filter.cc",
"evdev/touch_filter/horizontally_aligned_touch_noise_filter.h",
"evdev/touch_filter/low_pressure_filter.cc",
"evdev/touch_filter/low_pressure_filter.h",
"evdev/touch_filter/single_position_touch_noise_filter.cc",
"evdev/touch_filter/single_position_touch_noise_filter.h",
"evdev/touch_filter/touch_filter.h",
......
......@@ -12,6 +12,7 @@
#include "ui/events/ozone/evdev/touch_filter/edge_touch_filter.h"
#include "ui/events/ozone/evdev/touch_filter/far_apart_taps_touch_noise_filter.h"
#include "ui/events/ozone/evdev/touch_filter/horizontally_aligned_touch_noise_filter.h"
#include "ui/events/ozone/evdev/touch_filter/low_pressure_filter.h"
#include "ui/events/ozone/evdev/touch_filter/single_position_touch_noise_filter.h"
#include "ui/events/ozone/evdev/touch_filter/touch_filter.h"
......@@ -25,9 +26,13 @@ std::unique_ptr<FalseTouchFinder> FalseTouchFinder::Create(
switches::kExtraTouchNoiseFiltering);
bool edge_filtering = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEdgeTouchFiltering);
if (noise_filtering || edge_filtering) {
return base::WrapUnique(new FalseTouchFinder(
noise_filtering, edge_filtering, touchscreen_size));
bool low_pressure_filtering =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kLowPressureTouchFiltering);
if (noise_filtering || edge_filtering || low_pressure_filtering) {
return base::WrapUnique(
new FalseTouchFinder(noise_filtering, edge_filtering,
low_pressure_filtering, touchscreen_size));
}
return nullptr;
}
......@@ -62,6 +67,7 @@ bool FalseTouchFinder::SlotShouldDelay(size_t slot) const {
FalseTouchFinder::FalseTouchFinder(bool noise_filtering,
bool edge_filtering,
bool low_pressure_filtering,
gfx::Size touchscreen_size)
: last_noise_time_(ui::EventTimeForNow()) {
if (noise_filtering) {
......@@ -75,6 +81,9 @@ FalseTouchFinder::FalseTouchFinder(bool noise_filtering,
delay_filters_.push_back(
std::make_unique<EdgeTouchFilter>(touchscreen_size));
}
if (low_pressure_filtering) {
delay_filters_.push_back(std::make_unique<LowPressureFilter>());
}
}
void FalseTouchFinder::RecordUMA(bool had_noise, base::TimeTicks time) {
......
......@@ -45,6 +45,7 @@ class EVENTS_OZONE_EVDEV_EXPORT FalseTouchFinder {
private:
FalseTouchFinder(bool touch_noise_filtering,
bool edge_filtering,
bool low_pressure_filtering,
gfx::Size touchscreen_size);
// Records how frequently noisy touches occur to UMA.
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/events/ozone/evdev/touch_filter/low_pressure_filter.h"
#include <stddef.h>
#include <cmath>
#include "base/macros.h"
namespace ui {
namespace {
const float kMinPressure = 0.19;
} // namespace
LowPressureFilter::LowPressureFilter() {}
LowPressureFilter::~LowPressureFilter() {}
void LowPressureFilter::Filter(
const std::vector<InProgressTouchEvdev>& touches,
base::TimeTicks time,
std::bitset<kNumTouchEvdevSlots>* slots_should_delay) {
for (const InProgressTouchEvdev& touch : touches) {
size_t slot = touch.slot;
if (!touch.touching && !touch.was_touching)
continue; // Only look at slots with active touches.
if (!touch.was_touching)
slots_filtered_.set(slot, true); // Start tracking a new touch.
if (touch.pressure >= kMinPressure)
slots_filtered_.set(slot, false); // Release touches above threshold.
}
(*slots_should_delay) |= slots_filtered_;
}
} // namespace ui
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_LOW_PRESSURE_FILTER_H_
#define UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_LOW_PRESSURE_FILTER_H_
#include "base/macros.h"
#include "base/time/time.h"
#include "ui/events/event_utils.h"
#include "ui/events/ozone/evdev/touch_filter/touch_filter.h"
namespace ui {
class LowPressureFilter : public TouchFilter {
public:
LowPressureFilter();
~LowPressureFilter() override;
// TouchFilter:
void Filter(const std::vector<InProgressTouchEvdev>& touches,
base::TimeTicks time,
std::bitset<kNumTouchEvdevSlots>* slots_should_delay) override;
private:
std::bitset<kNumTouchEvdevSlots> slots_filtered_;
DISALLOW_COPY_AND_ASSIGN(LowPressureFilter);
};
} // namespace ui
#endif // UI_EVENTS_OZONE_EVDEV_TOUCH_FILTER_LOW_PRESSURE_FILTER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment