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,64 +25,70 @@
struct grub_video_i386_vbeblit_info;
void
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (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_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,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
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,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
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,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
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);
void
grub_video_i386_vbeblit_index_R8G8B8A8 (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_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);
void
grub_video_i386_vbeblit_index_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_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 offset_x, int offset_y);
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 offset_x, int offset_y);
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);
void
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (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_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 offset_x, int offset_y);
void
grub_video_i386_vbeblit_index_R8G8B8 (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_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 offset_x, int offset_y);
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);
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);
void
grub_video_i386_vbeblit_blend (struct grub_video_i386_vbeblit_info *dst,
@ -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,
struct grub_video_i386_vbeblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
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 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,25 +880,42 @@ 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,
width, height);
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,
width, height);
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,146 +1007,193 @@ 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 (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
grub_video_i386_vbeblit_R8G8B8X8_R8G8B8X8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8X8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_R8G8B8X8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
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,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
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_BGRA_8888)
{
grub_video_i386_vbeblit_replace_BGRX8888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
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;
}
}
else if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGB_888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
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;
}
}
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_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
/* No optimized replace operator found, use default (slow) blitter. */
grub_video_i386_vbeblit_replace (target, source, x, y, width, height,
offset_x, offset_y);
offset_x, offset_y);
}
else
{
/* Try to figure out more optimized blend operator. */
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8A8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_blend_BGRA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_blend_RGBA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
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 (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8A8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_R8G8B8A8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8)
{
grub_video_i386_vbeblit_R8G8B8A8_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_R8G8B8)
{
grub_video_i386_vbeblit_R8G8B8_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR)
{
grub_video_i386_vbeblit_index_R8G8B8 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
}
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,
x, y, width, height,
offset_x, offset_y);
return;
}
}
if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGRA_8888)
{
grub_video_i386_vbeblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_RGBA_8888)
{
grub_video_i386_vbeblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
else if (target->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_BGR_888)
{
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;
}
}
/* No optimized blend operation found, use default (slow) blitter. */
grub_video_i386_vbeblit_blend (target, source, x, y, width, height,
offset_x, offset_y);
offset_x, offset_y);
}
}

File diff suppressed because it is too large Load diff

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,40 +152,82 @@ 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->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))
{
return GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8;
}
&& (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_BGRA_8888;
}
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_RGBA_8888;
}
}
/* Check if we have any known 24 bit modes. */
if (mode_info->bpp == 24)
else if (mode_info->bpp == 24)
{
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;
}
&& (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)
{
if (mode_info->reserved_mask_size > 0)
{
return GRUB_VIDEO_BLIT_FORMAT_RGBA;
}
return GRUB_VIDEO_BLIT_FORMAT_RGB;
{
return GRUB_VIDEO_BLIT_FORMAT_RGBA;
}
else
{
return GRUB_VIDEO_BLIT_FORMAT_RGB;
}
}
/* Assume as indexcolor mode. */