Flutter Engine
The Flutter Engine
StatsLayer.h
Go to the documentation of this file.
1/*
2* Copyright 2017 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#ifndef StatsLayer_DEFINED
9#define StatsLayer_DEFINED
10
14#include "tools/sk_app/Window.h"
15
16class SkSurface;
17
19public:
20 StatsLayer();
21 void resetMeasurements();
22
23 typedef int Timer;
24
25 Timer addTimer(const char* label, SkColor color, SkColor labelColor = 0);
26 void beginTiming(Timer);
27 void endTiming(Timer);
28
29 void onPrePaint() override;
30 void onPaint(SkSurface*) override;
31
32 void setDisplayScale(float scale) { fDisplayScale = scale; }
33
34private:
35 static const int kMeasurementCount = 1 << 6; // should be power of 2 for fast mod
36 struct TimerData {
37 double fTimes[kMeasurementCount];
38 SkString fLabel;
39 SkColor fColor;
40 SkColor fLabelColor;
41 };
43 double fTotalTimes[kMeasurementCount];
44 int fCurrentMeasurement;
45 double fLastTotalBegin;
46 double fCumulativeMeasurementTime;
47 int fCumulativeMeasurementCount;
48 float fDisplayScale;
49};
50
51#endif
uint32_t SkColor
Definition: SkColor.h:37
Timer addTimer(const char *label, SkColor color, SkColor labelColor=0)
Definition: StatsLayer.cpp:49
void onPrePaint() override
Definition: StatsLayer.cpp:71
void resetMeasurements()
Definition: StatsLayer.cpp:38
void beginTiming(Timer)
Definition: StatsLayer.cpp:59
void setDisplayScale(float scale)
Definition: StatsLayer.h:32
void onPaint(SkSurface *) override
Definition: StatsLayer.cpp:82
void endTiming(Timer)
Definition: StatsLayer.cpp:65
DlColor color
const Scalar scale