mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/6] graphic_utils: pass image so we can draw only the visible part of the image
Date: Wed, 26 Sep 2012 11:59:01 +0200	[thread overview]
Message-ID: <1348653544-27095-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1348653544-27095-1-git-send-email-plagnioj@jcrosoft.com>

This is needed if the image is bigger than the screen.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/gui/graphic_utils.h |    5 ++++-
 lib/gui/graphic_utils.c     |    7 ++++---
 lib/gui/png.c               |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/gui/graphic_utils.h b/include/gui/graphic_utils.h
index 9909b6c..4690e51 100644
--- a/include/gui/graphic_utils.h
+++ b/include/gui/graphic_utils.h
@@ -7,7 +7,10 @@
 #ifndef __GRAPHIC_UTILS_H__
 #define __GRAPHIC_UTILS_H__
 
-void rgba_blend(struct fb_info *info, void *image, void* dest, int height,
+#include <fb.h>
+#include <gui/image.h>
+
+void rgba_blend(struct fb_info *info, struct image *img, void* dest, int height,
 	int width, int startx, int starty, bool is_rgba);
 void set_pixel(struct fb_info *info, void *adr, u32 px);
 void set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b);
diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index bf42103..06f811c 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -157,13 +157,14 @@ void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a)
 	set_pixel(info, adr, px);
 }
 
-void rgba_blend(struct fb_info *info, void *image, void* buf, int height,
+void rgba_blend(struct fb_info *info, struct image *img, void* buf, int height,
 	int width, int startx, int starty, bool is_rgba)
 {
 	unsigned char *adr;
 	int x, y;
 	int xres;
 	int img_byte_per_pixel = 3;
+	void *image;
 
 	if (is_rgba)
 		img_byte_per_pixel++;
@@ -173,11 +174,11 @@ void rgba_blend(struct fb_info *info, void *image, void* buf, int height,
 	for (y = 0; y < height; y++) {
 		adr = buf + ((y + starty) * xres + startx) *
 				(info->bits_per_pixel >> 3);
+		image = img->data + (y * img->width *img_byte_per_pixel);
 
 		for (x = 0; x < width; x++) {
-			char *pixel;
+			uint8_t *pixel = image;
 
-			pixel = image;
 			if (is_rgba)
 				set_rgba_pixel(info, adr, pixel[0], pixel[1],
 						pixel[2], pixel[3]);
diff --git a/lib/gui/png.c b/lib/gui/png.c
index 5d77c8c..1e9efd5 100644
--- a/lib/gui/png.c
+++ b/lib/gui/png.c
@@ -63,7 +63,7 @@ static int png_renderer(struct fb_info *info, struct image *img, void* fb,
 
 	buf = offscreenbuf ? offscreenbuf : fb;
 
-	rgba_blend(info, img->data, buf, height, width, startx, starty, true);
+	rgba_blend(info, img, buf, height, width, startx, starty, true);
 
 	if (offscreenbuf) {
 		int fbsize;
-- 
1.7.10.4


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

  parent reply	other threads:[~2012-09-26 10:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  9:56 [PATCH 0/6] gui: factorise code Jean-Christophe PLAGNIOL-VILLARD
2012-09-26  9:58 ` [PATCH 1/6] image_renderer: fix size type Jean-Christophe PLAGNIOL-VILLARD
2012-09-26  9:59   ` [PATCH 2/6] gui: move gui file to include/gui and lib/gui Jean-Christophe PLAGNIOL-VILLARD
2012-09-26  9:59   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-26  9:59   ` [PATCH 4/6] gui: introduce screen and surface to factorize and simplify code Jean-Christophe PLAGNIOL-VILLARD
2012-09-26  9:59   ` [PATCH 5/6] graphic_utils: introduce common fb_open/close Jean-Christophe PLAGNIOL-VILLARD
2012-09-26  9:59   ` [PATCH 6/6] gui: blit the surface on demand Jean-Christophe PLAGNIOL-VILLARD
2012-09-30 13:47 ` [PATCH 0/6] gui: factorise code Jean-Christophe PLAGNIOL-VILLARD
2012-10-01 18:12   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02  8:54     ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-02  9:37       ` Eric Bénard
2012-10-02 13:38       ` Sascha Hauer
2012-10-04 17:26 ` Sascha Hauer

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=1348653544-27095-3-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.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