diff options
author | Phil Jones <philj56@gmail.com> | 2022-06-09 17:34:13 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-06-09 17:34:13 +0100 |
commit | 68132ab8fb66a0462b77304a5bbc9313f3dcb7bc (patch) | |
tree | 25c93385e204064ac54c221eed3c130f7471d201 | |
parent | 05861ed6737f6b7b139895c4eeb26791edc333b4 (diff) |
Speed up Cairo initialisation.
Rather than using cairo_paint() and re-drawing the middle of the window
multiple times, use cairo_rectangle() + cairo_stroke(). This especially
helps for large (e.g. fullscreen) windows.
-rw-r--r-- | src/entry.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/entry.c b/src/entry.c index eb58695..464c225 100644 --- a/src/entry.c +++ b/src/entry.c @@ -28,7 +28,10 @@ void entry_init(struct entry *entry, uint32_t width, uint32_t height, uint32_t s /* Draw the outer outline */ struct color color = entry->border.outline_color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); - cairo_paint(cr); + cairo_set_line_width(cr, 2 * entry->border.outline_width); + cairo_rectangle(cr, 0, 0, width, height); + cairo_stroke(cr); + /* Move and clip following draws to be within this outline */ cairo_translate( @@ -43,7 +46,9 @@ void entry_init(struct entry *entry, uint32_t width, uint32_t height, uint32_t s /* Draw the border */ color = entry->border.color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); - cairo_paint(cr); + cairo_set_line_width(cr, 2 * entry->border.width); + cairo_rectangle(cr, 0, 0, width, height); + cairo_stroke(cr); /* Move and clip following draws to be within the border */ cairo_translate(cr, entry->border.width, entry->border.width); @@ -55,7 +60,9 @@ void entry_init(struct entry *entry, uint32_t width, uint32_t height, uint32_t s /* Draw the inner outline */ color = entry->border.outline_color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); - cairo_paint(cr); + cairo_set_line_width(cr, 2 * entry->border.outline_width); + cairo_rectangle(cr, 0, 0, width, height); + cairo_stroke(cr); /* Move and clip following draws to be within this outline */ cairo_translate( |