Move blit and fill dispatcher to appropriate files to decrease export

and relocation overhead.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-30 22:06:28 +02:00
parent b8323067e8
commit 6570b2050e
7 changed files with 394 additions and 601 deletions

View File

@ -1,3 +1,8 @@
2013-05-30 Vladimir Serbinenko <phcoder@gmail.com>
Move blit and fill dispatcher to appropriate files to decrease export
and relocation overhead.
2013-05-30 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/font/font.c, include/grub/font.h: Inline simple font

View File

@ -35,7 +35,7 @@
#include <grub/video.h>
/* Generic replacing blitter (slow). Works for every supported format. */
void
static void
grub_video_fbblit_replace (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
@ -68,7 +68,7 @@ grub_video_fbblit_replace (struct grub_video_fbblit_info *dst,
}
/* Block copy replacing blitter. Works with modes multiple of 8 bits. */
void
static void
grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
@ -92,7 +92,7 @@ grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 32bit. */
void
static void
grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -163,7 +163,7 @@ grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
/* Optimized replacing blitter for 1-bit to 24-bit. */
void
static void
grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -252,7 +252,7 @@ grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
#endif
/* Optimized replacing blitter for 1-bit to 16-bit. */
void
static void
grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -321,7 +321,7 @@ grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 8-bit. */
void
static void
grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -389,7 +389,7 @@ grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
}
}
void
static void
grub_video_fbblit_replace_32bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -434,7 +434,7 @@ grub_video_fbblit_replace_32bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 16bit. */
void
static void
grub_video_fbblit_replace_24bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -488,7 +488,7 @@ grub_video_fbblit_replace_24bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 16bit. */
void
static void
grub_video_fbblit_replace_16bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -533,7 +533,7 @@ grub_video_fbblit_replace_16bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 8bit. */
void
static void
grub_video_fbblit_replace_8bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -578,7 +578,7 @@ grub_video_fbblit_replace_8bit_indexa (struct grub_video_fbblit_info *dst,
}
void
static void
grub_video_fbblit_blend_32bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -620,7 +620,7 @@ grub_video_fbblit_blend_32bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 16bit. */
void
static void
grub_video_fbblit_blend_24bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -675,7 +675,7 @@ grub_video_fbblit_blend_24bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 16bit. */
void
static void
grub_video_fbblit_blend_16bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -717,7 +717,7 @@ grub_video_fbblit_blend_16bit_indexa (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for 1-bit to 8bit. */
void
static void
grub_video_fbblit_blend_8bit_indexa (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -760,7 +760,7 @@ grub_video_fbblit_blend_8bit_indexa (struct grub_video_fbblit_info *dst,
/* Optimized replacing blitter for RGBX8888 to BGRX8888. */
void
static void
grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -813,7 +813,7 @@ grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGB888 to BGRX8888. */
void
static void
grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -864,7 +864,7 @@ grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGBX8888 to BGR888. */
void
static void
grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -918,7 +918,7 @@ grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGB888 to BGR888. */
void
static void
grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -959,7 +959,7 @@ grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGB888 to RGBX8888. */
void
static void
grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1006,7 +1006,7 @@ grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGBX8888 to RGB888. */
void
static void
grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1055,7 +1055,7 @@ grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGBX8888 to indexed color. */
void
static void
grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1098,7 +1098,7 @@ grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized replacing blitter for RGB888 to indexed color. */
void
static void
grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1146,7 +1146,7 @@ grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
}
/* Generic blending blitter. Works for every supported format. */
void
static void
grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
@ -1207,7 +1207,7 @@ grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for RGBA8888 to BGRA8888. */
void
static void
grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1288,7 +1288,7 @@ grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for RGBA8888 to BGR888. */
void
static void
grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1382,7 +1382,7 @@ grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for RGBA888 to RGBA8888. */
void
static void
grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1454,7 +1454,7 @@ grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for RGBA8888 to RGB888. */
void
static void
grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1545,7 +1545,7 @@ grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for RGBA8888 to indexed color. */
void
static void
grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1615,7 +1615,7 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
}
/* Optimized blending blitter for 1-bit to XXXA8888. */
void
static void
grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1714,7 +1714,7 @@ grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
/* Optimized blending blitter for 1-bit to XXX888. */
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
void
static void
grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1820,7 +1820,7 @@ grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
#endif
/* Optimized blending blitter for 1-bit to XXX888. */
void
static void
grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
@ -1915,3 +1915,302 @@ grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
GRUB_VIDEO_FB_ADVANCE_POINTER (dstptr, dstrowskip);
}
}
/* NOTE: This function assumes that given coordinates are within bounds of
handled data. */
void
grub_video_fb_dispatch_blit (struct grub_video_fbblit_info *target,
struct grub_video_fbblit_info *source,
enum grub_video_blit_operators oper, int x, int y,
unsigned int width, unsigned int height,
int offset_x, int offset_y)
{
if (oper == GRUB_VIDEO_BLIT_REPLACE)
{
/* Try to figure out more optimized version for replace operator. */
switch (source->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_RGB888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_replace_32bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 3:
grub_video_fbblit_replace_24bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 2:
grub_video_fbblit_replace_16bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_replace_8bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_replace_32bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
case 3:
grub_video_fbblit_replace_24bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#endif
case 2:
grub_video_fbblit_replace_16bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_replace_8bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
break;
default:
break;
}
/* No optimized replace operator found, use default (slow) blitter. */
grub_video_fbblit_replace (target, source, x, y, width, height,
offset_x, offset_y);
}
else
{
/* Try to figure out more optimized blend operator. */
switch (source->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_blend_BGRA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_blend_RGBA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_blend_BGR888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_blend_RGB888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_blend_index_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
/* Note: There is really no alpha information here, so blend is
changed to replace. */
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_blend_XXXA8888_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_blend_XXX888_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#endif
case GRUB_VIDEO_BLIT_FORMAT_BGR_565:
case GRUB_VIDEO_BLIT_FORMAT_RGB_565:
grub_video_fbblit_blend_XXX565_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_blend_32bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 3:
grub_video_fbblit_blend_24bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 2:
grub_video_fbblit_blend_16bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_blend_8bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
break;
default:
break;
}
/* No optimized blend operation found, use default (slow) blitter. */
grub_video_fbblit_blend (target, source, x, y, width, height,
offset_x, offset_y);
}
}

