Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
SkColor4f color
uint32_t SkColor
Definition SkColor.h:37
Timer addTimer(const char *label, SkColor color, SkColor labelColor=0)
void onPrePaint() override
void resetMeasurements()
void beginTiming(Timer)
void setDisplayScale(float scale)
Definition StatsLayer.h:32
void onPaint(SkSurface *) override
void endTiming(Timer)
const Scalar scale