mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-21 06:46:46 -04:00
backend/wayland: extract layer viewport check to a helper
Improves readability, and we'll need to use it from another function.
This commit is contained in:
parent
26f9510e07
commit
09c7af0bd4
1 changed files with 18 additions and 10 deletions
|
|
@ -247,6 +247,23 @@ static struct wlr_wl_buffer *get_or_create_wl_buffer(struct wlr_wl_backend *wl,
|
||||||
return create_wl_buffer(wl, wlr_buffer);
|
return create_wl_buffer(wl, wlr_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool layer_needs_viewport(struct wlr_output_layer_state *layer_state) {
|
||||||
|
if (layer_state->buffer == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (layer_state->dst_box.width != layer_state->buffer->width ||
|
||||||
|
layer_state->dst_box.height != layer_state->buffer->height) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (layer_state->src_box.x != 0 ||
|
||||||
|
layer_state->src_box.y != 0 ||
|
||||||
|
layer_state->src_box.width != layer_state->dst_box.width ||
|
||||||
|
layer_state->src_box.height != layer_state->dst_box.height) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool test_layer(struct wlr_wl_output *output, struct wlr_output_layer_state *layer_state) {
|
static bool test_layer(struct wlr_wl_output *output, struct wlr_output_layer_state *layer_state) {
|
||||||
if (layer_state->buffer == NULL) {
|
if (layer_state->buffer == NULL) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -265,16 +282,7 @@ static bool test_layer(struct wlr_wl_output *output, struct wlr_output_layer_sta
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need viewporter for scaling and cropping
|
// We need viewporter for scaling and cropping
|
||||||
bool needs_viewport = width != layer_state->buffer->width ||
|
if (output->backend->viewporter == NULL && layer_needs_viewport(layer_state)) {
|
||||||
height != layer_state->buffer->height;
|
|
||||||
if (!wlr_fbox_empty(&layer_state->src_box)) {
|
|
||||||
needs_viewport = needs_viewport ||
|
|
||||||
layer_state->src_box.x != 0 ||
|
|
||||||
layer_state->src_box.y != 0 ||
|
|
||||||
layer_state->src_box.width != width ||
|
|
||||||
layer_state->src_box.height != height;
|
|
||||||
}
|
|
||||||
if (output->backend->viewporter == NULL && needs_viewport) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue