2d-primitives: Introduce gu_draw_text()
PATCH 1/4 2d-primitives: Introduce gu_draw_text()
Add code to draw characters/string on a display.
--- include/gui/2d-primitives.h | 12 ++++++++ lib/gui/2d-primitives.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+)
include/gui/2d-primitives.h +12 -0
@@ -2,6 +2,7 @@#define __2D_PRIMITIVES__#include <fb.h> +#include <linux/font.h> void gu_draw_line(struct screen *sc, int x1, int y1, int x2, int y2,
@@ -12,4 +13,15 @@ void gu_draw_circle(struct screen *sc, int x0, int y0, int radius, u8 r, u8 g, u8 b, u8 a); +#ifdef CONFIG_FONTS +void gu_draw_text (struct screen *sc,const struct font_desc *font, +int x,int y,const char *text, +u8 fr,u8 fg,u8 fb,u8 fa, +u8 br,u8 bg,u8 bb,u8 ba); +#else +static inline void gu_draw_text (struct screen *sc,const struct font_desc *font, +int x,int y,const char *text, +u8 fr,u8 fg,u8 fb,u8 fa, +u8 br,u8 bg,u8 bb,u8 ba) {} +#endif #endif
lib/gui/2d-primitives.c +67 -0
76 lines not on this page · raw message
Signature · 7 lines
2.14.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/4 gui: graphic_utils: Stub out fb_* functions
Stub out fb_* functions so as to avoid having to #ifdef the code using them.
--- include/gui/graphic_utils.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
include/gui/graphic_utils.h +47 -0
@@ -11,6 +11,8 @@#include <gui/image.h> #include <gui/gui.h> +#ifdef CONFIG_IMAGE_RENDERER +u32 gu_hex_to_pixel (struct fb_info *info,u32 color);u32 gu_rgb_to_pixel (struct fb_info *info,u8 r,u8 g,u8 b,u8 t); void gu_rgba_blend(struct fb_info *info, struct image *img, void* dest, int height,
@@ -31,4 +33,49 @@ void gu_screen_blit_area(struct screen *sc, int startx, int starty, int width,void gu_fill_rectangle (struct screen *sc,int x1,int y1,int x2,int y2,u8 r,u8 g,u8 b,u8 a); +#else + +static inline u32 gu_hex_to_pixel (struct fb_info *info,u32 color) +{ +return 0 ; +} +static inline u32 gu_rgb_to_pixel (struct fb_info *info,u8 r, +u8 g,u8 b,u8 t) +{ +return 0 ; +} +static inline void gu_rgba_blend (struct fb_info *info,struct image *img, +void * dest,int height, +int width,int startx, +int starty,bool is_rgba) {} +static inline void gu_set_pixel (struct fb_info *info,void *adr,u32 px) {} +static inline void gu_set_rgb_pixel (struct fb_info *info,void *adr, +u8 r,u8 g,u8 b) {} +static inline void gu_set_rgba_pixel (struct fb_info *info,void *adr, +u8 r,u8 g,u8 b,u8 a) {} +static inline void gu_memset_pixel (struct fb_info *info,void * buf, +u32 color,size_t size) {} +static inline struct screen *fb_create_screen (struct fb_info *info) +{ +return ERR_PTR (-ENOTSUPP ); +} + +static inline struct screen *fb_open (const char *fbdev) +{ +return ERR_PTR (-ENOTSUPP ); +} + +static inline void fb_close (struct screen *sc) {} +static inline void gu_screen_blit (struct screen *sc) {} +static inline void gu_invert_area (struct fb_info *info,void *buf,int startx, +int starty,int width,int height) {} +static inline void gu_screen_blit_area (struct screen *sc,int startx, +int starty,int width, +int height) {} +static inline void gu_fill_rectangle (struct screen *sc,int x1,int y1, +int x2,int y2,u8 r,u8 g,u8 b,u8 a) {} + +#endif + +#endif /* __GRAPHIC_UTILS_H__ */
Signature · 7 lines
2.14.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/4 linux/font.h: Stub out font functions
In reply to Andrey SmirnovStub out font-related funtions functions so as to avoid having to ifdef the code using them.
--- include/linux/font.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/linux/font.h +30 -0
@@ -30,6 +30,8 @@ struct font_desc {/* Max. length for the name of a predefined font */ #define MAX_FONT_NAME 32 +#ifdef CONFIG_FONTS +extern int find_font_index (const struct font_desc *font,int ch);extern const struct font_desc *find_font_enum (int n); extern struct param_d *add_param_font(struct device_d *dev,
@@ -39,4 +41,32 @@ extern struct param_d *add_param_font(struct device_d *dev,int font_register (struct font_desc *font); +#else + +static inline int find_font_index (const struct font_desc *font,int ch) +{ +return -ENOTSUPP ; +} + +static inline const struct font_desc *find_font_enum (int n) +{ +return NULL ; +} + +static inline struct param_d * +add_param_font (struct device_d *dev, +int (*set)(struct param_d *p,void *priv), +int (*get)(struct param_d *p,void *priv), +int *value,void *priv) +{ +return NULL ; +} + +static inline int font_register (struct font_desc *font) +{ +return -ENOTSUPP ; +} + +#endif +#endif /* _VIDEO_FONT_H */
Signature · 7 lines
2.14.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/4 commands: version: Add framebuffer output support
In reply to Andrey SmirnovExtend "version" command to be capable of rendeing version information on framebuffer devices.
--- commands/Kconfig | 8 +++ commands/version.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 2 deletions(-)
commands/Kconfig +8 -0
@@ -238,6 +238,14 @@ config CMD_VERSION barebox 2014.05.0-00142-gb289373 #177 Mon May 12 20:35:55 CEST 2014 +config CMD_VERSION_OUTPUT_TO_FRAMEBUFFER + bool + depends on CMD_VERSION + prompt "support displaying version via framebuffer" + help + Selecting this option will enable version command to output + version information onto display backed by a frambuffer + config CMD_MMC_EXTCSD tristate prompt "read/write eMMC ext. CSD register"
commands/version.c +196 -2
212 lines not on this page · raw message
Signature · 7 lines
2.14.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/4] commands: version: Add framebuffer output support
Hi Andrey,
Quoted 108 lines · Andrey Smirnov
Extend "version" command to be capable of rendeing version information on framebuffer devices.
Signed-off-by Andrey Smirnov <[email protected]>--- commands/Kconfig | 8 +++ commands/version.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 2 deletions(-)commands/Kconfig +8
-0@@ -238,6 +238,14 @@ config CMD_VERSION barebox 2014.05.0-00142-gb289373 #177 Mon May 12 20:35:55 CEST 2014 +config CMD_VERSION_OUTPUT_TO_FRAMEBUFFER + bool + depends on CMD_VERSION + prompt "support displaying version via framebuffer" + help + Selecting this option will enable version command to output + version information onto display backed by a frambuffer + config CMD_MMC_EXTCSD tristate prompt "read/write eMMC ext. CSD register"commands/version.c +68
-1@@ -20,16 +20,210 @@#include <common.h> #include <command.h> #include <complete.h> +#include <getopt.h> +#include <fb.h> +#include <gui/graphic_utils.h> +#include <gui/2d-primitives.h> + +#define FRAME_SIZE 8 + +struct placement { +int x, y; +}; + +typedef struct placement placement_function_t (struct screen *,int ,int ); + +struct placement +placement_center (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = (sc->info->xres - text_width) /2 ; + p.y = (sc->info->yres - text_height) /2 ; + +return p; +} + +struct placement +placement_upper_left (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x =FRAME_SIZE ; + p.y =FRAME_SIZE ; + +return p; +} + +struct placement +placement_upper_right (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = sc->info->xres -1 - text_width -FRAME_SIZE ; + p.y =FRAME_SIZE ; + +return p; +} + +struct placement +placement_lower_left (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x =FRAME_SIZE ; + p.y = sc->info->yres -1 - text_height -FRAME_SIZE ; + +return p; +} + +struct placement +placement_lower_right (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = sc->info->xres -1 - text_width -FRAME_SIZE ; + p.y = sc->info->yres -1 - text_height -FRAME_SIZE ; + +return p; +}static int do_version (int argc,char *argv[]) { -printf ("\n%s\n" , version_string); +const struct font_desc *font;
commands/version.c line 103
Quoted 10 lines
commands/version.c +10
-0+const char *fbdev =NULL ; +struct screen *sc; +u8 fg[3 ], bg[3 ]; +int text_width; +int text_height; + +placement_function_t *place; +struct placement placement; + +if (IS_ENABLED (CONFIG_CMD_VERSION_OUTPUT_TO_FRAMEBUFFER )) {
This is quite much code added to the version command, given that the command previously only was a one-liner. I think this should rather be a separate command. This could depend on framebuffer and other needed stuff which would make the first two patches unnecessary. I think stubbing away graphics functions when the user is graphics-only code is a bit over the top.
The placement functions look as if they should be moved to some font handling generic code.
Also it's always nice to have a C API for anything we also have as command. It has proven to be useful so many times.
commands/version.c line 214
Quoted 2 lines
commands/version.c +2
-0+BAREBOX_CMD_HELP_OPT ("-f color\t", "foreground color, in hex RRGGBB format") +BAREBOX_CMD_HELP_OPT ("-b color\t" ,"background color, in hex RRGGBB format" )
I'm not sure how useful these are as parameters to a command. How about a nv variable? This could be used by the framebuffer console aswell.
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
Re: [PATCH 4/4] commands: version: Add framebuffer output support
Quoted 120 lines · Sascha Hauer
Hi Andrey,
Quoted 117 lines · Andrey Smirnov
Extend "version" command to be capable of rendeing version information on framebuffer devices.
Signed-off-by Andrey Smirnov <[email protected]>--- commands/Kconfig | 8 +++ commands/version.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 204 insertions(+), 2 deletions(-)commands/Kconfig +8
-0@@ -238,6 +238,14 @@ config CMD_VERSION barebox 2014.05.0-00142-gb289373 #177 Mon May 12 20:35:55 CEST 2014 +config CMD_VERSION_OUTPUT_TO_FRAMEBUFFER + bool + depends on CMD_VERSION + prompt "support displaying version via framebuffer" + help + Selecting this option will enable version command to output + version information onto display backed by a frambuffer + config CMD_MMC_EXTCSD tristate prompt "read/write eMMC ext. CSD register"commands/version.c +77
-1@@ -20,16 +20,210 @@#include <common.h> #include <command.h> #include <complete.h> +#include <getopt.h> +#include <fb.h> +#include <gui/graphic_utils.h> +#include <gui/2d-primitives.h> + +#define FRAME_SIZE 8 + +struct placement { +int x, y; +}; + +typedef struct placement placement_function_t (struct screen *,int ,int ); + +struct placement +placement_center (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = (sc->info->xres - text_width) /2 ; + p.y = (sc->info->yres - text_height) /2 ; + +return p; +} + +struct placement +placement_upper_left (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x =FRAME_SIZE ; + p.y =FRAME_SIZE ; + +return p; +} + +struct placement +placement_upper_right (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = sc->info->xres -1 - text_width -FRAME_SIZE ; + p.y =FRAME_SIZE ; + +return p; +} + +struct placement +placement_lower_left (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x =FRAME_SIZE ; + p.y = sc->info->yres -1 - text_height -FRAME_SIZE ; + +return p; +} + +struct placement +placement_lower_right (struct screen *sc,int text_width,int text_height) +{ +struct placement p; + + p.x = sc->info->xres -1 - text_width -FRAME_SIZE ; + p.y = sc->info->yres -1 - text_height -FRAME_SIZE ; + +return p; +}static int do_version (int argc,char *argv[]) { -printf ("\n%s\n" , version_string); +const struct font_desc *font; +const char *fbdev =NULL ; +struct screen *sc; +u8 fg[3 ], bg[3 ]; +int text_width; +int text_height; + +placement_function_t *place; +struct placement placement; +
Quoted 9 lines
commands/version.c line 103
Quoted 1 line
commands/version.c +1
-0+if (IS_ENABLED (CONFIG_CMD_VERSION_OUTPUT_TO_FRAMEBUFFER )) {This is quite much code added to the version command, given that the command previously only was a one-liner. I think this should rather be a separate command. This could depend on framebuffer and other needed stuff which would make the first two patches unnecessary. I think stubbing away graphics functions when the user is graphics-only code is a bit over the top.
OK, will change in v2.
Quoted 2 lines
The placement functions look as if they should be moved to some font handling generic code.
OK, will do.
Quoted 4 lines
Also it's always nice to have a C API for anything we also have as command. It has proven to be useful so many times.
Sure, will do.
Quoted 6 lines
commands/version.c line 214
Quoted 2 lines
commands/version.c +2
-0+BAREBOX_CMD_HELP_OPT ("-f color\t", "foreground color, in hex RRGGBB format") +BAREBOX_CMD_HELP_OPT ("-b color\t" ,"background color, in hex RRGGBB format" )I'm not sure how useful these are as parameters to a command. How about a nv variable? This could be used by the framebuffer console aswell.
Sure, sounds reasonable.
Thanks,
Andrey Smirnov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox