mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 22:48:14 +02:00
clients/simple-egl: Fix angle reset on benchmark interval
Commit62ab6891dbintended 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. Fixes62ab6891dbSigned-off-by: Robert Mader <robert.mader@collabora.com>
This commit is contained in:
parent
ae9643f729
commit
f7541d9e42
1 changed files with 7 additions and 3 deletions
|
|
@ -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…
Add table
Reference in a new issue