mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] GUI: Add a function to draw solid rectangles
@ 2016-06-22  4:39 Andrey Smirnov
  2016-06-22  4:39 ` [PATCH 2/3] GUI: Add code to draw simple graphics Andrey Smirnov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Andrey Smirnov @ 2016-06-22  4:39 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add a routine implementing midpoint circle algorithm

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/gui/graphic_utils.h |  3 +++
 lib/gui/graphic_utils.c     | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h
index 231b3a9..279fdf9 100644
--- a/include/gui/graphic_utils.h
+++ b/include/gui/graphic_utils.h
@@ -28,4 +28,7 @@ void gu_invert_area(struct fb_info *info, void *buf, int startx, int starty, int
 void gu_screen_blit_area(struct screen *sc, int startx, int starty, int width,
 		int height);
 
+void gu_fill_rectangle(struct screen *sc,
+		       int x1, int y1, int x2, int y2,
+		       u8 r, u8 g, u8 b, u8 a);
 #endif /* __GRAPHIC_UTILS_H__ */
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 2fe9fa3..c6c4373 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -336,3 +336,29 @@ 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);
+
+	BUG_ON(x1 < 0 || y1 < 0 ||
+	       x2 < 0 || y2 < 0);
+
+	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;
+		}
+	}
+}
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-06-24  5:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22  4:39 [PATCH 1/3] GUI: Add a function to draw solid rectangles Andrey Smirnov
2016-06-22  4:39 ` [PATCH 2/3] GUI: Add code to draw simple graphics Andrey Smirnov
2016-06-23  7:30   ` Holger Schurig
2016-06-24  4:57     ` Andrey Smirnov
2016-06-22  4:39 ` [PATCH 3/3] GUI: Add fbtest command Andrey Smirnov
2016-06-22 10:49   ` Antony Pavlov
2016-06-24  4:50     ` Andrey Smirnov
2016-06-22 10:57   ` Antony Pavlov
2016-06-24  3:18     ` Andrey Smirnov
2016-06-23  6:22   ` Sascha Hauer
2016-06-24  3:21     ` Andrey Smirnov
2016-06-23  7:31   ` Holger Schurig
2016-06-23  9:28     ` Sascha Hauer
2016-06-24  4:49     ` Andrey Smirnov
2016-06-23  7:28 ` [PATCH 1/3] GUI: Add a function to draw solid rectangles Holger Schurig
2016-06-24  5:00   ` Andrey Smirnov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox