From b036a1603468f6a9dd818bfbb7598f62fc0b0bf0 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Sun, 24 Mar 2024 13:22:30 +0300 Subject: [PATCH] Deduplicate rt_border_draw --- src/renderer-tiles.cc | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/renderer-tiles.cc b/src/renderer-tiles.cc index 8c1a1c22..65d27bff 100644 --- a/src/renderer-tiles.cc +++ b/src/renderer-tiles.cc @@ -213,6 +213,14 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) cr = cairo_create(rt->surface); + auto draw = [rt, pr, cr](gint x, gint y, gint w, gint h) + { + cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); + cairo_rectangle(cr, x + rt->stereo_off_x, y + rt->stereo_off_y, w, h); + cairo_fill(cr); + rt_overlay_draw(rt, x, y, w, h, nullptr); + }; + if (!pr->pixbuf && !pr->source_tiles_enabled) { if (pr_clip_region(x, y, w, h, @@ -220,10 +228,7 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->viewport_width, pr->viewport_height, &rx, &ry, &rw, &rh)) { - cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); - cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); - cairo_fill(cr); - rt_overlay_draw(rt, rx, ry, rw, rh, nullptr); + draw(rx, ry, rw, rh); } cairo_destroy(cr); return; @@ -237,10 +242,7 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->x_offset, pr->viewport_height, &rx, &ry, &rw, &rh)) { - cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); - cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); - cairo_fill(cr); - rt_overlay_draw(rt, rx, ry, rw, rh, nullptr); + draw(rx, ry, rw, rh); } if (pr->viewport_width - pr->vis_width - pr->x_offset > 0 && pr_clip_region(x, y, w, h, @@ -248,10 +250,7 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height, &rx, &ry, &rw, &rh)) { - cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); - cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); - cairo_fill(cr); - rt_overlay_draw(rt, rx, ry, rw, rh, nullptr); + draw(rx, ry, rw, rh); } } if (pr->vis_height < pr->viewport_height) @@ -262,10 +261,7 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->vis_width, pr->y_offset, &rx, &ry, &rw, &rh)) { - cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); - cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); - cairo_fill(cr); - rt_overlay_draw(rt, rx, ry, rw, rh, nullptr); + draw(rx, ry, rw, rh); } if (pr->viewport_height - pr->vis_height - pr->y_offset > 0 && pr_clip_region(x, y, w, h, @@ -273,10 +269,7 @@ static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h) pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset, &rx, &ry, &rw, &rh)) { - cairo_set_source_rgb(cr, static_cast(pr->color.red), static_cast(pr->color.green), static_cast(pr->color.blue)); - cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh); - cairo_fill(cr); - rt_overlay_draw(rt, rx, ry, rw, rh, nullptr); + draw(rx, ry, rw, rh); } } cairo_destroy(cr); -- 2.20.1