From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bIVYY-00028x-Mr for barebox@lists.infradead.org; Thu, 30 Jun 2016 06:34:36 +0000 Date: Thu, 30 Jun 2016 08:34:11 +0200 From: Sascha Hauer Message-ID: <20160630063411.GV20657@pengutronix.de> References: <1467088079-476-1-git-send-email-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1467088079-476-1-git-send-email-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH v3 1/4] GUI: Add a function to draw vertical/horizontal bars To: Andrey Smirnov Cc: barebox@lists.infradead.org On Mon, Jun 27, 2016 at 09:27:56PM -0700, Andrey Smirnov wrote: > Add a function to draw solid vertical or horizontal bars. > > Signed-off-by: Andrey Smirnov > --- > > Changes since v2: > > - Negative coordinates now mean edge of the screen instead of > being a bug. Applied, thanks Sascha > > include/gui/graphic_utils.h | 3 +++ > lib/gui/graphic_utils.c | 29 +++++++++++++++++++++++++++++ > 2 files changed, 32 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..d3f5cce 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; > + } > + } > +} > -- > 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