diff options
author | Phil Jones <philj56@gmail.com> | 2022-08-09 12:31:50 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-08-09 12:35:58 +0100 |
commit | 6998cf1f0d6692255e09a46b5d59db08a7fd3d49 (patch) | |
tree | 05f2b6cd60d74e92145c03f60008d7d4d40540c0 /src/entry_backend/harfbuzz.c | |
parent | 81025108db445ab31d7506a88e8919a5eebcadcb (diff) |
Improve performance for some themes.
When not highlighting matches or drawing a selection background box, we
can skip a bunch of slow code to improve performance.
Diffstat (limited to 'src/entry_backend/harfbuzz.c')
-rw-r--r-- | src/entry_backend/harfbuzz.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c index 9868578..b90936f 100644 --- a/src/entry_backend/harfbuzz.c +++ b/src/entry_backend/harfbuzz.c @@ -270,8 +270,21 @@ void entry_backend_harfbuzz_update(struct entry *entry) } const char *result = entry->results.buf[index].string; - /* If this isn't the selected result, just print as normal. */ - if (i != entry->selection) { + /* + * If this isn't the selected result, or it is but we're not + * doing any fancy match-highlighting or backgrounds, just + * print as normal. + */ + if (i != entry->selection + || (entry->selection_highlight_color.a == 0 + && entry->selection_background_color.a == 0)) { + if (i == entry->selection) { + color = entry->selection_foreground_color; + } else { + color = entry->foreground_color; + } + cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); + hb_buffer_clear_contents(buffer); setup_hb_buffer(buffer); hb_buffer_add_utf8(buffer, result, -1, 0, -1); @@ -444,8 +457,6 @@ void entry_backend_harfbuzz_update(struct entry *entry) cairo_fill(cr); cairo_restore(cr); cairo_paint(cr); - color = entry->foreground_color; - cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); } } entry->num_results_drawn = i; |