clients/simple-egl: Fix angle reset on benchmark interval

Commit 62ab6891db intended to change the angle calculation
so that the a time delta since the first frame would be used
instead of the absolute time. That was done in order to ensure
the angle would always start with the same value, allowing users
to differentiate left and right, which again is needed when
testing flipped transforms.

However, the `benchmark_time` variable is unsuitable for that
purpose as it gets reset on each benchmark interval, abruptly
changing the angle.

Thus introduce a dedicated variable.

Fixes 62ab6891db

Signed-off-by: Robert Mader <robert.mader@collabora.com>
dev
Robert Mader 3 years ago
parent ae9643f729
commit f7541d9e42
  1. 10
      clients/simple-egl.c

@ -99,7 +99,9 @@ struct window {
GLuint col;
} gl;
uint32_t benchmark_time, frames;
uint32_t frames;
uint32_t initial_frame_time;
uint32_t benchmark_time;
struct wl_egl_window *native;
struct wl_surface *surface;
struct xdg_surface *xdg_surface;
@ -624,8 +626,10 @@ redraw(struct window *window)
gettimeofday(&tv, NULL);
uint32_t time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
if (window->frames == 0)
if (window->frames == 0) {
window->initial_frame_time = time;
window->benchmark_time = time;
}
if (time - window->benchmark_time > (benchmark_interval * 1000)) {
printf("%d frames in %d seconds: %f fps\n",
window->frames,
@ -636,7 +640,7 @@ redraw(struct window *window)
}
weston_matrix_init(&rotation);
angle = ((time - window->benchmark_time) / speed_div) % 360 * M_PI / 180.0;
angle = ((time - window->initial_frame_time) / speed_div) % 360 * M_PI / 180.0;
rotation.d[0] = cos(angle);
rotation.d[2] = sin(angle);
rotation.d[8] = -sin(angle);

Loading…
Cancel
Save