From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/4] GUI: Add a function to draw vertical/horizontal bars
Date: Mon, 27 Jun 2016 07:33:53 +0200 [thread overview]
Message-ID: <20160627053353.GQ20657@pengutronix.de> (raw)
In-Reply-To: <1466746535-17382-2-git-send-email-andrew.smirnov@gmail.com>
On Thu, Jun 23, 2016 at 10:35:32PM -0700, Andrey Smirnov wrote:
> Add a function to draw solid vertical or horizontal bars.
>
> 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);
Not sure if this should be a bug. How about cropping the rectangle to
the screen boundaries instead? The same test should be donw for the
lower right corner.
Sascha
> +
> + 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
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-06-27 5:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 5:35 [PATCH] commands/Kconfig: Fix a typo Andrey Smirnov
2016-06-24 5:35 ` [PATCH v2 1/4] GUI: Add a function to draw vertical/horizontal bars Andrey Smirnov
2016-06-27 5:33 ` Sascha Hauer [this message]
2016-06-28 3:52 ` Andrey Smirnov
2016-06-24 5:35 ` [PATCH v2 2/4] GUI: Add code to draw simple graphics Andrey Smirnov
2016-06-24 5:35 ` [PATCH v2 3/4] GUI: Add fbtest command Andrey Smirnov
2016-06-27 5:57 ` Sascha Hauer
2016-06-28 3:53 ` Andrey Smirnov
2016-06-24 5:35 ` [PATCH v2 4/4] video/edid: Move int_sqrt() out Andrey Smirnov
2016-06-24 9:18 ` Antony Pavlov
2016-06-28 3:55 ` Andrey Smirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160627053353.GQ20657@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox