Flutter Engine
 
Loading...
Searching...
No Matches
flutter::StopwatchVisualizer Class Referenceabstract

Abstract class for visualizing (i.e. drawing) a stopwatch. More...

#include <stopwatch.h>

Inheritance diagram for flutter::StopwatchVisualizer:
flutter::DlStopwatchVisualizer

Public Member Functions

 StopwatchVisualizer (const Stopwatch &stopwatch)
 
virtual ~StopwatchVisualizer ()=default
 
virtual void Visualize (DlCanvas *canvas, const DlRect &rect) const =0
 Renders the stopwatch as a graph.
 
 FML_DISALLOW_COPY_AND_ASSIGN (StopwatchVisualizer)
 

Protected Member Functions

double UnitFrameInterval (double time_ms) const
 Converts a raster time to a unit interval.
 
double UnitHeight (double time_ms, double max_height) const
 Converts a raster time to a unit height.
 
fml::Milliseconds GetFrameBudget () const
 

Protected Attributes

const Stopwatchstopwatch_
 
fml::Milliseconds frame_budget_
 

Detailed Description

Abstract class for visualizing (i.e. drawing) a stopwatch.

Note
This was originally folded into the |Stopwatch| class, but was separated out to make it easier to change the underlying implementation (which relied directly on Skia, not showing on Impeller: https://github.com/flutter/flutter/issues/126009).

Definition at line 96 of file stopwatch.h.

Constructor & Destructor Documentation

◆ StopwatchVisualizer()

flutter::StopwatchVisualizer::StopwatchVisualizer ( const Stopwatch stopwatch)
inlineexplicit

Definition at line 98 of file stopwatch.h.

99 : stopwatch_(stopwatch) {
100 // Looking up the frame budget from the stopwatch delegate class may call
101 // into JNI or make platform calls which are slow. This value is safe to
102 // cache since the StopwatchVisualizer is recreated on each frame.
104 }
fml::Milliseconds GetFrameBudget() const
All places which want to get frame_budget should call this function.
Definition stopwatch.cc:85
const Stopwatch & stopwatch_
Definition stopwatch.h:125
fml::Milliseconds frame_budget_
Definition stopwatch.h:126

References frame_budget_, flutter::Stopwatch::GetFrameBudget(), and stopwatch_.

◆ ~StopwatchVisualizer()

virtual flutter::StopwatchVisualizer::~StopwatchVisualizer ( )
virtualdefault

Member Function Documentation

◆ FML_DISALLOW_COPY_AND_ASSIGN()

flutter::StopwatchVisualizer::FML_DISALLOW_COPY_AND_ASSIGN ( StopwatchVisualizer  )

◆ GetFrameBudget()

fml::Milliseconds flutter::StopwatchVisualizer::GetFrameBudget ( ) const
inlineprotected

Definition at line 123 of file stopwatch.h.

123{ return frame_budget_; }

References frame_budget_.

Referenced by flutter::DlStopwatchVisualizer::Visualize().

◆ UnitFrameInterval()

double flutter::StopwatchVisualizer::UnitFrameInterval ( double  time_ms) const
protected

Converts a raster time to a unit interval.

Definition at line 54 of file stopwatch.cc.

54 {
55 return raster_time_ms / frame_budget_.count();
56}

References frame_budget_.

Referenced by UnitHeight(), and flutter::DlStopwatchVisualizer::Visualize().

◆ UnitHeight()

double flutter::StopwatchVisualizer::UnitHeight ( double  time_ms,
double  max_height 
) const
protected

Converts a raster time to a unit height.

Definition at line 58 of file stopwatch.cc.

59 {
60 double unit_height = UnitFrameInterval(raster_time_ms) / max_unit_interval;
61 if (unit_height > 1.0) {
62 unit_height = 1.0;
63 }
64 return unit_height;
65}
double UnitFrameInterval(double time_ms) const
Converts a raster time to a unit interval.
Definition stopwatch.cc:54

References UnitFrameInterval().

Referenced by flutter::DlStopwatchVisualizer::Visualize().

◆ Visualize()

virtual void flutter::StopwatchVisualizer::Visualize ( DlCanvas canvas,
const DlRect rect 
) const
pure virtual

Renders the stopwatch as a graph.

Parameters
canvasThe canvas to draw on.
[in]rectThe rectangle to draw in.

Implemented in flutter::DlStopwatchVisualizer.

Member Data Documentation

◆ frame_budget_

fml::Milliseconds flutter::StopwatchVisualizer::frame_budget_
protected

Definition at line 126 of file stopwatch.h.

Referenced by GetFrameBudget(), StopwatchVisualizer(), and UnitFrameInterval().

◆ stopwatch_

const Stopwatch& flutter::StopwatchVisualizer::stopwatch_
protected

Definition at line 125 of file stopwatch.h.

Referenced by StopwatchVisualizer(), and flutter::DlStopwatchVisualizer::Visualize().


The documentation for this class was generated from the following files: