2008-09-07 Vesa Jääskeläinen <chaac@nic.fi>

Based on patch created by Colin D Bennett <colin@gibibit.com>.
	Adds optimization support for BGR based modes.

	* include/grub/i386/pc/vbeblit.h (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8) Removed.
	(grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8A8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_index_index): Likewise.
	(grub_video_i386_vbeblit_replace_directN): Added.
	(grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_BGRX8888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_BGR888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_BGR888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_RGBX8888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_RGB888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_index_RGBX8888): Likewise.	
	(grub_video_i386_vbeblit_replace_index_RGB888): Likewise.
	(grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_BGR888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_RGB888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_index_RGBA8888): Likewise.

	* include/grub/i386/pc/vbefill.h (grub_video_i386_vbefill_R8G8B8A8) Removed.
	(grub_video_i386_vbefill_R8G8B8): Likewise.
	(grub_video_i386_vbefill_index): Likewise.
	(grub_video_i386_vbefill_direct32): Added.
	(grub_video_i386_vbefill_direct24): Likewise.
	(grub_video_i386_vbefill_direct16): Likewise.
	(grub_video_i386_vbefill_direct8): Likewise.

	* include/grub/video.h (grub_video_blit_format): Removed 
	GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8, GRUB_VIDEO_BLIT_FORMAT_R8G8B8.
	(grub_video_blit_format): Added GRUB_VIDEO_BLIT_FORMAT_RGBA_8888,
	GRUB_VIDEO_BLIT_FORMAT_BGRA_8888, GRUB_VIDEO_BLIT_FORMAT_RGB_888,
	GRUB_VIDEO_BLIT_FORMAT_BGR_888, GRUB_VIDEO_BLIT_FORMAT_RGB_565,
	GRUB_VIDEO_BLIT_FORMAT_BGR_565.
	
	* video/video.c (grub_video_get_blit_format): Updated to use new
	blit formats.  Added handling for 16 bit color modes.
	
	* video/i386/pc/vbe.c (grub_video_vbe_fill_rect): Updated to use new 
	fillers.
	(common_blitter): Updated to use new blitters.

	* video/i386/pc/vbeblit.c (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8):
	Removed.
	(grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8A8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8X8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_index_R8G8B8): Likewise.
	(grub_video_i386_vbeblit_index_index): Likewise.
	(grub_video_i386_vbeblit_replace_directN): Added.
	(grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_BGRX8888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_BGR888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_BGR888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_RGBX8888_RGB888): Likewise.
	(grub_video_i386_vbeblit_replace_RGB888_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_index_RGBX8888): Likewise.
	(grub_video_i386_vbeblit_replace_index_RGB888): Likewise.
	(grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_BGR888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_RGB888_RGBA8888): Likewise.
	(grub_video_i386_vbeblit_blend_index_RGBA8888): Likewise.
	
	* video/i386/pc/vbefill.c (grub_video_i386_vbefill_R8G8B8A8): Removed.
	(grub_video_i386_vbefill_R8G8B8): Likewise.
	(grub_video_i386_vbefill_index): Likewise.
	(grub_video_i386_vbefill_direct32): Added.
	(grub_video_i386_vbefill_direct24): Likewise.
	(grub_video_i386_vbefill_direct16): Likewise.
	(grub_video_i386_vbefill_direct8): Likewise.
	
	* video/readers/jpeg.c (grub_jpeg_decode_sos): Adapt to new blitter
	types.
	
	* video/readers/tga.c (grub_video_reader_tga): Adapt to new blitter
	types.
	
	* video/readers/png.c (grub_png_decode_image_header): Adapt to new
	blitter types.
	
	* video/bitmap.c (grub_video_bitmap_create): Adapt to new blitter
	types.
This commit is contained in:
chaac 2008-09-07 15:55:58 +00:00
parent e8a83df664
commit 0ea85a3787
12 changed files with 1274 additions and 683 deletions

View file

