mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-08-29 07:12:02 +02:00
Implement double buffering
Until this point we was using one single buffer. This cause tearing when they are scanned while we are drawing. This refactorize our buffer and damage tracking to use two buffers. One buffer, the back_buffer, is our dirty area. The other one, the display_buffer, is left untouched. Now we only flip buffers on adequate moments, indicated by the compositor sending the frame callback event. We can draw multiple time between those events, and we store all damaged areas. We only schedule frame callbacks when needed, after storing a new damaged area. Once flipped, we backport the damaged area from the new display_buffer to the new back_buffer. Which generally means, for wvkbd, one rectangle for each one of the surf and popup_surf. Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
committed by
Maarten van Gompel
parent
646d47d072
commit
686b27a72d
6
main.c
6
main.c
@@ -62,6 +62,7 @@ static int wl_outputs_size;
|
||||
|
||||
/* drawing */
|
||||
static struct drw draw_ctx;
|
||||
static struct drwbuf draw_surf_back_buffer, draw_surf_display_buffer, popup_draw_surf_back_buffer, popup_draw_surf_display_buffer;
|
||||
static struct drwsurf draw_surf, popup_draw_surf;
|
||||
|
||||
/* layer surface parameters */
|
||||
@@ -332,7 +333,6 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
}
|
||||
|
||||
kbd_next_layer(&keyboard, NULL, (value >= 0));
|
||||
drwsurf_flip(keyboard.surf);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1018,7 +1018,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
draw_surf.ctx = &draw_ctx;
|
||||
draw_surf.back_buffer = &draw_surf_back_buffer;
|
||||
draw_surf.display_buffer = &draw_surf_display_buffer;
|
||||
popup_draw_surf.ctx = &draw_ctx;
|
||||
popup_draw_surf.back_buffer = &popup_draw_surf_back_buffer;
|
||||
popup_draw_surf.display_buffer = &popup_draw_surf_display_buffer;
|
||||
keyboard.surf = &draw_surf;
|
||||
keyboard.popup_surf = &popup_draw_surf;
|
||||
|
||||
|
Reference in New Issue
Block a user