summaryrefslogtreecommitdiffstats
path: root/lib/gui
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2016-06-27 21:27:56 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2016-06-30 08:33:53 +0200
commit0cd1a5192400ee4b700d33418f08d6eb7fe4dfdf (patch)
tree262e1f14debc7d99fded70f5fee0db1bd53b0c72 /lib/gui
parentd7fc1c18e785277f24a69e2aaa1a2c6e80e2b0cf (diff)
downloadbarebox-0cd1a5192400ee4b700d33418f08d6eb7fe4dfdf.tar.gz
barebox-0cd1a5192400ee4b700d33418f08d6eb7fe4dfdf.tar.xz
GUI: Add a function to draw vertical/horizontal bars
Add a function to draw solid vertical or horizontal bars. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/graphic_utils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 2fe9fa358a..d3f5cce4b7 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -336,3 +336,32 @@ void gu_screen_blit(struct screen *sc)
if (info->screen_base_shadow)
memcpy(info->screen_base, info->screen_base_shadow, sc->fbsize);
}
+
+void gu_fill_rectangle(struct screen *sc,
+ int x1, int y1, int x2, int y2,
+ u8 r, u8 g, u8 b, u8 a)
+{
+ int y;
+ void *buf = gui_screen_render_buffer(sc);
+
+ x1 = max(0, x1);
+ y1 = max(0, y1);
+
+ x2 = (x2 < 0) ? sc->info->xres - 1 : x2;
+ y2 = (y2 < 0) ? sc->info->yres - 1 : y2;
+
+ if (x2 < x1)
+ swap(x1, x2);
+ if (y2 < y1)
+ swap(y1, y2);
+
+ for(y = y1; y <= y2; y++) {
+ int x;
+ unsigned char *pixel = buf + y * sc->info->line_length +
+ x1 * (sc->info->bits_per_pixel / 8);
+ for(x = x1; x <= x2; x++) {
+ gu_set_rgba_pixel(sc->info, pixel, r, g, b, a);
+ pixel += sc->info->bits_per_pixel / 8;
+ }
+ }
+}