2006-07-29 Vesa Jaaskelainen <chaac@nic.fi>

* include/grub/video.h: Code cleanup.

        * include/grub/i386/pc/vbe.h: Likewise.

        * video/i386/pc/vbe.c: Likewise.

        * video/i386/pc/vbeblit.c: Likewise.

        * video/i386/pc/vbefill.c: Likewise.

        * video/video.c: Likewise.  Also added more comments.
This commit is contained in:
chaac 2006-07-29 11:22:52 +00:00
parent 5915059b61
commit 684a8eff89
7 changed files with 316 additions and 339 deletions

View file

@ -1,3 +1,17 @@
2006-07-29 Vesa Jaaskelainen <chaac@nic.fi>
* include/grub/video.h: Code cleanup.
* include/grub/i386/pc/vbe.h: Likewise.
* video/i386/pc/vbe.c: Likewise.
* video/i386/pc/vbeblit.c: Likewise.
* video/i386/pc/vbefill.c: Likewise.
* video/video.c: Likewise. Also added more comments.
2006-07-29 Vesa Jaaskelainen <chaac@nic.fi>
* disk/i386/pc/biosdisk.c (struct grub_biosdisk_drp): Moved to ...

View file

@ -206,11 +206,9 @@ grub_err_t grub_vbe_get_video_mode_info (grub_uint32_t mode,
/* VBE module internal prototypes (should not be used from elsewhere). */
grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_render_target *source,
grub_uint32_t x,
grub_uint32_t y);
grub_uint32_t x, grub_uint32_t y);
grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red,
grub_uint8_t green,
grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue);
void grub_video_vbe_unmap_color (struct grub_video_render_target * source,

View file

@ -158,77 +158,51 @@ struct grub_video_adapter
/* Clean up the video adapter. */
grub_err_t (*fini) (void);
grub_err_t (*setup) (unsigned int width,
unsigned int height,
grub_err_t (*setup) (unsigned int width, unsigned int height,
unsigned int mode_type);
grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
grub_err_t (*set_palette) (unsigned int start,
unsigned int count,
grub_err_t (*set_palette) (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
grub_err_t (*get_palette) (unsigned int start,
unsigned int count,
grub_err_t (*get_palette) (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
grub_err_t (*set_viewport) (unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
grub_err_t (*set_viewport) (unsigned int x, unsigned int y,
unsigned int width, unsigned int height);
grub_err_t (*get_viewport) (unsigned int *x,
unsigned int *y,
unsigned int *width,
unsigned int *height);
grub_err_t (*get_viewport) (unsigned int *x, unsigned int *y,
unsigned int *width, unsigned int *height);
grub_video_color_t (*map_color) (grub_uint32_t color_name);
grub_video_color_t (*map_rgb) (grub_uint8_t red,
grub_uint8_t green,
grub_video_color_t (*map_rgb) (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue);
grub_video_color_t (*map_rgba) (grub_uint8_t red,
grub_uint8_t green,
grub_uint8_t blue,
grub_uint8_t alpha);
grub_video_color_t (*map_rgba) (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,
unsigned int width,
unsigned int height);
grub_err_t (*fill_rect) (grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height);
grub_err_t (*blit_glyph) (struct grub_font_glyph *glyph,
grub_video_color_t color,
int x,
int y);
grub_video_color_t color, int x, int y);
grub_err_t (*blit_bitmap) (struct grub_video_bitmap *bitmap,
int x,
int y,
int offset_x,
int offset_y,
unsigned int width,
unsigned int height);
int x, int y, int offset_x, int offset_y,
unsigned int width, unsigned int height);
grub_err_t (*blit_render_target) (struct grub_video_render_target *source,
int x,
int y,
int offset_x,
int offset_y,
unsigned int width,
unsigned int height);
int x, int y, int offset_x, int offset_y,
unsigned int width, unsigned int height);
grub_err_t (*scroll) (grub_video_color_t color,
int dx,
int dy);
grub_err_t (*scroll) (grub_video_color_t color, int dx, int dy);
grub_err_t (*swap_buffers) (void);
grub_err_t (*create_render_target) (struct grub_video_render_target **result,
unsigned int width,
unsigned int height,
unsigned int width, unsigned int height,
unsigned int mode_type);
grub_err_t (*delete_render_target) (struct grub_video_render_target *target);
@ -244,8 +218,7 @@ void grub_video_register (grub_video_adapter_t adapter);
void grub_video_unregister (grub_video_adapter_t adapter);
void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter));
grub_err_t grub_video_setup (unsigned int width,
unsigned int height,
grub_err_t grub_video_setup (unsigned int width, unsigned int height,
unsigned int mode_type);
grub_err_t grub_video_restore (void);
@ -254,65 +227,43 @@ grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
grub_err_t grub_video_set_palette (unsigned int start,
unsigned int count,
grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
grub_err_t grub_video_get_palette (unsigned int start,
unsigned int count,
grub_err_t grub_video_get_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
grub_err_t grub_video_set_viewport (unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_set_viewport (unsigned int x, unsigned int y,
unsigned int width, unsigned int height);
grub_err_t grub_video_get_viewport (unsigned int *x,
unsigned int *y,
unsigned int *width,
unsigned int *height);
grub_err_t grub_video_get_viewport (unsigned int *x, unsigned int *y,
unsigned int *width, unsigned int *height);
grub_video_color_t grub_video_map_color (grub_uint32_t color_name);
grub_video_color_t grub_video_map_rgb (grub_uint8_t red,
grub_uint8_t green,
grub_video_color_t grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue);
grub_video_color_t grub_video_map_rgba (grub_uint8_t red,
grub_uint8_t green,
grub_uint8_t blue,
grub_uint8_t alpha);
grub_video_color_t grub_video_map_rgba (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,
unsigned int width,
unsigned int height);
grub_err_t grub_video_fill_rect (grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height);
grub_err_t grub_video_blit_glyph (struct grub_font_glyph *glyph,
grub_video_color_t color,
int x,
int y);
grub_video_color_t color, int x, int y);
grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
int x,
int y,
int offset_x,
int offset_y,
unsigned int width,
unsigned int height);
int x, int y, int offset_x, int offset_y,
unsigned int width, unsigned int height);
grub_err_t grub_video_blit_render_target (struct grub_video_render_target *source,
int x,
int y,
int offset_x,
int offset_y,
int x, int y,
int offset_x, int offset_y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_scroll (grub_video_color_t color,
int dx,
int dy);
grub_err_t grub_video_scroll (grub_video_color_t color, int dx, int dy);
grub_err_t grub_video_swap_buffers (void);

View file

@ -238,15 +238,7 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
0,
palette);
/* For now, ignore the status. Not sure if this is fatal. */
#if 0
if (status != GRUB_VBE_STATUS_OK)
{
grub_vbe_bios_set_mode (old_mode, 0);
return grub_error (GRUB_ERR_BAD_DEVICE,
"cannot set the default VGA palette");
}
#endif
/* Just ignore the status. */
}
/* Copy mode info for caller. */

View file

@ -269,7 +269,6 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_render_target *dst,
}
}
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_render_target *dst,
struct grub_video_render_target *src,
@ -341,7 +340,6 @@ grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_render_target *dst,
}
}
void
grub_video_i386_vbeblit_index_index (struct grub_video_render_target *dst,
struct grub_video_render_target *src,

View file

@ -77,7 +77,6 @@ grub_video_i386_vbefill_R8G8B8 (struct grub_video_render_target *dst,
}
}
void
grub_video_i386_vbefill_index (struct grub_video_render_target *dst,
grub_video_color_t color, int x, int y,

View file

@ -27,6 +27,7 @@ static grub_video_adapter_t grub_video_adapter_list;
/* Active video adapter. */
static grub_video_adapter_t grub_video_adapter_active;
/* Register video driver. */
void
grub_video_register (grub_video_adapter_t adapter)
{
@ -34,6 +35,7 @@ grub_video_register (grub_video_adapter_t adapter)
grub_video_adapter_list = adapter;
}
/* Unregister video driver. */
void
grub_video_unregister (grub_video_adapter_t adapter)
{
@ -47,6 +49,7 @@ grub_video_unregister (grub_video_adapter_t adapter)
}
}
/* Iterate thru all registered video drivers. */
void
grub_video_iterate (int (*hook) (grub_video_adapter_t adapter))
{
@ -57,6 +60,7 @@ grub_video_iterate (int (*hook) (grub_video_adapter_t adapter))
break;
}
/* Setup specified video mode. */
grub_err_t
grub_video_setup (unsigned int width, unsigned int height,
unsigned int mode_type)
@ -109,6 +113,7 @@ grub_video_setup (unsigned int width, unsigned int height,
"Can't locate valid adapter for mode");
}
/* Restore back to initial mode (where applicaple). */
grub_err_t
grub_video_restore (void)
{
@ -123,6 +128,7 @@ grub_video_restore (void)
return GRUB_ERR_NONE;
}
/* Get information about active video mode. */
grub_err_t
grub_video_get_info (struct grub_video_mode_info *mode_info)
{
@ -132,6 +138,7 @@ grub_video_get_info (struct grub_video_mode_info *mode_info)
return grub_video_adapter_active->get_info (mode_info);
}
/* Determine optimized blitting formation for specified video mode info. */
enum grub_video_blit_format
grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
{
@ -179,6 +186,7 @@ grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
return GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR;
}
/* Set new indexed color palette entries. */
grub_err_t
grub_video_set_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data)
@ -189,6 +197,7 @@ grub_video_set_palette (unsigned int start, unsigned int count,
return grub_video_adapter_active->set_palette (start, count, palette_data);
}
/* Get indexed color palette entries. */
grub_err_t
grub_video_get_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data)
@ -199,6 +208,7 @@ grub_video_get_palette (unsigned int start, unsigned int count,
return grub_video_adapter_active->get_palette (start, count, palette_data);
}
/* Set viewport dimensions. */
grub_err_t
grub_video_set_viewport (unsigned int x, unsigned int y,
unsigned int width, unsigned int height)
@ -209,6 +219,7 @@ grub_video_set_viewport (unsigned int x, unsigned int y,
return grub_video_adapter_active->set_viewport (x, y, width, height);
}
/* Get viewport dimensions. */
grub_err_t
grub_video_get_viewport (unsigned int *x, unsigned int *y,
unsigned int *width, unsigned int *height)
@ -219,6 +230,7 @@ grub_video_get_viewport (unsigned int *x, unsigned int *y,
return grub_video_adapter_active->get_viewport (x, y, width, height);
}
/* Map color name to adapter specific color. */
grub_video_color_t
grub_video_map_color (grub_uint32_t color_name)
{
@ -228,6 +240,7 @@ grub_video_map_color (grub_uint32_t color_name)
return grub_video_adapter_active->map_color (color_name);
}
/* Map RGB value to adapter specific color. */
grub_video_color_t
grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue)
{
@ -237,6 +250,7 @@ grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue)
return grub_video_adapter_active->map_rgb (red, green, blue);
}
/* Map RGBA value to adapter specific color. */
grub_video_color_t
grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue,
grub_uint8_t alpha)
@ -247,6 +261,7 @@ grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green, grub_uint8_t blue,
return grub_video_adapter_active->map_rgba (red, green, blue, alpha);
}
/* Fill rectangle using specified color. */
grub_err_t
grub_video_fill_rect (grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height)
@ -257,6 +272,7 @@ grub_video_fill_rect (grub_video_color_t color, int x, int y,
return grub_video_adapter_active->fill_rect (color, x, y, width, height);
}
/* Blit glyph to screen using specified color. */
grub_err_t
grub_video_blit_glyph (struct grub_font_glyph *glyph,
grub_video_color_t color, int x, int y)
@ -267,6 +283,7 @@ grub_video_blit_glyph (struct grub_font_glyph *glyph,
return grub_video_adapter_active->blit_glyph (glyph, color, x, y);
}
/* Blit bitmap to screen. */
grub_err_t
grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
int x, int y, int offset_x, int offset_y,
@ -280,6 +297,7 @@ grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
width, height);
}
/* Blit render target to active render target. */
grub_err_t
grub_video_blit_render_target (struct grub_video_render_target *target,
int x, int y, int offset_x, int offset_y,
@ -293,6 +311,7 @@ grub_video_blit_render_target (struct grub_video_render_target *target,
width, height);
}
/* Scroll viewport and fill new areas with specified color. */
grub_err_t
grub_video_scroll (grub_video_color_t color, int dx, int dy)
{
@ -302,6 +321,7 @@ grub_video_scroll (grub_video_color_t color, int dx, int dy)
return grub_video_adapter_active->scroll (color, dx, dy);
}
/* Swap buffers (swap active render target). */
grub_err_t
grub_video_swap_buffers (void)
{
@ -311,6 +331,7 @@ grub_video_swap_buffers (void)
return grub_video_adapter_active->swap_buffers ();
}
/* Create new render target. */
grub_err_t
grub_video_create_render_target (struct grub_video_render_target **result,
unsigned int width, unsigned int height,
@ -324,6 +345,7 @@ grub_video_create_render_target (struct grub_video_render_target **result,
mode_type);
}
/* Delete render target. */
grub_err_t
grub_video_delete_render_target (struct grub_video_render_target *target)
{
@ -333,6 +355,7 @@ grub_video_delete_render_target (struct grub_video_render_target *target)
return grub_video_adapter_active->delete_render_target (target);
}
/* Set active render target. */
grub_err_t
grub_video_set_active_render_target (struct grub_video_render_target *target)
{
@ -342,12 +365,14 @@ grub_video_set_active_render_target (struct grub_video_render_target *target)
return grub_video_adapter_active->set_active_render_target (target);
}
/* Initialize Video API module. */
GRUB_MOD_INIT(video_video)
{
grub_video_adapter_active = 0;
grub_video_adapter_list = 0;
}
/* Finalize Video API module. */
GRUB_MOD_FINI(video_video)
{
}