1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h"
6 
7 #include "base/logging.h"
8 
9 namespace ui {
10 
11 NeuralStylusPalmDetectionFilterModelConfig::
12     NeuralStylusPalmDetectionFilterModelConfig() = default;
13 
14 NeuralStylusPalmDetectionFilterModelConfig::
15     NeuralStylusPalmDetectionFilterModelConfig(
16         const NeuralStylusPalmDetectionFilterModelConfig& other) = default;
17 
18 NeuralStylusPalmDetectionFilterModelConfig::
19     ~NeuralStylusPalmDetectionFilterModelConfig() = default;
20 
21 base::TimeDelta
GetEquivalentDuration(uint32_t sample_count) const22 NeuralStylusPalmDetectionFilterModelConfig::GetEquivalentDuration(
23     uint32_t sample_count) const {
24   if (!resample_period) {
25     LOG(DFATAL) << __func__
26                 << " should only be called if resampling is enabled";
27     return base::TimeDelta::FromMicroseconds(0);
28   }
29   if (sample_count <= 1) {
30     return base::TimeDelta::FromMicroseconds(0);
31   }
32   return (sample_count - 1) * (*resample_period);
33 }
34 
35 }  // namespace ui