655002b8b0
This updates viewer to show the full frametime including getting new buffers and presenting buffers to the screen. This is more useful information than simply the sum the flush and paint. In a follow up CL we'll enable disabling vsync so we can truly measure how long it takes us to draw. Bug: skia: Change-Id: Ibdbf16b37b44309fca6e771272ce38fd31a0e95c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202708 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
/*
|
|
* 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
|
|
|
|
#include "SkColor.h"
|
|
#include "SkString.h"
|
|
#include "sk_app/Window.h"
|
|
|
|
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);
|
|
|
|
void onPrePaint() override;
|
|
void onPaint(SkSurface*) override;
|
|
|
|
void setDisplayScale(float scale) { fDisplayScale = scale; }
|
|
|
|
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;
|
|
double fTotalTimes[kMeasurementCount];
|
|
int fCurrentMeasurement;
|
|
double fLastTotalBegin;
|
|
double fCumulativeMeasurementTime;
|
|
int fCumulativeMeasurementCount;
|
|
float fDisplayScale;
|
|
};
|
|
|
|
#endif
|