Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
flutter::StopwatchVisualizer Class Referenceabstract

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

#include <stopwatch.h>

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

Public Member Functions

 StopwatchVisualizer (const Stopwatch &stopwatch)
 
virtual ~StopwatchVisualizer ()=default
 
virtual void Visualize (DlCanvas *canvas, const SkRect &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 93 of file stopwatch.h.

Constructor & Destructor Documentation

◆ StopwatchVisualizer()

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

Definition at line 95 of file stopwatch.h.

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

◆ ~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 120 of file stopwatch.h.

120{ return frame_budget_; }

◆ UnitFrameInterval()

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

Converts a raster time to a unit interval.

Definition at line 57 of file stopwatch.cc.

57 {
58 return raster_time_ms / frame_budget_.count();
59}

◆ UnitHeight()

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

Converts a raster time to a unit height.

Definition at line 61 of file stopwatch.cc.

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

◆ Visualize()

virtual void flutter::StopwatchVisualizer::Visualize ( DlCanvas canvas,
const SkRect 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, and flutter::SkStopwatchVisualizer.

Member Data Documentation

◆ frame_budget_

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

Definition at line 123 of file stopwatch.h.

◆ stopwatch_

const Stopwatch& flutter::StopwatchVisualizer::stopwatch_
protected

Definition at line 122 of file stopwatch.h.


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