View File

@ -34,7 +34,7 @@
#include <grub/video.h>
/* Generic filler that works for every supported mode. */
void
static void
grub_video_fbfill (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
@ -49,7 +49,7 @@ grub_video_fbfill (struct grub_video_fbblit_info *dst,
/* Optimized filler for direct color 32 bit modes. It is assumed that color
is already mapped to destination format. */
void
static void
grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
@ -78,7 +78,7 @@ grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
/* Optimized filler for direct color 24 bit modes. It is assumed that color
is already mapped to destination format. */
void
static void
grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
@ -119,7 +119,7 @@ grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
/* Optimized filler for direct color 16 bit modes. It is assumed that color
is already mapped to destination format. */
void
static void
grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
@ -148,7 +148,7 @@ grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
/* Optimized filler for index color. It is assumed that color
is already mapped to destination format. */
void
static void
grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height)
@ -175,3 +175,34 @@ grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
dstptr += rowskip;
}
}
void
grub_video_fb_fill_dispatch (struct grub_video_fbblit_info *target,
grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height)
{
/* Try to figure out more optimized version. Note that color is already
mapped to target format so we can make assumptions based on that. */
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbfill_direct32 (target, color, x, y,
width, height);
return;
case 3:
grub_video_fbfill_direct24 (target, color, x, y,
width, height);
return;
case 2:
grub_video_fbfill_direct16 (target, color, x, y,
width, height);
return;
case 1:
grub_video_fbfill_direct8 (target, color, x, y,
width, height);
return;
}
/* No optimized version found, use default (slow) filler. */
grub_video_fbfill (target, color, x, y, width, height);
}

View File

