From f0834fb0341815886a20e0ac2dbe42b578b36c09 Mon Sep 17 00:00:00 2001
From: Marten Richter <marten.richter@freenet.de>
Date: Thu, 17 May 2012 13:09:33 +0200
Subject: [PATCH] Added FPS benchmarking

---
 osdopengl.cc | 16 ++++++++++++++++
 osdopengl.h  |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 osdopengl.h

diff --git a/osdopengl.cc b/osdopengl.cc
index 23d3054..79e79cc 100755
--- a/osdopengl.cc
+++ b/osdopengl.cc
@@ -57,6 +57,10 @@ OsdOpenGL::OsdOpenGL()
   gen_shader=0;
   osd_program=0;
 
+#ifdef BENCHMARK_FPS
+	last_benchmark_time=getTimeMS();
+	num_benchmark_frames=0;
+#endif
 
   
 }
@@ -556,6 +560,18 @@ void OsdOpenGL::InternalRendering(GLuint  present){
 	eglSwapBuffers(egl_display, egl_surface);
 
 	EndPainting();
+#ifdef BENCHMARK_FPS
+	num_benchmark_frames++;
+	if (getTimeMS()-last_benchmark_time>4000) {
+		float fps=1000./(float)(getTimeMS()-last_benchmark_time);
+		fps*=((float)num_benchmark_frames);
+		num_benchmark_frames=0;
+		Log::getInstance()->log("OSD", Log::NOTICE, "Current FPS %g", fps);
+		last_benchmark_time=getTimeMS();
+
+	}
+
+#endif
 
 	
 //	if (!external_driving) {
diff --git a/osdopengl.h b/osdopengl.h
old mode 100644
new mode 100755
index 0e9d08e..4d7d83d
--- a/osdopengl.h
+++ b/osdopengl.h
@@ -35,7 +35,7 @@
 #include "threadp.h"
 #include "mutex.h"
 
-
+#define BENCHMARK_FPS
 
 
 
@@ -127,6 +127,10 @@ private:
 	EGLDisplay egl_display;
 	EGLSurface egl_surface;
 	EGLContext egl_context;
+#ifdef BENCHMARK_FPS
+	long long last_benchmark_time;
+	unsigned int num_benchmark_frames;
+#endif
 
 };
 
-- 
2.39.5