On Tue, Jan 27, 2009 at 06:02:09PM +0100, Bernhard Reutner-Fischer wrote:
>On Mon, Jan 12, 2009 at 09:30:19PM +0100, Michele Sanges wrote:
>> This patch for the fbsplash applet, adds the ability to render text
>> messages on top of the displayed image.
>>
>> The sintax for the new option is the following:
>> echo write:this is the message to print > fbfifo
>>
>> By means of the fbsplash.cfg file it's also possible to specify the
>> position, the color and the size of the text displayed.
>>
>> I also attach a font map file, to use with the -m option if you don't
>> want to compile the applet with the hardcoded fonts.
>>
>> Oh yes, the patch is the same I have sent three or four times last year
>> :-) I hope to be more lucky.
>
>You forgot to mention size(1) figures and/or scripts/bloat-o-meter output
>for your patch.
>
>While looking over the current fbsplash, i came up with the attached
>patch to shrink it (untested):
>
>$ ./scripts/bloat-o-meter _bb_un.oorig busybox_unstripped
>function old new delta
>fbsplash_main 595 985 +390
>fb_drawimage 493 - -493
>------------------------------------------------------------------------------
>(add/remove: 0/1 grow/shrink: 1/0 up/down: 390/-493) Total: -103 bytes
>
>$ size miscutils/fbsplash.o*
> text data bss dec hex filename
> 2019 0 0 2019 7e3 miscutils/fbsplash.o.oorig
> 1857 0 0 1857 741 miscutils/fbsplash.o.new
>
>
>Can you please have a look at the patch and perhaps test it?
I've applied this shrinkage now (r25333), please holler if it broke something.
cheers,
Bernhard
>
>See below for some comments on your patch..
>
>>diff -urP busybox-1.13.2_originale/include/usage.h
>>busybox-1.13.2_fbsplash/include/usage.h
>>--- busybox-1.13.2_originale/include/usage.h 2008-11-09 18:28:17.000000000
>>+0100
>>+++ busybox-1.13.2_fbsplash/include/usage.h 2009-01-12 16:29:40.000000000
>>+0100
>>@@ -128,7 +128,7 @@
>> "bar"
>>
>> #define fbsplash_trivial_usage \
>>- "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
>>+ "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD] [-m FONTMAPFILE]"
>> #define fbsplash_full_usage "\n\n" \
>> "Options:\n" \
>> "\n -s Image" \
>>@@ -137,8 +137,10 @@
>> "\n -i Config file (var=value):" \
>> "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" \
>> "\n BAR_R,BAR_G,BAR_B" \
>>+ "\n
>>TEXT_LEFT,TEXT_TOP,TEXT_R,TEXT_G,TEXT_B,TEXT_SIZE" \
>> "\n -f Control pipe (else exit after drawing image)" \
>>- "\n commands: 'NN' (% for progress bar) or 'exit'" \
>>+ "\n -m Font map file" \
>>+ "\n commands: 'NN' (% for progress bar),
>>'write:string to print' or 'exit'"
>>
>> #define brctl_trivial_usage \
>
>Somebody goofed with the alphabetical ordering in usage.h, it seems.
>Can you please have a look if fbsplash's helptext is really in the
>correct place here?
>
>
>>diff -urP busybox-1.13.2_originale/miscutils/Config.in
>>busybox-1.13.2_fbsplash/miscutils/Config.in
>>--- busybox-1.13.2_originale/miscutils/Config.in 2008-11-09
>>18:28:17.000000000 +0100
>>+++ busybox-1.13.2_fbsplash/miscutils/Config.in 2009-01-12
>>16:32:17.000000000 +0100
>>@@ -238,6 +238,34 @@
>> "NN" (ASCII decimal number) - percentage to show on progress bar
>> "exit" - well you guessed it
>>
>>+config FBSPLASH_TEXT_RENDERING
>>+ bool "text rendering"
>>+ default n
>>+ depends on FBSPLASH
>>+ help
>>+ This option adds the ability to print text messages on the
>>+ image displayed by the fbsplash applet.
>>+ - command for fifo:
>>+ "write:string to print" - print the string after the word "write:"
>>+
>>+choice
>>+ prompt "Choose the font map"
>>+ depends on FBSPLASH_TEXT_RENDERING
>>+ default FONTMAP_HARDCODED
>>+
>>+config FONTMAP_HARDCODED
>
>there is FBSPLASH missing in that symbol name. Better use
>config FBSPLASH_FONTMAP_HARDCODED
>
>>+ bool "hardcoded"
>>+ help
>>+ The font map is hard-coded to use the default font map.
>>+ Adds about 1.6Kb.
>>+
>>+config FONTMAP_DYNAMICALLY_LOADED
>
>same here.
>Index: miscutils/fbsplash.c
>===================================================================
>--- miscutils/fbsplash.c (revision 25074)
>+++ miscutils/fbsplash.c (working copy)
>@@ -87,7 +87,7 @@ static void fb_open(const char *strfb_de
> * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/ ,
> PROT_WRITE, MAP_SHARED, fbfd, 0);
> if (G.addr == MAP_FAILED)
>- bb_perror_msg_and_die("can't mmap %s", strfb_device);
>+ bb_perror_msg_and_die("mmap");
> close(fbfd);
> }
>
>@@ -121,7 +121,7 @@ static void fb_drawrectangle(void)
> // vertical lines
> ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) *
> BYTES_PER_PIXEL);
> ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx +
> G.nbar_width - 1) * BYTES_PER_PIXEL);
>- cnt = G.nbar_posy + G.nbar_height - 1 - G.nbar_posy;
>+ cnt = G.nbar_height - 1 /* HUH?! G.nbar_posy + G.nbar_height - 1 -
>G.nbar_posy*/;
> do {
> *ptr1 = thispix; ptr1 += G.scr_var.xres;
> *ptr2 = thispix; ptr2 += G.scr_var.xres;
>@@ -216,18 +216,18 @@ static void fb_drawprogressbar(unsigned
> */
> static void fb_drawimage(void)
> {
>- char head[256];
>- char s[80];
>- FILE *theme_file;
>+ RESERVE_CONFIG_BUFFER(head, 256);
>+ RESERVE_CONFIG_BUFFER(s, 80);
>+ int theme_file;
> unsigned char *pixline;
> unsigned i, j, width, height, line_size;
>
> memset(head, 0, sizeof(head));
>- theme_file = xfopen_stdin(G.image_filename);
>+ theme_file = open_or_warn_stdin(G.image_filename);
>
> // parse ppm header
> while (1) {
>- if (fgets(s, sizeof(s), theme_file) == NULL)
>+ if (safe_read(theme_file, s, sizeof(s)) <= 0)
> bb_error_msg_and_die("bad PPM file '%s'",
> G.image_filename);
>
> if (s[0] == '#')
>@@ -257,7 +257,7 @@ static void fb_drawimage(void)
> unsigned char *pixel = pixline;
> DATA *src = (DATA *)(G.addr + j * G.scr_fix.line_length);
>
>- if (fread(pixline, 1, line_size, theme_file) != line_size)
>+ if (safe_read(theme_file, pixline, line_size) != line_size)
> bb_error_msg_and_die("bad PPM file '%s'",
> G.image_filename);
> for (i = 0; i < width; i++) {
> unsigned thispix;
>@@ -268,8 +268,12 @@ static void fb_drawimage(void)
> pixel += 3;
> }
> }
>- free(pixline);
>- fclose(theme_file);
>+ if (ENABLE_FEATURE_CLEAN_UP) {
>+ free(pixline);
>+ RELEASE_CONFIG_BUFFER(s);
>+ RELEASE_CONFIG_BUFFER(head);
>+ }
>+ close(theme_file);
> }
>
>
>@@ -294,7 +298,7 @@ static void init(const char *cfg_filenam
> unsigned val = xatoi_u(token[1]);
> int i = index_in_strings(param_names, token[0]);
> if (i < 0)
>- bb_error_msg_and_die("syntax error: '%s'", token[0]);
>+ bb_error_msg_and_die("syntax error: %s", token[0]);
> if (i >= 0 && i < 7)
> G.ns[i] = val;
> #if DEBUG
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox