From: Arkadiy Illarionov Date: Sun, 24 Mar 2024 10:22:30 +0000 (+0300) Subject: Deduplicate rt_border_draw X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=b036a1603468f6a9dd818bfbb7598f62fc0b0bf0 Deduplicate rt_border_draw --- 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);