pub struct QualityManager {
pub current: QualityLevel,
pub target_fps: f32,
pub cooldown_seconds: f32,
pub upgrade_headroom: f32,
pub downgrade_threshold: f32,
/* private fields */
}Expand description
Dynamically adjusts quality level to maintain a target frame rate.
Fields§
§current: QualityLevel§target_fps: f32§cooldown_seconds: f32Minimum time (seconds) between quality changes.
upgrade_headroom: f32FPS must be above target * this factor before considering upgrade.
downgrade_threshold: f32FPS must be below target * this factor before considering downgrade.
Implementations§
Source§impl QualityManager
impl QualityManager
pub fn new(initial: QualityLevel, target_fps: f32) -> Self
Sourcepub fn tick(&mut self, current_fps: f32, dt: f32)
pub fn tick(&mut self, current_fps: f32, dt: f32)
Call each frame with current FPS and delta time.
Sourcepub fn average_fps(&self) -> f32
pub fn average_fps(&self) -> f32
Average FPS over the history window.
Sourcepub fn should_upgrade(&self) -> bool
pub fn should_upgrade(&self) -> bool
Whether the manager would upgrade at this moment.
Sourcepub fn should_downgrade(&self) -> bool
pub fn should_downgrade(&self) -> bool
Whether the manager would downgrade at this moment.
Sourcepub fn profile(&self) -> QualityProfile
pub fn profile(&self) -> QualityProfile
Current quality profile.
Sourcepub fn set_quality(&mut self, level: QualityLevel)
pub fn set_quality(&mut self, level: QualityLevel)
Force a specific quality level.
Auto Trait Implementations§
impl Freeze for QualityManager
impl RefUnwindSafe for QualityManager
impl Send for QualityManager
impl Sync for QualityManager
impl Unpin for QualityManager
impl UnsafeUnpin for QualityManager
impl UnwindSafe for QualityManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.