diff --git a/include/libweston/backend-headless.h b/include/libweston/backend-headless.h index 5d4f03eb3..ed26d88ad 100644 --- a/include/libweston/backend-headless.h +++ b/include/libweston/backend-headless.h @@ -45,7 +45,9 @@ struct weston_headless_backend_config { /** Use output decorations, requires use_gl = true */ bool decorate; - /** Output repaint refresh rate (in mHz). */ + /** Output repaint refresh rate (in mHz). Supported values range from 0 + * mHz to 1,000,000 mHz. 0 is a special value that triggers repaints + * only on capture requests, not on damages. */ int refresh; }; diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 667b79ea2..423d8a655 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -507,6 +507,9 @@ struct weston_output { /** Used only between repaint_begin and repaint_cancel. */ bool repainted; + /** Repaints are triggered only on capture requests, not on damages. */ + bool repaint_only_on_capture; + /** State of the repaint loop */ enum { REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */ diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index 2d74eea09..107ef3f5a 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -68,6 +68,7 @@ struct headless_backend { unsigned int formats_count; int refresh; + bool repaint_only_on_capture; }; struct headless_head { @@ -458,6 +459,7 @@ headless_output_create(struct weston_backend *backend, const char *name) output->base.disable = headless_output_disable; output->base.enable = headless_output_enable; output->base.attach_head = NULL; + output->base.repaint_only_on_capture = b->repaint_only_on_capture; output->backend = b; @@ -573,11 +575,16 @@ headless_backend_create(struct weston_compositor *compositor, b->formats = pixel_format_get_array(headless_formats, b->formats_count); /* Wayland event source's timeout has a granularity of the order of - * milliseconds so the highest supported rate is 1 kHz. */ - if (config->refresh > 0) + * milliseconds so the highest supported rate is 1 kHz. 0 is a special + * value that enables repaints only on capture. */ + if (config->refresh > 0) { b->refresh = MIN(config->refresh, 1000000); - else + } else if (config->refresh == 0) { + b->refresh = 1000000; + b->repaint_only_on_capture = true; + } else { b->refresh = DEFAULT_OUTPUT_REPAINT_REFRESH; + } if (!compositor->renderer) { switch (config->renderer) { diff --git a/libweston/compositor.c b/libweston/compositor.c index 8d8aa778a..af3c79cbc 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -3673,6 +3673,10 @@ weston_output_maybe_repaint(struct weston_output *output, struct timespec *now) if (output->power_state == WESTON_OUTPUT_POWER_FORCED_OFF) goto err; + if (output->repaint_only_on_capture && + !weston_output_has_renderer_capture_tasks(output)) + goto err; + /* If repaint fails, we aren't going to get weston_output_finish_frame * to trigger a new repaint, so drop it from repaint and hope * something schedules a successful repaint later. As repainting may @@ -7799,6 +7803,7 @@ weston_output_init(struct weston_output *output, output->desired_protection = WESTON_HDCP_DISABLE; output->allow_protection = true; output->power_state = WESTON_OUTPUT_POWER_NORMAL; + output->repaint_only_on_capture = false; wl_list_init(&output->head_list);