Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::PerformanceOverlayLayer Class Reference

#include <performance_overlay_layer.h>

Inheritance diagram for flutter::PerformanceOverlayLayer:
flutter::Layer

Public Member Functions

bool IsReplacing (DiffContext *context, const Layer *layer) const override
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
const PerformanceOverlayLayeras_performance_overlay_layer () const override
 
 PerformanceOverlayLayer (uint64_t options, const char *font_path=nullptr)
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void PaintChildren (PaintContext &context) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const SkRectpaint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const ContainerLayeras_container_layer () const
 
virtual const DisplayListLayeras_display_list_layer () const
 
virtual const TextureLayeras_texture_layer () const
 
virtual const testing::MockLayeras_mock_layer () const
 

Static Public Member Functions

static sk_sp< SkTextBlobMakeStatisticsText (const Stopwatch &stopwatch, const std::string &label_prefix, const std::string &font_path)
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 

Detailed Description

Definition at line 23 of file performance_overlay_layer.h.

Constructor & Destructor Documentation

◆ PerformanceOverlayLayer()

flutter::PerformanceOverlayLayer::PerformanceOverlayLayer ( uint64_t  options,
const char *  font_path = nullptr 
)
explicit

Definition at line 105 of file performance_overlay_layer.cc.

107 : options_(options) {
108 if (font_path != nullptr) {
109 font_path_ = font_path;
110 }
111}
const char * options

Member Function Documentation

◆ as_performance_overlay_layer()

const PerformanceOverlayLayer * flutter::PerformanceOverlayLayer::as_performance_overlay_layer ( ) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 35 of file performance_overlay_layer.h.

35 {
36 return this;
37 }

◆ Diff()

void flutter::PerformanceOverlayLayer::Diff ( DiffContext context,
const Layer old_layer 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 113 of file performance_overlay_layer.cc.

114 {
115 DiffContext::AutoSubtreeRestore subtree(context);
116 if (!context->IsSubtreeDirty()) {
117 FML_DCHECK(old_layer);
118 auto prev = old_layer->as_performance_overlay_layer();
119 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(prev));
120 }
121 context->AddLayerBounds(paint_bounds());
122 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
123}
static float prev(float f)
const SkRect & paint_bounds() const
Definition layer.h:209
#define FML_DCHECK(condition)
Definition logging.h:103

◆ IsReplacing()

bool flutter::PerformanceOverlayLayer::IsReplacing ( DiffContext context,
const Layer layer 
) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 29 of file performance_overlay_layer.h.

29 {
30 return layer->as_performance_overlay_layer() != nullptr;
31 }

◆ MakeStatisticsText()

sk_sp< SkTextBlob > flutter::PerformanceOverlayLayer::MakeStatisticsText ( const Stopwatch stopwatch,
const std::string &  label_prefix,
const std::string &  font_path 
)
static

Definition at line 72 of file performance_overlay_layer.cc.

75 {
78 if (font_path == "") {
79 if (sk_sp<SkTypeface> face = font_mgr->matchFamilyStyle(nullptr, {})) {
80 font = SkFont(face, 15);
81 } else {
82 // In Skia's Android fontmgr, matchFamilyStyle can return null instead
83 // of falling back to a default typeface. If that's the case, we can use
84 // legacyMakeTypeface, which *does* use that default typeface.
85 font = SkFont(font_mgr->legacyMakeTypeface(nullptr, {}), 15);
86 }
87 } else {
88 font = SkFont(font_mgr->makeFromFile(font_path.c_str()), 15);
89 }
90 // Make sure there's not an empty typeface returned, or we won't see any text.
91 FML_DCHECK(font.getTypeface()->countGlyphs() > 0);
92
93 double max_ms_per_frame = stopwatch.MaxDelta().ToMillisecondsF();
94 double average_ms_per_frame = stopwatch.AverageDelta().ToMillisecondsF();
95 std::stringstream stream;
96 stream.setf(std::ios::fixed | std::ios::showpoint);
97 stream << std::setprecision(1);
98 stream << label_prefix << " " << "max " << max_ms_per_frame << " ms/frame, "
99 << "avg " << average_ms_per_frame << " ms/frame";
100 auto text = stream.str();
101 return SkTextBlob::MakeFromText(text.c_str(), text.size(), font,
103}
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
std::u16string text
font
Font Metadata and Metrics.
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
Definition platform.cc:17

◆ Paint()

void flutter::PerformanceOverlayLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 125 of file performance_overlay_layer.cc.

125 {
126 const int padding = 8;
127
128 if (!options_) {
129 return;
130 }
131
132 SkScalar x = paint_bounds().x() + padding;
133 SkScalar y = paint_bounds().y() + padding;
134 SkScalar width = paint_bounds().width() - (padding * 2);
136 auto mutator = context.state_stack.save();
137
138 VisualizeStopWatch(
139 context.canvas, context.impeller_enabled, context.raster_time, x, y,
140 width, height - padding, options_ & kVisualizeRasterizerStatistics,
141 options_ & kDisplayRasterizerStatistics, "Raster", font_path_);
142
143 VisualizeStopWatch(context.canvas, context.impeller_enabled, context.ui_time,
144 x, y + height, width, height - padding,
146 options_ & kDisplayEngineStatistics, "UI", font_path_);
147}
float SkScalar
Definition extension.cpp:12
double y
double x
const int kVisualizeEngineStatistics
const int kDisplayEngineStatistics
const int kVisualizeRasterizerStatistics
const int kDisplayRasterizerStatistics
int32_t height
int32_t width
constexpr float x() const
Definition SkRect.h:720
constexpr float y() const
Definition SkRect.h:727
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762

◆ Preroll()

void flutter::PerformanceOverlayLayer::Preroll ( PrerollContext context)
inlineoverridevirtual

Implements flutter::Layer.

Definition at line 42 of file performance_overlay_layer.h.

42{}

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