summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mader <robert.mader@collabora.com>2022-05-04 17:57:27 +0200
committerMarius Vlad <marius.vlad@collabora.com>2022-05-24 22:11:23 +0300
commit01af0e4e0ef9e61e70a0b9413c7697f285258b27 (patch)
tree42bd3b5c9a0758143e0fab2ab48bee98152063c9
parent35c6a4b814dc179ed28456cac17fd7510da6e6e0 (diff)
downloadweston-01af0e4e0ef9e61e70a0b9413c7697f285258b27.tar.gz
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 34f7e01c2bb2cd19be00f7dcd1340390e1bf901a)
-rw-r--r--clients/simple-dmabuf-feedback.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/clients/simple-dmabuf-feedback.c b/clients/simple-dmabuf-feedback.c
index 0100c0a5..516cdbc8 100644
--- a/clients/simple-dmabuf-feedback.c
+++ b/clients/simple-dmabuf-feedback.c
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <libudev.h>
#include <sys/mman.h>
+#include <time.h>
#include "shared/helpers.h"
#include "shared/platform.h"
@@ -667,8 +668,6 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
window->display->output.height);
wl_surface_set_opaque_region(window->surface, region);
wl_region_destroy(region);
-
- window->n_redraws++;
}
static const struct wl_callback_listener frame_listener = {
@@ -1451,6 +1450,9 @@ main(int argc, char **argv)
struct display *display;
struct window *window;
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 " \
"Weston's dma-buf feedback implementation. See main() " \
@@ -1459,9 +1461,14 @@ main(int argc, char **argv)
display = create_display();
window = create_window(display);
+ clock_gettime(CLOCK_MONOTONIC, &start_time);
+
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);
+ clock_gettime(CLOCK_MONOTONIC, &current_time);
+ delta_time = current_time.tv_sec - start_time.tv_sec;
+ }
destroy_window(window);
destroy_display(display);