output: Drop pending state

master
Alexander Orzechowski 2 years ago committed by Kirill Primak
parent f91fc445ff
commit cca2bfbe92

@ -156,8 +156,6 @@ struct wlr_output {
// true for example with VR headsets
bool non_desktop;
struct wlr_output_state pending;
// Commit sequence number. Incremented on each commit, may overflow.
uint32_t commit_seq;
@ -268,14 +266,6 @@ struct wlr_output_event_request_state {
struct wlr_surface;
/**
* Enables or disables the output. A disabled output is turned off and doesn't
* emit `frame` events.
*
* Whether an output is enabled is double-buffered state, see
* wlr_output_commit().
*/
void wlr_output_enable(struct wlr_output *output, bool enable);
void wlr_output_create_global(struct wlr_output *output, struct wl_display *display);
void wlr_output_destroy_global(struct wlr_output *output);
/**
@ -296,72 +286,6 @@ bool wlr_output_init_render(struct wlr_output *output,
* modes, returns NULL.
*/
struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output);
/**
* Sets the output mode. The output needs to be enabled.
*
* Mode is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode);
/**
* Sets a custom mode on the output.
*
* When the output advertises fixed modes, custom modes are not guaranteed to
* work correctly, they may result in visual artifacts. If a suitable fixed mode
* is available, compositors should prefer it and use wlr_output_set_mode()
* instead of custom modes.
*
* Setting `refresh` to zero lets the backend pick a preferred value. The
* output needs to be enabled.
*
* Custom mode is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh);
/**
* Sets a transform for the output.
*
* Transform is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_transform(struct wlr_output *output,
enum wl_output_transform transform);
/**
* Enables or disables adaptive sync (ie. variable refresh rate) on this
* output. On some backends, this is just a hint and may be ignored.
* Compositors can inspect `wlr_output.adaptive_sync_status` to query the
* effective status. Backends that don't support adaptive sync will reject
* the output commit.
*
* 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);
/**
* Set the output buffer render format. Default value: DRM_FORMAT_XRGB8888
*
* While high bit depth render formats are necessary for a monitor to receive
* useful high bit data, they do not guarantee it; a DRM_FORMAT_XBGR2101010
* buffer will only lead to sending 10-bpc image data to the monitor if
* hardware and software permit this.
*
* This only affects the format of the output buffer used when rendering,
* as with wlr_output_begin_render_pass(). It has no impact on the cursor buffer
* format, or on the formats supported for direct scan-out (see also
* wlr_output_attach_buffer()).
*
* This format is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_render_format(struct wlr_output *output, uint32_t format);
/**
* Sets a scale for the output.
*
* Scale is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_scale(struct wlr_output *output, float scale);
void wlr_output_set_subpixel(struct wlr_output *output,
enum wl_output_subpixel subpixel);
/**
* Set the output name.
*
@ -391,59 +315,6 @@ void wlr_output_transformed_resolution(struct wlr_output *output,
*/
void wlr_output_effective_resolution(struct wlr_output *output,
int *width, int *height);
/**
* Attach a buffer to the output. Compositors should call wlr_output_commit()
* to submit the new frame. The output needs to be enabled.
*
* Not all backends support direct scan-out on all buffers. Compositors can
* check whether a buffer is supported by calling wlr_output_test().
*/
void wlr_output_attach_buffer(struct wlr_output *output,
struct wlr_buffer *buffer);
/**
* Set the damage region for the frame to be submitted. This is the region of
* the screen that has changed since the last frame.
*
* Compositors implementing damage tracking should call this function with the
* damaged region in output-buffer-local coordinates.
*
* This region is not to be confused with the renderer's buffer damage, ie. the
* region compositors need to repaint. Compositors usually need to repaint more
* than what changed since last frame since multiple render buffers are used.
*/
void wlr_output_set_damage(struct wlr_output *output,
const pixman_region32_t *damage);
/**
* Set the output layers state.
*
* See struct wlr_output_layer for more details on output layers.
*
* This state is double-buffered, see wlr_output_commit(). The layers array
* must remain valid until the wlr_output_test() or wlr_output_commit() call.
*/
void wlr_output_set_layers(struct wlr_output *output,
struct wlr_output_layer_state *layers, size_t layers_len);
/**
* Test whether the pending output state would be accepted by the backend. If
* this function returns true, wlr_output_commit() can only fail due to a
* runtime error.
*
* This function doesn't mutate the pending state.
*/
bool wlr_output_test(struct wlr_output *output);
/**
* Commit the pending output state. If wlr_output_begin_render_pass() has been
* called, the pending frame will be submitted for display and a `frame` event
* will be scheduled.
*
* On failure, the pending changes are rolled back.
*/
bool wlr_output_commit(struct wlr_output *output);
/**
* Discard the pending output state.
*/
void wlr_output_rollback(struct wlr_output *output);
/**
* Test whether this output state would be accepted by the backend. If this
* function returns true, wlr_output_commit_state() will only fail due to a
@ -471,17 +342,6 @@ void wlr_output_schedule_frame(struct wlr_output *output);
* Returns the maximum length of each gamma ramp, or 0 if unsupported.
*/
size_t wlr_output_get_gamma_size(struct wlr_output *output);
/**
* Sets the gamma table for this output. `r`, `g` and `b` are gamma ramps for
* red, green and blue. `size` is the length of the ramps and must not exceed
* the value returned by wlr_output_get_gamma_size().
*
* Providing zero-sized ramps resets the gamma table.
*
* The gamma table is double-buffered state, see wlr_output_commit().
*/
void wlr_output_set_gamma(struct wlr_output *output, size_t size,
const uint16_t *r, const uint16_t *g, const uint16_t *b);
/**
* Returns the wlr_output matching the provided wl_output resource. If the
* resource isn't a wl_output, it aborts. If the resource is inert (because the

@ -193,52 +193,6 @@ struct wlr_output *wlr_output_from_resource(struct wl_resource *resource) {
return wl_resource_get_user_data(resource);
}
void wlr_output_enable(struct wlr_output *output, bool enable) {
wlr_output_state_set_enabled(&output->pending, enable);
}
void wlr_output_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode) {
wlr_output_state_set_mode(&output->pending, mode);
}
void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh) {
// If there is a fixed mode which matches what the user wants, use that
struct wlr_output_mode *mode;
wl_list_for_each(mode, &output->modes, link) {
if (mode->width == width && mode->height == height &&
mode->refresh == refresh) {
wlr_output_set_mode(output, mode);
return;
}
}
wlr_output_state_set_custom_mode(&output->pending, width, height, refresh);
}
void wlr_output_set_transform(struct wlr_output *output,
enum wl_output_transform transform) {
wlr_output_state_set_transform(&output->pending, transform);
}
void wlr_output_set_scale(struct wlr_output *output, float scale) {
wlr_output_state_set_scale(&output->pending, scale);
}
void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled) {
wlr_output_state_set_adaptive_sync_enabled(&output->pending, enabled);
}
void wlr_output_set_render_format(struct wlr_output *output, uint32_t format) {
wlr_output_state_set_render_format(&output->pending, format);
}
void wlr_output_set_subpixel(struct wlr_output *output,
enum wl_output_subpixel subpixel) {
wlr_output_state_set_subpixel(&output->pending, subpixel);
}
void wlr_output_set_name(struct wlr_output *output, const char *name) {
assert(output->global == NULL);
@ -268,12 +222,6 @@ void wlr_output_set_description(struct wlr_output *output, const char *desc) {
wl_signal_emit_mutable(&output->events.description, output);
}
static void output_state_move(struct wlr_output_state *dst,
struct wlr_output_state *src) {
*dst = *src;
wlr_output_state_init(src);
}
static void output_apply_state(struct wlr_output *output,
const struct wlr_output_state *state) {
if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
@ -417,7 +365,6 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
wl_signal_init(&output->events.description);
wl_signal_init(&output->events.request_state);
wl_signal_init(&output->events.destroy);
wlr_output_state_init(&output->pending);
output->software_cursor_locks = env_parse_bool("WLR_NO_HARDWARE_CURSORS");
if (output->software_cursor_locks) {
@ -478,8 +425,6 @@ void wlr_output_destroy(struct wlr_output *output) {
free(output->model);
free(output->serial);
wlr_output_state_finish(&output->pending);
if (output->impl && output->impl->destroy) {
output->impl->destroy(output);
} else {
@ -521,42 +466,6 @@ struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) {
return wl_container_of(output->modes.next, mode, link);
}
static void output_state_clear_buffer(struct wlr_output_state *state) {
if (!(state->committed & WLR_OUTPUT_STATE_BUFFER)) {
return;
}
wlr_buffer_unlock(state->buffer);
state->buffer = NULL;
state->committed &= ~WLR_OUTPUT_STATE_BUFFER;
}
void wlr_output_set_damage(struct wlr_output *output,
const pixman_region32_t *damage) {
pixman_region32_intersect_rect(&output->pending.damage, damage,
0, 0, output->width, output->height);
output->pending.committed |= WLR_OUTPUT_STATE_DAMAGE;
}
void wlr_output_set_layers(struct wlr_output *output,
struct wlr_output_layer_state *layers, size_t layers_len) {
wlr_output_state_set_layers(&output->pending, layers, layers_len);
}
static void output_state_clear_gamma_lut(struct wlr_output_state *state) {
free(state->gamma_lut);
state->gamma_lut = NULL;
state->committed &= ~WLR_OUTPUT_STATE_GAMMA_LUT;
}
static void output_state_clear(struct wlr_output_state *state) {
output_state_clear_buffer(state);
output_state_clear_gamma_lut(state);
pixman_region32_clear(&state->damage);
state->committed = 0;
}
void output_pending_resolution(struct wlr_output *output,
const struct wlr_output_state *state, int *width, int *height) {
if (state->committed & WLR_OUTPUT_STATE_MODE) {
@ -758,12 +667,6 @@ bool wlr_output_test_state(struct wlr_output *output,
return success;
}
bool wlr_output_test(struct wlr_output *output) {
struct wlr_output_state state = output->pending;
return wlr_output_test_state(output, &state);
}
bool wlr_output_commit_state(struct wlr_output *output,
const struct wlr_output_state *state) {
uint32_t unchanged = output_compare_state(output, state);
@ -829,25 +732,6 @@ bool wlr_output_commit_state(struct wlr_output *output,
return true;
}
bool wlr_output_commit(struct wlr_output *output) {
// Make sure the pending state is cleared before the output is committed
struct wlr_output_state state = {0};
output_state_move(&state, &output->pending);
bool ok = wlr_output_commit_state(output, &state);
wlr_output_state_finish(&state);
return ok;
}
void wlr_output_rollback(struct wlr_output *output) {
output_state_clear(&output->pending);
}
void wlr_output_attach_buffer(struct wlr_output *output,
struct wlr_buffer *buffer) {
wlr_output_state_set_buffer(&output->pending, buffer);
}
void wlr_output_send_frame(struct wlr_output *output) {
output->frame_pending = false;
if (output->enabled) {
@ -953,11 +837,6 @@ void wlr_output_send_request_state(struct wlr_output *output,
wl_signal_emit_mutable(&output->events.request_state, &event);
}
void wlr_output_set_gamma(struct wlr_output *output, size_t size,
const uint16_t *r, const uint16_t *g, const uint16_t *b) {
wlr_output_state_set_gamma_lut(&output->pending, size, r, g, b);
}
size_t wlr_output_get_gamma_size(struct wlr_output *output) {
if (!output->impl->get_gamma_size) {
return 0;

Loading…
Cancel
Save