From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1PWSGm-000377-Jz for mharc-grub-devel@gnu.org; Sat, 25 Dec 2010 06:26:40 -0500 Received: from [140.186.70.92] (port=44669 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWSGh-00036v-N2 for grub-devel@gnu.org; Sat, 25 Dec 2010 06:26:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWSGe-0001YB-U2 for grub-devel@gnu.org; Sat, 25 Dec 2010 06:26:35 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]:55439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWSGe-0001Xy-Fj for grub-devel@gnu.org; Sat, 25 Dec 2010 06:26:32 -0500 Received: by wwb17 with SMTP id 17so7704254wwb.30 for ; Sat, 25 Dec 2010 03:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=TNGpmDc5V5P+pQyXMirt35x69Q6/rs3IRckW8vooLj4=; b=oFOvb6Pkmw9m9CG6z9+ixB6cetSq3sg/XMMFsI9x7KYzkIoKfOj2ub2sOsSDnRepkK oqbRkRlCycxJHOG4Bg78n7PRskqLqSAy2Lg0TYn0yaZWb8baHn8veikIpr0wvoyWhNN7 wrjKgqGHuku7gWQsif9eDZTnj/8s2FU6coCJM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=QywBMQc/CKutmvDIjZXp4+eXwbptybhCaOwC9w0TO4dAFxJdMZPWfcT3KqH3D//s5L j5WT3dlS0/DacfBMF3Oyq2IPEAFQPnSBVbFdXri9wadIIUIog91fec9Y/+guTjD2iQrk r/9i6SHxKMl47vHjnK4TWLhfv/Tb0Y81I99cA= Received: by 10.216.188.67 with SMTP id z45mr3200757wem.7.1293276389747; Sat, 25 Dec 2010 03:26:29 -0800 (PST) Received: from debian.bg45.phnet (64.122.202.62.cust.bluewin.ch [62.202.122.64]) by mx.google.com with ESMTPS id x3sm4788249wes.22.2010.12.25.03.26.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 25 Dec 2010 03:26:26 -0800 (PST) Message-ID: <4D15D4D5.1090901@gmail.com> Date: Sat, 25 Dec 2010 12:26:13 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20101211 Icedove/3.0.11 MIME-Version: 1.0 To: grub-devel@gnu.org References: <20101210123941.GX21862@riva.ucam.org> <20101210175342.GA686@riva.ucam.org> <4D0D0FA6.6000703@gmail.com> <20101223122152.GX21862@riva.ucam.org> In-Reply-To: <20101223122152.GX21862@riva.ucam.org> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig8D8D426192AF9046A4BC33CA" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] background_color command X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Dec 2010 11:26:38 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig8D8D426192AF9046A4BC33CA Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Go ahead for experimental On 12/23/2010 01:21 PM, Colin Watson wrote: > On Sat, Dec 18, 2010 at 08:46:46PM +0100, Vladimir '=CF=86-coder/phcode= r' Serbinenko wrote: > =20 >> On 12/10/2010 06:53 PM, Colin Watson wrote: >> =20 >>> module =3D { >>> + name =3D video_colors; >>> + common =3D video/colors.c; >>> + enable =3D videomodules; >>> +}; >>> =20 >> Both main users of video (gfxmenu and gfxterm) use color routines. So = I >> feel like video/colors.c can go into video.mod >> =20 > Fixed. > > =20 >>> + /* Create a filled bitmap so that we get suitable text blending. = */ >>> + grub_video_bitmap_create (&bitmap, window.width, window.height, >>> + GRUB_VIDEO_BLIT_FORMAT_RGB_888); >>> + if (grub_errno !=3D GRUB_ERR_NONE) >>> + return grub_errno; >>> =20 >>> =20 >> You should check the return value and not grub_errno. >> =20 >>> + >>> =20 >>> =20 >> It would be more optimal if in this case the image would be saved simp= ly >> as the color rather than a filled array and use grub_video_fill_rect >> when this image is supposed to be blitted. also it would be neat to be= >> able to specify the bgcolor around non-stretched image. >> =20 >>> + data =3D bitmap->data; >>> + for (i =3D 0; i < window.height * window.width; i++) >>> + { >>> + *data++ =3D color.red; >>> + *data++ =3D color.green; >>> + *data++ =3D color.blue; >>> + } >>> + >>> =20 >>> =20 >> grub_video_fill_rect is the function for such kind of operations. >> =20 > This was all fixed in r2981 on the parse-color branch, which now just > sets virtual_screen.bg_color and virtual_screen.bg_color_display and > handles that appropriately. > > =20 >>> + /* All was ok. */ >>> + grub_errno =3D GRUB_ERR_NONE; >>> =20 >>> =20 >> You shouldn't discard grub_errno manually unless there is an error you= >> want to ignore. >> =20 >>> + return grub_errno; >>> =20 >>> =20 >> I'd rather use return GRUB_ERR_NONE; >> =20 > Fixed. > > Updated patch follows: > > 2010-12-23 Colin Watson > > Move gfxmenu color handling to video, so that gfxterm can use it > too. > > * grub-core/gfxmenu/named_colors.c: Move to ... > * grub-core/video/colors.c: ... here. Rename > grub_gui_get_named_color to grub_video_get_named_color. > * grub-core/gfxmenu/gui_string_util.c (my_isxdigit): Move to ... > * grub-core/video/colors.c (my_isxdigit): ... here. > * grub-core/gfxmenu/gui_string_util.c (parse_hex_color_component): > Move to ... > * grub-core/video/colors.c (parse_hex_color_component): ... here. > * grub-core/gfxmenu/gui_string_util.c (grub_gui_parse_color): Move > to ... > * grub-core/video/colors.c (grub_video_parse_color): ... here. > > * include/grub/gui.h (grub_gui_color_t): Move to ... > * include/grub/video.h (grub_video_rgba_color_t): ... here. > * include/grub/gui.h (grub_gui_color_rgb): Move to ... > * include/grub/video.h (grub_video_rgba_color_rgb): ... here. > * include/grub/gui.h (grub_gui_map_color): Move to ... > * include/grub/video.h (grub_video_map_rgba_color): ... here. > * include/grub/gui_string_util.h (grub_gui_get_named_color): Move > to ... > * include/grub/video.h (grub_video_get_named_color): ... here. > * include/grub/gui_string_util.h (grub_gui_parse_color): Move to ... > * include/grub/video.h (grub_video_parse_color): ... here. > > * grub-core/Makefile.core.def (kernel) [videoinkernel]: Add > video/colors.c. > (gfxmenu): Remove gfxmenu/named_colors.c. > (video) [videomodules]: Add video/colors.c. > > Add a background_color command. > > * grub-core/term/gfxterm.c (grub_gfxterm_background_color_cmd): New > function. > (GRUB_MOD_INIT): Register background_color command. > (GRUB_MOD_FINI): Unregister background_color command. > (redraw_screen_rect): Allow blend/replace of text layer to be > controlled independently from whether there is a background bitmap. > (grub_gfxterm_fullscreen): Change blend_text_bg when changing > bitmap. > (destroy_window): Likewise. > (grub_gfxterm_background_image_cmd): Likewise. > > Fix border repainting. > > * grub-core/term/gfxterm.c (dirty_region_add): When a repaint is > already scheduled, merge the virtual screen with the requested > region rather than repainting only the virtual screen. > > =3D=3D=3D modified file 'grub-core/Makefile.core.def' > --- grub-core/Makefile.core.def 2010-12-01 21:42:11 +0000 > +++ grub-core/Makefile.core.def 2010-12-23 12:10:37 +0000 > @@ -178,6 +178,7 @@ kernel =3D { > videoinkernel =3D io/bufio.c; > videoinkernel =3D video/bitmap.c; > videoinkernel =3D video/bitmap_scale.c; > + videoinkernel =3D video/colors.c; > videoinkernel =3D video/fb/fbblit.c; > videoinkernel =3D video/fb/fbfill.c; > videoinkernel =3D video/fb/fbutil.c; > @@ -1049,7 +1050,6 @@ module =3D { > common =3D gfxmenu/gui_progress_bar.c; > common =3D gfxmenu/gui_util.c; > common =3D gfxmenu/gui_string_util.c; > - common =3D gfxmenu/named_colors.c; > }; > =20 > module =3D { > @@ -1454,6 +1454,7 @@ module =3D { > module =3D { > name =3D video; > common =3D video/video.c; > + common =3D video/colors.c; > enable =3D videomodules; > }; > =20 > > =3D=3D=3D modified file 'grub-core/gfxmenu/gui_label.c' > --- grub-core/gfxmenu/gui_label.c 2010-05-13 01:56:14 +0000 > +++ grub-core/gfxmenu/gui_label.c 2010-12-10 15:32:01 +0000 > @@ -48,7 +48,7 @@ struct grub_gui_label > char *text; > char *template; > grub_font_t font; > - grub_gui_color_t color; > + grub_video_rgba_color_t color; > int value; > enum align_mode align; > }; > @@ -107,7 +107,7 @@ label_paint (void *vself, const grub_vid > grub_gui_set_viewport (&self->bounds, &vpsave); > grub_font_draw_string (self->text, > self->font, > - grub_gui_map_color (self->color), > + grub_video_map_rgba_color (self->color), > left_x, > grub_font_get_ascent (self->font)); > grub_gui_restore_viewport (&vpsave); > @@ -186,7 +186,7 @@ label_set_property (void *vself, const c > } > else if (grub_strcmp (name, "color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->color); > + grub_video_parse_color (value, &self->color); > } > else if (grub_strcmp (name, "align") =3D=3D 0) > { > > =3D=3D=3D modified file 'grub-core/gfxmenu/gui_list.c' > --- grub-core/gfxmenu/gui_list.c 2010-10-16 20:16:52 +0000 > +++ grub-core/gfxmenu/gui_list.c 2010-12-10 15:40:32 +0000 > @@ -41,9 +41,9 @@ struct grub_gui_list_impl > int item_spacing; > grub_font_t item_font; > grub_font_t selected_item_font; > - grub_gui_color_t item_color; > + grub_video_rgba_color_t item_color; > int selected_item_color_set; > - grub_gui_color_t selected_item_color; > + grub_video_rgba_color_t selected_item_color; > =20 > int draw_scrollbar; > int need_to_recreate_scrollbar; > @@ -267,13 +267,13 @@ draw_menu (list_impl_t self, int num_sho > (is_selected && self->selected_item_font > ? self->selected_item_font > : self->item_font); > - grub_gui_color_t text_color =3D > + grub_video_rgba_color_t text_color =3D > ((is_selected && self->selected_item_color_set) > ? self->selected_item_color > : self->item_color); > grub_font_draw_string (item_title, > font, > - grub_gui_map_color (text_color), > + grub_video_map_rgba_color (text_color), > sel_leftpad + self->icon_width + icon_tex= t_space, > (item_top + (item_height - (ascent + desc= ent)) > / 2 + ascent)); > @@ -429,7 +429,7 @@ list_set_property (void *vself, const ch > } > else if (grub_strcmp (name, "item_color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->item_color); > + grub_video_parse_color (value, &self->item_color); > } > else if (grub_strcmp (name, "selected_item_color") =3D=3D 0) > { > @@ -439,7 +439,7 @@ list_set_property (void *vself, const ch > } > else > { > - if (grub_gui_parse_color (value, &self->selected_item_color)= > + if (grub_video_parse_color (value, &self->selected_item_colo= r) > =3D=3D GRUB_ERR_NONE) > self->selected_item_color_set =3D 1; > } > @@ -562,7 +562,7 @@ grub_gui_list_new (void) > { > list_impl_t self; > grub_font_t default_font; > - grub_gui_color_t default_fg_color; > + grub_video_rgba_color_t default_fg_color; > =20 > self =3D grub_zalloc (sizeof (*self)); > if (! self) > @@ -574,7 +574,7 @@ grub_gui_list_new (void) > self->visible =3D 1; > =20 > default_font =3D grub_font_get ("Unknown Regular 16"); > - default_fg_color =3D grub_gui_color_rgb (0, 0, 0); > + default_fg_color =3D grub_video_rgba_color_rgb (0, 0, 0); > =20 > self->icon_width =3D 32; > self->icon_height =3D 32; > > =3D=3D=3D modified file 'grub-core/gfxmenu/gui_progress_bar.c' > --- grub-core/gfxmenu/gui_progress_bar.c 2010-05-13 01:56:14 +0000 > +++ grub-core/gfxmenu/gui_progress_bar.c 2010-12-10 15:31:57 +0000 > @@ -40,10 +40,10 @@ struct grub_gui_progress_bar > int show_text; > char *template; > grub_font_t font; > - grub_gui_color_t text_color; > - grub_gui_color_t border_color; > - grub_gui_color_t bg_color; > - grub_gui_color_t fg_color; > + grub_video_rgba_color_t text_color; > + grub_video_rgba_color_t border_color; > + grub_video_rgba_color_t bg_color; > + grub_video_rgba_color_t fg_color; > =20 > char *theme_dir; > int need_to_recreate_pixmaps; > @@ -109,7 +109,7 @@ draw_filled_rect_bar (grub_gui_progress_ > f.height =3D self->bounds.height - 2; > =20 > /* Border. */ > - grub_video_fill_rect (grub_gui_map_color (self->border_color), > + grub_video_fill_rect (grub_video_map_rgba_color (self->border_color)= , > f.x - 1, f.y - 1, > f.width + 2, f.height + 2); > =20 > @@ -117,12 +117,12 @@ draw_filled_rect_bar (grub_gui_progress_ > int barwidth =3D (f.width > * (self->value - self->start) > / (self->end - self->start)); > - grub_video_fill_rect (grub_gui_map_color (self->bg_color), > + grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color), > f.x + barwidth, f.y, > f.width - barwidth, f.height); > =20 > /* Bar foreground. */ > - grub_video_fill_rect (grub_gui_map_color (self->fg_color), > + grub_video_fill_rect (grub_video_map_rgba_color (self->fg_color), > f.x, f.y, > barwidth, f.height); > } > @@ -161,7 +161,8 @@ draw_text (grub_gui_progress_bar_t self) > if (self->template) > { > grub_font_t font =3D self->font; > - grub_video_color_t text_color =3D grub_gui_map_color (self->text= _color); > + grub_video_color_t text_color =3D > + grub_video_map_rgba_color (self->text_color); > int width =3D self->bounds.width; > int height =3D self->bounds.height; > char *text; > @@ -298,19 +299,19 @@ progress_bar_set_property (void *vself, > } > else if (grub_strcmp (name, "text_color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->text_color); > + grub_video_parse_color (value, &self->text_color); > } > else if (grub_strcmp (name, "border_color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->border_color); > + grub_video_parse_color (value, &self->border_color); > } > else if (grub_strcmp (name, "bg_color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->bg_color); > + grub_video_parse_color (value, &self->bg_color); > } > else if (grub_strcmp (name, "fg_color") =3D=3D 0) > { > - grub_gui_parse_color (value, &self->fg_color); > + grub_video_parse_color (value, &self->fg_color); > } > else if (grub_strcmp (name, "bar_style") =3D=3D 0) > { > @@ -379,9 +380,9 @@ grub_gui_progress_bar_new (void) > self->progress.component.ops =3D &progress_bar_ops; > self->visible =3D 1; > self->font =3D grub_font_get ("Unknown Regular 16"); > - grub_gui_color_t black =3D { .red =3D 0, .green =3D 0, .blue =3D 0, = =2Ealpha =3D 255 }; > - grub_gui_color_t gray =3D { .red =3D 128, .green =3D 128, .blue =3D = 128, .alpha =3D 255 }; > - grub_gui_color_t lightgray =3D { .red =3D 200, .green =3D 200, .blue= =3D 200, .alpha =3D 255 }; > + grub_video_rgba_color_t black =3D { .red =3D 0, .green =3D 0, .blue = =3D 0, .alpha =3D 255 }; > + grub_video_rgba_color_t gray =3D { .red =3D 128, .green =3D 128, .bl= ue =3D 128, .alpha =3D 255 }; > + grub_video_rgba_color_t lightgray =3D { .red =3D 200, .green =3D 200= , .blue =3D 200, .alpha =3D 255 }; > self->text_color =3D black; > self->border_color =3D black; > self->bg_color =3D gray; > > =3D=3D=3D modified file 'grub-core/gfxmenu/gui_string_util.c' > --- grub-core/gfxmenu/gui_string_util.c 2009-12-29 16:31:02 +0000 > +++ grub-core/gfxmenu/gui_string_util.c 2010-12-10 15:30:31 +0000 > @@ -204,124 +204,3 @@ grub_get_dirname (const char *file_path) > =20 > return grub_new_substring (file_path, 0, last_slash + 1); > } > - > -static __inline int > -my_isxdigit (char c) > -{ > - return ((c >=3D '0' && c <=3D '9') > - || (c >=3D 'a' && c <=3D 'f') > - || (c >=3D 'A' && c <=3D 'F')); > -} > - > -static int > -parse_hex_color_component (const char *s, unsigned start, unsigned end= ) > -{ > - unsigned len; > - char buf[3]; > - > - len =3D end - start; > - /* Check the limits so we don't overrun the buffer. */ > - if (len < 1 || len > 2) > - return 0; > - > - if (len =3D=3D 1) > - { > - buf[0] =3D s[start]; /* Get the first and only hex digit. */ > - buf[1] =3D buf[0]; /* Duplicate the hex digit. */ > - } > - else if (len =3D=3D 2) > - { > - buf[0] =3D s[start]; > - buf[1] =3D s[start + 1]; > - } > - > - buf[2] =3D '\0'; > - > - return grub_strtoul (buf, 0, 16); > -} > - > -/* Parse a color string of the form "r, g, b", "#RGB", "#RGBA", > - "#RRGGBB", or "#RRGGBBAA". */ > -grub_err_t > -grub_gui_parse_color (const char *s, grub_gui_color_t *color) > -{ > - grub_gui_color_t c; > - > - /* Skip whitespace. */ > - while (*s && grub_isspace (*s)) > - s++; > - > - if (*s =3D=3D '#') > - { > - /* HTML-style. Number if hex digits: > - [6] #RRGGBB [3] #RGB > - [8] #RRGGBBAA [4] #RGBA */ > - > - s++; /* Skip the '#'. */ > - /* Count the hexits to determine the format. */ > - int hexits =3D 0; > - const char *end =3D s; > - while (my_isxdigit (*end)) > - { > - end++; > - hexits++; > - } > - > - /* Parse the color components based on the format. */ > - if (hexits =3D=3D 3 || hexits =3D=3D 4) > - { > - c.red =3D parse_hex_color_component (s, 0, 1); > - c.green =3D parse_hex_color_component (s, 1, 2); > - c.blue =3D parse_hex_color_component (s, 2, 3); > - if (hexits =3D=3D 4) > - c.alpha =3D parse_hex_color_component (s, 3, 4); > - else > - c.alpha =3D 255; > - } > - else if (hexits =3D=3D 6 || hexits =3D=3D 8) > - { > - c.red =3D parse_hex_color_component (s, 0, 2); > - c.green =3D parse_hex_color_component (s, 2, 4); > - c.blue =3D parse_hex_color_component (s, 4, 6); > - if (hexits =3D=3D 8) > - c.alpha =3D parse_hex_color_component (s, 6, 8); > - else > - c.alpha =3D 255; > - } > - else > - return grub_error (GRUB_ERR_BAD_ARGUMENT, > - "invalid HTML-type color string `%s'", s); > - } > - else if (grub_isdigit (*s)) > - { > - /* Comma separated decimal values. */ > - c.red =3D grub_strtoul (s, 0, 0); > - if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > - return grub_error (GRUB_ERR_BAD_ARGUMENT, > - "missing 1st comma separator in color `%s'"= , s); > - s++; > - c.green =3D grub_strtoul (s, 0, 0); > - if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > - return grub_error (GRUB_ERR_BAD_ARGUMENT, > - "missing 2nd comma separator in color `%s'"= , s); > - s++; > - c.blue =3D grub_strtoul (s, 0, 0); > - if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > - c.alpha =3D 255; > - else > - { > - s++; > - c.alpha =3D grub_strtoul (s, 0, 0); > - } > - } > - else > - { > - if (! grub_gui_get_named_color (s, &c)) > - return grub_error (GRUB_ERR_BAD_ARGUMENT, > - "invalid named color `%s'", s); > - } > - > - if (grub_errno =3D=3D GRUB_ERR_NONE) > - *color =3D c; > - return grub_errno; > -} > > =3D=3D=3D modified file 'grub-core/gfxmenu/theme_loader.c' > --- grub-core/gfxmenu/theme_loader.c 2010-01-05 20:06:27 +0000 > +++ grub-core/gfxmenu/theme_loader.c 2010-12-10 15:32:00 +0000 > @@ -135,11 +135,11 @@ theme_set_string (grub_gfxmenu_view_t vi > return grub_errno; > } > else if (! grub_strcmp ("title-color", name)) > - grub_gui_parse_color (value, &view->title_color); > + grub_video_parse_color (value, &view->title_color); > else if (! grub_strcmp ("message-color", name)) > - grub_gui_parse_color (value, &view->message_color); > + grub_video_parse_color (value, &view->message_color); > else if (! grub_strcmp ("message-bg-color", name)) > - grub_gui_parse_color (value, &view->message_bg_color); > + grub_video_parse_color (value, &view->message_bg_color); > else if (! grub_strcmp ("desktop-image", name)) > { > struct grub_video_bitmap *raw_bitmap; > @@ -170,7 +170,7 @@ theme_set_string (grub_gfxmenu_view_t vi > view->desktop_image =3D scaled_bitmap; > } > else if (! grub_strcmp ("desktop-color", name)) > - grub_gui_parse_color (value, &view->desktop_color); > + grub_video_parse_color (value, &view->desktop_color); > else if (! grub_strcmp ("terminal-box", name)) > { > grub_err_t err; > > =3D=3D=3D modified file 'grub-core/gfxmenu/view.c' > --- grub-core/gfxmenu/view.c 2010-10-16 20:16:52 +0000 > +++ grub-core/gfxmenu/view.c 2010-12-10 15:29:48 +0000 > @@ -50,8 +50,8 @@ grub_gfxmenu_view_new (const char *theme > { > grub_gfxmenu_view_t view; > grub_font_t default_font; > - grub_gui_color_t default_fg_color; > - grub_gui_color_t default_bg_color; > + grub_video_rgba_color_t default_fg_color; > + grub_video_rgba_color_t default_bg_color; > =20 > view =3D grub_malloc (sizeof (*view)); > if (! view) > @@ -63,8 +63,8 @@ grub_gfxmenu_view_new (const char *theme > view->screen.height =3D height; > =20 > default_font =3D grub_font_get ("Unknown Regular 16"); > - default_fg_color =3D grub_gui_color_rgb (0, 0, 0); > - default_bg_color =3D grub_gui_color_rgb (255, 255, 255); > + default_fg_color =3D grub_video_rgba_color_rgb (0, 0, 0); > + default_bg_color =3D grub_video_rgba_color_rgb (255, 255, 255); > =20 > view->canvas =3D 0; > =20 > @@ -131,7 +131,7 @@ redraw_background (grub_gfxmenu_view_t v > } > else > { > - grub_video_fill_rect (grub_gui_map_color (view->desktop_color), > + grub_video_fill_rect (grub_video_map_rgba_color (view->desktop_c= olor), > bounds->x, bounds->y, > bounds->width, bounds->height); > } > @@ -150,7 +150,7 @@ draw_title (grub_gfxmenu_view_t view) > int y =3D 40 + grub_font_get_ascent (view->title_font); > grub_font_draw_string (view->title_text, > view->title_font, > - grub_gui_map_color (view->title_color), > + grub_video_map_rgba_color (view->title_color)= , > x, y); > } > =20 > @@ -244,13 +244,13 @@ draw_message (grub_gfxmenu_view_t view) > return; > =20 > grub_font_t font =3D view->message_font; > - grub_video_color_t color =3D grub_gui_map_color (view->message_color= ); > + grub_video_color_t color =3D grub_video_map_rgba_color (view->messag= e_color); > =20 > /* Border. */ > grub_video_fill_rect (color, > f.x-1, f.y-1, f.width+2, f.height+2); > /* Fill. */ > - grub_video_fill_rect (grub_gui_map_color (view->message_bg_color), > + grub_video_fill_rect (grub_video_map_rgba_color (view->message_bg_co= lor), > f.x, f.y, f.width, f.height); > =20 > /* Center the text. */ > > =3D=3D=3D modified file 'grub-core/term/gfxterm.c' > --- grub-core/term/gfxterm.c 2010-09-14 21:06:01 +0000 > +++ grub-core/term/gfxterm.c 2010-12-23 12:15:40 +0000 > @@ -128,6 +128,7 @@ static struct grub_video_render_target * > static unsigned int bitmap_width; > static unsigned int bitmap_height; > static struct grub_video_bitmap *bitmap; > +static int blend_text_bg; > =20 > static struct grub_dirty_region dirty_region; > =20 > @@ -344,6 +345,7 @@ grub_gfxterm_fullscreen (void) > grub_video_fill_rect (color, 0, 0, mode_info.width, mode_info.he= ight); > } > bitmap =3D 0; > + blend_text_bg =3D 0; > =20 > /* Select the font to use. */ > font_name =3D grub_env_get ("gfxterm_font"); > @@ -396,6 +398,7 @@ destroy_window (void) > { > grub_video_bitmap_destroy (bitmap); > bitmap =3D 0; > + blend_text_bg =3D 0; > } > =20 > repaint_callback =3D 0; > @@ -481,26 +484,27 @@ redraw_screen_rect (unsigned int x, unsi > /* Render background layer. */ > grub_video_fill_rect (color, x, ty, width, h); > } > - > - /* Render text layer as blended. */ > - grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND= , x, y, > - x - virtual_screen.offset_x, > - y - virtual_screen.offset_y, > - width, height); > } > else > { > /* Render background layer. */ > color =3D virtual_screen.bg_color_display; > grub_video_fill_rect (color, x, y, width, height); > - > - /* Render text layer as replaced (to get texts background color)= =2E */ > - grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_REPLA= CE, x, y, > - x - virtual_screen.offset_x, > - y - virtual_screen.offset_y, > - width, height); > } > =20 > + if (blend_text_bg) > + /* Render text layer as blended. */ > + grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, = x, y, > + x - virtual_screen.offset_x, > + y - virtual_screen.offset_y, > + width, height); > + else > + /* Render text layer as replaced (to get texts background color). = */ > + grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_REPLACE= , x, y, > + x - virtual_screen.offset_x, > + y - virtual_screen.offset_y, > + width, height); > + > /* Restore saved viewport. */ > grub_video_set_viewport (saved_view.x, saved_view.y, > saved_view.width, saved_view.height); > @@ -539,10 +543,20 @@ dirty_region_add (int x, int y, unsigned > =20 > if (repaint_scheduled) > { > - x =3D virtual_screen.offset_x; > - y =3D virtual_screen.offset_y; > - width =3D virtual_screen.width; > - height =3D virtual_screen.height; > + if (x > (int)virtual_screen.offset_x) > + { > + width +=3D virtual_screen.offset_x - x; > + x =3D virtual_screen.offset_x; > + } > + if (y > (int)virtual_screen.offset_y) > + { > + height +=3D virtual_screen.offset_y - y; > + y =3D virtual_screen.offset_y; > + } > + if (width < virtual_screen.width) > + width =3D virtual_screen.width; > + if (height < virtual_screen.height) > + height =3D virtual_screen.height; > repaint_scheduled =3D 0; > repaint_was_scheduled =3D 1; > } > @@ -1127,6 +1141,7 @@ grub_gfxterm_background_image_cmd (grub_ > { > grub_video_bitmap_destroy (bitmap); > bitmap =3D 0; > + blend_text_bg =3D 0; > =20 > /* Mark whole screen as dirty. */ > dirty_region_add (0, 0, window.width, window.height); > @@ -1159,6 +1174,7 @@ grub_gfxterm_background_image_cmd (grub_ > /* Replace the original bitmap with the scaled one= =2E */ > grub_video_bitmap_destroy (bitmap); > bitmap =3D scaled_bitmap; > + blend_text_bg =3D 1; > } > } > } > @@ -1180,6 +1196,48 @@ grub_gfxterm_background_image_cmd (grub_ > return grub_errno; > } > =20 > +static grub_err_t > +grub_gfxterm_background_color_cmd (grub_command_t cmd __attribute__ ((= unused)), > + int argc, char **args) > +{ > + grub_video_rgba_color_t color; > + struct grub_video_render_target *old_target; > + > + if (argc !=3D 1) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand"); > + > + /* Check that we have video adapter active. */ > + if (grub_video_get_info (NULL) !=3D GRUB_ERR_NONE) > + return grub_errno; > + > + if (grub_video_parse_color (args[0], &color) !=3D GRUB_ERR_NONE) > + return grub_errno; > + > + /* Destroy existing background bitmap if loaded. */ > + if (bitmap) > + { > + grub_video_bitmap_destroy (bitmap); > + bitmap =3D 0; > + > + /* Mark whole screen as dirty. */ > + dirty_region_add (0, 0, window.width, window.height); > + } > + > + /* Set the background and border colors. The background color needs= to be > + compatible with the text layer. */ > + grub_video_get_active_render_target (&old_target); > + grub_video_set_active_render_target (text_layer); > + virtual_screen.bg_color =3D grub_video_map_rgba_color (color); > + grub_video_set_active_render_target (old_target); > + virtual_screen.bg_color_display =3D grub_video_map_rgba_color (color= ); > + blend_text_bg =3D 1; > + > + /* Mark whole screen as dirty. */ > + dirty_region_add (0, 0, window.width, window.height); > + > + return GRUB_ERR_NONE; > +} > + > static struct grub_term_output grub_video_term =3D > { > .name =3D "gfxterm", > @@ -1201,6 +1259,7 @@ static struct grub_term_output grub_vide > }; > =20 > static grub_extcmd_t background_image_cmd_handle; > +static grub_command_t background_color_cmd_handle; > =20 > GRUB_MOD_INIT(gfxterm) > { > @@ -1211,10 +1270,16 @@ GRUB_MOD_INIT(gfxterm) > N_("[-m (stretch|normal)] FILE"), > N_("Load background image for active termina= l."), > background_image_cmd_options); > + background_color_cmd_handle =3D > + grub_register_command ("background_color", > + grub_gfxterm_background_color_cmd, > + N_("COLOR"), > + N_("Set background color for active termina= l.")); > } > =20 > GRUB_MOD_FINI(gfxterm) > { > + grub_unregister_command (background_color_cmd_handle); > grub_unregister_extcmd (background_image_cmd_handle); > grub_term_unregister_output (&grub_video_term); > } > > =3D=3D=3D renamed file 'grub-core/gfxmenu/named_colors.c' =3D> 'grub-co= re/video/colors.c' > --- grub-core/gfxmenu/named_colors.c 2009-11-20 15:02:58 +0000 > +++ grub-core/video/colors.c 2010-12-10 15:31:32 +0000 > @@ -25,7 +25,7 @@ > struct named_color > { > const char *name; > - grub_gui_color_t color; > + grub_video_rgba_color_t color; > }; > =20 > /* > @@ -193,8 +193,8 @@ static struct named_color named_colors[] > stores the color into *COLOR. If the color was not found, returns = 0 and > does not modify *COLOR. */ > int > -grub_gui_get_named_color (const char *name, > - grub_gui_color_t *color) > +grub_video_get_named_color (const char *name, > + grub_video_rgba_color_t *color) > { > int i; > for (i =3D 0; named_colors[i].name; i++) > @@ -207,3 +207,124 @@ grub_gui_get_named_color (const char *na > } > return 0; > } > + > +static __inline int > +my_isxdigit (char c) > +{ > + return ((c >=3D '0' && c <=3D '9') > + || (c >=3D 'a' && c <=3D 'f') > + || (c >=3D 'A' && c <=3D 'F')); > +} > + > +static int > +parse_hex_color_component (const char *s, unsigned start, unsigned end= ) > +{ > + unsigned len; > + char buf[3]; > + > + len =3D end - start; > + /* Check the limits so we don't overrun the buffer. */ > + if (len < 1 || len > 2) > + return 0; > + > + if (len =3D=3D 1) > + { > + buf[0] =3D s[start]; /* Get the first and only hex digit. */ > + buf[1] =3D buf[0]; /* Duplicate the hex digit. */ > + } > + else if (len =3D=3D 2) > + { > + buf[0] =3D s[start]; > + buf[1] =3D s[start + 1]; > + } > + > + buf[2] =3D '\0'; > + > + return grub_strtoul (buf, 0, 16); > +} > + > +/* Parse a color string of the form "r, g, b", "#RGB", "#RGBA", > + "#RRGGBB", or "#RRGGBBAA". */ > +grub_err_t > +grub_video_parse_color (const char *s, grub_video_rgba_color_t *color)= > +{ > + grub_video_rgba_color_t c; > + > + /* Skip whitespace. */ > + while (*s && grub_isspace (*s)) > + s++; > + > + if (*s =3D=3D '#') > + { > + /* HTML-style. Number if hex digits: > + [6] #RRGGBB [3] #RGB > + [8] #RRGGBBAA [4] #RGBA */ > + > + s++; /* Skip the '#'. */ > + /* Count the hexits to determine the format. */ > + int hexits =3D 0; > + const char *end =3D s; > + while (my_isxdigit (*end)) > + { > + end++; > + hexits++; > + } > + > + /* Parse the color components based on the format. */ > + if (hexits =3D=3D 3 || hexits =3D=3D 4) > + { > + c.red =3D parse_hex_color_component (s, 0, 1); > + c.green =3D parse_hex_color_component (s, 1, 2); > + c.blue =3D parse_hex_color_component (s, 2, 3); > + if (hexits =3D=3D 4) > + c.alpha =3D parse_hex_color_component (s, 3, 4); > + else > + c.alpha =3D 255; > + } > + else if (hexits =3D=3D 6 || hexits =3D=3D 8) > + { > + c.red =3D parse_hex_color_component (s, 0, 2); > + c.green =3D parse_hex_color_component (s, 2, 4); > + c.blue =3D parse_hex_color_component (s, 4, 6); > + if (hexits =3D=3D 8) > + c.alpha =3D parse_hex_color_component (s, 6, 8); > + else > + c.alpha =3D 255; > + } > + else > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + "invalid HTML-type color string `%s'", s); > + } > + else if (grub_isdigit (*s)) > + { > + /* Comma separated decimal values. */ > + c.red =3D grub_strtoul (s, 0, 0); > + if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + "missing 1st comma separator in color `%s'"= , s); > + s++; > + c.green =3D grub_strtoul (s, 0, 0); > + if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + "missing 2nd comma separator in color `%s'"= , s); > + s++; > + c.blue =3D grub_strtoul (s, 0, 0); > + if ((s =3D grub_strchr (s, ',')) =3D=3D 0) > + c.alpha =3D 255; > + else > + { > + s++; > + c.alpha =3D grub_strtoul (s, 0, 0); > + } > + } > + else > + { > + if (! grub_video_get_named_color (s, &c)) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + "invalid named color `%s'", s); > + } > + > + if (grub_errno =3D=3D GRUB_ERR_NONE) > + *color =3D c; > + return grub_errno; > +} > > =3D=3D=3D modified file 'include/grub/gfxmenu_view.h' > --- include/grub/gfxmenu_view.h 2010-03-23 17:17:54 +0000 > +++ include/grub/gfxmenu_view.h 2010-12-10 15:28:54 +0000 > @@ -87,11 +87,11 @@ struct grub_gfxmenu_view > grub_font_t title_font; > grub_font_t message_font; > char *terminal_font_name; > - grub_gui_color_t title_color; > - grub_gui_color_t message_color; > - grub_gui_color_t message_bg_color; > + grub_video_rgba_color_t title_color; > + grub_video_rgba_color_t message_color; > + grub_video_rgba_color_t message_bg_color; > struct grub_video_bitmap *desktop_image; > - grub_gui_color_t desktop_color; > + grub_video_rgba_color_t desktop_color; > grub_gfxmenu_box_t terminal_box; > char *title_text; > char *progress_message_text; > > =3D=3D=3D modified file 'include/grub/gui.h' > --- include/grub/gui.h 2010-05-13 01:56:14 +0000 > +++ include/grub/gui.h 2010-12-10 15:27:20 +0000 > @@ -31,16 +31,6 @@ > status changes. */ > #define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__" > =20 > -/* A representation of a color. Unlike grub_video_color_t, this > - representation is independent of any video mode specifics. */ > -typedef struct grub_gui_color > -{ > - grub_uint8_t red; > - grub_uint8_t green; > - grub_uint8_t blue; > - grub_uint8_t alpha; > -} grub_gui_color_t; > - > typedef struct grub_gui_component *grub_gui_component_t; > typedef struct grub_gui_container *grub_gui_container_t; > typedef struct grub_gui_list *grub_gui_list_t; > @@ -242,23 +232,6 @@ grub_gui_set_viewport (const grub_video_ > r->height); > } > =20 > -static __inline grub_gui_color_t > -grub_gui_color_rgb (int r, int g, int b) > -{ > - grub_gui_color_t c; > - c.red =3D r; > - c.green =3D g; > - c.blue =3D b; > - c.alpha =3D 255; > - return c; > -} > - > -static __inline grub_video_color_t > -grub_gui_map_color (grub_gui_color_t c) > -{ > - return grub_video_map_rgba (c.red, c.green, c.blue, c.alpha); > -} > - > static inline int > grub_video_have_common_points (const grub_video_rect_t *a, > const grub_video_rect_t *b) > > =3D=3D=3D modified file 'include/grub/gui_string_util.h' > --- include/grub/gui_string_util.h 2009-12-29 16:31:02 +0000 > +++ include/grub/gui_string_util.h 2010-12-10 15:25:37 +0000 > @@ -30,8 +30,4 @@ char *grub_resolve_relative_path (const > =20 > char *grub_get_dirname (const char *file_path); > =20 > -int grub_gui_get_named_color (const char *name, grub_gui_color_t *colo= r); > - > -grub_err_t grub_gui_parse_color (const char *s, grub_gui_color_t *colo= r); > - > #endif /* GRUB_GUI_STRING_UTIL_HEADER */ > > =3D=3D=3D modified file 'include/grub/video.h' > --- include/grub/video.h 2010-09-12 00:09:09 +0000 > +++ include/grub/video.h 2010-12-10 15:35:07 +0000 > @@ -27,6 +27,15 @@ > specific coding format. */ > typedef grub_uint32_t grub_video_color_t; > =20 > +/* Video color in hardware independent format. */ > +typedef struct grub_video_rgba_color > +{ > + grub_uint8_t red; > + grub_uint8_t green; > + grub_uint8_t blue; > + grub_uint8_t alpha; > +} grub_video_rgba_color_t; > + > /* This structure is driver specific and should not be accessed direct= ly by > outside code. */ > struct grub_video_render_target; > @@ -428,4 +437,27 @@ grub_video_check_mode_flag (grub_video_m > =20 > grub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id) (void); > =20 > +static __inline grub_video_rgba_color_t > +grub_video_rgba_color_rgb (int r, int g, int b) > +{ > + grub_video_rgba_color_t c; > + c.red =3D r; > + c.green =3D g; > + c.blue =3D b; > + c.alpha =3D 255; > + return c; > +} > + > +static __inline grub_video_color_t > +grub_video_map_rgba_color (grub_video_rgba_color_t c) > +{ > + return grub_video_map_rgba (c.red, c.green, c.blue, c.alpha); > +} > + > +int EXPORT_FUNC (grub_video_get_named_color) (const char *name, > + grub_video_rgba_color_t *color); > + > +grub_err_t EXPORT_FUNC (grub_video_parse_color) (const char *s, > + grub_video_rgba_color_t *color); > + > #endif /* ! GRUB_VIDEO_HEADER */ > > Thanks, > > =20 --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig8D8D426192AF9046A4BC33CA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk0V1NwACgkQNak7dOguQgkFkQD+Oi3UcZJrtVchv6h48L66zhwn DfplQEzW7g8J8pPxrm4BAMB9dyQ8ZmeagRFK/Z2Q4z0W7U552DWOuhNoR9RtVil0 =rvI9 -----END PGP SIGNATURE----- --------------enig8D8D426192AF9046A4BC33CA--