Documentation
¶
Overview ¶
Package animclock is the animation scheduler the application loop drives: launched pieces, the frame deadlines the loop wakes on, and the tick that advances them. The public timeline API lives in package anim; only the loop and tests reach this package.
Index ¶
- Constants
- func Active() bool
- func Drive(fn func(now time.Time) bool) (cancel func())
- func Due(now time.Time, pace Pace) bool
- func Launch(pieces []Piece) (cancel func())
- func Next(pace Pace) (time.Time, bool)
- func Now() time.Time
- func Reset()
- func SetClock(fn func() time.Time) (restore func())
- func Tick(now time.Time) bool
- type FrameClock
- type Pace
- type Piece
Constants ¶
const FallbackInterval = time.Second / 4
FallbackInterval is the period a running piece ticks at while a surface waits on a frame callback, or no surface can show it: the callback paces it when the compositor answers, and an occluded window's animations still land.
const FrameInterval = time.Second / 60
FrameInterval is the period the timer paces a running piece at while no surface waits on a frame callback.
Variables ¶
This section is empty.
Functions ¶
func Drive ¶
Drive runs fn once per frame with the frame's instant until it reports false (settled) or the returned cancel runs.
func Due ¶ added in v0.2.5
Due reports whether the clock's deadline at pace has come by now, so a pass that was not woken by a frame callback ticks it; a pass woken by anything else leaves running pieces where they are.
func Launch ¶
func Launch(pieces []Piece) (cancel func())
Launch schedules pieces from the current instant and returns the cancel that stops every piece not yet finished. A piece with no duration and no offset lands at once, outside the schedule.
func Next ¶
Next returns the earliest instant the loop must wake to keep the clock running at pace: one interval past the last tick while a piece is mid-flight, or a later piece's start while a timeline holds in a delay. At Timer a piece's end counts too, so its last frame lands on time. False means nothing runs and the loop may park.
func SetClock ¶
SetClock replaces the time source launches and deadlines read and returns the restore function; nil restores time.Now.
func Tick ¶
Tick advances every running piece to now and drops finished or cancelled ones. Time never runs back: a now older than the last tick, or than the last launch (a compositor timestamp lags the local clock), counts as that instant. Callbacks run after the pass settles with the lock released, so they may launch or cancel freely; a callback cancelling its own timeline still stops that timeline's later pieces in the same tick. It reports whether any callback ran.
Types ¶
type FrameClock ¶ added in v0.2.5
type FrameClock struct {
// contains filtered or unexported fields
}
FrameClock converts a frame callback's timestamp, milliseconds from an undefined base that wraps, to an instant on the local clock.
func (*FrameClock) Instant ¶ added in v0.2.5
Instant is when the compositor's ms happened on the local clock, never after now. It keeps the earliest local reading of the compositor's clock as its anchor, so a delivery's latency is what it subtracts, and starts again from now when ms sits further behind than any delivery plausibly does.