@ -1,3 +1,101 @@
2008-09-07 Vesa Jääskeläinen <chaac@nic.fi>
Based on patch created by Colin D Bennett <colin@gibibit.com>.
Adds optimization support for BGR based modes.
* include/grub/i386/pc/vbeblit.h (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8) Removed.
(grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8A8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8): Likewise.
(grub_video_i386_vbeblit_index_index): Likewise.
(grub_video_i386_vbeblit_replace_directN): Added.
(grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_BGRX8888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_BGR888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_BGR888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_RGBX8888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_RGB888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_index_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_index_RGB888): Likewise.
(grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_BGR888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_RGB888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_index_RGBA8888): Likewise.
* include/grub/i386/pc/vbefill.h (grub_video_i386_vbefill_R8G8B8A8) Removed.
(grub_video_i386_vbefill_R8G8B8): Likewise.
(grub_video_i386_vbefill_index): Likewise.
(grub_video_i386_vbefill_direct32): Added.
(grub_video_i386_vbefill_direct24): Likewise.
(grub_video_i386_vbefill_direct16): Likewise.
(grub_video_i386_vbefill_direct8): Likewise.
* include/grub/video.h (grub_video_blit_format): Removed
GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8, GRUB_VIDEO_BLIT_FORMAT_R8G8B8.
(grub_video_blit_format): Added GRUB_VIDEO_BLIT_FORMAT_RGBA_8888,
GRUB_VIDEO_BLIT_FORMAT_BGRA_8888, GRUB_VIDEO_BLIT_FORMAT_RGB_888,
GRUB_VIDEO_BLIT_FORMAT_BGR_888, GRUB_VIDEO_BLIT_FORMAT_RGB_565,
GRUB_VIDEO_BLIT_FORMAT_BGR_565.
* video/video.c (grub_video_get_blit_format): Updated to use new
blit formats. Added handling for 16 bit color modes.
* video/i386/pc/vbe.c (grub_video_vbe_fill_rect): Updated to use new
fillers.
(common_blitter): Updated to use new blitters.
* video/i386/pc/vbeblit.c (grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8):
Removed.
(grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8A8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8A8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8X8): Likewise.
(grub_video_i386_vbeblit_R8G8B8A8_R8G8B8): Likewise.
(grub_video_i386_vbeblit_R8G8B8_R8G8B8): Likewise.
(grub_video_i386_vbeblit_index_R8G8B8): Likewise.
(grub_video_i386_vbeblit_index_index): Likewise.
(grub_video_i386_vbeblit_replace_directN): Added.
(grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_BGRX8888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_BGR888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_BGR888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_RGBX8888_RGB888): Likewise.
(grub_video_i386_vbeblit_replace_RGB888_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_index_RGBX8888): Likewise.
(grub_video_i386_vbeblit_replace_index_RGB888): Likewise.
(grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_BGR888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_RGB888_RGBA8888): Likewise.
(grub_video_i386_vbeblit_blend_index_RGBA8888): Likewise.
* video/i386/pc/vbefill.c (grub_video_i386_vbefill_R8G8B8A8): Removed.
(grub_video_i386_vbefill_R8G8B8): Likewise.
(grub_video_i386_vbefill_index): Likewise.
(grub_video_i386_vbefill_direct32): Added.
(grub_video_i386_vbefill_direct24): Likewise.
(grub_video_i386_vbefill_direct16): Likewise.
(grub_video_i386_vbefill_direct8): Likewise.
* video/readers/jpeg.c (grub_jpeg_decode_sos): Adapt to new blitter
types.
* video/readers/tga.c (grub_video_reader_tga): Adapt to new blitter
types.
* video/readers/png.c (grub_png_decode_image_header): Adapt to new
blitter types.
* video/bitmap.c (grub_video_bitmap_create): Adapt to new blitter
types.
2008-09-06 Felix Zielcke <fzielcke@z-51.de>
* disk/raid.c (insert_array): Set `array->chunk_size' to 64 for

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,61 +25,67 @@
struct grub_video_i386_vbeblit_info;
void
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_directN (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_index_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGR888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_index_index (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
@ -91,9 +97,38 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_i386_vbeblit_blend_index_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
#endif /* ! GRUB_VBEBLIT_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,24 +24,29 @@
struct grub_video_i386_vbeblit_info;
void
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_index (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_i386_vbefill_direct8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
#endif /* ! GRUB_VBEFILL_MACHINE_HEADER */

View file

@ -55,14 +55,22 @@ struct grub_video_bitmap;
/* Defined blitting formats. */
enum grub_video_blit_format
{
/* Follow exactly field & mask information. */
/* Generic RGBA, use fields & masks. */
GRUB_VIDEO_BLIT_FORMAT_RGBA,
/* Make optimization assumption. */
GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8,
/* Follow exactly field & mask information. */
/* Optimized RGBA's. */
GRUB_VIDEO_BLIT_FORMAT_RGBA_8888,
GRUB_VIDEO_BLIT_FORMAT_BGRA_8888,
/* Generic RGB, use fields & masks. */
GRUB_VIDEO_BLIT_FORMAT_RGB,
/* Make optimization assumption. */
GRUB_VIDEO_BLIT_FORMAT_R8G8B8,
/* Optimized RGB's. */
GRUB_VIDEO_BLIT_FORMAT_RGB_888,
GRUB_VIDEO_BLIT_FORMAT_BGR_888,
GRUB_VIDEO_BLIT_FORMAT_RGB_565,
GRUB_VIDEO_BLIT_FORMAT_BGR_565,
/* When needed, decode color or just use value as is. */
GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
};

View file

@ -78,7 +78,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
switch (blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8:
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB
| GRUB_VIDEO_MODE_TYPE_ALPHA;
mode_info->bpp = 32;
@ -94,7 +94,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
mode_info->reserved_field_pos = 24;
break;
case GRUB_VIDEO_BLIT_FORMAT_R8G8B8:
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
mode_info->bpp = 24;
mode_info->bytes_per_pixel = 3;

View file

@ -646,6 +646,7 @@ grub_video_vbe_get_viewport (unsigned int *x, unsigned int *y,
return GRUB_ERR_NONE;
}
/* Maps color name to target optimized color format. */
static grub_video_color_t
grub_video_vbe_map_color (grub_uint32_t color_name)
{
@ -671,6 +672,7 @@ grub_video_vbe_map_color (grub_uint32_t color_name)
return 0;
}
/* Maps RGB to target optimized color format. */
grub_video_color_t
grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue)
@ -728,6 +730,7 @@ grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
}
/* Maps RGBA to target optimized color format. */
grub_video_color_t
grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue, grub_uint8_t alpha)
@ -755,6 +758,7 @@ grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
}
}
/* Splits target optimized format to components. */
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)
@ -769,6 +773,7 @@ grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color,
return GRUB_ERR_NONE;
}
/* Splits color in source format to components. */
void
grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info * source,
grub_video_color_t color,
@ -875,24 +880,41 @@ grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y,
target.mode_info = &render_target->mode_info;
target.data = render_target->data;
/* Try to figure out more optimized version. */
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
/* Try to figure out more optimized version. Note that color is already
mapped to target format so we can make assumptions based on that. */
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbefill_R8G8B8A8 (&target, color, x, y,
grub_video_i386_vbefill_direct32 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbefill_R8G8B8 (&target, color, x, y,
grub_video_i386_vbefill_direct32 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
grub_video_i386_vbefill_index (&target, color, x, y,
grub_video_i386_vbefill_direct24 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_565)
{
grub_video_i386_vbefill_direct16 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_565)
{
grub_video_i386_vbefill_direct16 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
else if (target.mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbefill_direct8 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
@ -985,65 +1007,97 @@ common_blitter (struct grub_video_i386_vbeblit_info *target,
if (oper == GRUB_VIDEO_BLIT_REPLACE)
{
/* Try to figure out more optimized version for replace operator. */
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (target, source,
grub_video_i386_vbeblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (target, source,
grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
grub_video_i386_vbeblit_index_R8G8B8X8 (target, source,
grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_replace_index_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
grub_video_i386_vbeblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_index (target, source,
grub_video_i386_vbeblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
@ -1057,65 +1111,80 @@ common_blitter (struct grub_video_i386_vbeblit_info *target,
else
{
/* Try to figure out more optimized blend operator. */
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (target, source,
grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (target, source,
grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
grub_video_i386_vbeblit_index_R8G8B8A8 (target, source,
grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_blend_index_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
/* Note: There is really no alpha information here, so blend is
changed to replace. */
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
grub_video_i386_vbeblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
grub_video_i386_vbeblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_index (target, source,
grub_video_i386_vbeblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;

View file

@ -34,74 +34,42 @@
#include <grub/types.h>
#include <grub/video.h>
/* Generic replacing blitter (slow). Works for every supported format. */
void
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint32_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
grub_uint8_t src_red;
grub_uint8_t src_green;
grub_uint8_t src_blue;
grub_uint8_t src_alpha;
grub_video_color_t src_color;
grub_video_color_t dst_color;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
src_color = get_pixel (src, i + offset_x, j + offset_y);
a = color >> 24;
grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green,
&src_blue, &src_alpha);
if (a == 0)
{
dstptr++;
continue;
}
dst_color = grub_video_vbe_map_rgba (src_red, src_green,
src_blue, src_alpha);
if (a == 255)
{
*dstptr++ = color;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
color = *dstptr;
dr = (color >> 0) & 0xFF;
dg = (color >> 8) & 0xFF;
db = (color >> 16) & 0xFF;
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
color = (a << 24) | (db << 16) | (dg << 8) | dr;
*dstptr++ = color;
set_pixel (dst, x + i, y + j, dst_color);
}
}
}
/* Block copy replacing blitter. Works with modes multiple of 8 bits. */
void
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_directN (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y)
@ -109,232 +77,201 @@ grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *
int j;
grub_uint32_t *srcptr;
grub_uint32_t *dstptr;
int pitch;
int bpp;
pitch = src->mode_info->bytes_per_pixel;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
bpp = src->mode_info->bytes_per_pixel;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
grub_memmove (dstptr, srcptr, width * pitch);
grub_memmove (dstptr, srcptr, width * bpp);
}
}
/* Optimized replacing blitter for RGBX8888 to BGRX8888. */
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
unsigned int srcrowskip;
unsigned int dstrowskip;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
grub_uint8_t r = *srcptr++;
grub_uint8_t g = *srcptr++;
grub_uint8_t b = *srcptr++;
grub_uint8_t a = *srcptr++;
a = color >> 24;
if (a == 0)
{
dstptr += 3;
continue;
*dstptr++ = b;
*dstptr++ = g;
*dstptr++ = r;
*dstptr++ = a;
}
srcptr += srcrowskip;
dstptr += dstrowskip;
}
}
/* Optimized replacing blitter for RGB888 to BGRX8888. */
void
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
int i;
int j;
grub_uint8_t *srcptr;
grub_uint8_t *dstptr;
unsigned int srcrowskip;
unsigned int dstrowskip;
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
grub_uint8_t r = *srcptr++;
grub_uint8_t g = *srcptr++;
grub_uint8_t b = *srcptr++;
*dstptr++ = b;
*dstptr++ = g;
*dstptr++ = r;
/* Set alpha component as opaque. */
*dstptr++ = 255;
}
srcptr += srcrowskip;
dstptr += dstrowskip;
}
}
/* Optimized replacing blitter for RGBX8888 to BGR888. */
void
grub_video_i386_vbeblit_replace_BGR888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int srcrowskip;
unsigned int dstrowskip;
int i;
int j;
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
grub_uint32_t color;
grub_uint8_t sr;
grub_uint8_t sg;
grub_uint8_t sb;
color = *srcptr++;
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
*dstptr++ = sr;
*dstptr++ = sg;
*dstptr++ = sb;
continue;
}
dr = dstptr[0];
dg = dstptr[1];
db = dstptr[2];
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
*dstptr++ = dr;
*dstptr++ = dg;
*dstptr++ = db;
}
}
}
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
*dstptr++ = sr;
*dstptr++ = sg;
*dstptr++ = sb;
*dstptr++ = sr;
}
srcptr = (grub_uint32_t *) (((grub_uint8_t *) srcptr) + srcrowskip);
dstptr += dstrowskip;
}
}
/* Optimized replacing blitter for RGB888 to BGR888. */
void
grub_video_i386_vbeblit_index_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_BGR888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned char dr;
unsigned char dg;
unsigned char db;
unsigned char da;
unsigned int srcrowskip;
unsigned int dstrowskip;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint8_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
grub_uint8_t r = *srcptr++;
grub_uint8_t g = *srcptr++;
grub_uint8_t b = *srcptr++;
a = color >> 24;
if (a == 0)
{
dstptr++;
continue;
*dstptr++ = b;
*dstptr++ = g;
*dstptr++ = r;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
color = grub_video_vbe_map_rgb(sr, sg, sb);
*dstptr++ = color & 0xFF;
continue;
}
grub_video_vbe_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da);
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
color = grub_video_vbe_map_rgb(dr, dg, db);
*dstptr++ = color & 0xFF;
}
srcptr += srcrowskip;
dstptr += dstrowskip;
}
}
/* Optimized replacing blitter for RGB888 to RGBX8888. */
void
grub_video_i386_vbeblit_index_R8G8B8X8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
color = grub_video_vbe_map_rgb(sr, sg, sb);
*dstptr++ = color & 0xFF;
}
}
}
void
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
@ -346,9 +283,6 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *ds
unsigned int sg;
unsigned int sb;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
@ -360,6 +294,7 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *ds
sg = *srcptr++;
sb = *srcptr++;
/* Set alpha as opaque. */
color = 0xFF000000 | (sb << 16) | (sg << 8) | sr;
*dstptr++ = color;
@ -367,35 +302,85 @@ grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (struct grub_video_i386_vbeblit_info *ds
}
}
/* Optimized replacing blitter for RGBX8888 to RGB888. */
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_RGB888_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint8_t *srcptr;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
int pitch;
pitch = src->mode_info->bytes_per_pixel;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
unsigned int sr;
unsigned int sg;
unsigned int sb;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
grub_memmove (dstptr, srcptr, width * pitch);
for (i = 0; i < width; i++)
{
color = *srcptr++;
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
*dstptr++ = sr;
*dstptr++ = sg;
*dstptr++ = sb;
}
}
}
/* Optimized replacing blitter for RGBX8888 to indexed color. */
void
grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_replace_index_RGBX8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
color = grub_video_vbe_map_rgb(sr, sg, sb);
*dstptr++ = color & 0xFF;
}
}
}
/* Optimized replacing blitter for RGB888 to indexed color. */
void
grub_video_i386_vbeblit_replace_index_RGB888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
@ -407,9 +392,6 @@ grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
unsigned int sg;
unsigned int sb;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
@ -428,31 +410,7 @@ grub_video_i386_vbeblit_index_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
}
}
void
grub_video_i386_vbeblit_index_index (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y)
{
int j;
grub_uint8_t *srcptr;
grub_uint8_t *dstptr;
int pitch;
pitch = src->mode_info->bytes_per_pixel;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
srcptr = (grub_uint8_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
grub_memmove (dstptr, srcptr, width * pitch);
}
}
/* Generic blending blitter. Works for every supported format. */
void
grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
@ -462,9 +420,6 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
int i;
int j;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
@ -516,35 +471,358 @@ grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
}
}
/* Optimized blending blitter for RGBA8888 to BGRA8888. */
void
grub_video_i386_vbeblit_replace (struct grub_video_i386_vbeblit_info *dst,
grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t *srcptr;
grub_uint32_t *dstptr;
unsigned int srcrowskip;
unsigned int dstrowskip;
int i;
int j;
grub_uint8_t src_red;
grub_uint8_t src_green;
grub_uint8_t src_blue;
grub_uint8_t src_alpha;
grub_video_color_t src_color;
grub_video_color_t dst_color;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint32_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
src_color = get_pixel (src, i + offset_x, j + offset_y);
grub_video_vbe_unmap_color_int (src, src_color, &src_red, &src_green,
&src_blue, &src_alpha);
grub_uint32_t color;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
dst_color = grub_video_vbe_map_rgba (src_red, src_green,
src_blue, src_alpha);
set_pixel (dst, x + i, y + j, dst_color);
color = *srcptr++;
a = color >> 24;
if (a == 0)
{
/* Skip transparent source pixels. */
dstptr++;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
/* Opaque pixel shortcut. */
dr = sr;
dg = sg;
db = sb;
}
else
{
/* General pixel color blending. */
color = *dstptr;
dr = (color >> 16) & 0xFF;
dr = (dr * (255 - a) + sr * a) / 255;
dg = (color >> 8) & 0xFF;
dg = (dg * (255 - a) + sg * a) / 255;
db = (color >> 0) & 0xFF;
db = (db * (255 - a) + sb * a) / 255;
}
color = (a << 24) | (dr << 16) | (dg << 8) | db;
*dstptr++ = color;
}
srcptr = (grub_uint32_t *) (((grub_uint8_t *) srcptr) + srcrowskip);
dstptr = (grub_uint32_t *) (((grub_uint8_t *) dstptr) + dstrowskip);
}
}
/* Optimized blending blitter for RGBA8888 to BGR888. */
void
grub_video_i386_vbeblit_blend_BGR888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int srcrowskip;
unsigned int dstrowskip;
int i;
int j;
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
srcrowskip = src->mode_info->pitch - src->mode_info->bytes_per_pixel * width;
dstrowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
srcptr = (grub_uint32_t *) get_data_ptr (src, offset_x, offset_y);
dstptr = (grub_uint8_t *) get_data_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
grub_uint32_t color;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
color = *srcptr++;
a = color >> 24;
if (a == 0)
{
/* Skip transparent source pixels. */
dstptr += 3;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
/* Opaque pixel shortcut. */
dr = sr;
dg = sg;
db = sb;
}
else
{
/* General pixel color blending. */
color = *dstptr;
db = dstptr[0];
db = (db * (255 - a) + sb * a) / 255;
dg = dstptr[1];
dg = (dg * (255 - a) + sg * a) / 255;
dr = dstptr[2];
dr = (dr * (255 - a) + sr * a) / 255;
}
*dstptr++ = db;
*dstptr++ = dg;
*dstptr++ = dr;
}
srcptr = (grub_uint32_t *) (((grub_uint8_t *) srcptr) + srcrowskip);
dstptr += dstrowskip;
}
}
/* Optimized blending blitter for RGBA888 to RGBA8888. */
void
grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint32_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint32_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
a = color >> 24;
if (a == 0)
{
dstptr++;
continue;
}
if (a == 255)
{
*dstptr++ = color;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
color = *dstptr;
dr = (color >> 0) & 0xFF;
dg = (color >> 8) & 0xFF;
db = (color >> 16) & 0xFF;
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
color = (a << 24) | (db << 16) | (dg << 8) | dr;
*dstptr++ = color;
}
}
}
/* Optimized blending blitter for RGBA8888 to RGB888. */
void
grub_video_i386_vbeblit_blend_RGB888_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned int dr;
unsigned int dg;
unsigned int db;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
a = color >> 24;
if (a == 0)
{
dstptr += 3;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
*dstptr++ = sr;
*dstptr++ = sg;
*dstptr++ = sb;
continue;
}
dr = dstptr[0];
dg = dstptr[1];
db = dstptr[2];
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
*dstptr++ = dr;
*dstptr++ = dg;
*dstptr++ = db;
}
}
}
/* Optimized blending blitter for RGBA8888 to indexed color. */
void
grub_video_i386_vbeblit_blend_index_RGBA8888 (struct grub_video_i386_vbeblit_info *dst,
struct grub_video_i386_vbeblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y)
{
grub_uint32_t color;
int i;
int j;
grub_uint32_t *srcptr;
grub_uint8_t *dstptr;
unsigned int sr;
unsigned int sg;
unsigned int sb;
unsigned int a;
unsigned char dr;
unsigned char dg;
unsigned char db;
unsigned char da;
for (j = 0; j < height; j++)
{
srcptr = (grub_uint32_t *)get_data_ptr (src, offset_x, j + offset_y);
dstptr = (grub_uint8_t *)get_data_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
color = *srcptr++;
a = color >> 24;
if (a == 0)
{
dstptr++;
continue;
}
sr = (color >> 0) & 0xFF;
sg = (color >> 8) & 0xFF;
sb = (color >> 16) & 0xFF;
if (a == 255)
{
color = grub_video_vbe_map_rgb(sr, sg, sb);
*dstptr++ = color & 0xFF;
continue;
}
grub_video_vbe_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da);
dr = (dr * (255 - a) + sr * a) / 255;
dg = (dg * (255 - a) + sg * a) / 255;
db = (db * (255 - a) + sb * a) / 255;
color = grub_video_vbe_map_rgb(dr, dg, db);
*dstptr++ = color & 0xFF;
}
}
}

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,77 +33,7 @@
#include <grub/types.h>
#include <grub/video.h>
void
grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_uint32_t *dstptr;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
dstptr = (grub_uint32_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
*dstptr++ = color;
}
}
void
grub_video_i386_vbefill_R8G8B8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_uint8_t *dstptr;
grub_uint8_t fillr = (grub_uint8_t)((color >> 0) & 0xFF);
grub_uint8_t fillg = (grub_uint8_t)((color >> 8) & 0xFF);
grub_uint8_t fillb = (grub_uint8_t)((color >> 16) & 0xFF);
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
{
*dstptr++ = fillr;
*dstptr++ = fillg;
*dstptr++ = fillb;
}
}
}
void
grub_video_i386_vbefill_index (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_uint8_t *dstptr;
grub_uint8_t fill = (grub_uint8_t)color & 0xFF;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
{
dstptr = (grub_uint8_t *)grub_video_vbe_get_video_ptr (dst, x, y + j);
for (i = 0; i < width; i++)
*dstptr++ = fill;
}
}
/* Generic filler that works for every supported mode. */
void
grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
@ -112,10 +42,136 @@ grub_video_i386_vbefill (struct grub_video_i386_vbeblit_info *dst,
int i;
int j;
/* We do not need to worry about data being out of bounds
as we assume that everything has been checked before. */
for (j = 0; j < height; j++)
for (i = 0; i < width; i++)
set_pixel (dst, x+i, y+j, color);
}
/* Optimized filler for direct color 32 bit modes. It is assumed that color
is already mapped to destination format. */
void
grub_video_i386_vbefill_direct32 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_uint32_t *dstptr;
grub_size_t rowskip;
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
/* Get the start address. */
dstptr = (grub_uint32_t *) grub_video_vbe_get_video_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
*dstptr++ = color;
/* Advance the dest pointer to the right location on the next line. */
dstptr = (grub_uint32_t *) (((char *) dstptr) + rowskip);
}
}
/* Optimized filler for direct color 24 bit modes. It is assumed that color
is already mapped to destination format. */
void
grub_video_i386_vbefill_direct24 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_size_t rowskip;
grub_uint8_t *dstptr;
grub_uint8_t fill0 = (grub_uint8_t)((color >> 0) & 0xFF);
grub_uint8_t fill1 = (grub_uint8_t)((color >> 8) & 0xFF);
grub_uint8_t fill2 = (grub_uint8_t)((color >> 16) & 0xFF);
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
/* Get the start address. */
dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
*dstptr++ = fill0;
*dstptr++ = fill1;
*dstptr++ = fill2;
}
/* Advance the dest pointer to the right location on the next line. */
dstptr += rowskip;
}
}
/* Optimized filler for direct color 16 bit modes. It is assumed that color
is already mapped to destination format. */
void
grub_video_i386_vbefill_direct16 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_size_t rowskip;
grub_uint8_t *dstptr;
grub_uint8_t fill0 = (grub_uint8_t)((color >> 0) & 0xFF);
grub_uint8_t fill1 = (grub_uint8_t)((color >> 8) & 0xFF);
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
/* Get the start address. */
dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
{
*dstptr++ = fill0;
*dstptr++ = fill1;
}
/* Advance the dest pointer to the right location on the next line. */
dstptr += rowskip;
}
}
/* Optimized filler for index color. It is assumed that color
is already mapped to destination format. */
void
grub_video_i386_vbefill_direct8 (struct grub_video_i386_vbeblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
{
int i;
int j;
grub_size_t rowskip;
grub_uint8_t *dstptr;
grub_uint8_t fill = (grub_uint8_t)color & 0xFF;
/* Calculate the number of bytes to advance from the end of one line
to the beginning of the next line. */
rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
/* Get the start address. */
dstptr = (grub_uint8_t *) grub_video_vbe_get_video_ptr (dst, x, y);
for (j = 0; j < height; j++)
{
for (i = 0; i < width; i++)
*dstptr++ = fill;
/* Advance the dest pointer to the right location on the next line. */
dstptr += rowskip;
}
}

View file

@ -542,7 +542,7 @@ grub_jpeg_decode_sos (struct grub_jpeg_data *data)
if (grub_video_bitmap_create (data->bitmap, data->image_width,
data->image_height,
GRUB_VIDEO_BLIT_FORMAT_R8G8B8))
GRUB_VIDEO_BLIT_FORMAT_RGB_888))
return grub_errno;
data->bit_mask = 0x0;

View file

@ -231,7 +231,7 @@ grub_png_decode_image_header (struct grub_png_data *data)
{
if (grub_video_bitmap_create (data->bitmap, data->image_width,
data->image_height,
GRUB_VIDEO_BLIT_FORMAT_R8G8B8))
GRUB_VIDEO_BLIT_FORMAT_RGB_888))
return grub_errno;
data->bpp = 3;
}
@ -239,7 +239,7 @@ grub_png_decode_image_header (struct grub_png_data *data)
{
if (grub_video_bitmap_create (data->bitmap, data->image_width,
data->image_height,
GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8))
GRUB_VIDEO_BLIT_FORMAT_RGBA_8888))
return grub_errno;
data->bpp = 4;
}

View file

@ -397,7 +397,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap,
{
grub_video_bitmap_create (bitmap, header.image_width,
header.image_height,
GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8);
GRUB_VIDEO_BLIT_FORMAT_RGBA_8888);
if (grub_errno != GRUB_ERR_NONE)
{
grub_file_close (file);
@ -420,7 +420,7 @@ grub_video_reader_tga (struct grub_video_bitmap **bitmap,
{
grub_video_bitmap_create (bitmap, header.image_width,
header.image_height,
GRUB_VIDEO_BLIT_FORMAT_R8G8B8);
GRUB_VIDEO_BLIT_FORMAT_RGB_888);
if (grub_errno != GRUB_ERR_NONE)
{
grub_file_close (file);

View file

@ -152,31 +152,70 @@ grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
if (mode_info->bpp == 32)
{
if ((mode_info->red_mask_size == 8)
&& (mode_info->red_field_pos == 0)
&& (mode_info->red_field_pos == 16)
&& (mode_info->green_mask_size == 8)
&& (mode_info->green_field_pos == 8)
&& (mode_info->blue_mask_size == 8)
&& (mode_info->blue_field_pos == 16)
&& (mode_info->reserved_mask_size == 8)
&& (mode_info->reserved_field_pos == 24))
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8;
return GRUB_VIDEO_BLIT_FORMAT_BGRA_8888;
}
}
/* Check if we have any known 24 bit modes. */
if (mode_info->bpp == 24)
{
if ((mode_info->red_mask_size == 8)
else if ((mode_info->red_mask_size == 8)
&& (mode_info->red_field_pos == 0)
&& (mode_info->green_mask_size == 8)
&& (mode_info->green_field_pos == 8)
&& (mode_info->blue_mask_size == 8)
&& (mode_info->blue_field_pos == 16))
{
return GRUB_VIDEO_BLIT_FORMAT_R8G8B8;
return GRUB_VIDEO_BLIT_FORMAT_RGBA_8888;
}
}
/* Check if we have any known 24 bit modes. */
else if (mode_info->bpp == 24)
{
if ((mode_info->red_mask_size == 8)
&& (mode_info->red_field_pos == 16)
&& (mode_info->green_mask_size == 8)
&& (mode_info->green_field_pos == 8)
&& (mode_info->blue_mask_size == 8)
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_BGR_888;
}
else if ((mode_info->red_mask_size == 8)
&& (mode_info->red_field_pos == 0)
&& (mode_info->green_mask_size == 8)
&& (mode_info->green_field_pos == 8)
&& (mode_info->blue_mask_size == 8)
&& (mode_info->blue_field_pos == 16))
{
return GRUB_VIDEO_BLIT_FORMAT_RGB_888;
}
}
/* Check if we have any known 16 bit modes. */
else if (mode_info->bpp == 16)
{
if ((mode_info->red_mask_size == 5)
&& (mode_info->red_field_pos == 11)
&& (mode_info->green_mask_size == 6)
&& (mode_info->green_field_pos == 5)
&& (mode_info->blue_mask_size == 5)
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_BGR_565;
}
else if ((mode_info->red_mask_size == 5)
&& (mode_info->red_field_pos == 0)
&& (mode_info->green_mask_size == 6)
&& (mode_info->green_field_pos == 5)
&& (mode_info->blue_mask_size == 5)
&& (mode_info->blue_field_pos == 11))
{
return GRUB_VIDEO_BLIT_FORMAT_RGB_565;
}
}
/* Backup route. Unknown format. */
/* If there are more than 8 bits per color, assume RGB(A) mode. */
if (mode_info->bpp > 8)
@ -185,8 +224,11 @@ grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
{
return GRUB_VIDEO_BLIT_FORMAT_RGBA;
}
else
{
return GRUB_VIDEO_BLIT_FORMAT_RGB;
}
}
/* Assume as indexcolor mode. */
return GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR;