#include "ui/events/gestures/physics_based_fling_curve.h"
#include <algorithm>
#include <cmath>
#include "base/check.h"
namespace {
const float kDefaultP1X = …;
const float kDefaultP1Y = …;
const float kDefaultP2X = …;
const float kDefaultP2Y = …;
const float kDefaultPixelDeceleration = …;
const float kMaxCurveDurationForFling = …;
const float kDefaultPhysicalDeceleration = …;
inline gfx::Vector2dF GetPositionAtValue(const gfx::Vector2dF& end_point,
double progress) { … }
inline gfx::Vector2dF GetVelocityAtTime(const gfx::Vector2dF& current_offset,
const gfx::Vector2dF& prev_offset,
base::TimeDelta delta) { … }
float GetOffset(float velocity, float deceleration, float duration) { … }
gfx::Vector2dF GetDecelerationInPixelsPerMs2(
const gfx::Vector2dF& pixels_per_inch) { … }
gfx::Vector2dF GetDuration(const gfx::Vector2dF& velocity,
const gfx::Vector2dF& deceleration) { … }
gfx::Vector2dF CalculateEndPoint(const gfx::Vector2dF& pixels_per_inch,
const gfx::Vector2dF& velocity_pixels_per_ms,
const gfx::Size& bounding_size) { … }
}
namespace ui {
PhysicsBasedFlingCurve::PhysicsBasedFlingCurve(
const gfx::Vector2dF& velocity,
base::TimeTicks start_timestamp,
const gfx::Vector2dF& pixels_per_inch,
const float boost_multiplier,
const gfx::Size& bounding_size)
: … { … }
PhysicsBasedFlingCurve::~PhysicsBasedFlingCurve() = default;
bool PhysicsBasedFlingCurve::ComputeScrollOffset(base::TimeTicks time,
gfx::Vector2dF* offset,
gfx::Vector2dF* velocity) { … }
base::TimeDelta
PhysicsBasedFlingCurve::CalculateDurationAndConfigureControlPoints(
const gfx::Vector2dF& velocity) { … }
}