diff options
author | M Stoeckl <code@mstoeckl.com> | 2024-11-06 14:31:46 -0500 |
---|---|---|
committer | M Stoeckl <code@mstoeckl.com> | 2024-11-08 15:28:11 -0500 |
commit | 3ad4b5ca3f9f66c71ec521d0d7261228ec7b4631 (patch) | |
tree | 8eeb87d3e9c96e0353314081d70182281978eba4 | |
parent | 48ec172b4bd51da0736c24d84c72b574e4107b31 (diff) | |
download | wmenu-3ad4b5ca3f9f66c71ec521d0d7261228ec7b4631.tar.gz |
Simplify render_menu
-rw-r--r-- | render.c | 31 |
1 files changed, 6 insertions, 25 deletions
@@ -189,41 +189,22 @@ static void render_to_cairo(struct menu *menu, cairo_t *cairo) { void render_menu(struct menu *menu) { struct wl_context *context = menu->context; - cairo_surface_t *recorder = cairo_recording_surface_create( - CAIRO_CONTENT_COLOR_ALPHA, NULL); - cairo_t *cairo = cairo_create(recorder); - cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); - cairo_font_options_t *fo = cairo_font_options_create(); - cairo_set_font_options(cairo, fo); - cairo_font_options_destroy(fo); - cairo_save(cairo); - cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); - cairo_paint(cairo); - cairo_restore(cairo); - - render_to_cairo(menu, cairo); - int scale = context_get_scale(context); struct pool_buffer *buffer = context_get_next_buffer(context, scale); if (!buffer) { - goto cleanup; + return; } cairo_t *shm = buffer->cairo; - cairo_save(shm); - cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR); - cairo_paint(shm); - cairo_restore(shm); - cairo_set_source_surface(shm, recorder, 0, 0); - cairo_paint(shm); + cairo_set_antialias(shm, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_set_font_options(shm, fo); + cairo_font_options_destroy(fo); + render_to_cairo(menu, shm); struct wl_surface *surface = context_get_surface(context); wl_surface_set_buffer_scale(surface, scale); wl_surface_attach(surface, buffer->buffer, 0, 0); wl_surface_damage(surface, 0, 0, menu->width, menu->height); wl_surface_commit(surface); - -cleanup: - cairo_destroy(cairo); - cairo_surface_destroy(recorder); } |