Move blit and fill dispatcher to appropriate files to decrease export
and relocation overhead.
This commit is contained in:
parent
b8323067e8
commit
6570b2050e
7 changed files with 394 additions and 601 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue