diff options
author | Phil Jones <philj56@gmail.com> | 2022-06-10 00:44:42 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-06-10 00:44:42 +0100 |
commit | c980335b5858746772cb7b9588ca709c5d2dfa23 (patch) | |
tree | ba120d14c8aa760062e36392bfccafe63861724e /src/main.c | |
parent | 72d98fd99f350d2592c63ee6e1ac28cd38fbcb93 (diff) |
Delay second buffer initialisation.
We don't actually need to initialise our second Cairo context / surface
until after the first one has been painted to the screen. This commit
therefore delays this initialisation (or at least the expensive memcpy),
granting a significant reduction in startup time.
The downside is that main() and entry_init() are now tied together
somewhat, but hopefully the comments help.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -819,6 +819,20 @@ int main(int argc, char *argv[]) &tofi.window.entry.background_color, &tofi.window.entry.image); + /* + * entry_init() left the second of the two buffers we use for + * double-buffering unpainted to lower startup time, as described + * there. Here, we flush our first, finished buffer to the screen, then + * copy over the image to the second buffer before we need to use it in + * the main loop. This ensures we paint to the screen as quickly as + * possible after startup. + */ + wl_display_roundtrip(tofi.wl_display); + memcpy( + cairo_image_surface_get_data(tofi.window.entry.cairo[1].surface), + cairo_image_surface_get_data(tofi.window.entry.cairo[0].surface), + tofi.window.entry.image.width * tofi.window.entry.image.height * sizeof(uint32_t) + ); /* We've just rendered, so we don't need to do it again right now. */ tofi.window.surface.redraw = false; |