From 3ad4b5ca3f9f66c71ec521d0d7261228ec7b4631 Mon Sep 17 00:00:00 2001 From: M Stoeckl Date: Wed, 6 Nov 2024 14:31:46 -0500 Subject: Simplify render_menu --- render.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/render.c b/render.c index 63dc4ab..eca498f 100644 --- a/render.c +++ b/render.c @@ -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); } -- cgit v1.2.3