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
impl FpsCounter
Sourcepub const LABELS: [&'static str; 4]
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.
Sourcepub fn new(text_renderer: Rc<DiagnosticTextRenderer>, now: Duration) -> Self
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.
pub fn fps_tick(&self)
Sourcepub 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
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).
pub fn reset(&self)
Auto Trait Implementations§
impl !Freeze for FpsCounter
impl !RefUnwindSafe for FpsCounter
impl !Send for FpsCounter
impl !Sync for FpsCounter
impl !UnwindSafe for FpsCounter
impl Unpin for FpsCounter
impl UnsafeUnpin for FpsCounter
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more