mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
Support direct scanout with src crop and dst boxes
Enable scene-tree direct scanout of a single buffer with various options for scaling and source crop. This is intended to support direct scanout for fullscreen video with/without scaling, letterboxing/pillarboxing (e.g. 4:3 content on a 16:9 display), and source crop (e.g. when 1920x1088 planes are used for 1920x1080 video). This works by explicitly specifying the source crop and destination box for the primary buffer in the output state. DRM atomic and libliftoff backends will turn this into a crop and scale of the plane (assuming the hardware supports that). For the Wayland/X11/DRM-legacy backends I just reject this so scanout will be disabled. The previous behaviour is preserved if buffer_src_box and buffer_dst_box are unset: the buffer is displayed at native size at the top-left of the output with no crop. The change to `struct wlr_output_state` makes this a binary breaking change (but this works transparently for scene-tree compositors like labwc after a recompile).
This commit is contained in:
parent
47fb00f66d
commit
c87ab6465d
10 changed files with 230 additions and 59 deletions
|
|
@ -1831,6 +1831,7 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
|
|||
return false;
|
||||
}
|
||||
|
||||
// The native size of the buffer after any transform is applied
|
||||
int default_width = buffer->buffer->width;
|
||||
int default_height = buffer->buffer->height;
|
||||
wlr_output_transform_coords(buffer->transform, &default_width, &default_height);
|
||||
|
|
@ -1839,11 +1840,6 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
|
|||
.height = default_height,
|
||||
};
|
||||
|
||||
if (!wlr_fbox_empty(&buffer->src_box) &&
|
||||
!wlr_fbox_equal(&buffer->src_box, &default_box)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buffer->transform != data->transform) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1851,10 +1847,6 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
|
|||
struct wlr_box node_box = { .x = entry->x, .y = entry->y };
|
||||
scene_node_get_size(node, &node_box.width, &node_box.height);
|
||||
|
||||
if (!wlr_box_equal(&data->logical, &node_box)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buffer->primary_output == scene_output) {
|
||||
struct wlr_linux_dmabuf_feedback_v1_init_options options = {
|
||||
.main_renderer = scene_output->output->renderer,
|
||||
|
|
@ -1871,6 +1863,12 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!wlr_fbox_empty(&buffer->src_box) &&
|
||||
!wlr_fbox_equal(&buffer->src_box, &default_box)) {
|
||||
pending.buffer_src_box = buffer->src_box;
|
||||
}
|
||||
pending.buffer_dst_box = node_box;
|
||||
|
||||
wlr_output_state_set_buffer(&pending, buffer->buffer);
|
||||
if (buffer->wait_timeline != NULL) {
|
||||
wlr_output_state_set_wait_timeline(&pending, buffer->wait_timeline, buffer->wait_point);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue