Skip to main content

FrameRatePreference

Enum FrameRatePreference 

Source
pub enum FrameRatePreference {
    Auto,
    NoPreference,
    Exact(f32),
}
Expand description

How the platform should vote the display’s frame rate on behalf of the app.

Compose apps get 120 Hz gameplay on a 120 Hz panel not by presenting faster but because HWUI votes a rate on the window while animations and gestures run, and clears it when they stop. A window that never votes is pinned by SurfaceFlinger’s cadence inference instead — which also throttles the app’s choreographer, so the inference reinforces itself. Auto reproduces the HWUI behaviour; the platform backends read it every frame and vote through the native window when the desired rate changes.

Variants§

§

Auto

Ask for the panel’s fastest rate while frames are being produced, no preference when the scene is still. This is the default, matching what Compose/HWUI do for every app without the app’s involvement.

§

NoPreference

Never vote; the OS infers a rate from presentation cadence.

§

Exact(f32)

Always vote exactly this rate in Hz. Values <= 0 behave like FrameRatePreference::NoPreference.

Implementations§

Source§

impl FrameRatePreference

Source

pub const AUTO_QUIET_RATE_HZ: f32 = 60.0

The baseline Auto votes while animating without interaction — the same rate HWUI’s NORMAL frame-rate category resolves to on phone panels. The quiet vote cannot simply be “no vote”: SurfaceFlinger infers a non-voting window’s rate from whatever cadence it last observed and pins it, so an app that ever ran the panel’s fast rate would stay there forever (measured on a Pixel 9 Pro, both directions).

Source

pub fn desired_rate_hz( self, producing_frames: bool, interacting: bool, panel_max_hz: Option<f32>, ) -> f32

The rate the platform should vote right now, in Hz, where 0.0 means “clear the vote”. producing_frames is whether the frame loop has a frame scheduled, interacting whether input arrived within the platform’s boost hold-off, and panel_max_hz the display’s fastest supported rate when the platform knows it.

While interacting, Auto holds the boost even through moments with no frame scheduled: a gesture sequence crosses still screens (a tap lands, the old scene stops animating, the new one hasn’t started), and letting each of those instantly clear the vote flapped the display between the boost rate and no-vote several times per second on device. This mirrors SurfaceFlinger’s own touch boost, which also outlives the touch by seconds regardless of what the app presents in between.

Trait Implementations§

Source§

impl Clone for FrameRatePreference

Source§

fn clone(&self) -> FrameRatePreference

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FrameRatePreference

Source§

impl Debug for FrameRatePreference

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FrameRatePreference

Source§

fn default() -> FrameRatePreference

Returns the “default value” for a type. Read more
Source§

impl PartialEq for FrameRatePreference

Source§

fn eq(&self, other: &FrameRatePreference) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FrameRatePreference

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.