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:
parent
e8a83df664
commit
0ea85a3787
12 changed files with 1274 additions and 683 deletions
|
@ -217,7 +217,7 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
case 8: framebuffer.bytes_per_pixel = 1; break;
|
||||
default:
|
||||
grub_vbe_bios_set_mode (old_mode, 0);
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot set VBE mode %x",
|
||||
mode);
|
||||
break;
|
||||
|
@ -231,9 +231,9 @@ grub_vbe_set_video_mode (grub_uint32_t mode,
|
|||
|
||||
/* Make sure that the BIOS can reach the palette. */
|
||||
grub_memcpy (palette, vga_colors, sizeof (vga_colors));
|
||||
status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
|
||||
/ sizeof (struct grub_vbe_palette_data),
|
||||
0,
|
||||
status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
|
||||
/ sizeof (struct grub_vbe_palette_data),
|
||||
0,
|
||||
palette);
|
||||
|
||||
/* Just ignore the status. */
|
||||
|
@ -413,7 +413,7 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
unsigned int i;
|
||||
|
||||
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
||||
|
||||
/* Walk thru mode list and try to find matching mode. */
|
||||
|
@ -490,7 +490,7 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
/* Try to initialize best mode found. */
|
||||
if (best_mode != 0)
|
||||
{
|
||||
/* If this fails, then we have mode selection heuristics problem,
|
||||
/* If this fails, then we have mode selection heuristics problem,
|
||||
or adapter failure. */
|
||||
grub_vbe_set_video_mode (best_mode, &active_mode_info);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
|
@ -538,8 +538,8 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
render_target->data = framebuffer.ptr;
|
||||
|
||||
/* Copy default palette to initialize emulated palette. */
|
||||
for (i = 0;
|
||||
i < (sizeof (vga_colors)
|
||||
for (i = 0;
|
||||
i < (sizeof (vga_colors)
|
||||
/ sizeof (struct grub_vbe_palette_data));
|
||||
i++)
|
||||
{
|
||||
|
@ -560,7 +560,7 @@ static grub_err_t
|
|||
grub_video_vbe_get_info (struct grub_video_mode_info *mode_info)
|
||||
{
|
||||
/* Copy mode info from active render target. */
|
||||
grub_memcpy (mode_info, &render_target->mode_info,
|
||||
grub_memcpy (mode_info, &render_target->mode_info,
|
||||
sizeof (struct grub_video_mode_info));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -575,9 +575,9 @@ grub_video_vbe_set_palette (unsigned int start, unsigned int count,
|
|||
if (framebuffer.index_color_mode)
|
||||
{
|
||||
/* TODO: Implement setting indexed color mode palette to hardware. */
|
||||
//status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
|
||||
// / sizeof (struct grub_vbe_palette_data),
|
||||
// 0,
|
||||
//status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
|
||||
// / sizeof (struct grub_vbe_palette_data),
|
||||
// 0,
|
||||
// palette);
|
||||
|
||||
}
|
||||
|
@ -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,11 +672,12 @@ 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)
|
||||
{
|
||||
if ((render_target->mode_info.mode_type
|
||||
if ((render_target->mode_info.mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||
{
|
||||
int minindex = 0;
|
||||
|
@ -728,11 +730,12 @@ 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)
|
||||
{
|
||||
if ((render_target->mode_info.mode_type
|
||||
if ((render_target->mode_info.mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||
/* No alpha available in index color modes, just use
|
||||
same value as in only RGB modes. */
|
||||
|
@ -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)
|
||||
|
@ -765,10 +769,11 @@ grub_err_t grub_video_vbe_unmap_color (grub_video_color_t color,
|
|||
target_info.data = render_target->data;
|
||||
|
||||
grub_video_vbe_unmap_color_int (&target_info, color, red, green, blue, alpha);
|
||||
|
||||
|
||||
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,
|
||||
|
@ -778,7 +783,7 @@ grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info * source,
|
|||
struct grub_video_mode_info *mode_info;
|
||||
mode_info = source->mode_info;
|
||||
|
||||
if ((mode_info->mode_type
|
||||
if ((mode_info->mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||
{
|
||||
/* If we have an out-of-bounds color, return transparent black. */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -965,15 +987,15 @@ grub_video_vbe_blit_glyph (struct grub_font_glyph * glyph,
|
|||
/* Draw glyph. */
|
||||
for (j = 0; j < height; j++)
|
||||
for (i = 0; i < width; i++)
|
||||
if ((glyph->bitmap[((i + x_offset) / 8)
|
||||
+ (j + y_offset) * (charwidth / 8)]
|
||||
if ((glyph->bitmap[((i + x_offset) / 8)
|
||||
+ (j + y_offset) * (charwidth / 8)]
|
||||
& (1 << ((charwidth - (i + x_offset) - 1) % 8))))
|
||||
set_pixel (&target, x+i, y+j, color);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* NOTE: This function assumes that given coordinates are within bounds of
|
||||
/* NOTE: This function assumes that given coordinates are within bounds of
|
||||
handled data. */
|
||||
static void
|
||||
common_blitter (struct grub_video_i386_vbeblit_info *target,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1148,10 +1217,10 @@ grub_video_vbe_blit_bitmap (struct grub_video_bitmap *bitmap,
|
|||
return GRUB_ERR_NONE;
|
||||
if ((y + (int)bitmap->mode_info.height) < 0)
|
||||
return GRUB_ERR_NONE;
|
||||
if ((offset_x >= (int)bitmap->mode_info.width)
|
||||
if ((offset_x >= (int)bitmap->mode_info.width)
|
||||
|| (offset_x + (int)width < 0))
|
||||
return GRUB_ERR_NONE;
|
||||
if ((offset_y >= (int)bitmap->mode_info.height)
|
||||
if ((offset_y >= (int)bitmap->mode_info.height)
|
||||
|| (offset_y + (int)height < 0))
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
|
@ -1239,10 +1308,10 @@ grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
|||
return GRUB_ERR_NONE;
|
||||
if ((y + (int)source->mode_info.height) < 0)
|
||||
return GRUB_ERR_NONE;
|
||||
if ((offset_x >= (int)source->mode_info.width)
|
||||
if ((offset_x >= (int)source->mode_info.width)
|
||||
|| (offset_x + (int)width < 0))
|
||||
return GRUB_ERR_NONE;
|
||||
if ((offset_y >= (int)source->mode_info.height)
|
||||
if ((offset_y >= (int)source->mode_info.height)
|
||||
|| (offset_y + (int)height < 0))
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
|
@ -1304,7 +1373,7 @@ grub_video_vbe_blit_render_target (struct grub_video_render_target *source,
|
|||
target_info.data = render_target->data;
|
||||
|
||||
/* Do actual blitting. */
|
||||
common_blitter (&target_info, &source_info, oper, x, y, width, height,
|
||||
common_blitter (&target_info, &source_info, oper, x, y, width, height,
|
||||
offset_x, offset_y);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
@ -1350,7 +1419,7 @@ grub_video_vbe_scroll (grub_video_color_t color, int dx, int dy)
|
|||
}
|
||||
|
||||
/* 2. Check if there is need to copy data. */
|
||||
if ((grub_abs (dx) < render_target->viewport.width)
|
||||
if ((grub_abs (dx) < render_target->viewport.width)
|
||||
&& (grub_abs (dy) < render_target->viewport.height))
|
||||
{
|
||||
/* 3. Move data in render target. */
|
||||
|
@ -1389,7 +1458,7 @@ grub_video_vbe_scroll (grub_video_color_t color, int dx, int dy)
|
|||
|
||||
/* 4b. Fill left & right parts. */
|
||||
if (dx > 0)
|
||||
grub_video_vbe_fill_rect (color, 0, 0,
|
||||
grub_video_vbe_fill_rect (color, 0, 0,
|
||||
dx, render_target->viewport.height);
|
||||
else if (dx < 0)
|
||||
{
|
||||
|
@ -1403,7 +1472,7 @@ grub_video_vbe_scroll (grub_video_color_t color, int dx, int dy)
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
static grub_err_t
|
||||
grub_video_vbe_swap_buffers (void)
|
||||
{
|
||||
/* TODO: Implement buffer swapping. */
|
||||
|
@ -1445,7 +1514,7 @@ grub_video_vbe_create_render_target (struct grub_video_render_target **result,
|
|||
/* Setup render target format. */
|
||||
target->mode_info.width = width;
|
||||
target->mode_info.height = height;
|
||||
target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB
|
||||
target->mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB
|
||||
| GRUB_VIDEO_MODE_TYPE_ALPHA;
|
||||
target->mode_info.bpp = 32;
|
||||
target->mode_info.bytes_per_pixel = 4;
|
||||
|
@ -1513,11 +1582,11 @@ grub_video_vbe_set_active_render_target (struct grub_video_render_target *target
|
|||
}
|
||||
|
||||
if (target == GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"double buffering not implemented yet.");
|
||||
|
||||
if (! target->data)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"invalid render target given.");
|
||||
|
||||
render_target = target;
|
||||
|
@ -1529,7 +1598,7 @@ static grub_err_t
|
|||
grub_video_vbe_get_active_render_target (struct grub_video_render_target **target)
|
||||
{
|
||||
*target = render_target;
|
||||
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue