output: add adaptive_sync_enabled property
This commit is contained in:
parent
8afc1ed68c
commit
7017fa95b8
|
@ -46,6 +46,12 @@ struct wlr_output_cursor {
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum wlr_output_adaptive_sync_status {
|
||||||
|
WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED,
|
||||||
|
WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED,
|
||||||
|
WLR_OUTPUT_ADAPTIVE_SYNC_UNKNOWN, // requested, but maybe disabled
|
||||||
|
};
|
||||||
|
|
||||||
enum wlr_output_state_field {
|
enum wlr_output_state_field {
|
||||||
WLR_OUTPUT_STATE_BUFFER = 1 << 0,
|
WLR_OUTPUT_STATE_BUFFER = 1 << 0,
|
||||||
WLR_OUTPUT_STATE_DAMAGE = 1 << 1,
|
WLR_OUTPUT_STATE_DAMAGE = 1 << 1,
|
||||||
|
@ -53,6 +59,7 @@ enum wlr_output_state_field {
|
||||||
WLR_OUTPUT_STATE_ENABLED = 1 << 3,
|
WLR_OUTPUT_STATE_ENABLED = 1 << 3,
|
||||||
WLR_OUTPUT_STATE_SCALE = 1 << 4,
|
WLR_OUTPUT_STATE_SCALE = 1 << 4,
|
||||||
WLR_OUTPUT_STATE_TRANSFORM = 1 << 5,
|
WLR_OUTPUT_STATE_TRANSFORM = 1 << 5,
|
||||||
|
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED = 1 << 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum wlr_output_state_buffer_type {
|
enum wlr_output_state_buffer_type {
|
||||||
|
@ -74,6 +81,7 @@ struct wlr_output_state {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
float scale;
|
float scale;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
|
bool adaptive_sync_enabled;
|
||||||
|
|
||||||
// only valid if WLR_OUTPUT_STATE_BUFFER
|
// only valid if WLR_OUTPUT_STATE_BUFFER
|
||||||
enum wlr_output_state_buffer_type buffer_type;
|
enum wlr_output_state_buffer_type buffer_type;
|
||||||
|
@ -126,6 +134,7 @@ struct wlr_output {
|
||||||
float scale;
|
float scale;
|
||||||
enum wl_output_subpixel subpixel;
|
enum wl_output_subpixel subpixel;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
|
enum wlr_output_adaptive_sync_status adaptive_sync_status;
|
||||||
|
|
||||||
bool needs_frame;
|
bool needs_frame;
|
||||||
// damage for cursors and fullscreen surface, in output-local coordinates
|
// damage for cursors and fullscreen surface, in output-local coordinates
|
||||||
|
@ -246,6 +255,16 @@ void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
|
||||||
*/
|
*/
|
||||||
void wlr_output_set_transform(struct wlr_output *output,
|
void wlr_output_set_transform(struct wlr_output *output,
|
||||||
enum wl_output_transform transform);
|
enum wl_output_transform transform);
|
||||||
|
/**
|
||||||
|
* Enables or disables adaptive sync (ie. variable refresh rate) on this
|
||||||
|
* output. This is just a hint, the backend is free to ignore this setting.
|
||||||
|
*
|
||||||
|
* When enabled, compositors can submit frames a little bit later than the
|
||||||
|
* deadline without dropping a frame.
|
||||||
|
*
|
||||||
|
* Adaptive sync is double-buffered state, see `wlr_output_commit`.
|
||||||
|
*/
|
||||||
|
void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
|
||||||
/**
|
/**
|
||||||
* Sets a scale for the output.
|
* Sets a scale for the output.
|
||||||
*
|
*
|
||||||
|
|
|
@ -240,6 +240,18 @@ void wlr_output_set_scale(struct wlr_output *output, float scale) {
|
||||||
output->pending.scale = scale;
|
output->pending.scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled) {
|
||||||
|
bool currently_enabled =
|
||||||
|
output->adaptive_sync_status != WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED;
|
||||||
|
if (currently_enabled == enabled) {
|
||||||
|
output->pending.committed &= ~WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
output->pending.committed |= WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
|
||||||
|
output->pending.adaptive_sync_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_output_set_subpixel(struct wlr_output *output,
|
void wlr_output_set_subpixel(struct wlr_output *output,
|
||||||
enum wl_output_subpixel subpixel) {
|
enum wl_output_subpixel subpixel) {
|
||||||
if (output->subpixel == subpixel) {
|
if (output->subpixel == subpixel) {
|
||||||
|
@ -487,6 +499,10 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
wlr_log(WLR_ERROR, "Tried to modeset a disabled output");
|
wlr_log(WLR_ERROR, "Tried to modeset a disabled output");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
|
||||||
|
wlr_log(WLR_ERROR, "Tried to enable adaptive sync on a disabled output");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
Loading…
Reference in New Issue