Optimize the backporting condition

At the moment we flip the two buffers, and we backport the damaged
area on every frame callback. We completely ignore the compositor
sent event buffer->release. This event means that the compositor
finished reading the buffer pixels, and will never read them again. So
we can keep using the same buffer instead of fliping, if we receive the
event before asking for a new frame callback.

The change is not complicated, but we have to distinguish
drwsurf_attach, and drwsurf_flip. We try to flip before trying to
draw anything. And if the buffer has already been released, we don't
flip.

We also have to track the backport_damage separately than the buffer
current damage.

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
Willow Barraco
2025-04-17 17:58:38 +02:00
committed by Maarten van Gompel
parent 686b27a72d
commit 55b88bc14f
3 changed files with 39 additions and 11 deletions

4
main.c
View File

@@ -517,7 +517,7 @@ xdg_popup_surface_configure(void *data, struct xdg_surface *xdg_surface,
{
xdg_surface_ack_configure(xdg_surface, serial);
popup_xdg_surface_configured = true;
drwsurf_flip(&popup_draw_surf);
drwsurf_attach(&popup_draw_surf);
}
static const struct xdg_surface_listener xdg_popup_surface_listener = {
@@ -664,7 +664,7 @@ layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
zwlr_layer_surface_v1_ack_configure(surface, serial);
kbd_resize(&keyboard, layouts, NumLayouts);
drwsurf_flip(&draw_surf);
drwsurf_attach(&draw_surf);
} else {
zwlr_layer_surface_v1_ack_configure(surface, serial);
}