Skip to main content

FpsCounter

Struct FpsCounter 

Source
pub struct FpsCounter { /* private fields */ }
Expand description

An FPS counter helper that can draw itself on the render thread. The labels are shaped once and the changing numbers are drawn in a fixed digit grid, so a frame neither formats nor measures any text.

The C# class owns a stopwatch started at construction. Here the caller supplies the time instead: new and render_fps take the current reading of a monotonic clock (any epoch), and the counter works with the time elapsed between the two.

Implementations§

Source§

impl FpsCounter

Source

pub const LABELS: [&'static str; 4]

The fixed labels of the counter. The compositor shapes them with the text renderer on the UI thread (ServerCompositor::diagnostic_text_renderer), so that a counter created by the first frame of the render thread finds them shaped: shaping creates glyph runs, whose platform implementation comes from the services of the UI thread (the render thread of the browser has none). Upstream shapes them in the constructor.

Source

pub fn new(text_renderer: Rc<DiagnosticTextRenderer>, now: Duration) -> Self

now is the current reading of the monotonic clock that is also passed to render_fps.

Source

pub fn fps_tick(&self)

Source

pub fn render_fps( &self, context: &mut dyn IDrawingContextImpl, memory: Option<(u64, u64)>, visited_visuals: i32, rendered_visuals: i32, has_layer: bool, old_rect: Option<Rect>, now: Duration, ) -> Rect

Counts a frame and draws the counter at the origin of the current transform of context. Returns the rectangle that was covered.

memory is the managed and the native size of the batch pools of the compositor in bytes (M: and N:), or None to draw no memory text: the compositor of the port has no such pools (see the member waivers of ServerCompositor).

Source

pub fn reset(&self)

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.