2017-12-19 16:15:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef StatsLayer_DEFINED
|
|
|
|
#define StatsLayer_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "tools/sk_app/Window.h"
|
2017-12-19 16:15:16 +00:00
|
|
|
|
|
|
|
class StatsLayer : public sk_app::Window::Layer {
|
|
|
|
public:
|
|
|
|
StatsLayer();
|
|
|
|
void resetMeasurements();
|
|
|
|
|
|
|
|
typedef int Timer;
|
|
|
|
|
|
|
|
Timer addTimer(const char* label, SkColor color, SkColor labelColor = 0);
|
|
|
|
void beginTiming(Timer);
|
|
|
|
void endTiming(Timer);
|
|
|
|
|
2019-03-21 18:43:00 +00:00
|
|
|
void onPrePaint() override;
|
2019-03-04 16:00:10 +00:00
|
|
|
void onPaint(SkSurface*) override;
|
2017-12-19 16:15:16 +00:00
|
|
|
|
2018-07-24 22:01:53 +00:00
|
|
|
void setDisplayScale(float scale) { fDisplayScale = scale; }
|
|
|
|
|
2017-12-19 16:15:16 +00:00
|
|
|
private:
|
|
|
|
static const int kMeasurementCount = 1 << 6; // should be power of 2 for fast mod
|
|
|
|
struct TimerData {
|
|
|
|
double fTimes[kMeasurementCount];
|
|
|
|
SkString fLabel;
|
|
|
|
SkColor fColor;
|
|
|
|
SkColor fLabelColor;
|
|
|
|
};
|
|
|
|
SkTArray<TimerData> fTimers;
|
2019-03-21 18:43:00 +00:00
|
|
|
double fTotalTimes[kMeasurementCount];
|
2017-12-19 16:15:16 +00:00
|
|
|
int fCurrentMeasurement;
|
2019-03-21 18:43:00 +00:00
|
|
|
double fLastTotalBegin;
|
2017-12-19 16:15:16 +00:00
|
|
|
double fCumulativeMeasurementTime;
|
|
|
|
int fCumulativeMeasurementCount;
|
2018-07-24 22:01:53 +00:00
|
|
|
float fDisplayScale;
|
2017-12-19 16:15:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|