gui: factorise code
Subsystems (2)
cover gui: factorise code
Hi,
The following changes since commit 05b9f24e3ea4071f76ffc4157526946a1c2b1b96:
Merge branch 'for-next/sandbox' into next (2012-09-25 10:20:03 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git tags/gui_fbcon_prepare
for you to fetch changes up to 267da5665afa3be979cbab2c2787128f4b763f33:
gui: blit the surface on demand (2012-09-26 16:51:11 +0800)
----------------------------------------------------------------
gui: factorise code
This patch series move the gui framework to lib/gui and include/gui and commands to there own menu
This also factorise code to handle screen and framebuffer
This is a preparation for the framebuffer console support and other gui
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (6):
image_renderer: fix size type
gui: move gui file to include/gui and lib/gui
graphic_utils: pass image so we can draw only the visible part of the image
gui: introduce screen and surface to factorize and simplify code
graphic_utils: introduce common fb_open/close
gui: blit the surface on demand
commands/Kconfig | 23 +++++++++++++++--------
commands/splash.c | 76 +++++++++++++++++++++++-----------------------------------------------------
drivers/video/sdl.c | 2 +-
include/{ => gui}/graphic_utils.h | 9 ++++++++-
include/gui/gui.h | 38 ++++++++++++++++++++++++++++++++++++++
include/gui/image.h | 20 ++++++++++++++++++++
include/{ => gui}/image_renderer.h | 25 +++++++------------------
lib/Kconfig | 36 +-----------------------------------
lib/Makefile | 6 +-----
lib/gui/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++
lib/gui/Makefile | 5 +++++
lib/{ => gui}/bmp.c | 54 +++++++++++++++++++++++++++---------------------------
lib/{ => gui}/bmp_layout.h | 0
lib/{ => gui}/graphic_utils.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
lib/{ => gui}/image_renderer.c | 9 ++++-----
lib/{ => gui}/lodepng.c | 0
lib/{ => gui}/lodepng.h | 0
lib/{ => gui}/picopng.c | 0
lib/{ => gui}/picopng.h | 0
lib/{ => gui}/png.c | 39 ++++++++++++++++++---------------------
lib/{ => gui}/png.h | 0
lib/{ => gui}/png_lode.c | 4 ++--
lib/{ => gui}/png_pico.c | 4 ++--
23 files changed, 276 insertions(+), 182 deletions(-)
rename include/{ => gui}/graphic_utils.h (65%)
create mode 100644 include/gui/gui.h
create mode 100644 include/gui/image.h
rename include/{ => gui}/image_renderer.h (65%)
create mode 100644 lib/gui/Kconfig
create mode 100644 lib/gui/Makefile
rename lib/{ => gui}/bmp.c (69%)
rename lib/{ => gui}/bmp_layout.h (100%)
rename lib/{ => gui}/graphic_utils.c (74%)
rename lib/{ => gui}/image_renderer.c (85%)
rename lib/{ => gui}/lodepng.c (100%)
rename lib/{ => gui}/lodepng.h (100%)
rename lib/{ => gui}/picopng.c (100%)
rename lib/{ => gui}/picopng.h (100%)
rename lib/{ => gui}/png.c (60%)
rename lib/{ => gui}/png.h (100%)
rename lib/{ => gui}/png_lode.c (96%)
rename lib/{ => gui}/png_pico.c (96%)Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/6 image_renderer: fix size type
/opt/work/barebox/lib/image_renderer.c: In function 'image_renderer_open':/opt/work/barebox/lib/image_renderer.c:37:2: warning: passing argument 2 of 'read_file' from incompatible pointer type [enabled by default] In file included from /opt/work/barebox/lib/image_renderer.c:11:0:/opt/work/barebox/include/fs.h:167:7: note: expected 'size_t *' but argument is of type 'int *'
--- lib/image_renderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/image_renderer.c +1 -1
@@ -29,7 +29,7 @@ static struct image_renderer *get_renderer(void* buf)struct image *image_renderer_open (const char * file) {void *data; -int size; +size_t size;struct image_renderer *ir;struct image *img;int ret;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/6 gui: move gui file to include/gui and lib/gui
---
commands/Kconfig | 23 +++++++++++++--------
commands/splash.c | 4 ++--
drivers/video/sdl.c | 2 +-
include/{ => gui}/graphic_utils.h | 0
include/gui/image.h | 20 ++++++++++++++++++
include/{ => gui}/image_renderer.h | 9 +--------
lib/Kconfig | 36 +--------------------------------
lib/Makefile | 6 +-----
lib/gui/Kconfig | 39 ++++++++++++++++++++++++++++++++++++
lib/gui/Makefile | 5 +++++
lib/{ => gui}/bmp.c | 4 ++--
lib/{ => gui}/bmp_layout.h | 0
lib/{ => gui}/graphic_utils.c | 2 +-
lib/{ => gui}/image_renderer.c | 2 +-
lib/{ => gui}/lodepng.c | 0
lib/{ => gui}/lodepng.h | 0
lib/{ => gui}/picopng.c | 0
lib/{ => gui}/picopng.h | 0
lib/{ => gui}/png.c | 4 ++--
lib/{ => gui}/png.h | 0
lib/{ => gui}/png_lode.c | 4 ++--
lib/{ => gui}/png_pico.c | 4 ++--
22 files changed, 95 insertions(+), 69 deletions(-)
rename include/{ => gui}/graphic_utils.h (100%)
create mode 100644 include/gui/image.h
rename include/{ => gui}/image_renderer.h (94%)
create mode 100644 lib/gui/Kconfig
create mode 100644 lib/gui/Makefile
rename lib/{ => gui}/bmp.c (97%)
rename lib/{ => gui}/bmp_layout.h (100%)
rename lib/{ => gui}/graphic_utils.c (99%)
rename lib/{ => gui}/image_renderer.c (98%)
rename lib/{ => gui}/lodepng.c (100%)
rename lib/{ => gui}/lodepng.h (100%)
rename lib/{ => gui}/picopng.c (100%)
rename lib/{ => gui}/picopng.h (100%)
rename lib/{ => gui}/png.c (96%)
rename lib/{ => gui}/png.h (100%)
rename lib/{ => gui}/png_lode.c (96%)
rename lib/{ => gui}/png_pico.c (96%)commands/Kconfig +15 -8
@@ -486,6 +486,21 @@ config CMD_MTEST_ALTERNATIVE endmenu +menu "video command " + +if VIDEO + +config CMD_SPLASH + bool + select IMAGE_RENDERER + prompt "splash" + help + show bmp files on framebuffer devices + +endif + +endmenu + config CMD_TIMEOUT tristate prompt "timeout"
@@ -549,14 +564,6 @@ config CMD_LSMOD depends on MODULES prompt "lsmod" -config CMD_SPLASH - bool - depends on VIDEO - select IMAGE_RENDERER - prompt "splash" - help - show bmp files on framebuffer devices - config CMD_GPIO bool depends on GENERIC_GPIO
commands/splash.c +2 -2
@@ -7,8 +7,8 @@#include <getopt.h> #include <fcntl.h> #include <fb.h> -#include <image_renderer.h> -#include <graphic_utils.h> +#include <gui/image_renderer.h> +#include <gui/graphic_utils.h> static int do_splash (int argc,char *argv[]) {
drivers/video/sdl.c +1 -1
@@ -11,7 +11,7 @@#include <mach/linux.h> #include <fb.h> #include <errno.h> -#include <graphic_utils.h> +#include <gui/graphic_utils.h> static void sdlfb_enable (struct fb_info *info) {
include/gui/graphic_utils.h renamed from include/graphic_utils.h +0 -0
include/gui/image.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPL v2 +*/ + +#ifndef __GUI_IMAGE_H__ +#define __GUI_IMAGE_H__ + +struct image_renderer ; + +struct image { +void *data; +struct image_renderer *ir; +int height; +int width; +int bits_per_pixel; +}; + +#endif /* __IMAGE_RENDERER_H__ */
include/gui/image_renderer.h renamed from include/image_renderer.h +1 -8
@@ -12,14 +12,7 @@#include <errno.h> #include <linux/err.h> #include <fb.h> - -struct image { -void *data; -struct image_renderer *ir; -int height; -int width; -int bits_per_pixel; -}; +#include <gui/image.h> struct image_renderer {enum filetype type;
lib/Kconfig +1 -35
@@ -38,40 +38,6 @@ config BITREV config QSORT bool -config IMAGE_RENDERER - bool - depends on VIDEO - select FILETYPE - -if IMAGE_RENDERER - -config BMP - bool "bmp" - -config PNG - bool "png" - select ZLIB - -if PNG - -choice - prompt "PNG Lib" - -config LODEPNG - bool "lodePNG" - help - This PNG library supports most PNG formats. - -config PICOPNG - bool "picoPNG" - help - This PNG library only supports RGBA PNG8 but is much smaller - in binary size than lodepng. - -endchoice - -endif - -endif +source lib/gui/Kconfig endmenu
lib/Makefile +1 -5
@@ -34,8 +34,4 @@ obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o -obj-$(CONFIG_BMP) += bmp.o -obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o -obj-$(CONFIG_PNG) += png.o -obj-$(CONFIG_LODEPNG) += png_lode.o lodepng.o -obj-$(CONFIG_PICOPNG) += png_pico.o picopng.o +obj-y += gui/
lib/gui/Kconfig new file +39 -0
@@ -0,0 +1,39 @@ +menu "Library gui routines " + +config IMAGE_RENDERER + bool + depends on VIDEO + select FILETYPE + +if IMAGE_RENDERER + +config BMP + bool "bmp" + +config PNG + bool "png" + select ZLIB + +if PNG + +choice + prompt "PNG Lib" + +config LODEPNG + bool "lodePNG" + help + This PNG library supports most PNG formats. + +config PICOPNG + bool "picoPNG" + help + This PNG library only supports RGBA PNG8 but is much smaller + in binary size than lodepng. + +endchoice + +endif + +endif + +endmenu
lib/gui/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +obj-$(CONFIG_BMP) += bmp.o +obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o +obj-$(CONFIG_PNG) += png.o +obj-$(CONFIG_LODEPNG) += png_lode.o lodepng.o +obj-$(CONFIG_PICOPNG) += png_pico.o picopng.o
lib/gui/bmp.c renamed from lib/bmp.c +2 -2
@@ -4,9 +4,9 @@#include <fb.h> #include "bmp_layout.h" #include <asm/byteorder.h> -#include <graphic_utils.h> +#include <gui/graphic_utils.h> #include <init.h> -#include <image_renderer.h> +#include <gui/image_renderer.h> struct image *bmp_open (char *inbuf,int insize) {
lib/gui/bmp_layout.h renamed from lib/bmp_layout.h +0 -0
lib/gui/graphic_utils.c renamed from lib/graphic_utils.c +1 -1
@@ -1,6 +1,6 @@#include <common.h> #include <fb.h> -#include <graphic_utils.h> +#include <gui/graphic_utils.h> static u32 get_pixel (struct fb_info *info,u32 color) {
lib/gui/image_renderer.c renamed from lib/image_renderer.c +1 -1
@@ -6,7 +6,7 @@#include <common.h> #include <fb.h> -#include <image_renderer.h> +#include <gui/image_renderer.h> #include <errno.h> #include <fs.h> #include <malloc.h>
lib/gui/lodepng.c renamed from lib/lodepng.c +0 -0
lib/gui/lodepng.h renamed from lib/lodepng.h +0 -0
lib/gui/picopng.c renamed from lib/picopng.c +0 -0
lib/gui/picopng.h renamed from lib/picopng.h +0 -0
lib/gui/png.c renamed from lib/png.c +2 -2
@@ -4,8 +4,8 @@#include <fb.h> #include <asm/byteorder.h> #include <init.h> -#include <image_renderer.h> -#include <graphic_utils.h> +#include <gui/image_renderer.h> +#include <gui/graphic_utils.h> #include <linux/zlib.h> #include "png.h"
lib/gui/png.h renamed from lib/png.h +0 -0
lib/gui/png_lode.c renamed from lib/png_lode.c +2 -2
@@ -4,8 +4,8 @@#include <fb.h> #include <asm/byteorder.h> #include <init.h> -#include <image_renderer.h> -#include <graphic_utils.h> +#include <gui/image_renderer.h> +#include <gui/graphic_utils.h> #include <linux/zlib.h> #include "lodepng.h"
lib/gui/png_pico.c renamed from lib/png_pico.c +2 -2
@@ -4,8 +4,8 @@#include <fb.h> #include <asm/byteorder.h> #include <init.h> -#include <image_renderer.h> -#include <graphic_utils.h> +#include <gui/image_renderer.h> +#include <gui/graphic_utils.h> #include <linux/zlib.h> #include "picopng.h"
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/6 graphic_utils: pass image so we can draw only the visible part of the image
In reply to Jean-Christophe PLAGNIOL-VILLARDThis is needed if the image is bigger than the screen.
--- include/gui/graphic_utils.h | 5 ++++- lib/gui/graphic_utils.c | 7 ++++--- lib/gui/png.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)
include/gui/graphic_utils.h +4 -1
@@ -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);
lib/gui/graphic_utils.c +4 -3
@@ -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 ]);
lib/gui/png.c +1 -1
@@ -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;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/6 gui: introduce screen and surface to factorize and simplify code
In reply to Jean-Christophe PLAGNIOL-VILLARDInstead of passing hundreds of parameter, just pass the right structure.
struct screen represent the screen with a without double buffering. struct surface represent the part of the screen we want to render.
--- commands/splash.c | 42 +++++++++++++++++------------------ include/gui/graphic_utils.h | 2 ++ include/gui/gui.h | 36 ++++++++++++++++++++++++++++++ include/gui/image_renderer.h | 16 +++++--------- lib/gui/bmp.c | 50 +++++++++++++++++++++++------------------- lib/gui/image_renderer.c | 5 ++--- lib/gui/png.c | 34 +++++++++++++++------------- 7 files changed, 113 insertions(+), 72 deletions(-) create mode 100644 include/gui/gui.h
commands/splash.c +21 -21
@@ -12,17 +12,20 @@static int do_splash (int argc,char *argv[]) { +struct surface s; +struct screen sc;int ret, opt, fd;char *fbdev ="/dev/fb0" ; -void *fb;struct fb_info info;char *image_file; -int startx =-1 , starty =-1 ; -int xres, yres;int offscreen =0 ;u32 bg_color =0x00000000 ;bool do_bg = false; -void *offscreenbuf =NULL ; + + s.x =-1 ; + s.y =-1 ; + s.width =-1 ; + s.height =-1 ;while ((opt =getopt (argc, argv,"f:x:y:ob:" )) >0 ) {switch (opt) {
@@ -34,10 +37,10 @@ static int do_splash(int argc, char *argv[]) do_bg = true;break ;case 'x' : - startx =simple_strtoul (optarg,NULL ,0 ); + s.x =simple_strtoul (optarg,NULL ,0 );break ;case 'y' : - starty =simple_strtoul (optarg,NULL ,0 ); + s.y =simple_strtoul (optarg,NULL ,0 );case 'o' : offscreen =1 ; }
@@ -55,8 +58,8 @@ static int do_splash(int argc, char *argv[])return 1 ; } - fb =memmap (fd,PROT_READ |PROT_WRITE ); -if (fb == (void *)-1 ) { + sc.fb =memmap (fd,PROT_READ |PROT_WRITE ); +if (sc.fb == (void *)-1 ) {perror ("memmap" ); goto failed_memmap; }
@@ -67,33 +70,30 @@ static int do_splash(int argc, char *argv[]) goto failed_memmap; } - xres = info.xres; - yres = info.yres; -if (offscreen) {int fbsize;/* Don't fail if malloc fails, just continue rendering directly * on the framebuffer */ - fbsize = xres * yres * (info.bits_per_pixel >>3 ); - offscreenbuf =malloc (fbsize); -if (offscreenbuf) { + fbsize = sc.s.x * sc.s.x * (sc.info.bits_per_pixel >>3 ); + sc.offscreenbuf =malloc (fbsize); +if (sc.offscreenbuf) {if (do_bg) -memset_pixel (&info, offscreenbuf, bg_color, xres * yres); +memset_pixel (&info, sc.offscreenbuf, bg_color, + sc.s.width * sc.s.height);else -memcpy (offscreenbuf, fb, fbsize); +memcpy (sc.offscreenbuf, sc.fb, fbsize); } }else if (do_bg) { -memset_pixel (&info, fb, bg_color, xres * yres); +memset_pixel (&info, sc.fb, bg_color, sc.s.width * sc.s.height); } -if (image_renderer_file (&info, image_file, fb, startx, starty, - offscreenbuf) <0 ) +if (image_renderer_file (&sc, &s, image_file) <0 ) ret =1 ; -if (offscreenbuf) -free (offscreenbuf); +if (sc.offscreenbuf) +free (sc.offscreenbuf);close (fd);
include/gui/graphic_utils.h +2 -0
@@ -9,6 +9,7 @@#include <fb.h> #include <gui/image.h> +#include <gui/gui.h> void rgba_blend (struct fb_info *info,struct image *img,void * dest,int height,int width,int startx,int starty,bool is_rgba);
@@ -16,5 +17,6 @@ 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);void set_rgba_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b,u8 a);void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size); +int fb_open (const char * fbdev,struct screen *sc);#endif /* __GRAPHIC_UTILS_H__ */
include/gui/gui.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPL v2 +*/ + +#ifndef __GUI_H__ +#define __GUI_H__ + +#include <fb.h> + +struct surface { +int x; +int y; +int width; +int height; +}; + +struct screen { +struct fb_info info; + +struct surface s; + +void *fb; +void *offscreenbuf; +}; + +static inline void *gui_screen_redering_buffer (struct screen *sc) +{ +if (sc->offscreenbuf) +return sc->offscreenbuf; +return sc->fb; +} + + +#endif /* __GUI_H__ */
include/gui/image_renderer.h +6 -10
@@ -13,13 +13,13 @@#include <linux/err.h> #include <fb.h> #include <gui/image.h> +#include <gui/gui.h> struct image_renderer {enum filetype type;struct image *(*open)(char *data,int size);void (*close)(struct image *img); -int (*renderer)(struct fb_info *info,struct image *img,void * fb, -int startx,int starty,void * offscreenbuf); +int (*renderer)(struct screen *sc,struct surface *s,struct image *img);/* * do not free the data read from the file
@@ -34,8 +34,7 @@ struct image_renderer {int image_renderer_register (struct image_renderer *ir);void image_render_unregister (struct image_renderer *ir); -int image_renderer_image (struct fb_info *info,struct image *img,void * fb, -int startx,int starty,void * offscreenbuf); +int image_renderer_image (struct screen *sc,struct surface *s,struct image *img);struct image *image_renderer_open (const char * file);void image_renderer_close (struct image *img);
@@ -54,12 +53,10 @@ static inline struct image *image_renderer_open(const char* file)static inline void image_renderer_close (struct image *img) {} -int image_renderer_image (struct fb_info *info,struct image *img,void * fb, -int startx,int starty,void * offscreenbuf); +int image_renderer_image (struct surface *s,struct image *img);#endif -static inline int image_renderer_file (struct fb_info *info,const char * file,void * fb, -int startx,int starty,void * offscreenbuf) +static inline int image_renderer_file (struct screen *sc,struct surface *s,const char * file) {struct image * img =image_renderer_open (file);int ret;
@@ -67,8 +64,7 @@ static inline int image_renderer_file(struct fb_info *info, const char* file, voif (IS_ERR (img))return PTR_ERR (img); - ret =image_renderer_image (info, img, fb, startx, starty, - offscreenbuf); + ret =image_renderer_image (sc, s, img);image_renderer_close (img);
lib/gui/bmp.c +27 -23
106 lines not on this page · raw message
lib/gui/image_renderer.c +2 -3
@@ -71,10 +71,9 @@ void image_renderer_close(struct image *img)free (img); } -int image_renderer_image (struct fb_info *info,struct image *img,void * fb, -int startx,int starty,void * offscreenbuf) +int image_renderer_image (struct screen *sc,struct surface *s,struct image *img) { -return img->ir->renderer (info, img, fb, startx, starty, offscreenbuf); +return img->ir->renderer (sc, s, img); }int image_renderer_register (struct image_renderer *ir)
lib/gui/png.c +19 -15
@@ -36,40 +36,44 @@ void png_uncompress_exit(void) } } -static int png_renderer (struct fb_info *info,struct image *img,void * fb, -int startx,int starty,void * offscreenbuf) +static int png_renderer (struct screen *sc,struct surface *s,struct image *img) { -int width, height;void *buf; -int xres, yres; +int width = s->width; +int height = s->height; +int startx = s->x; +int starty = s->y; - xres = info->xres; - yres = info->yres; +if (s->width <0 ) + width = img->width; + +if (s->height <0 ) + height = img->height;if (startx <0 ) { - startx = (xres - img->width) /2 ; + startx = (sc->s.width - width) /2 ;if (startx <0 ) startx =0 ; }if (starty <0 ) { - starty = (yres - img->height) /2 ; + starty = (sc->s.height - height) /2 ;if (starty <0 ) starty =0 ; } - width =min (img->width, xres - startx); - height =min (img->height, yres - starty); + width =min (width, sc->s.width - startx); + height =min (height, sc->s.height - starty); - buf = offscreenbuf ? offscreenbuf : fb; + buf =gui_screen_redering_buffer (sc); -rgba_blend (info, img, buf, height, width, startx, starty, true); +rgba_blend (&sc->info, img, buf, height, width, startx, starty, true); -if (offscreenbuf) { +if (sc->offscreenbuf) {int fbsize; - fbsize = xres * yres * (info->bits_per_pixel >>3 ); -memcpy (fb, offscreenbuf, fbsize); + fbsize = sc->s.width * sc->s.height * (sc->info.bits_per_pixel >>3 ); +memcpy (sc->fb, sc->offscreenbuf, fbsize); }return img->height;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/6 graphic_utils: introduce common fb_open/close
In reply to Jean-Christophe PLAGNIOL-VILLARDTo open, memmap, get the fb_info and if needed allocate the offscreen buffer
--- commands/splash.c | 50 ++++++++--------------------------------- include/gui/graphic_utils.h | 3 ++- include/gui/gui.h | 2 ++ lib/gui/bmp.c | 5 ++--- lib/gui/graphic_utils.c | 52 +++++++++++++++++++++++++++++++++++++++++++ lib/gui/png.c | 8 ++----- 6 files changed, 69 insertions(+), 51 deletions(-)
commands/splash.c +9 -41
@@ -1,11 +1,8 @@#include <common.h> #include <command.h> -#include <fs.h> -#include <linux/stat.h> #include <errno.h> #include <malloc.h> #include <getopt.h> -#include <fcntl.h> #include <fb.h> #include <gui/image_renderer.h> #include <gui/graphic_utils.h>
@@ -52,39 +49,18 @@ static int do_splash(int argc, char *argv[]) } image_file = argv[optind]; - fd =open (fbdev,O_RDWR ); + fd =fb_open (fbdev, &sc, offscreen);if (fd <0 ) { -perror ("open" ); +perror ("fd_open" );return 1 ; } - sc.fb =memmap (fd,PROT_READ |PROT_WRITE ); -if (sc.fb == (void *)-1 ) { -perror ("memmap" ); - goto failed_memmap; - } - - ret =ioctl (fd,FBIOGET_SCREENINFO , &info); -if (ret) { -perror ("ioctl" ); - goto failed_memmap; - } - -if (offscreen) { -int fbsize; -/* Don't fail if malloc fails, just continue rendering directly -* on the framebuffer -*/ - - fbsize = sc.s.x * sc.s.x * (sc.info.bits_per_pixel >>3 ); - sc.offscreenbuf =malloc (fbsize); -if (sc.offscreenbuf) { -if (do_bg) -memset_pixel (&info, sc.offscreenbuf, bg_color, - sc.s.width * sc.s.height); -else -memcpy (sc.offscreenbuf, sc.fb, fbsize); - } +if (sc.offscreenbuf) { +if (do_bg) +memset_pixel (&info, sc.offscreenbuf, bg_color, + sc.s.width * sc.s.height); +else +memcpy (sc.offscreenbuf, sc.fb, sc.fbsize); }else if (do_bg) {memset_pixel (&info, sc.fb, bg_color, sc.s.width * sc.s.height); }
@@ -92,17 +68,9 @@ static int do_splash(int argc, char *argv[])if (image_renderer_file (&sc, &s, image_file) <0 ) ret =1 ; -if (sc.offscreenbuf) -free (sc.offscreenbuf); - -close (fd); +fb_close (&sc);return ret; - -failed_memmap: -close (fd); - -return 1 ; }BAREBOX_CMD_HELP_START (splash)
include/gui/graphic_utils.h +2 -1
@@ -17,6 +17,7 @@ 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);void set_rgba_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b,u8 a);void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size); -int fb_open (const char * fbdev,struct screen *sc); +int fb_open (const char * fbdev,struct screen *sc,bool offscreen); +void fb_close (struct screen *sc);#endif /* __GRAPHIC_UTILS_H__ */
include/gui/gui.h +2 -0
@@ -17,12 +17,14 @@ struct surface { };struct screen { +int fd;struct fb_info info;struct surface s;void *fb;void *offscreenbuf; +int fbsize; };static inline void *gui_screen_redering_buffer (struct screen *sc)
lib/gui/bmp.c +2 -3
@@ -37,7 +37,7 @@ void bmp_close(struct image *img)static int bmp_renderer (struct screen *sc,struct surface *s,struct image *img) {struct bmp_image *bmp = img->data; -int bits_per_pixel, fbsize; +int bits_per_pixel;void *adr, *buf;char *image;int width = s->width;
@@ -69,7 +69,6 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img) buf =gui_screen_redering_buffer (sc); bits_per_pixel = img->bits_per_pixel; - fbsize = sc->s.width * sc->s.height * (sc->info.bits_per_pixel >>3 );if (bits_per_pixel ==8 ) {int x, y;
@@ -119,7 +118,7 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img)printf ("bmp: illegal bits per pixel value: %d\n" , bits_per_pixel);if (sc->offscreenbuf) -memcpy (sc->fb, sc->offscreenbuf, fbsize); +memcpy (sc->fb, sc->offscreenbuf, sc->fbsize);return img->height; }
lib/gui/graphic_utils.c +52 -0
61 lines not on this page · raw message
lib/gui/png.c +2 -6
@@ -69,12 +69,8 @@ static int png_renderer(struct screen *sc, struct surface *s, struct image *img)rgba_blend (&sc->info, img, buf, height, width, startx, starty, true); -if (sc->offscreenbuf) { -int fbsize; - - fbsize = sc->s.width * sc->s.height * (sc->info.bits_per_pixel >>3 ); -memcpy (sc->fb, sc->offscreenbuf, fbsize); - } +if (sc->offscreenbuf) +memcpy (sc->fb, sc->offscreenbuf, sc->fbsize);return img->height; }
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/6 gui: blit the surface on demand
In reply to Jean-Christophe PLAGNIOL-VILLARDDo not blit the surface everytime we write an image
As we want to able to render multiple image this will cause 1 blit per image;
--- commands/splash.c | 2 ++ include/gui/graphic_utils.h | 1 + lib/gui/bmp.c | 3 --- lib/gui/graphic_utils.c | 8 ++++++++ lib/gui/png.c | 3 --- 5 files changed, 11 insertions(+), 6 deletions(-)
commands/splash.c +2 -0
@@ -68,6 +68,8 @@ static int do_splash(int argc, char *argv[])if (image_renderer_file (&sc, &s, image_file) <0 ) ret =1 ; +screen_blit (&sc); +fb_close (&sc);return ret;
include/gui/graphic_utils.h +1 -0
@@ -19,5 +19,6 @@ void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a);void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size);int fb_open (const char * fbdev,struct screen *sc,bool offscreen);void fb_close (struct screen *sc); +void screen_blit (struct screen *sc);#endif /* __GRAPHIC_UTILS_H__ */
lib/gui/bmp.c +0 -3
@@ -117,9 +117,6 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img) }else printf ("bmp: illegal bits per pixel value: %d\n" , bits_per_pixel); -if (sc->offscreenbuf) -memcpy (sc->fb, sc->offscreenbuf, sc->fbsize); -return img->height; }
lib/gui/graphic_utils.c +8 -0
@@ -242,3 +242,11 @@ void fb_close(struct screen *sc)free (sc->offscreenbuf);close (sc->fd); } + +void screen_blit (struct screen *sc) +{ +if (!sc->offscreenbuf) +return ; + +memcpy (sc->fb, sc->offscreenbuf, sc->fbsize); +}
lib/gui/png.c +0 -3
@@ -69,9 +69,6 @@ static int png_renderer(struct screen *sc, struct surface *s, struct image *img)rgba_blend (&sc->info, img, buf, height, width, startx, starty, true); -if (sc->offscreenbuf) -memcpy (sc->fb, sc->offscreenbuf, sc->fbsize); -return img->height; }
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi,
ping
Best Regards,
J.
Quoted 79 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
The following changes since commit
05b9f24e3ea4071f76ffc4157526946a1c2b1b96:Merge branch 'for-next/sandbox' into next (2012-09-25 10:20:03 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gittags/gui_fbcon_preparefor you to fetch changes up to
267da5665afa3be979cbab2c2787128f4b763f33:gui: blit the surface on demand (2012-09-26 16:51:11 +0800)
----------------------------------------------------------------
gui: factorise codeThis patch series move the gui framework to lib/gui and
include/guiand commands to there own menuThis also factorise code to handle screen and framebuffer
This is a preparation for the framebuffer console support and other gui
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (6):
image_renderer: fix size type
gui: move gui file toinclude/guiand lib/gui
graphic_utils: pass image so we can draw only the visible part of the image
gui: introduce screen and surface to factorize and simplify code
graphic_utils: introduce common fb_open/close
gui: blit the surface on demandcommands/Kconfig | 23 +++++++++++++++-------- commands/splash.c | 76 +++++++++++++++++++++++----------------------------------------------------- drivers/video/sdl.c | 2 +- include/{ => gui}/graphic_utils.h | 9 ++++++++- include/gui/gui.h | 38 ++++++++++++++++++++++++++++++++++++++ include/gui/image.h | 20 ++++++++++++++++++++ include/{ => gui}/image_renderer.h | 25 +++++++------------------ lib/Kconfig | 36 +----------------------------------- lib/Makefile | 6 +----- lib/gui/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++ lib/gui/Makefile | 5 +++++ lib/{ => gui}/bmp.c | 54 +++++++++++++++++++++++++++--------------------------- lib/{ => gui}/bmp_layout.h | 0 lib/{ => gui}/graphic_utils.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- lib/{ => gui}/image_renderer.c | 9 ++++----- lib/{ => gui}/lodepng.c | 0 lib/{ => gui}/lodepng.h | 0 lib/{ => gui}/picopng.c | 0 lib/{ => gui}/picopng.h | 0 lib/{ => gui}/png.c | 39 ++++++++++++++++++--------------------- lib/{ => gui}/png.h | 0 lib/{ => gui}/png_lode.c | 4 ++-- lib/{ => gui}/png_pico.c | 4 ++-- 23 files changed, 276 insertions(+), 182 deletions(-) rename include/{ => gui}/graphic_utils.h (65%) create mode 100644 include/gui/gui.h create mode 100644 include/gui/image.h rename include/{ => gui}/image_renderer.h (65%) create mode 100644 lib/gui/Kconfig create mode 100644 lib/gui/Makefile rename lib/{ => gui}/bmp.c (69%) rename lib/{ => gui}/bmp_layout.h (100%) rename lib/{ => gui}/graphic_utils.c (74%) rename lib/{ => gui}/image_renderer.c (85%) rename lib/{ => gui}/lodepng.c (100%) rename lib/{ => gui}/lodepng.h (100%) rename lib/{ => gui}/picopng.c (100%) rename lib/{ => gui}/picopng.h (100%) rename lib/{ => gui}/png.c (60%) rename lib/{ => gui}/png.h (100%) rename lib/{ => gui}/png_lode.c (96%) rename lib/{ => gui}/png_pico.c (96%)
Quoted 7 lines
Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
ping
Quoted 94 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
ping
Best Regards,
J.Quoted 79 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
The following changes since commit
05b9f24e3ea4071f76ffc4157526946a1c2b1b96:Merge branch 'for-next/sandbox' into next (2012-09-25 10:20:03 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gittags/gui_fbcon_preparefor you to fetch changes up to
267da5665afa3be979cbab2c2787128f4b763f33:gui: blit the surface on demand (2012-09-26 16:51:11 +0800)
----------------------------------------------------------------
gui: factorise codeThis patch series move the gui framework to lib/gui and
include/guiand commands to there own menuThis also factorise code to handle screen and framebuffer
This is a preparation for the framebuffer console support and other gui
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (6):
image_renderer: fix size type
gui: move gui file toinclude/guiand lib/gui
graphic_utils: pass image so we can draw only the visible part of the image
gui: introduce screen and surface to factorize and simplify code
graphic_utils: introduce common fb_open/close
gui: blit the surface on demandcommands/Kconfig | 23 +++++++++++++++-------- commands/splash.c | 76 +++++++++++++++++++++++----------------------------------------------------- drivers/video/sdl.c | 2 +- include/{ => gui}/graphic_utils.h | 9 ++++++++- include/gui/gui.h | 38 ++++++++++++++++++++++++++++++++++++++ include/gui/image.h | 20 ++++++++++++++++++++ include/{ => gui}/image_renderer.h | 25 +++++++------------------ lib/Kconfig | 36 +----------------------------------- lib/Makefile | 6 +----- lib/gui/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++ lib/gui/Makefile | 5 +++++ lib/{ => gui}/bmp.c | 54 +++++++++++++++++++++++++++--------------------------- lib/{ => gui}/bmp_layout.h | 0 lib/{ => gui}/graphic_utils.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- lib/{ => gui}/image_renderer.c | 9 ++++----- lib/{ => gui}/lodepng.c | 0 lib/{ => gui}/lodepng.h | 0 lib/{ => gui}/picopng.c | 0 lib/{ => gui}/picopng.h | 0 lib/{ => gui}/png.c | 39 ++++++++++++++++++--------------------- lib/{ => gui}/png.h | 0 lib/{ => gui}/png_lode.c | 4 ++-- lib/{ => gui}/png_pico.c | 4 ++-- 23 files changed, 276 insertions(+), 182 deletions(-) rename include/{ => gui}/graphic_utils.h (65%) create mode 100644 include/gui/gui.h create mode 100644 include/gui/image.h rename include/{ => gui}/image_renderer.h (65%) create mode 100644 lib/gui/Kconfig create mode 100644 lib/gui/Makefile rename lib/{ => gui}/bmp.c (69%) rename lib/{ => gui}/bmp_layout.h (100%) rename lib/{ => gui}/graphic_utils.c (74%) rename lib/{ => gui}/image_renderer.c (85%) rename lib/{ => gui}/lodepng.c (100%) rename lib/{ => gui}/lodepng.h (100%) rename lib/{ => gui}/picopng.c (100%) rename lib/{ => gui}/picopng.h (100%) rename lib/{ => gui}/png.c (60%) rename lib/{ => gui}/png.h (100%) rename lib/{ => gui}/png_lode.c (96%) rename lib/{ => gui}/png_pico.c (96%)Quoted 7 lines
Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 4 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
HI,
can you announce publicy if you now decide to refuse my contribution in Barebox
Best Regards,
J.
Quoted 101 lines · Jean-Christophe PLAGNIOL-VILLARD
ping
Quoted 94 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
ping
Best Regards,
J.Quoted 79 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
The following changes since commit
05b9f24e3ea4071f76ffc4157526946a1c2b1b96:Merge branch 'for-next/sandbox' into next (2012-09-25 10:20:03 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gittags/gui_fbcon_preparefor you to fetch changes up to
267da5665afa3be979cbab2c2787128f4b763f33:gui: blit the surface on demand (2012-09-26 16:51:11 +0800)
----------------------------------------------------------------
gui: factorise codeThis patch series move the gui framework to lib/gui and
include/guiand commands to there own menuThis also factorise code to handle screen and framebuffer
This is a preparation for the framebuffer console support and other gui
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (6):
image_renderer: fix size type
gui: move gui file toinclude/guiand lib/gui
graphic_utils: pass image so we can draw only the visible part of the image
gui: introduce screen and surface to factorize and simplify code
graphic_utils: introduce common fb_open/close
gui: blit the surface on demandcommands/Kconfig | 23 +++++++++++++++-------- commands/splash.c | 76 +++++++++++++++++++++++----------------------------------------------------- drivers/video/sdl.c | 2 +- include/{ => gui}/graphic_utils.h | 9 ++++++++- include/gui/gui.h | 38 ++++++++++++++++++++++++++++++++++++++ include/gui/image.h | 20 ++++++++++++++++++++ include/{ => gui}/image_renderer.h | 25 +++++++------------------ lib/Kconfig | 36 +----------------------------------- lib/Makefile | 6 +----- lib/gui/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++ lib/gui/Makefile | 5 +++++ lib/{ => gui}/bmp.c | 54 +++++++++++++++++++++++++++--------------------------- lib/{ => gui}/bmp_layout.h | 0 lib/{ => gui}/graphic_utils.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- lib/{ => gui}/image_renderer.c | 9 ++++----- lib/{ => gui}/lodepng.c | 0 lib/{ => gui}/lodepng.h | 0 lib/{ => gui}/picopng.c | 0 lib/{ => gui}/picopng.h | 0 lib/{ => gui}/png.c | 39 ++++++++++++++++++--------------------- lib/{ => gui}/png.h | 0 lib/{ => gui}/png_lode.c | 4 ++-- lib/{ => gui}/png_pico.c | 4 ++-- 23 files changed, 276 insertions(+), 182 deletions(-) rename include/{ => gui}/graphic_utils.h (65%) create mode 100644 include/gui/gui.h create mode 100644 include/gui/image.h rename include/{ => gui}/image_renderer.h (65%) create mode 100644 lib/gui/Kconfig create mode 100644 lib/gui/Makefile rename lib/{ => gui}/bmp.c (69%) rename lib/{ => gui}/bmp_layout.h (100%) rename lib/{ => gui}/graphic_utils.c (74%) rename lib/{ => gui}/image_renderer.c (85%) rename lib/{ => gui}/lodepng.c (100%) rename lib/{ => gui}/lodepng.h (100%) rename lib/{ => gui}/picopng.c (100%) rename lib/{ => gui}/picopng.h (100%) rename lib/{ => gui}/png.c (60%) rename lib/{ => gui}/png.h (100%) rename lib/{ => gui}/png_lode.c (96%) rename lib/{ => gui}/png_pico.c (96%)Quoted 7 lines
Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/bareboxQuoted 4 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 4 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hi,
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
can you announce publicy if you now decide to refuse my contribution in Barebox
keep cool Jean Christophe, I believe Sascha needs some time to review your patches and has other occupations at Pengutronix which can slow down the review process.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
HI,
can you announce publicy if you now decide to refuse my contribution in Barebox
I do not intend to refuse your contribution to barebox, but if you want to drop huge amounts of code into the repository please give me the feeling that you have looked at your patches and have tested them. The series you are pinging here refactors code which didn't even hit the master branch.
That said, I think this series looks ok and I'm going to apply it.
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
The following changes since commit
05b9f24e3ea4071f76ffc4157526946a1c2b1b96:Merge branch 'for-next/sandbox' into next (2012-09-25 10:20:03 +0200)
are available in the git repository at:
Applied, thanks
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox