scene: Apply output offset for direct scanout

When setting the primary buffer location for direct scanout, subtract
the offset of that output to put the buffer location in output-relative
coordinates.

Fixes #3910
master
David Turner 4 weeks ago committed by itycodes
parent 421e92be59
commit 044f75f26f

@ -96,11 +96,13 @@ struct wlr_output_state {
struct wlr_buffer *buffer; struct wlr_buffer *buffer;
// Source crop for the buffer. If all zeros then no crop is applied. // Source crop for the buffer. If all zeros then no crop is applied.
// As usual with source crop, this is in buffer coordinates.
// Double-buffered by WLR_OUTPUT_STATE_BUFFER along with `buffer`. // Double-buffered by WLR_OUTPUT_STATE_BUFFER along with `buffer`.
struct wlr_fbox buffer_src_box; struct wlr_fbox buffer_src_box;
// Destination rect to scale the buffer to (after source crop). If width // Destination rect to scale the buffer to (after source crop). If width
// and height are zero then the buffer is displayed at native size. // and height are zero then the buffer is displayed at native size. The
// Double-buffered by WLR_OUTPUT_STATE_BUFFER along with `buffer`. // offset is relative to the origin of this output. Double-buffered by
// WLR_OUTPUT_STATE_BUFFER along with `buffer`.
struct wlr_box buffer_dst_box; struct wlr_box buffer_dst_box;
/* Request a tearing page-flip. When enabled, this may cause the output to /* Request a tearing page-flip. When enabled, this may cause the output to

@ -1844,9 +1844,6 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
return false; return false;
} }
struct wlr_box node_box = { .x = entry->x, .y = entry->y };
scene_node_get_size(node, &node_box.width, &node_box.height);
if (buffer->primary_output == scene_output) { if (buffer->primary_output == scene_output) {
struct wlr_linux_dmabuf_feedback_v1_init_options options = { struct wlr_linux_dmabuf_feedback_v1_init_options options = {
.main_renderer = scene_output->output->renderer, .main_renderer = scene_output->output->renderer,
@ -1867,7 +1864,11 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
!wlr_fbox_equal(&buffer->src_box, &default_box)) { !wlr_fbox_equal(&buffer->src_box, &default_box)) {
pending.buffer_src_box = buffer->src_box; pending.buffer_src_box = buffer->src_box;
} }
pending.buffer_dst_box = node_box;
// Translate the location from scene coordinates to output coordinates
pending.buffer_dst_box.x = entry->x - scene_output->x;
pending.buffer_dst_box.y = entry->y - scene_output->y;
scene_node_get_size(node, &pending.buffer_dst_box.width, &pending.buffer_dst_box.height);
wlr_output_state_set_buffer(&pending, buffer->buffer); wlr_output_state_set_buffer(&pending, buffer->buffer);
if (buffer->wait_timeline != NULL) { if (buffer->wait_timeline != NULL) {

Loading…
Cancel
Save