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
drw.h
View File

@@ -10,11 +10,12 @@ struct drw {
struct drwbuf {
uint32_t size;
struct wl_buffer *buf;
cairo_region_t *damage;
cairo_region_t *damage, *backport_damage;
cairo_surface_t *cairo_surf;
cairo_t *cairo;
PangoLayout *layout;
unsigned char *pool_data;
bool released;
};
struct drwsurf {
uint32_t width, height;
@@ -34,6 +35,7 @@ struct kbd;
void drwsurf_damage(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s);
void drwsurf_attach(struct drwsurf *ds);
void drwsurf_flip(struct drwsurf *ds);
typedef union {