diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 191: Main: Implement seamless transition of FPS display when changing scenes.

Message ID 20120119110812.13346.51782.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org Jan. 19, 2012, 11:08 a.m. UTC
------------------------------------------------------------
revno: 191
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Thu 2012-01-19 12:58:18 +0200
message:
  Main: Implement seamless transition of FPS display when changing scenes.
modified:
  src/main.cpp


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/main.cpp'
--- src/main.cpp	2012-01-18 21:44:06 +0000
+++ src/main.cpp	2012-01-19 10:58:18 +0000
@@ -162,11 +162,20 @@ 
     }
 }
 
+static inline void
+fps_renderer_update_text(TextRenderer &fps_renderer, unsigned int fps)
+{
+    std::stringstream ss;
+    ss << "FPS: " << fps;
+    fps_renderer.text(ss.str());
+}
+
 void
 do_benchmark(Canvas &canvas, vector<Benchmark *> &benchmarks)
 {
     static const unsigned int fps_interval = 500000;
     unsigned score = 0;
+    unsigned int last_fps = 0;
     unsigned int benchmarks_run = 0;
 
     for (vector<Benchmark *>::iterator bench_iter = benchmarks.begin();
@@ -176,11 +185,14 @@ 
         if (!Options::reuse_context)
             canvas.reset();
 
+        TextRenderer fps_renderer(canvas);
+        if (Options::show_fps)
+            fps_renderer_update_text(fps_renderer, last_fps);
+
         bool keep_running = true;
         Benchmark *bench = *bench_iter;
         uint64_t fps_timestamp = Util::get_timestamp_us();
         Scene &scene = bench->setup_scene();
-        TextRenderer fps_renderer(canvas);
 
         if (!scene.name().empty()) {
             Log::info("%s", scene.info_string().c_str());
@@ -197,9 +209,8 @@ 
                 if (Options::show_fps) {
                     uint64_t now = Util::get_timestamp_us();
                     if (now - fps_timestamp >= fps_interval) {
-                        std::stringstream ss;
-                        ss << "FPS: " << scene.average_fps();
-                        fps_renderer.text(ss.str());
+                        last_fps = scene.average_fps();
+                        fps_renderer_update_text(fps_renderer, last_fps);
                         fps_timestamp = now;
                     }
                     fps_renderer.render();