mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
output: add wlr_output_test_state
Same as wlr_output_test, but takes a wlr_output_state argument.
This commit is contained in:
parent
9e25d3074d
commit
c4253fef9c
2 changed files with 33 additions and 25 deletions
|
@ -425,6 +425,8 @@ bool wlr_output_commit(struct wlr_output *output);
|
||||||
* Discard the pending output state.
|
* Discard the pending output state.
|
||||||
*/
|
*/
|
||||||
void wlr_output_rollback(struct wlr_output *output);
|
void wlr_output_rollback(struct wlr_output *output);
|
||||||
|
bool wlr_output_test_state(struct wlr_output *output,
|
||||||
|
const struct wlr_output_state *state);
|
||||||
/**
|
/**
|
||||||
* Manually schedules a `frame` event. If a `frame` event is already pending,
|
* Manually schedules a `frame` event. If a `frame` event is already pending,
|
||||||
* it is a no-op.
|
* it is a no-op.
|
||||||
|
|
|
@ -555,8 +555,9 @@ void output_pending_resolution(struct wlr_output *output,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool output_basic_test(struct wlr_output *output) {
|
static bool output_basic_test(struct wlr_output *output,
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
const struct wlr_output_state *state) {
|
||||||
|
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
if (output->frame_pending) {
|
if (output->frame_pending) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to commit a buffer while a frame is pending");
|
wlr_log(WLR_DEBUG, "Tried to commit a buffer while a frame is pending");
|
||||||
return false;
|
return false;
|
||||||
|
@ -583,24 +584,24 @@ static bool output_basic_test(struct wlr_output *output) {
|
||||||
// If the size doesn't match, reject buffer (scaling is not
|
// If the size doesn't match, reject buffer (scaling is not
|
||||||
// supported)
|
// supported)
|
||||||
int pending_width, pending_height;
|
int pending_width, pending_height;
|
||||||
output_pending_resolution(output, &output->pending,
|
output_pending_resolution(output, state,
|
||||||
&pending_width, &pending_height);
|
&pending_width, &pending_height);
|
||||||
if (output->pending.buffer->width != pending_width ||
|
if (state->buffer->width != pending_width ||
|
||||||
output->pending.buffer->height != pending_height) {
|
state->buffer->height != pending_height) {
|
||||||
wlr_log(WLR_DEBUG, "Direct scan-out buffer size mismatch");
|
wlr_log(WLR_DEBUG, "Direct scan-out buffer size mismatch");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
|
if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
|
||||||
struct wlr_allocator *allocator = output->allocator;
|
struct wlr_allocator *allocator = output->allocator;
|
||||||
assert(allocator != NULL);
|
assert(allocator != NULL);
|
||||||
|
|
||||||
const struct wlr_drm_format_set *display_formats =
|
const struct wlr_drm_format_set *display_formats =
|
||||||
wlr_output_get_primary_formats(output, allocator->buffer_caps);
|
wlr_output_get_primary_formats(output, allocator->buffer_caps);
|
||||||
struct wlr_drm_format *format = output_pick_format(output, display_formats,
|
struct wlr_drm_format *format = output_pick_format(output, display_formats,
|
||||||
output->pending.render_format);
|
state->render_format);
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
wlr_log(WLR_ERROR, "Failed to pick primary buffer format for output");
|
wlr_log(WLR_ERROR, "Failed to pick primary buffer format for output");
|
||||||
return false;
|
return false;
|
||||||
|
@ -610,14 +611,14 @@ static bool output_basic_test(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enabled = output->enabled;
|
bool enabled = output->enabled;
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_ENABLED) {
|
if (state->committed & WLR_OUTPUT_STATE_ENABLED) {
|
||||||
enabled = output->pending.enabled;
|
enabled = state->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled && (output->pending.committed & (WLR_OUTPUT_STATE_ENABLED |
|
if (enabled && (state->committed & (WLR_OUTPUT_STATE_ENABLED |
|
||||||
WLR_OUTPUT_STATE_MODE))) {
|
WLR_OUTPUT_STATE_MODE))) {
|
||||||
int pending_width, pending_height;
|
int pending_width, pending_height;
|
||||||
output_pending_resolution(output, &output->pending,
|
output_pending_resolution(output, state,
|
||||||
&pending_width, &pending_height);
|
&pending_width, &pending_height);
|
||||||
if (pending_width == 0 || pending_height == 0) {
|
if (pending_width == 0 || pending_height == 0) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to enable an output with a zero mode");
|
wlr_log(WLR_DEBUG, "Tried to enable an output with a zero mode");
|
||||||
|
@ -625,27 +626,27 @@ static bool output_basic_test(struct wlr_output *output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to commit a buffer on a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to commit a buffer on a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_MODE) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_MODE) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to modeset a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to modeset a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to enable adaptive sync on a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to enable adaptive sync on a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to set format for a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to set format for a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_GAMMA_LUT) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to set the gamma lut on a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to set the gamma lut on a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!enabled && output->pending.committed & WLR_OUTPUT_STATE_SUBPIXEL) {
|
if (!enabled && state->committed & WLR_OUTPUT_STATE_SUBPIXEL) {
|
||||||
wlr_log(WLR_DEBUG, "Tried to set the subpixel layout on a disabled output");
|
wlr_log(WLR_DEBUG, "Tried to set the subpixel layout on a disabled output");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -653,30 +654,35 @@ static bool output_basic_test(struct wlr_output *output) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_output_test(struct wlr_output *output) {
|
bool wlr_output_test_state(struct wlr_output *output,
|
||||||
bool had_buffer = output->pending.committed & WLR_OUTPUT_STATE_BUFFER;
|
const struct wlr_output_state *state) {
|
||||||
bool success;
|
bool had_buffer = state->committed & WLR_OUTPUT_STATE_BUFFER;
|
||||||
|
|
||||||
if (!output_basic_test(output)) {
|
// Duplicate the satte because we might mutate it in output_ensure_buffer
|
||||||
|
struct wlr_output_state pending = *state;
|
||||||
|
if (!output_basic_test(output, &pending)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!output_ensure_buffer(output, &output->pending)) {
|
if (!output_ensure_buffer(output, &pending)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!output->impl->test) {
|
if (!output->impl->test) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = output->impl->test(output, &output->pending);
|
bool success = output->impl->test(output, &pending);
|
||||||
|
|
||||||
if (!had_buffer) {
|
if (!had_buffer) {
|
||||||
output_clear_back_buffer(output);
|
output_clear_back_buffer(output);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wlr_output_test(struct wlr_output *output) {
|
||||||
|
return wlr_output_test_state(output, &output->pending);
|
||||||
|
}
|
||||||
|
|
||||||
bool wlr_output_commit(struct wlr_output *output) {
|
bool wlr_output_commit(struct wlr_output *output) {
|
||||||
if (!output_basic_test(output)) {
|
if (!output_basic_test(output, &output->pending)) {
|
||||||
wlr_log(WLR_ERROR, "Basic output test failed for %s", output->name);
|
wlr_log(WLR_ERROR, "Basic output test failed for %s", output->name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue