summaryrefslogtreecommitdiff
path: root/kon/kondebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'kon/kondebug.c')
-rw-r--r--kon/kondebug.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/kon/kondebug.c b/kon/kondebug.c
index a68ebcf..54e8d13 100644
--- a/kon/kondebug.c
+++ b/kon/kondebug.c
@@ -91,6 +91,7 @@ struct kon_debug {
double accumTime;
int accumFrames;
float fps;
+ double times[4]; /* update, draw, present, blit */
float graph[KON_DEBUG_GRAPH];
int graphHead;
};
@@ -607,6 +608,16 @@ void kon_debugFrame(kon_debug_t *d)
d->graphHead = (d->graphHead + 1) % KON_DEBUG_GRAPH;
}
+void kon_debugTimes(kon_debug_t *d, double update, double draw, double present, double blit)
+{
+ double in[4];
+ int i;
+
+ if (!d) return;
+ in[0] = update; in[1] = draw; in[2] = present; in[3] = blit;
+ for (i = 0; i < 4; i++) d->times[i] += (in[i] - d->times[i]) * 0.1;
+}
+
static void kon_debugBox_(const kon_debug_t *d, kon_framebuffer_t *fb, int x, int y, const char *s, uint32_t color)
{
int w = 0;
@@ -628,6 +639,9 @@ static void kon_debugDrawOverlay_(kon_debug_t *d, kon_framebuffer_t *fb)
y += d->lineH + 3;
if (d->overlay >= 1) {
+ snprintf(line, sizeof(line), "upd %.1f draw %.1f scale %.1f blit %.1f", d->times[0] * 1000.0, d->times[1] * 1000.0, d->times[2] * 1000.0, d->times[3] * 1000.0);
+ kon_debugBox_(d, fb, x, y, line, dim);
+ y += d->lineH + 3;
kon_fillRectangle(fb, x - 2, y - 2, KON_DEBUG_GRAPH + 4, 34, 0xB0000000);
for (i = 0; i < KON_DEBUG_GRAPH; i++) {
float ms = d->graph[(d->graphHead + i) % KON_DEBUG_GRAPH];