@ -748,335 +748,11 @@ grub_video_fb_fill_rect (grub_video_color_t color, int x, int y,
target.mode_info = &framebuffer.render_target->mode_info;
target.data = framebuffer.render_target->data;
/* Try to figure out more optimized version. Note that color is already
mapped to target format so we can make assumptions based on that. */
switch (target.mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbfill_direct32 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
case 3:
grub_video_fbfill_direct24 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
case 2:
grub_video_fbfill_direct16 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
case 1:
grub_video_fbfill_direct8 (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
/* No optimized version found, use default (slow) filler. */
grub_video_fbfill (&target, color, x, y, width, height);
grub_video_fb_fill_dispatch (&target, color, x, y,
width, height);
return GRUB_ERR_NONE;
}
/* NOTE: This function assumes that given coordinates are within bounds of
handled data. */
static void
common_blitter (struct grub_video_fbblit_info *target,
struct grub_video_fbblit_info *source,
enum grub_video_blit_operators oper, int x, int y,
unsigned int width, unsigned int height,
int offset_x, int offset_y)
{
dirty (y, height);
if (oper == GRUB_VIDEO_BLIT_REPLACE)
{
/* Try to figure out more optimized version for replace operator. */
switch (source->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_RGB888_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGBX8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_replace_32bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 3:
grub_video_fbblit_replace_24bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 2:
grub_video_fbblit_replace_16bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_replace_8bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_replace_32bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
case 3:
grub_video_fbblit_replace_24bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#endif
case 2:
grub_video_fbblit_replace_16bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_replace_8bit_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
break;
default:
break;
}
/* No optimized replace operator found, use default (slow) blitter. */
grub_video_fbblit_replace (target, source, x, y, width, height,
offset_x, offset_y);
}
else
{
/* Try to figure out more optimized blend operator. */
switch (source->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_blend_BGRA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_blend_RGBA8888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_blend_BGR888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_blend_RGB888_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_blend_index_RGBA8888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
/* Note: There is really no alpha information here, so blend is
changed to replace. */
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
grub_video_fbblit_replace_BGRX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_replace_RGBX8888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
grub_video_fbblit_replace_BGR888_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_replace_directN (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR:
grub_video_fbblit_replace_index_RGB888 (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED:
switch (target->mode_info->blit_format)
{
case GRUB_VIDEO_BLIT_FORMAT_BGRA_8888:
case GRUB_VIDEO_BLIT_FORMAT_RGBA_8888:
grub_video_fbblit_blend_XXXA8888_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
case GRUB_VIDEO_BLIT_FORMAT_BGR_888:
case GRUB_VIDEO_BLIT_FORMAT_RGB_888:
grub_video_fbblit_blend_XXX888_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
#endif
case GRUB_VIDEO_BLIT_FORMAT_BGR_565:
case GRUB_VIDEO_BLIT_FORMAT_RGB_565:
grub_video_fbblit_blend_XXX565_1bit (target, source,
x, y, width, height,
offset_x, offset_y);
return;
default:
break;
}
break;
case GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR_ALPHA:
switch (target->mode_info->bytes_per_pixel)
{
case 4:
grub_video_fbblit_blend_32bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 3:
grub_video_fbblit_blend_24bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 2:
grub_video_fbblit_blend_16bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
case 1:
grub_video_fbblit_blend_8bit_indexa (target, source,
x, y, width, height,
offset_x, offset_y);
return;
}
break;
default:
break;
}
/* No optimized blend operation found, use default (slow) blitter. */
grub_video_fbblit_blend (target, source, x, y, width, height,
offset_x, offset_y);
}
}
grub_err_t
grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap,
enum grub_video_blit_operators oper, int x, int y,
@ -1162,8 +838,9 @@ grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap,
target.data = framebuffer.render_target->data;
/* Do actual blitting. */
common_blitter (&target, &source, oper, x, y, width, height,
offset_x, offset_y);
dirty (y, height);
grub_video_fb_dispatch_blit (&target, &source, oper, x, y, width, height,
offset_x, offset_y);
return GRUB_ERR_NONE;
}
@ -1253,8 +930,9 @@ grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source,
target_info.data = framebuffer.render_target->data;
/* Do actual blitting. */
common_blitter (&target_info, &source_info, oper, x, y, width, height,
offset_x, offset_y);
dirty (y, height);
grub_video_fb_dispatch_blit (&target_info, &source_info, oper, x, y, width, height,
offset_x, offset_y);
return GRUB_ERR_NONE;
}

View File

@ -24,159 +24,13 @@
struct grub_video_fbblit_info;
/* NOTE: This function assumes that given coordinates are within bounds of
handled data. */
void
grub_video_fbblit_replace (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y, int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
grub_video_fb_dispatch_blit (struct grub_video_fbblit_info *target,
struct grub_video_fbblit_info *source,
enum grub_video_blit_operators oper,
int x, int y,
unsigned int width, unsigned int height,
int offset_x, int offset_y);
#endif /* ! GRUB_FBBLIT_HEADER */

View File

@ -48,28 +48,8 @@ struct grub_video_fbrender_target
};
void
grub_video_fbfill (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
void
grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
grub_video_color_t color, int x, int y,
int width, int height);
grub_video_fb_fill_dispatch (struct grub_video_fbblit_info *target,
grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height);
#endif /* ! GRUB_FBFILL_HEADER */

View File

@ -118,72 +118,18 @@ EXPORT_FUNC(grub_video_fb_get_active_render_target) (struct grub_video_fbrender_
grub_err_t
EXPORT_FUNC(grub_video_fb_set_active_render_target) (struct grub_video_fbrender_target *target);
void
EXPORT_FUNC (grub_video_fbblit_blend_32bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_blend_24bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_blend_16bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_blend_8bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_replace_32bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_replace_24bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_replace_16bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
EXPORT_FUNC (grub_video_fbblit_replace_8bit_indexa) (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
typedef grub_err_t (*grub_video_fb_set_page_t) (int page);
grub_err_t
grub_video_fb_setup (unsigned int mode_type, unsigned int mode_mask,
EXPORT_FUNC (grub_video_fb_setup) (unsigned int mode_type, unsigned int mode_mask,
struct grub_video_mode_info *mode_info,
volatile void *page0_ptr,
grub_video_fb_set_page_t set_page_in,
volatile void *page1_ptr);
grub_err_t
grub_video_fb_swap_buffers (void);
EXPORT_FUNC (grub_video_fb_swap_buffers) (void);
grub_err_t
grub_video_fb_get_info_and_fini (struct grub_video_mode_info *mode_info,
void **framebuf);
EXPORT_FUNC (grub_video_fb_get_info_and_fini) (struct grub_video_mode_info *mode_info,
void **framebuf);
#endif /* ! GRUB_VIDEO_FB_HEADER */