diff options
author | Phil Jones <philj56@gmail.com> | 2022-06-25 14:03:27 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-06-25 14:03:27 +0100 |
commit | a6c20eb3713fc5e4b2c8f4075762b899bf9c1857 (patch) | |
tree | 3917d4528964fc8a24a518cc0401efe1e2e47508 /src/entry.c | |
parent | eacb7c80619dd0c2d8bf601215374f64779373b6 (diff) |
Don't double-draw background colour on first draw.
This improves start-up performance for large windows.
Diffstat (limited to 'src/entry.c')
-rw-r--r-- | src/entry.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/entry.c b/src/entry.c index 133a706..d387f2c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -132,6 +132,20 @@ void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, u } /* + * Perform an initial render of the text. + * This is done here rather than by calling entry_update to avoid the + * unnecessary cairo_paint() of the background for the first frame, + * which can be slow for large (e.g. fullscreen) windows. + */ + log_debug("Initial text render.\n"); + if (entry->use_pango) { + entry_backend_pango_update(entry); + } else { + entry_backend_harfbuzz_update(entry); + } + entry->index = !entry->index; + + /* * To avoid performing all this drawing twice, we take a small * shortcut. After performing all the drawing as normal on our first * Cairo context, we can copy over just the important state (the @@ -169,7 +183,6 @@ void entry_update(struct entry *entry) { log_debug("Start rendering entry.\n"); cairo_t *cr = entry->cairo[entry->index].cr; - cairo_save(cr); /* Clear the image. */ struct color color = entry->background_color; @@ -180,16 +193,12 @@ void entry_update(struct entry *entry) cairo_restore(cr); /* Draw our text. */ - color = entry->foreground_color; - cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); - if (entry->use_pango) { entry_backend_pango_update(entry); } else { entry_backend_harfbuzz_update(entry); } - cairo_restore(cr); log_debug("Finish rendering entry.\n"); entry->index = !entry->index; |