clients/simple-dmabuf-feedback: use time instead of redraws

Weston uses a timeout of 2 seconds before it sends scanout
tranches to clients in order to not trigger excessive buffer
reallocations in clients.
`simple-dmabuf-feedback` in turn counts redraws (200) before
exiting. That doesn't work on e.g. 144Hz screens, thus use a
timer here as well.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
(cherry picked from commit 34f7e01c2b)
dev
Robert Mader 3 years ago committed by Marius Vlad
parent 35c6a4b814
commit 01af0e4e0e
  1. 13
      clients/simple-dmabuf-feedback.c

@ -32,6 +32,7 @@
#include <stdio.h> #include <stdio.h>
#include <libudev.h> #include <libudev.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <time.h>
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/platform.h" #include "shared/platform.h"
@ -667,8 +668,6 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
window->display->output.height); window->display->output.height);
wl_surface_set_opaque_region(window->surface, region); wl_surface_set_opaque_region(window->surface, region);
wl_region_destroy(region); wl_region_destroy(region);
window->n_redraws++;
} }
static const struct wl_callback_listener frame_listener = { static const struct wl_callback_listener frame_listener = {
@ -1451,6 +1450,9 @@ main(int argc, char **argv)
struct display *display; struct display *display;
struct window *window; struct window *window;
int ret = 0; int ret = 0;
struct timespec start_time, current_time;
const time_t MAX_TIME_SECONDS = 3;
time_t delta_time = 0;
fprintf(stderr, "This client was written with the purpose of manually test " \ fprintf(stderr, "This client was written with the purpose of manually test " \
"Weston's dma-buf feedback implementation. See main() " \ "Weston's dma-buf feedback implementation. See main() " \
@ -1459,9 +1461,14 @@ main(int argc, char **argv)
display = create_display(); display = create_display();
window = create_window(display); window = create_window(display);
clock_gettime(CLOCK_MONOTONIC, &start_time);
redraw(window, NULL, 0); redraw(window, NULL, 0);
while (ret != -1 && window->n_redraws < 200) while (ret != -1 && delta_time < MAX_TIME_SECONDS) {
ret = wl_display_dispatch(display->display); ret = wl_display_dispatch(display->display);
clock_gettime(CLOCK_MONOTONIC, &current_time);
delta_time = current_time.tv_sec - start_time.tv_sec;
}
destroy_window(window); destroy_window(window);
destroy_display(display); destroy_display(display);

Loading…
Cancel
Save