background_color command
PATCH 1/1 background_color command
This patch adds a background_color command to gfxterm, which is useful if you just want a simple background fill and don't want to have to worry about scaling a background image to the right size.
2010-12-10 Colin Watson <[email protected]>
* 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.
=== modified file 'grub-core/term/gfxterm.c'
term/gfxterm.c +77 -0
@@ -1180,6 +1180,76 @@ grub_gfxterm_background_image_cmd (grub_return grub_errno; } +static grub_err_t +grub_gfxterm_background_color_cmd (grub_command_t cmd __attribute__ ((unused)), +int argc,char **args) +{ +int i; +unsigned int j; +unsigned long raw_color; +grub_uint8_t red, green, blue; +grub_uint8_t *data; + +if (argc !=1 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,"missing operand" ); + +/* Check that we have video adapter active. */ +if (grub_video_get_info (NULL ) !=GRUB_ERR_NONE ) +return grub_errno; + +for (i =0 ; i <7 && args[0 ][i]; i++) +if ((args[0 ][i] <'0' || args[0 ][i] >'9' ) + && (args[0 ][i] <'a' || args[0 ][i] >'f' ) + && (args[0 ][i] <'A' || args[0 ][i] >'F' )) +break ; + +if (i !=6 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT , +"color `%s' is not in RRGGBB form" , args[0 ]); + + raw_color =grub_strtoul (args[0 ],0 ,16 ); + red = (raw_color >>16 ) &0xFF ; + green = (raw_color >>8 ) &0xFF ; + blue = raw_color &0xFF ; + +/* Destroy existing background bitmap if loaded. */ +if (bitmap) + { +grub_video_bitmap_destroy (bitmap); + bitmap =0 ; + +/* Mark whole screen as dirty. */ +dirty_region_add (0 ,0 , window.width, window.height); + } + +/* 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 !=GRUB_ERR_NONE ) +return grub_errno; + + data = bitmap->data; +for (j =0 ; j < window.height * window.width; j++) + { + *data++ = red; + *data++ = green; + *data++ = blue; + } + + bitmap_width = window.width; + bitmap_height = window.height; + +/* Set the border color. */ + virtual_screen.bg_color_display =grub_video_map_rgb (red, green, blue); + +/* Mark whole screen as dirty. */ +dirty_region_add (0 ,0 , window.width, window.height); + +/* All was ok. */ + grub_errno =GRUB_ERR_NONE ; +return grub_errno; +} +static struct grub_term_output grub_video_term = { .name ="gfxterm" ,
@@ -1201,6 +1271,7 @@ static struct grub_term_output grub_vide };static grub_extcmd_t background_image_cmd_handle; +static grub_command_t background_color_cmd_handle;GRUB_MOD_INIT (gfxterm) {
@@ -1211,10 +1282,16 @@ GRUB_MOD_INIT(gfxterm)N_ ("[-m (stretch|normal)] FILE" ),N_ ("Load background image for active terminal." ), background_image_cmd_options); + background_color_cmd_handle = +grub_register_command ("background_color" , + grub_gfxterm_background_color_cmd, +N_ ("RRGGBB" ), +N_ ("Set background color for active terminal." )); }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); }
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Quoted 10 lines · Colin Watson
This patch adds a
background_colorcommand to gfxterm, which is useful if you just want a simple background fill and don't want to have to worry about scaling a background image to the right size.2010-12-10 Colin Watson <[email protected]>
*
grub-core/term/gfxterm.c(grub_gfxterm_background_color_cmd): New function.
(GRUB_MOD_INIT): Registerbackground_colorcommand. (GRUB_MOD_FINI): Unregisterbackground_colorcommand.
Vladimir suggested on IRC that I should generalise the gfxmenu colour parsing code instead. Here's a patch that does this. I've pushed this to the parse-color branch here:
bzr+ssh://bzr.sv.gnu.org/grub/branches/parse-color/
2010-12-10 Colin Watson <[email protected]>
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_colors) [videomodules]: New module, containing 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.
=== modified file 'grub-core/Makefile.core.def'
Makefile.core.def +7 -1
@@ -178,6 +178,7 @@ kernel = { videoinkernel = io/bufio.c; videoinkernel = video/bitmap.c; videoinkernel = video/bitmap_scale.c; + videoinkernel = video/colors.c; videoinkernel = video/fb/fbblit.c; videoinkernel = video/fb/fbfill.c; videoinkernel = video/fb/fbutil.c;
@@ -1049,7 +1050,6 @@ module = { common = gfxmenu/gui_progress_bar.c; common = gfxmenu/gui_util.c; common = gfxmenu/gui_string_util.c; - common = gfxmenu/named_colors.c; }; module = {
@@ -1443,6 +1443,12 @@ module = { }; module = { + name = video_colors; + common = video/colors.c; + enable = videomodules; +}; + +module = { name = video_fb; common = video/fb/video_fb.c; common = video/fb/fbblit.c;
=== modified file 'grub-core/gfxmenu/gui_label.c'
gfxmenu/gui_label.c +3 -3
@@ -48,7 +48,7 @@ struct grub_gui_labelchar *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_vidgrub_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" ) ==0 ) { -grub_gui_parse_color (value, &self->color); +grub_video_parse_color (value, &self->color); }else if (grub_strcmp (name,"align" ) ==0 ) {
=== modified file 'grub-core/gfxmenu/gui_list.c'
gfxmenu/gui_list.c +8 -8
@@ -41,9 +41,9 @@ struct grub_gui_list_implint 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;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 = +grub_video_rgba_color_t text_color = ((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_text_space, (item_top + (item_height - (ascent + descent)) /2 + ascent));
@@ -429,7 +429,7 @@ list_set_property (void *vself, const ch }else if (grub_strcmp (name,"item_color" ) ==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" ) ==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_color) ==GRUB_ERR_NONE ) self->selected_item_color_set =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; self =grub_zalloc (sizeof (*self));if (! self)
@@ -574,7 +574,7 @@ grub_gui_list_new (void) self->visible =1 ; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); self->icon_width =32 ; self->icon_height =32 ;
=== modified file 'grub-core/gfxmenu/gui_progress_bar.c'
gfxmenu/gui_progress_bar.c +16 -15
@@ -40,10 +40,10 @@ struct grub_gui_progress_barint 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;char *theme_dir;int need_to_recreate_pixmaps;
@@ -109,7 +109,7 @@ draw_filled_rect_bar (grub_gui_progress_ f.height = self->bounds.height -2 ;/* 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 );
@@ -117,12 +117,12 @@ draw_filled_rect_bar (grub_gui_progress_int barwidth = (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);/* 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 = self->font; -grub_video_color_t text_color =grub_gui_map_color (self->text_color); +grub_video_color_t text_color = +grub_video_map_rgba_color (self->text_color);int width = self->bounds.width;int height = self->bounds.height;char *text;
@@ -298,19 +299,19 @@ progress_bar_set_property (void *vself, }else if (grub_strcmp (name,"text_color" ) ==0 ) { -grub_gui_parse_color (value, &self->text_color); +grub_video_parse_color (value, &self->text_color); }else if (grub_strcmp (name,"border_color" ) ==0 ) { -grub_gui_parse_color (value, &self->border_color); +grub_video_parse_color (value, &self->border_color); }else if (grub_strcmp (name,"bg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->bg_color); +grub_video_parse_color (value, &self->bg_color); }else if (grub_strcmp (name,"fg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->fg_color); +grub_video_parse_color (value, &self->fg_color); }else if (grub_strcmp (name,"bar_style" ) ==0 ) {
@@ -379,9 +380,9 @@ grub_gui_progress_bar_new (void) self->progress.component.ops = &progress_bar_ops; self->visible =1 ; self->font =grub_font_get ("Unknown Regular 16" ); -grub_gui_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; -grub_gui_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; -grub_gui_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; +grub_video_rgba_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; +grub_video_rgba_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; +grub_video_rgba_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; self->text_color = black; self->border_color = black; self->bg_color = gray;
=== modified file 'grub-core/gfxmenu/gui_string_util.c'
gfxmenu/gui_string_util.c +0 -121
124 lines not on this page · raw message
=== modified file 'grub-core/gfxmenu/theme_loader.c'
gfxmenu/theme_loader.c +4 -4
@@ -135,11 +135,11 @@ theme_set_string (grub_gfxmenu_view_t vireturn 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 = 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;
=== modified file 'grub-core/gfxmenu/view.c'
gfxmenu/view.c +8 -8
@@ -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; view =grub_malloc (sizeof (*view));if (! view)
@@ -63,8 +63,8 @@ grub_gfxmenu_view_new (const char *theme view->screen.height = height; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); - default_bg_color =grub_gui_color_rgb (255 ,255 ,255 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); + default_bg_color =grub_video_rgba_color_rgb (255 ,255 ,255 ); view->canvas =0 ;
@@ -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_color), bounds->x, bounds->y, bounds->width, bounds->height); }
@@ -150,7 +150,7 @@ draw_title (grub_gfxmenu_view_t view)int y =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); }
@@ -244,13 +244,13 @@ draw_message (grub_gfxmenu_view_t view)return ;grub_font_t font = view->message_font; -grub_video_color_t color =grub_gui_map_color (view->message_color); +grub_video_color_t color =grub_video_map_rgba_color (view->message_color);/* 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_color), f.x, f.y, f.width, f.height);/* Center the text. */
=== modified file 'grub-core/term/gfxterm.c'
term/gfxterm.c +63 -0
85 lines not on this page · raw message
=== renamed file 'grub-core/gfxmenu/named_colors.c' => 'grub-core/video/colors.c'
video/colors.c renamed from gfxmenu/named_colors.c +124 -3
142 lines not on this page · raw message
=== modified file 'include/grub/gfxmenu_view.h'
grub/gfxmenu_view.h +4 -4
@@ -87,11 +87,11 @@ struct grub_gfxmenu_viewgrub_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;
=== modified file 'include/grub/gui.h'
grub/gui.h +0 -27
@@ -31,16 +31,6 @@status changes. */ #define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__" -/* 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); } -static __inlinegrub_gui_color_t -grub_gui_color_rgb (int r,int g,int b) -{ -grub_gui_color_t c; - c.red = r; - c.green = g; - c.blue = b; - c.alpha =255 ; -return c; -} - -static __inlinegrub_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)
=== modified file 'include/grub/gui_string_util.h'
grub/gui_string_util.h +0 -4
@@ -30,8 +30,4 @@ char *grub_resolve_relative_path (constchar *grub_get_dirname (const char *file_path); -int grub_gui_get_named_color (const char *name,grub_gui_color_t *color); - -grub_err_t grub_gui_parse_color (const char *s,grub_gui_color_t *color); -#endif /* GRUB_GUI_STRING_UTIL_HEADER */
=== modified file 'include/grub/video.h'
grub/video.h +32 -0
@@ -27,6 +27,15 @@specific coding format. */ typedef grub_uint32_t grub_video_color_t ; +/* 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 directly by outside code. */ struct grub_video_render_target ;
@@ -428,4 +437,27 @@ grub_video_check_mode_flag (grub_video_mgrub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id ) (void ); +static __inlinegrub_video_rgba_color_t +grub_video_rgba_color_rgb (int r,int g,int b) +{ +grub_video_rgba_color_t c; + c.red = r; + c.green = g; + c.blue = b; + c.alpha =255 ; +return c; +} + +static __inlinegrub_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,
Signature · 1 line
Colin Watson [[email protected]]
Quoted 5 lines · Colin Watson
Vladimir suggested on IRC that I should generalise the gfxmenu colour parsing code instead. Here's a patch that does this. I've pushed this to the parse-color branch here:
bzr+ssh://bzr.sv.gnu.org/grub/branches/parse-color/
I applied an additional change on top of this, also pushed to that branch. This means that this sequence in grub.cfg works as intended:
terminal_output gfxterm
background_color 44,0,30
=== modified file 'ChangeLog.parse-color'
ChangeLog.parse-color +6 -0
@@ -39,3 +39,9 @@ function. (GRUB_MOD_INIT): Register background_color command. (GRUB_MOD_FINI): Unregister background_color command. + + 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.
=== modified file 'grub-core/term/gfxterm.c'
term/gfxterm.c +14 -4
@@ -539,10 +539,20 @@ dirty_region_add (int x, int y, unsignedif (repaint_scheduled) { - x = virtual_screen.offset_x; - y = virtual_screen.offset_y; - width = virtual_screen.width; - height = virtual_screen.height; +if (x > (int )virtual_screen.offset_x) + { + width += virtual_screen.offset_x - x; + x = virtual_screen.offset_x; + } +if (y > (int )virtual_screen.offset_y) + { + height += virtual_screen.offset_y - y; + y = virtual_screen.offset_y; + } +if (width < virtual_screen.width) + width = virtual_screen.width; +if (height < virtual_screen.height) + height = virtual_screen.height; repaint_scheduled =0 ; repaint_was_scheduled =1 ; }
Signature · 1 line
Colin Watson [[email protected]]
Makefile.core.def module = { · line 1449
Quoted 7 lines · Colin Watson
module = {
Makefile.core.def +4
-0+ name = video_colors; + common = video/colors.c; + enable = videomodules; +};
Both main users of video (gfxmenu and gfxterm) use color routines. So I feel like video/colors.c can go into video.mod
term/gfxterm.c grub_gfxterm_background_image_cmd (grub_ · line 1215
Quoted 7 lines
term/gfxterm.c +5
-0+/* 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 !=GRUB_ERR_NONE ) +return grub_errno;
You should check the return value and not grub_errno.
Quoted 2 lines
+
It would be more optimal if in this case the image would be saved simply 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.
term/gfxterm.c grub_gfxterm_background_image_cmd (grub_ · line 1224
Quoted 9 lines
term/gfxterm.c +8
-0+ data = bitmap->data; +for (i =0 ; i < window.height * window.width; i++) + { + *data++ = color.red; + *data++ = color.green; + *data++ = color.blue; + } +
grub_video_fill_rect is the function for such kind of operations.
term/gfxterm.c grub_gfxterm_background_image_cmd (grub_ · line 1235
Quoted 12 lines
term/gfxterm.c +11
-0+ bitmap_width = window.width; + bitmap_height = window.height; + +/* Set the border color. */ + virtual_screen.bg_color_display =grub_video_map_rgba_color (color); + +/* Mark whole screen as dirty. */ +dirty_region_add (0 ,0 , window.width, window.height); + +/* All was ok. */ + grub_errno =GRUB_ERR_NONE ;
You shouldn't discard grub_errno manually unless there is an error you want to ignore.
Quoted 2 lines
+ return
grub_errno;
I'd rather use return GRUB_ERR_NONE;
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Review
Quoted 5 lines · Colin Watson
module = {
(quoted diff) +4
-0+ name = video_colors; + common = video/colors.c; + enable = videomodules; +};Both main users of video (gfxmenu and gfxterm) use color routines. So I feel like
video/colors.ccan go into video.mod
Fixed.
Quoted 22 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+ /* 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 != GRUB_ERR_NONE) + return grub_errno;You should check the return value and not
grub_errno.Quoted 2 lines
+
It would be more optimal if in this case the image would be saved simply as the color rather than a filled array and use
grub_video_fill_rectwhen this image is supposed to be blitted. also it would be neat to be able to specify the bgcolor around non-stretched image.Review
Quoted 9 lines
(quoted diff) +8
-0+ data = bitmap->data; + for (i = 0; i < window.height * window.width; i++) + { + *data++ = color.red; + *data++ = color.green; + *data++ = color.blue; + } +
Quoted 1 line
grub_video_fill_rectis the function for such kind of operations.
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.
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ /* All was ok. */ + grub_errno = GRUB_ERR_NONE;You shouldn't discard
grub_errnomanually unless there is an error you want to ignore.Quoted 2 lines
+ return
grub_errno;I'd rather use return
GRUB_ERR_NONE;
Fixed.
Updated patch follows:
2010-12-23 Colin Watson <[email protected]>
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.
=== modified file 'grub-core/Makefile.core.def'
Makefile.core.def +2 -1
@@ -178,6 +178,7 @@ kernel = { videoinkernel = io/bufio.c; videoinkernel = video/bitmap.c; videoinkernel = video/bitmap_scale.c; + videoinkernel = video/colors.c; videoinkernel = video/fb/fbblit.c; videoinkernel = video/fb/fbfill.c; videoinkernel = video/fb/fbutil.c;
@@ -1049,7 +1050,6 @@ module = { common = gfxmenu/gui_progress_bar.c; common = gfxmenu/gui_util.c; common = gfxmenu/gui_string_util.c; - common = gfxmenu/named_colors.c; }; module = {
@@ -1454,6 +1454,7 @@ module = { module = { name = video; common = video/video.c; + common = video/colors.c; enable = videomodules; };
=== modified file 'grub-core/gfxmenu/gui_label.c'
gfxmenu/gui_label.c +3 -3
@@ -48,7 +48,7 @@ struct grub_gui_labelchar *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_vidgrub_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" ) ==0 ) { -grub_gui_parse_color (value, &self->color); +grub_video_parse_color (value, &self->color); }else if (grub_strcmp (name,"align" ) ==0 ) {
=== modified file 'grub-core/gfxmenu/gui_list.c'
gfxmenu/gui_list.c +8 -8
@@ -41,9 +41,9 @@ struct grub_gui_list_implint 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;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 = +grub_video_rgba_color_t text_color = ((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_text_space, (item_top + (item_height - (ascent + descent)) /2 + ascent));
@@ -429,7 +429,7 @@ list_set_property (void *vself, const ch }else if (grub_strcmp (name,"item_color" ) ==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" ) ==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_color) ==GRUB_ERR_NONE ) self->selected_item_color_set =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; self =grub_zalloc (sizeof (*self));if (! self)
@@ -574,7 +574,7 @@ grub_gui_list_new (void) self->visible =1 ; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); self->icon_width =32 ; self->icon_height =32 ;
=== modified file 'grub-core/gfxmenu/gui_progress_bar.c'
gfxmenu/gui_progress_bar.c +16 -15
@@ -40,10 +40,10 @@ struct grub_gui_progress_barint 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;char *theme_dir;int need_to_recreate_pixmaps;
@@ -109,7 +109,7 @@ draw_filled_rect_bar (grub_gui_progress_ f.height = self->bounds.height -2 ;/* 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 );
@@ -117,12 +117,12 @@ draw_filled_rect_bar (grub_gui_progress_int barwidth = (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);/* 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 = self->font; -grub_video_color_t text_color =grub_gui_map_color (self->text_color); +grub_video_color_t text_color = +grub_video_map_rgba_color (self->text_color);int width = self->bounds.width;int height = self->bounds.height;char *text;
@@ -298,19 +299,19 @@ progress_bar_set_property (void *vself, }else if (grub_strcmp (name,"text_color" ) ==0 ) { -grub_gui_parse_color (value, &self->text_color); +grub_video_parse_color (value, &self->text_color); }else if (grub_strcmp (name,"border_color" ) ==0 ) { -grub_gui_parse_color (value, &self->border_color); +grub_video_parse_color (value, &self->border_color); }else if (grub_strcmp (name,"bg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->bg_color); +grub_video_parse_color (value, &self->bg_color); }else if (grub_strcmp (name,"fg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->fg_color); +grub_video_parse_color (value, &self->fg_color); }else if (grub_strcmp (name,"bar_style" ) ==0 ) {
@@ -379,9 +380,9 @@ grub_gui_progress_bar_new (void) self->progress.component.ops = &progress_bar_ops; self->visible =1 ; self->font =grub_font_get ("Unknown Regular 16" ); -grub_gui_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; -grub_gui_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; -grub_gui_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; +grub_video_rgba_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; +grub_video_rgba_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; +grub_video_rgba_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; self->text_color = black; self->border_color = black; self->bg_color = gray;
=== modified file 'grub-core/gfxmenu/gui_string_util.c'
gfxmenu/gui_string_util.c +0 -121
124 lines not on this page · raw message
=== modified file 'grub-core/gfxmenu/theme_loader.c'
gfxmenu/theme_loader.c +4 -4
@@ -135,11 +135,11 @@ theme_set_string (grub_gfxmenu_view_t vireturn 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 = 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;
=== modified file 'grub-core/gfxmenu/view.c'
gfxmenu/view.c +8 -8
@@ -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; view =grub_malloc (sizeof (*view));if (! view)
@@ -63,8 +63,8 @@ grub_gfxmenu_view_new (const char *theme view->screen.height = height; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); - default_bg_color =grub_gui_color_rgb (255 ,255 ,255 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); + default_bg_color =grub_video_rgba_color_rgb (255 ,255 ,255 ); view->canvas =0 ;
@@ -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_color), bounds->x, bounds->y, bounds->width, bounds->height); }
@@ -150,7 +150,7 @@ draw_title (grub_gfxmenu_view_t view)int y =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); }
@@ -244,13 +244,13 @@ draw_message (grub_gfxmenu_view_t view)return ;grub_font_t font = view->message_font; -grub_video_color_t color =grub_gui_map_color (view->message_color); +grub_video_color_t color =grub_video_map_rgba_color (view->message_color);/* 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_color), f.x, f.y, f.width, f.height);/* Center the text. */
=== modified file 'grub-core/term/gfxterm.c'
term/gfxterm.c +81 -16
169 lines not on this page · raw message
=== renamed file 'grub-core/gfxmenu/named_colors.c' => 'grub-core/video/colors.c'
video/colors.c renamed from gfxmenu/named_colors.c +124 -3
142 lines not on this page · raw message
=== modified file 'include/grub/gfxmenu_view.h'
grub/gfxmenu_view.h +4 -4
@@ -87,11 +87,11 @@ struct grub_gfxmenu_viewgrub_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;
=== modified file 'include/grub/gui.h'
grub/gui.h +0 -27
@@ -31,16 +31,6 @@status changes. */ #define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__" -/* 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); } -static __inlinegrub_gui_color_t -grub_gui_color_rgb (int r,int g,int b) -{ -grub_gui_color_t c; - c.red = r; - c.green = g; - c.blue = b; - c.alpha =255 ; -return c; -} - -static __inlinegrub_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)
=== modified file 'include/grub/gui_string_util.h'
grub/gui_string_util.h +0 -4
@@ -30,8 +30,4 @@ char *grub_resolve_relative_path (constchar *grub_get_dirname (const char *file_path); -int grub_gui_get_named_color (const char *name,grub_gui_color_t *color); - -grub_err_t grub_gui_parse_color (const char *s,grub_gui_color_t *color); -#endif /* GRUB_GUI_STRING_UTIL_HEADER */
=== modified file 'include/grub/video.h'
grub/video.h +32 -0
@@ -27,6 +27,15 @@specific coding format. */ typedef grub_uint32_t grub_video_color_t ; +/* 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 directly by outside code. */ struct grub_video_render_target ;
@@ -428,4 +437,27 @@ grub_video_check_mode_flag (grub_video_mgrub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id ) (void ); +static __inlinegrub_video_rgba_color_t +grub_video_rgba_color_rgb (int r,int g,int b) +{ +grub_video_rgba_color_t c; + c.red = r; + c.green = g; + c.blue = b; + c.alpha =255 ; +return c; +} + +static __inlinegrub_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,
Signature · 1 line
Colin Watson [[email protected]]
Go ahead for experimental
Quoted 1,014 lines · Colin Watson
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Review
Quoted 6 lines · Colin Watson
module = {
(quoted diff) +4
-0+ name = video_colors; + common = video/colors.c; + enable = videomodules; +};Both main users of video (gfxmenu and gfxterm) use color routines. So I feel like
video/colors.ccan go into video.modFixed.
Quoted 27 lines
Review
Quoted 7 lines
(quoted diff) +5
-0+ /* 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 != GRUB_ERR_NONE) + return grub_errno;You should check the return value and not
grub_errno.Quoted 3 lines
+
It would be more optimal if in this case the image would be saved simply as the color rather than a filled array and use
grub_video_fill_rectwhen this image is supposed to be blitted. also it would be neat to be able to specify the bgcolor around non-stretched image.Review
Quoted 10 lines
(quoted diff) +8
-0+ data = bitmap->data; + for (i = 0; i < window.height * window.width; i++) + { + *data++ = color.red; + *data++ = color.green; + *data++ = color.blue; + } +Quoted 2 lines
grub_video_fill_rectis the function for such kind of operations.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.
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ /* All was ok. */ + grub_errno = GRUB_ERR_NONE;Quoted 8 lines
You shouldn't discard
grub_errnomanually unless there is an error you want to ignore.Quoted 3 lines
+ return
grub_errno;I'd rather use return
GRUB_ERR_NONE;Fixed.
Updated patch follows:
2010-12-23 Colin Watson <[email protected]>
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. Renamegrub_gui_get_named_colortogrub_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): Removegfxmenu/named_colors.c. (video) [videomodules]: Addvideo/colors.c.Add a
background_colorcommand.*
grub-core/term/gfxterm.c(grub_gfxterm_background_color_cmd): New function.
(GRUB_MOD_INIT): Registerbackground_colorcommand. (GRUB_MOD_FINI): Unregisterbackground_colorcommand. (redraw_screen_rect): Allow blend/replace of text layer to be controlled independently from whether there is a background bitmap. (grub_gfxterm_fullscreen): Changeblend_text_bgwhen 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.=== modified file 'grub-core/Makefile.core.def'
Makefile.core.def +2
-1@@ -178,6 +178,7 @@ kernel = { videoinkernel = io/bufio.c; videoinkernel = video/bitmap.c; videoinkernel = video/bitmap_scale.c; + videoinkernel = video/colors.c; videoinkernel = video/fb/fbblit.c; videoinkernel = video/fb/fbfill.c; videoinkernel = video/fb/fbutil.c;@@ -1049,7 +1050,6 @@ module = { common = gfxmenu/gui_progress_bar.c; common = gfxmenu/gui_util.c; common = gfxmenu/gui_string_util.c; - common = gfxmenu/named_colors.c; }; module = {@@ -1454,6 +1454,7 @@ module = { module = { name = video; common = video/video.c; + common = video/colors.c; enable = videomodules; };=== modified file '
grub-core/gfxmenu/gui_label.c'gfxmenu/gui_label.c +3
-3@@ -48,7 +48,7 @@ struct grub_gui_labelchar *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_vidgrub_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" ) ==0 ) { -grub_gui_parse_color (value, &self->color); +grub_video_parse_color (value, &self->color); }else if (grub_strcmp (name,"align" ) ==0 ) {=== modified file '
grub-core/gfxmenu/gui_list.c'gfxmenu/gui_list.c +8
-8@@ -41,9 +41,9 @@ struct grub_gui_list_implint 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;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 = +grub_video_rgba_color_t text_color = ((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_text_space, (item_top + (item_height - (ascent + descent)) /2 + ascent));@@ -429,7 +429,7 @@ list_set_property (void *vself, const ch }else if (grub_strcmp (name,"item_color" ) ==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" ) ==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_color) ==GRUB_ERR_NONE ) self->selected_item_color_set =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; self =grub_zalloc (sizeof (*self));if (! self)@@ -574,7 +574,7 @@ grub_gui_list_new (void) self->visible =1 ; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); self->icon_width =32 ; self->icon_height =32 ;=== modified file '
grub-core/gfxmenu/gui_progress_bar.c'gfxmenu/gui_progress_bar.c +16
-15@@ -40,10 +40,10 @@ struct grub_gui_progress_barint 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;char *theme_dir;int need_to_recreate_pixmaps;@@ -109,7 +109,7 @@ draw_filled_rect_bar (grub_gui_progress_ f.height = self->bounds.height -2 ;/* 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 );@@ -117,12 +117,12 @@ draw_filled_rect_bar (grub_gui_progress_int barwidth = (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);/* 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 = self->font; -grub_video_color_t text_color =grub_gui_map_color (self->text_color); +grub_video_color_t text_color = +grub_video_map_rgba_color (self->text_color);int width = self->bounds.width;int height = self->bounds.height;char *text;@@ -298,19 +299,19 @@ progress_bar_set_property (void *vself, }else if (grub_strcmp (name,"text_color" ) ==0 ) { -grub_gui_parse_color (value, &self->text_color); +grub_video_parse_color (value, &self->text_color); }else if (grub_strcmp (name,"border_color" ) ==0 ) { -grub_gui_parse_color (value, &self->border_color); +grub_video_parse_color (value, &self->border_color); }else if (grub_strcmp (name,"bg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->bg_color); +grub_video_parse_color (value, &self->bg_color); }else if (grub_strcmp (name,"fg_color" ) ==0 ) { -grub_gui_parse_color (value, &self->fg_color); +grub_video_parse_color (value, &self->fg_color); }else if (grub_strcmp (name,"bar_style" ) ==0 ) {@@ -379,9 +380,9 @@ grub_gui_progress_bar_new (void) self->progress.component.ops = &progress_bar_ops; self->visible =1 ; self->font =grub_font_get ("Unknown Regular 16" ); -grub_gui_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; -grub_gui_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; -grub_gui_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; +grub_video_rgba_color_t black = { .red =0 , .green =0 , .blue =0 , .alpha =255 }; +grub_video_rgba_color_t gray = { .red =128 , .green =128 , .blue =128 , .alpha =255 }; +grub_video_rgba_color_t lightgray = { .red =200 , .green =200 , .blue =200 , .alpha =255 }; self->text_color = black; self->border_color = black; self->bg_color = gray;=== modified file '
grub-core/gfxmenu/gui_string_util.c'gfxmenu/gui_string_util.c +0
-121@@ -204,124 +204,3 @@ grub_get_dirname (const char *file_path)return grub_new_substring (file_path,0 , last_slash +1 ); } - -static __inlineint -my_isxdigit (char c) -{ -return ((c >='0' && c <='9' ) - || (c >='a' && c <='f' ) - || (c >='A' && c <='F' )); -} - -static int -parse_hex_color_component (const char *s,unsigned start,unsigned end) -{ -unsigned len; -char buf[3 ]; - - len = end - start; -/* Check the limits so we don't overrun the buffer. */ -if (len <1 || len >2 ) -return 0 ; - -if (len ==1 ) - { - buf[0 ] = s[start];/* Get the first and only hex digit. */ - buf[1 ] = buf[0 ];/* Duplicate the hex digit. */ - } -else if (len ==2 ) - { - buf[0 ] = s[start]; - buf[1 ] = s[start +1 ]; - } - - buf[2 ] ='\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 =='#' ) - { -/* 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 =0 ; -const char *end = s; -while (my_isxdigit (*end)) - { - end++; - hexits++; - } - -/* Parse the color components based on the format. */ -if (hexits ==3 || hexits ==4 ) - { - c.red =parse_hex_color_component (s,0 ,1 ); - c.green =parse_hex_color_component (s,1 ,2 ); - c.blue =parse_hex_color_component (s,2 ,3 ); -if (hexits ==4 ) - c.alpha =parse_hex_color_component (s,3 ,4 ); -else - c.alpha =255 ; - } -else if (hexits ==6 || hexits ==8 ) - { - c.red =parse_hex_color_component (s,0 ,2 ); - c.green =parse_hex_color_component (s,2 ,4 ); - c.blue =parse_hex_color_component (s,4 ,6 ); -if (hexits ==8 ) - c.alpha =parse_hex_color_component (s,6 ,8 ); -else - c.alpha =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 =grub_strtoul (s,0 ,0 ); -if ((s =grub_strchr (s,',' )) ==0 ) -return grub_error (GRUB_ERR_BAD_ARGUMENT , -"missing 1st comma separator in color `%s'" , s); - s++; - c.green =grub_strtoul (s,0 ,0 ); -if ((s =grub_strchr (s,',' )) ==0 ) -return grub_error (GRUB_ERR_BAD_ARGUMENT , -"missing 2nd comma separator in color `%s'" , s); - s++; - c.blue =grub_strtoul (s,0 ,0 ); -if ((s =grub_strchr (s,',' )) ==0 ) - c.alpha =255 ; -else - { - s++; - c.alpha =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 ==GRUB_ERR_NONE ) - *color = c; -return grub_errno; -}=== modified file '
grub-core/gfxmenu/theme_loader.c'gfxmenu/theme_loader.c +4
-4@@ -135,11 +135,11 @@ theme_set_string (grub_gfxmenu_view_t vireturn 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 = 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;=== modified file '
grub-core/gfxmenu/view.c'gfxmenu/view.c +8
-8@@ -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; view =grub_malloc (sizeof (*view));if (! view)@@ -63,8 +63,8 @@ grub_gfxmenu_view_new (const char *theme view->screen.height = height; default_font =grub_font_get ("Unknown Regular 16" ); - default_fg_color =grub_gui_color_rgb (0 ,0 ,0 ); - default_bg_color =grub_gui_color_rgb (255 ,255 ,255 ); + default_fg_color =grub_video_rgba_color_rgb (0 ,0 ,0 ); + default_bg_color =grub_video_rgba_color_rgb (255 ,255 ,255 ); view->canvas =0 ;@@ -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_color), bounds->x, bounds->y, bounds->width, bounds->height); }@@ -150,7 +150,7 @@ draw_title (grub_gfxmenu_view_t view)int y =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); }@@ -244,13 +244,13 @@ draw_message (grub_gfxmenu_view_t view)return ;grub_font_t font = view->message_font; -grub_video_color_t color =grub_gui_map_color (view->message_color); +grub_video_color_t color =grub_video_map_rgba_color (view->message_color);/* 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_color), f.x, f.y, f.width, f.height);/* Center the text. */ === modified file '
grub-core/term/gfxterm.c'term/gfxterm.c +81
-16@@ -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;static struct grub_dirty_region dirty_region;@@ -344,6 +345,7 @@ grub_gfxterm_fullscreen (void)grub_video_fill_rect (color,0 ,0 , mode_info.width, mode_info.height); } bitmap =0 ; + blend_text_bg =0 ;/* Select the font to use. */ font_name =grub_env_get ("gfxterm_font" );@@ -396,6 +398,7 @@ destroy_window (void) {grub_video_bitmap_destroy (bitmap); bitmap =0 ; + blend_text_bg =0 ; } repaint_callback =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 = virtual_screen.bg_color_display;grub_video_fill_rect (color, x, y, width, height); - -/* 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); } +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, unsignedif (repaint_scheduled) { - x = virtual_screen.offset_x; - y = virtual_screen.offset_y; - width = virtual_screen.width; - height = virtual_screen.height; +if (x > (int )virtual_screen.offset_x) + { + width += virtual_screen.offset_x - x; + x = virtual_screen.offset_x; + } +if (y > (int )virtual_screen.offset_y) + { + height += virtual_screen.offset_y - y; + y = virtual_screen.offset_y; + } +if (width < virtual_screen.width) + width = virtual_screen.width; +if (height < virtual_screen.height) + height = virtual_screen.height; repaint_scheduled =0 ; repaint_was_scheduled =1 ; }@@ -1127,6 +1141,7 @@ grub_gfxterm_background_image_cmd (grub_ {grub_video_bitmap_destroy (bitmap); bitmap =0 ; + blend_text_bg =0 ;/* 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. */ grub_video_bitmap_destroy (bitmap); bitmap = scaled_bitmap; + blend_text_bg =1 ; } } }@@ -1180,6 +1196,48 @@ grub_gfxterm_background_image_cmd (grub_return grub_errno; } +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 !=1 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,"missing operand" ); + +/* Check that we have video adapter active. */ +if (grub_video_get_info (NULL ) !=GRUB_ERR_NONE ) +return grub_errno; + +if (grub_video_parse_color (args[0 ], &color) !=GRUB_ERR_NONE ) +return grub_errno; + +/* Destroy existing background bitmap if loaded. */ +if (bitmap) + { +grub_video_bitmap_destroy (bitmap); + bitmap =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 =grub_video_map_rgba_color (color); +grub_video_set_active_render_target (old_target); + virtual_screen.bg_color_display =grub_video_map_rgba_color (color); + blend_text_bg =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 = { .name ="gfxterm" ,@@ -1201,6 +1259,7 @@ static struct grub_term_output grub_vide };static grub_extcmd_t background_image_cmd_handle; +static grub_command_t background_color_cmd_handle;GRUB_MOD_INIT (gfxterm) {@@ -1211,10 +1270,16 @@ GRUB_MOD_INIT(gfxterm)N_ ("[-m (stretch|normal)] FILE" ),N_ ("Load background image for active terminal." ), background_image_cmd_options); + background_color_cmd_handle = +grub_register_command ("background_color" , + grub_gfxterm_background_color_cmd, +N_ ("COLOR" ), +N_ ("Set background color for active terminal." )); }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); }=== renamed file '
grub-core/gfxmenu/named_colors.c' => 'grub-core/video/colors.c'video/colors.c renamed from gfxmenu/named_colors.c +124
-3@@ -25,7 +25,7 @@struct named_color {const char *name; -grub_gui_color_t color; +grub_video_rgba_color_t color; };/* @@ -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 =0 ; named_colors[i].name; i++)@@ -207,3 +207,124 @@ grub_gui_get_named_color (const char *na }return 0 ; } + +static __inlineint +my_isxdigit (char c) +{ +return ((c >='0' && c <='9' ) + || (c >='a' && c <='f' ) + || (c >='A' && c <='F' )); +} + +static int +parse_hex_color_component (const char *s,unsigned start,unsigned end) +{ +unsigned len; +char buf[3 ]; + + len = end - start; +/* Check the limits so we don't overrun the buffer. */ +if (len <1 || len >2 ) +return 0 ; + +if (len ==1 ) + { + buf[0 ] = s[start];/* Get the first and only hex digit. */ + buf[1 ] = buf[0 ];/* Duplicate the hex digit. */ + } +else if (len ==2 ) + { + buf[0 ] = s[start]; + buf[1 ] = s[start +1 ]; + } + + buf[2 ] ='\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 =='#' ) + { +/* 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 =0 ; +const char *end = s; +while (my_isxdigit (*end)) + { + end++; + hexits++; + } + +/* Parse the color components based on the format. */ +if (hexits ==3 || hexits ==4 ) + { + c.red =parse_hex_color_component (s,0 ,1 ); + c.green =parse_hex_color_component (s,1 ,2 ); + c.blue =parse_hex_color_component (s,2 ,3 ); +if (hexits ==4 ) + c.alpha =parse_hex_color_component (s,3 ,4 ); +else + c.alpha =255 ; + } +else if (hexits ==6 || hexits ==8 ) + { + c.red =parse_hex_color_component (s,0 ,2 ); + c.green =parse_hex_color_component (s,2 ,4 ); + c.blue =parse_hex_color_component (s,4 ,6 ); +if (hexits ==8 ) + c.alpha =parse_hex_color_component (s,6 ,8 ); +else + c.alpha =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 =grub_strtoul (s,0 ,0 ); +if ((s =grub_strchr (s,',' )) ==0 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT , +"missing 1st comma separator in color `%s'" , s); + s++; + c.green =grub_strtoul (s,0 ,0 ); +if ((s =grub_strchr (s,',' )) ==0 ) +return grub_error (GRUB_ERR_BAD_ARGUMENT , +"missing 2nd comma separator in color `%s'" , s); + s++; + c.blue =grub_strtoul (s,0 ,0 ); +if ((s =grub_strchr (s,',' )) ==0 ) + c.alpha =255 ; +else + { + s++; + c.alpha =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 ==GRUB_ERR_NONE ) + *color = c; +return grub_errno; +}=== modified file '
include/grub/gfxmenu_view.h'grub/gfxmenu_view.h +4
-4@@ -87,11 +87,11 @@ struct grub_gfxmenu_viewgrub_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;=== modified file '
include/grub/gui.h'grub/gui.h +0
-27@@ -31,16 +31,6 @@status changes. */ #define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__" -/* 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); } -static __inlinegrub_gui_color_t -grub_gui_color_rgb (int r,int g,int b) -{ -grub_gui_color_t c; - c.red = r; - c.green = g; - c.blue = b; - c.alpha =255 ; -return c; -} - -static __inlinegrub_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)=== modified file '
include/grub/gui_string_util.h'grub/gui_string_util.h +0
-4@@ -30,8 +30,4 @@ char *grub_resolve_relative_path (constchar *grub_get_dirname (const char *file_path); -int grub_gui_get_named_color (const char *name,grub_gui_color_t *color); - -grub_err_t grub_gui_parse_color (const char *s,grub_gui_color_t *color); -#endif /* GRUB_GUI_STRING_UTIL_HEADER */ === modified file '
include/grub/video.h'grub/video.h +32
-0@@ -27,6 +27,15 @@specific coding format. */ typedef grub_uint32_t grub_video_color_t ; +/* 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 directly by outside code. */ struct grub_video_render_target ;@@ -428,4 +437,27 @@ grub_video_check_mode_flag (grub_video_mgrub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id ) (void ); +static __inlinegrub_video_rgba_color_t +grub_video_rgba_color_rgb (int r,int g,int b) +{ +grub_video_rgba_color_t c; + c.red = r; + c.green = g; + c.blue = b; + c.alpha =255 ; +return c; +} + +static __inlinegrub_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,
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko