Skip to contentSkip to conversation

Background support for gfxterm and improved scrolling performance.

PATCH In review Vesa Jääskeläinen 2 participants 3 messages Dec 30, 2007 – Jan 1, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Background support for gfxterm and improved scrolling performance.

Hi All,

Here is a patch that adds background image support to gfxterm. At same time I added some small optimizations that didn't need any extra memory. I also added some new commands to video subsystem interface to make it more easier to use it.

There are still some issues about saving and restoring state for video adapter that I think should be added but are still not there. Eg. trying different adapter/mode that is not working correctly and then restoring back to working configuration.

This patch should also fix Robert's problem with menu colors.

To make it absolute clear this patch does NOT make graphical menu, it is just to meet demands for background image support while waiting for the implementation ;).

Usage:

insmod video
insmod vbe
insmod gfxterm
insmod tga

terminal gfxterm

background_image <your tga file>

Thanks,
Vesa Jääskeläinen

Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.461

ChangeLog +51 -0
diff -u -p -1 -r1.461 ChangeLog
@@ -1 +1,52 @@
+2007-12-30  Vesa Jaaskelainen  <[email protected]>
+
+	* include/grub/video.h: Added grub_video_unmap_color and 
+	grub_video_get_active_render_target.
+	(grub_video_adapter): Added unmap_color and get_active_render_target.
+
+	* video/video.c: Added grub_video_unmap_color and 
+	grub_video_get_active_render_target.
+	(grub_video_get_info): Changed method to accept NULL pointer as an
+	argument to allow detection of active video adapter.
+
+	* video/i386/pc/vbe.c: Renamed grub_video_vbe_unmap_color as
+	grub_video_vbe_unmap_color_int.
+	Added grub_video_vbe_unmap_color and
+	grub_video_vbe_get_active_render_target.
+	(grub_video_vbe_adapter): Added unmap_color and
+	get_active_render_target.
+
+	* video/i386/pc/vbeblit.c: Replaced grub_video_vbe_unmap_color usage 
+	with grub_video_vbe_unmap_color_int.
+
+	* term/gfxterm.c (DEFAULT_STANDARD_COLOR): Added.
+	(DEFAULT_NORMAL_COLOR): Likewise.
+	(DEFAULT_HIGHLIGHT_COLOR) Likewise.
+	(DEFAULT_FG_COLOR): Removed.
+	(DEFAULT_BG_COLOR): Likewise.
+	(DEFAULT_CURSOR_COLOR): Changed value.
+	(grub_virtual_screen): Added standard_color_setting,
+	normal_color_setting, highlight_color_setting and term_color.
+	(grub_virtual_screen): Removed fg_color_setting and bg_color_setting.
+	(bitmap_width): Added.
+	(bitmap_height): Likewise.
+	(bitmap): Likewise.
+	(set_term_color): Likewise.
+	(grub_virtual_screen_setup): Changed to use new terminal coloring
+	settings.
+	(grub_gfxterm_init): Added init for bitmap.
+	(grub_gfxterm_fini): Added destroy for bitmap.
+	(redraw_screen_rect): Updated to use background bitmap and new
+	terminal coloring.
+	(scroll_up): Added optimization for case when there is no bitmap.
+	(grub_gfxterm_cls): Fixed to use correct background color.
+	(grub_virtual_screen_setcolorstate): Changed to use new terminal
+	coloring.
+	(grub_virtual_screen_setcolor): Likewise.
+	(grub_virtual_screen_getcolor): Added.
+	(grub_gfxterm_background_image_cmd): Likewise.
+	(grub_video_term): Added setcolor and getcolor.
+	(MOD_INIT): Added registration of background_image command.
+	(MOD_TERM): Added unregistration for background_image command.
+
 2007-12-30  Pavel Roskin  <[email protected]>

Index: include/grub/video.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/video.h,v retrieving revision 1.7

grub/video.h +12 -0
diff -u -p -1 -r1.7 video.h
@@ -175,2 +175,6 @@ struct grub_video_adapter
 
+  grub_err_t (*unmap_color) (grub_video_color_t color,
+                             grub_uint8_t *red, grub_uint8_t *green,
+                             grub_uint8_t *blue, grub_uint8_t *alpha);
+
   grub_err_t (*fill_rect) (grub_video_color_t color, int x, int y,
@@ -203,2 +207,4 @@ struct grub_video_adapter
 
+  grub_err_t (*get_active_render_target) (struct grub_video_render_target **target);
+
   /* The next video adapter.  */
@@ -241,2 +247,6 @@ grub_video_color_t grub_video_map_rgba (
 
+grub_err_t grub_video_unmap_color (grub_video_color_t color,
+                                   grub_uint8_t *red, grub_uint8_t *green,
+                                   grub_uint8_t *blue, grub_uint8_t *alpha);
+
 grub_err_t grub_video_fill_rect (grub_video_color_t color, int x, int y,
@@ -272,2 +282,4 @@ grub_err_t grub_video_set_active_render_
 
+grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
+
 #endif /* ! GRUB_VIDEO_HEADER */

Index: include/grub/i386/pc/vbe.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/i386/pc/vbe.h,v retrieving revision 1.9

grub/i386/pc/vbe.h +12 -4
diff -u -p -1 -r1.9 vbe.h
@@ -242,6 +242,14 @@ grub_video_color_t grub_video_vbe_map_rg
 
-void grub_video_vbe_unmap_color (struct grub_video_i386_vbeblit_info *source,
-                                 grub_video_color_t color, grub_uint8_t *red,
-                                 grub_uint8_t *green, grub_uint8_t *blue,
-                                 grub_uint8_t *alpha);
+grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color,
+                                       grub_uint8_t *red,
+                                       grub_uint8_t *green,
+                                       grub_uint8_t *blue,
+                                       grub_uint8_t *alpha);
+
+void grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info *source,
+                                     grub_video_color_t color,
+                                     grub_uint8_t *red,
+                                     grub_uint8_t *green,
+                                     grub_uint8_t *blue,
+                                     grub_uint8_t *alpha);
 

Index: term/gfxterm.c
===================================================================
RCS file: /sources/grub/grub2/term/gfxterm.c,v
retrieving revision 1.8

gfxterm.c +234 -24

301 lines not on this page · raw message

Index: video/video.c
===================================================================
RCS file: /sources/grub/grub2/video/video.c,v
retrieving revision 1.6

video.c +33 -0
diff -u -p -1 -r1.6 video.c
@@ -136,2 +136,9 @@ grub_video_get_info (struct grub_video_m
 
+  /* If mode_info is NULL just report that video adapter is active.  */
+  if (! mode_info)
+    {
+      grub_errno = GRUB_ERR_NONE;
+      return grub_errno;
+    }
+  
   return grub_video_adapter_active->get_info (mode_info);
@@ -262,2 +269,18 @@ grub_video_map_rgba (grub_uint8_t red, g
 
+/* Unmap video color back to RGBA components.  */
+grub_err_t
+grub_video_unmap_color (grub_video_color_t color, grub_uint8_t *red, 
+                        grub_uint8_t *green, grub_uint8_t *blue, 
+                        grub_uint8_t *alpha)
+{
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
+
+  return grub_video_adapter_active->unmap_color (color,
+                                                 red,
+                                                 green,
+                                                 blue,
+                                                 alpha);
+}
+
 /* Fill rectangle using specified color.  */
@@ -368,2 +391,12 @@ grub_video_set_active_render_target (str
 
+/* Get active render target.  */
+grub_err_t
+grub_video_get_active_render_target (struct grub_video_render_target **target)
+{
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
+
+  return grub_video_adapter_active->get_active_render_target (target);
+}
+
 /* Initialize Video API module.  */

Index: video/i386/pc/vbe.c
===================================================================
RCS file: /sources/grub/grub2/video/i386/pc/vbe.c,v retrieving revision 1.12

i386/pc/vbe.c +28 -4
diff -u -p -1 -r1.12 vbe.c
@@ -756,7 +756,21 @@ grub_video_vbe_map_rgba (grub_uint8_t re
 
+grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color,
+                                       grub_uint8_t *red, grub_uint8_t *green,
+                                       grub_uint8_t *blue, grub_uint8_t *alpha)
+{
+  struct grub_video_i386_vbeblit_info target_info;
+
+  target_info.mode_info = &render_target->mode_info;
+  target_info.data = render_target->data;
+
+  grub_video_vbe_unmap_color_int (&target_info, color, red, green, blue, alpha);
+  
+  return GRUB_ERR_NONE;
+}
+
 void
-grub_video_vbe_unmap_color (struct grub_video_i386_vbeblit_info * source,
-                            grub_video_color_t color,
-                            grub_uint8_t *red, grub_uint8_t *green,
-                            grub_uint8_t *blue, grub_uint8_t *alpha)
+grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info * source,
+                                grub_video_color_t color,
+                                grub_uint8_t *red, grub_uint8_t *green,
+                                grub_uint8_t *blue, grub_uint8_t *alpha)
 {
@@ -1512,2 +1526,10 @@ grub_video_vbe_set_active_render_target 
 
+static grub_err_t
+grub_video_vbe_get_active_render_target (struct grub_video_render_target **target)
+{
+  *target = render_target;
+  
+  return GRUB_ERR_NONE;
+}
+
 static struct grub_video_adapter grub_video_vbe_adapter =
@@ -1527,2 +1549,3 @@ static struct grub_video_adapter grub_vi
     .map_rgba = grub_video_vbe_map_rgba,
+    .unmap_color = grub_video_vbe_unmap_color,
     .fill_rect = grub_video_vbe_fill_rect,
@@ -1536,2 +1559,3 @@ static struct grub_video_adapter grub_vi
     .set_active_render_target = grub_video_vbe_set_active_render_target,
+    .get_active_render_target = grub_video_vbe_get_active_render_target,
 

Index: video/i386/pc/vbeblit.c
===================================================================
RCS file: /sources/grub/grub2/video/i386/pc/vbeblit.c,v retrieving revision 1.4

i386/pc/vbeblit.c +4 -4
diff -u -p -1 -r1.4 vbeblit.c
@@ -283,3 +283,3 @@ grub_video_i386_vbeblit_index_R8G8B8A8 (
 
-          grub_video_vbe_unmap_color (dst, *dstptr, &dr, &dg, &db, &da);
+          grub_video_vbe_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da);
 
@@ -483,3 +483,3 @@ grub_video_i386_vbeblit_blend (struct gr
           src_color = get_pixel (src, i + offset_x, j + offset_y);
-          grub_video_vbe_unmap_color (src, src_color, &src_red, &src_green,
+          grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green,
                                       &src_blue, &src_alpha);
@@ -499,3 +499,3 @@ grub_video_i386_vbeblit_blend (struct gr
 
-          grub_video_vbe_unmap_color (dst, dst_color, &dst_red,
+          grub_video_vbe_unmap_color_int (dst, dst_color, &dst_red,
                                       &dst_green, &dst_blue, &dst_alpha);
@@ -541,3 +541,3 @@ grub_video_i386_vbeblit_replace (struct 
       src_color = get_pixel (src, i + offset_x, j + offset_y);
-      grub_video_vbe_unmap_color (src, src_color, &src_red, &src_green,
+      grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green,
                                   &src_blue, &src_alpha);
#1 lore raw
Quoted 2 lines · Vesa Jääskeläinen

This patch should also fix Robert's problem with menu colors.

It does! Thanks Vesa

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
#2 lore raw
Quoted 4 lines · Robert Millan
Quoted 1 line · Vesa Jääskeläinen

This patch should also fix Robert's problem with menu colors.

It does! Thanks Vesa

In it went.