iris: drive animation from painter frame time

This commit is contained in:
iris committed 2026-09-12 21:37:47 -04:00
1 parent 5f4975285d
commit eb30a01f2d
14 files changed
+148 -116

No files matched your search

+8 -10
View File
@@ -1344,8 +1344,8 @@ impl FlingCalculator {
}
/// The signed distance covered by `elapsed` into a fling of this
/// `velocity` -- what a per-frame ticker (`ScrollController::tick`) calls to
/// find how far to have scrolled by now. Clamped to the full
/// `velocity` -- what a scrolling widget uses to find how far it should
/// have moved by this frame. Clamped to the full
/// `distance()` once `elapsed` reaches `duration()`, so a caller need
/// not special-case "past the end."
pub fn position_at(&self, velocity: f32, elapsed: Duration) -> f32 {
@@ -1373,7 +1373,7 @@ impl FlingCalculator {
/// go, are the caller's -- a `LazySpan` scrolls its anchor one way and a
/// `ScrollArea` moves its `amt` the other, and a `Flinger` that tried to know
/// which would have to be told, which is the same thing as not knowing.
/// So a caller applies [`Self::tick`]'s delta in its own convention and
/// So a caller applies [`Self::advance`]'s delta in its own convention and
/// calls [`Self::stop`] when it runs out of content.
pub struct Flinger {
fling: Option<InFlight>,
@@ -1382,7 +1382,7 @@ pub struct Flinger {
struct InFlight {
calc: FlingCalculator,
velocity: f32,
/// When the curve begins -- **the first [`Flinger::tick`], not the
/// When the curve begins -- **the first [`Flinger::advance`], not the
/// release**. Set there so the only clock this reads is the one its
/// driver hands it: a caller running frames on an explicit clock
/// (`iris::harness`, `bench_client.rs`'s scripted phases) would
@@ -1406,15 +1406,13 @@ impl Flinger {
}
/// Start a fling at `velocity_px_per_s`, in whatever pixel space the
/// caller applies [`Self::tick`]'s delta in. `density` is physical
/// caller applies [`Self::advance`]'s delta in. `density` is physical
/// pixels per dp, from the painter -- it does **not** cancel out of
/// the spline (see [`FlingCalculator`]), and a hardcoded 1.0 against a
/// 2.55-density screen made a one-second coast run for 45.
///
/// Answers whether a fling actually started, which is a caller's cue
/// to register for frames (`UiData::animate`): registering a widget
/// that is not animating only asks the next frame to find that out.
/// Cancels any fling already in progress.
/// Cancels any fling already in progress. A widget which owns one advances
/// it during `draw` and asks its painter for the following frame.
///
/// Compose's two thresholds at a release, and **only** those two. The
/// maximum is `ViewConfiguration.getScaledMaximumFlingVelocity()`
@@ -1476,7 +1474,7 @@ impl Flinger {
/// itself on the spline's own schedule, after which
/// [`Self::is_flinging`] is false and the caller stops asking for
/// frames.
pub fn tick(&mut self, now: Instant) -> f32 {
pub fn advance(&mut self, now: Instant) -> f32 {
let Some(f) = &mut self.fling else {
return 0.0;
};