chromium/ui/events/velocity_tracker/motion_event_buffer.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/velocity_tracker/motion_event_buffer.h"

#include <stddef.h>

#include <algorithm>
#include <iterator>
#include <utility>

#include "base/trace_event/trace_event.h"
#include "ui/events/velocity_tracker/motion_event_generic.h"

namespace ui {
namespace {

// Latency added during resampling. A few milliseconds doesn't hurt much but
// reduces the impact of mispredicted touch positions.
const int kResampleLatencyMs =;

// Minimum time difference between consecutive samples before attempting to
// resample.
const int kResampleMinDeltaMs =;

// Maximum time to predict forward from the last known state, to avoid
// predicting too far into the future.  This time is further bounded by 50% of
// the last time delta.
const int kResampleMaxPredictionMs =;

MotionEventVector;

float Lerp(float a, float b, float alpha) {}

bool CanAddSample(const MotionEvent& event0, const MotionEvent& event1) {}

bool ShouldResampleTool(MotionEvent::ToolType tool) {}

// Splits a chunk of events from the front of the provided |batch| and returns
// it. Requires that |batch| is sorted.
MotionEventVector ConsumeSamplesNoLaterThan(MotionEventVector* batch,
                                            base::TimeTicks time) {}

// Linearly interpolate the pointer position between two MotionEvent samples.
// Only pointers of finger or unknown type will be resampled.
PointerProperties ResamplePointer(const MotionEvent& event0,
                                  const MotionEvent& event1,
                                  size_t event0_pointer_index,
                                  size_t event1_pointer_index,
                                  float alpha) {}

// Linearly interpolate the pointers between two event samples using the
// provided |resample_time|.
std::unique_ptr<MotionEventGeneric> ResampleMotionEvent(
    const MotionEvent& event0,
    const MotionEvent& event1,
    base::TimeTicks resample_time) {}

// Synthesize a compound MotionEventGeneric event from a sequence of events.
// Events must be in non-decreasing (time) order.
std::unique_ptr<MotionEventGeneric> ConsumeSamples(MotionEventVector events) {}

// Consume a series of event samples, attempting to synthesize a new, synthetic
// event if the samples and sample time meet certain interpolation/extrapolation
// conditions. If such conditions are met, the provided samples will be added
// to the synthetic event's history, otherwise, the samples will be used to
// generate a basic, compound event.
// TODO(jdduke): Revisit resampling to handle cases where alternating frames
// are resampled or resampling is otherwise inconsistent, e.g., a 90hz input
// and 60hz frame signal could phase-align such that even frames yield an
// extrapolated event and odd frames are not resampled, crbug.com/399381.
std::unique_ptr<MotionEventGeneric> ConsumeSamplesAndTryResampling(
    base::TimeTicks resample_time,
    MotionEventVector events,
    const MotionEvent* next) {}

}  // namespace

MotionEventBuffer::MotionEventBuffer(MotionEventBufferClient* client,
                                     bool enable_resampling)
    :{}

MotionEventBuffer::~MotionEventBuffer() {}

void MotionEventBuffer::OnMotionEvent(const MotionEvent& event) {}

void MotionEventBuffer::Flush(base::TimeTicks frame_time) {}

void MotionEventBuffer::FlushWithResampling(MotionEventVector events,
                                            base::TimeTicks resample_time) {}

void MotionEventBuffer::FlushWithoutResampling(MotionEventVector events) {}

}  // namespace ui