blob: fa3667f5515d9587c475fcf6783930cbec698605 [file] [log] [blame]
// Copyright 2019 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 "base/component_export.h"
#include "base/macros.h"
#include "third_party/one_euro_filter/src/one_euro_filter.h"
#include "ui/base/prediction/input_filter.h"
namespace ui {
// This class uses the 1€ filter from third party.
// See this page :
// to know how the filter works and how to tune it
class COMPONENT_EXPORT(UI_BASE_PREDICTION) OneEuroFilter : public InputFilter {
OneEuroFilter(double mincutoff = kDefaultMincutoff,
double beta = kDefaultBeta);
~OneEuroFilter() override;
bool Filter(const base::TimeTicks& timestamp,
gfx::PointF* position) const override;
const char* GetName() const override;
InputFilter* Clone() override;
void Reset() override;
// Default parameters values for the filter
static constexpr double kDefaultFrequency = 60;
static constexpr double kDefaultMincutoff = 1.0;
static constexpr double kDefaultBeta = 0.001;
static constexpr double kDefaultDcutoff = 1.0;
// Names of the fieldtrials used to tune the filter
static constexpr char kParamBeta[] = "beta";
static constexpr char kParamMincutoff[] = "mincutoff";
std::unique_ptr<one_euro_filter::OneEuroFilter> x_filter_;
std::unique_ptr<one_euro_filter::OneEuroFilter> y_filter_;
} // namespace ui