From 72d98fd99f350d2592c63ee6e1ac28cd38fbcb93 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Fri, 10 Jun 2022 00:24:54 +0100 Subject: Avoid an unnecessary copy of the image buffer. By pointing Cairo at the mmap-ed file used to create wl_shm buffers, we can eliminate a memcpy() on every draw, providing a decent speedup (especially for large window sizes). This comes at the expense of having to keep track of two Cairo contexts, one for each of our two buffers used for double buffering. Additionally, a single memcpy() is still required for initialisation of the second buffer, so the startup latency isn't affected much. --- src/entry.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/entry.h') diff --git a/src/entry.h b/src/entry.h index 341e340..95cab5d 100644 --- a/src/entry.h +++ b/src/entry.h @@ -22,7 +22,8 @@ struct entry { struct { cairo_surface_t *surface; cairo_t *cr; - } cairo; + } cairo[2]; + int index; wchar_t input[MAX_INPUT_LENGTH]; /* Assume maximum of 4 bytes per wchar_t (for UTF-8) */ @@ -50,7 +51,7 @@ struct entry { } border; }; -void entry_init(struct entry *entry, uint32_t width, uint32_t height, uint32_t scale); +void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, uint32_t height, uint32_t scale); void entry_destroy(struct entry *entry); void entry_update(struct entry *entry); void entry_set_scale(struct entry *entry, uint32_t scale); -- cgit v1.2.3