backend-headless: Add support to repaint only on captures
Damages and captures both trigger repaints of outputs. Some configurations don't care about damages and use headless only for captures. This commit adds a new feature to libweston that lets outputs repaint only on captures, not on damages. The headless backend enables that new feature when given a special refresh rate of 0 mHz. Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
parent
6caeba699d
commit
7b2eddf022
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue