output: pass wlr_output_state to output_pending_resolution

This commit is contained in:
Simon Ser 2022-05-24 19:29:02 +02:00
parent 25dd3cc0cd
commit 927661d246
3 changed files with 16 additions and 14 deletions

View file

@ -4,8 +4,8 @@
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
void output_pending_resolution(struct wlr_output *output, int *width, void output_pending_resolution(struct wlr_output *output,
int *height); const struct wlr_output_state *state, int *width, int *height);
struct wlr_drm_format *output_pick_format(struct wlr_output *output, struct wlr_drm_format *output_pick_format(struct wlr_output *output,
const struct wlr_drm_format_set *display_formats, uint32_t format); const struct wlr_drm_format_set *display_formats, uint32_t format);

View file

@ -535,17 +535,17 @@ static void output_state_clear(struct wlr_output_state *state) {
state->committed = 0; state->committed = 0;
} }
void output_pending_resolution(struct wlr_output *output, int *width, void output_pending_resolution(struct wlr_output *output,
int *height) { const struct wlr_output_state *state, int *width, int *height) {
if (output->pending.committed & WLR_OUTPUT_STATE_MODE) { if (state->committed & WLR_OUTPUT_STATE_MODE) {
switch (output->pending.mode_type) { switch (state->mode_type) {
case WLR_OUTPUT_STATE_MODE_FIXED: case WLR_OUTPUT_STATE_MODE_FIXED:
*width = output->pending.mode->width; *width = state->mode->width;
*height = output->pending.mode->height; *height = state->mode->height;
return; return;
case WLR_OUTPUT_STATE_MODE_CUSTOM: case WLR_OUTPUT_STATE_MODE_CUSTOM:
*width = output->pending.custom_mode.width; *width = state->custom_mode.width;
*height = output->pending.custom_mode.height; *height = state->custom_mode.height;
return; return;
} }
abort(); abort();
@ -583,7 +583,8 @@ 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, &pending_width, &pending_height); output_pending_resolution(output, &output->pending,
&pending_width, &pending_height);
if (output->pending.buffer->width != pending_width || if (output->pending.buffer->width != pending_width ||
output->pending.buffer->height != pending_height) { output->pending.buffer->height != pending_height) {
wlr_log(WLR_DEBUG, "Direct scan-out buffer size mismatch"); wlr_log(WLR_DEBUG, "Direct scan-out buffer size mismatch");
@ -616,7 +617,8 @@ static bool output_basic_test(struct wlr_output *output) {
if (enabled && (output->pending.committed & (WLR_OUTPUT_STATE_ENABLED | if (enabled && (output->pending.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, &pending_width, &pending_height); output_pending_resolution(output, &output->pending,
&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");
return false; return false;

View file

@ -46,7 +46,7 @@ bool wlr_output_init_render(struct wlr_output *output,
static bool output_create_swapchain(struct wlr_output *output, static bool output_create_swapchain(struct wlr_output *output,
bool allow_modifiers) { bool allow_modifiers) {
int width, height; int width, height;
output_pending_resolution(output, &width, &height); output_pending_resolution(output, &output->pending, &width, &height);
struct wlr_allocator *allocator = output->allocator; struct wlr_allocator *allocator = output->allocator;
assert(allocator != NULL); assert(allocator != NULL);
@ -154,7 +154,7 @@ static bool output_attach_empty_buffer(struct wlr_output *output) {
} }
int width, height; int width, height;
output_pending_resolution(output, &width, &height); output_pending_resolution(output, &output->pending, &width, &height);
struct wlr_renderer *renderer = output->renderer; struct wlr_renderer *renderer = output->renderer;
wlr_renderer_begin(renderer, width, height); wlr_renderer_begin(renderer, width, height);