X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffps.c;h=97a2c8b6353337a30ca9b099f30610addcb6113a;hb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;hp=2164fcfe8d3705f8d78903429008d830bc164373;hpb=50be9bb40dc60130c99ffa568e6677779904ff70;p=xscreensaver diff --git a/hacks/fps.c b/hacks/fps.c index 2164fcfe..97a2c8b6 100644 --- a/hacks/fps.c +++ b/hacks/fps.c @@ -1,4 +1,4 @@ -/* fps, Copyright (c) 2001-2008 Jamie Zawinski +/* fps, Copyright (c) 2001-2014 Jamie Zawinski * Draw a frames-per-second display (Xlib and OpenGL). * * Permission to use, copy, modify, distribute, and sell this software and its @@ -14,6 +14,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include "screenhackI.h" #include "fpsI.h" @@ -81,7 +82,7 @@ fps_slept (fps_state *st, unsigned long usecs) double -fps_compute (fps_state *st, unsigned long polys) +fps_compute (fps_state *st, unsigned long polys, double depth) { if (! st) return 0; /* too early? */ @@ -149,6 +150,18 @@ fps_compute (fps_state *st, unsigned long polys) else sprintf (st->string + strlen(st->string), "%lu%s ", polys, s); } + + if (depth >= 0.0) + { + unsigned long L = strlen (st->string); + char *s = st->string + L; + strcat (s, "\nDepth: "); + sprintf (s + strlen(s), "%.1f", depth); + L = strlen (s); + /* Remove trailing ".0" in case depth is not a fraction. */ + if (s[L-2] == '.' && s[L-1] == '0') + s[L-2] = 0; + } } return st->last_fps; @@ -186,7 +199,7 @@ string_width (XFontStruct *f, const char *c, int *height_ret) } -/* This function is used only in Xlib mode. For GL mode, see glx/fps-glx.c. +/* This function is used only in Xlib mode. For GL mode, see glx/fps-gl.c. */ void fps_draw (fps_state *st) @@ -229,7 +242,7 @@ fps_draw (fps_state *st) s = strchr (string, '\n'); if (! s) s = string + strlen(string); XDrawString (st->dpy, st->window, st->draw_gc, - x, y, string, s - string); + x, y, string, (int) (s - string)); string = s; string++; lines--;