vt(4): Add vd_bitblt_bmp_t callback

The code was already there in all backends, we just expose it. This is
used to display the splash screen.

MFC after:	1 week
This commit is contained in:
dumbbell 2014-08-23 20:35:33 +00:00
parent a37c3b2b99
commit 2ecca071d5
10 changed files with 66 additions and 3 deletions

View File

@ -46,6 +46,7 @@ static vd_probe_t creatorfb_probe;
static vd_init_t creatorfb_init;
static vd_blank_t creatorfb_blank;
static vd_bitblt_text_t creatorfb_bitblt_text;
static vd_bitblt_bmp_t creatorfb_bitblt_bitmap;
static const struct vt_driver vt_creatorfb_driver = {
.vd_name = "creatorfb",
@ -53,6 +54,7 @@ static const struct vt_driver vt_creatorfb_driver = {
.vd_init = creatorfb_init,
.vd_blank = creatorfb_blank,
.vd_bitblt_text = creatorfb_bitblt_text,
.vd_bitblt_bmp = creatorfb_bitblt_bitmap,
.vd_fb_ioctl = vt_fb_ioctl,
.vd_fb_mmap = vt_fb_mmap,
.vd_priority = VD_PRIORITY_SPECIFIC

View File

@ -61,6 +61,7 @@ static struct vt_driver vt_efifb_driver = {
.vd_init = vt_efifb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_fb_ioctl = vt_fb_ioctl,
.vd_fb_mmap = vt_fb_mmap,
/* Better than VGA, but still generic driver. */

View File

@ -60,6 +60,7 @@ static struct vt_driver vt_fb_early_driver = {
.vd_init = vt_efb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_priority = VD_PRIORITY_GENERIC,
};

View File

@ -49,6 +49,7 @@ static struct vt_driver vt_fb_driver = {
.vd_init = vt_fb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_drawrect = vt_fb_drawrect,
.vd_setpixel = vt_fb_setpixel,
.vd_postswitch = vt_fb_postswitch,
@ -242,7 +243,7 @@ vt_fb_blank(struct vt_device *vd, term_color_t color)
}
}
static void
void
vt_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
const uint8_t *pattern, const uint8_t *mask,
unsigned int width, unsigned int height,

View File

@ -39,6 +39,7 @@ void vt_fb_suspend(void);
vd_init_t vt_fb_init;
vd_blank_t vt_fb_blank;
vd_bitblt_text_t vt_fb_bitblt_text;
vd_bitblt_bmp_t vt_fb_bitblt_bitmap;
vd_postswitch_t vt_fb_postswitch;
vd_fb_ioctl_t vt_fb_ioctl;
vd_fb_mmap_t vt_fb_mmap;

View File

@ -59,6 +59,7 @@ struct ofwfb_softc {
static vd_probe_t ofwfb_probe;
static vd_init_t ofwfb_init;
static vd_bitblt_text_t ofwfb_bitblt_text;
static vd_bitblt_bmp_t ofwfb_bitblt_bitmap;
static const struct vt_driver vt_ofwfb_driver = {
.vd_name = "ofwfb",
@ -66,6 +67,7 @@ static const struct vt_driver vt_ofwfb_driver = {
.vd_init = ofwfb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = ofwfb_bitblt_text,
.vd_bitblt_bmp = ofwfb_bitblt_bitmap,
.vd_fb_ioctl = vt_fb_ioctl,
.vd_fb_mmap = vt_fb_mmap,
.vd_priority = VD_PRIORITY_GENERIC+1,

View File

@ -89,6 +89,7 @@ static vd_probe_t vga_probe;
static vd_init_t vga_init;
static vd_blank_t vga_blank;
static vd_bitblt_text_t vga_bitblt_text;
static vd_bitblt_bmp_t vga_bitblt_bitmap;
static vd_drawrect_t vga_drawrect;
static vd_setpixel_t vga_setpixel;
static vd_postswitch_t vga_postswitch;
@ -99,6 +100,7 @@ static const struct vt_driver vt_vga_driver = {
.vd_init = vga_init,
.vd_blank = vga_blank,
.vd_bitblt_text = vga_bitblt_text,
.vd_bitblt_bmp = vga_bitblt_bitmap,
.vd_drawrect = vga_drawrect,
.vd_setpixel = vga_setpixel,
.vd_postswitch = vga_postswitch,
@ -827,6 +829,52 @@ vga_bitblt_text(struct vt_device *vd, const struct vt_window *vw,
}
}
static void
vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
const uint8_t *pattern, const uint8_t *mask,
unsigned int width, unsigned int height,
unsigned int x, unsigned int y, term_color_t fg, term_color_t bg)
{
unsigned int x1, y1, x2, y2, i, j, src_x, dst_x, x_count;
uint8_t pattern_2colors, pattern_ncolors;
/* Align coordinates with the 8-pxels grid. */
x1 = x / VT_VGA_PIXELS_BLOCK * VT_VGA_PIXELS_BLOCK;
y1 = y;
x2 = (x + width + VT_VGA_PIXELS_BLOCK - 1) /
VT_VGA_PIXELS_BLOCK * VT_VGA_PIXELS_BLOCK;
y2 = y + height;
x2 = min(x2, vd->vd_width - 1);
y2 = min(y2, vd->vd_height - 1);
pattern_ncolors = 0;
for (j = y1; j < y2; ++j) {
src_x = 0;
dst_x = x - x1;
x_count = VT_VGA_PIXELS_BLOCK - dst_x;
for (i = x1; i < x2; i += VT_VGA_MEMSIZE) {
pattern_2colors = 0;
vga_copy_bitmap_portion(
&pattern_2colors, &pattern_ncolors,
pattern, mask, width,
src_x, dst_x, x_count,
j - y1, 0, 1, fg, bg, 0);
vga_bitblt_pixels_block_2colors(vd,
&pattern_2colors, fg, bg,
i, j, 1);
src_x += x_count;
dst_x = (dst_x + x_count) % VT_VGA_PIXELS_BLOCK;
x_count = min(x + width - i, VT_VGA_PIXELS_BLOCK);
}
}
}
static void
vga_initialize_graphics(struct vt_device *vd)
{

View File

@ -305,6 +305,10 @@ typedef void vd_putchar_t(struct vt_device *vd, term_char_t,
vt_axis_t top, vt_axis_t left, term_color_t fg, term_color_t bg);
typedef void vd_bitblt_text_t(struct vt_device *vd, const struct vt_window *vw,
const term_rect_t *area);
typedef void vd_bitblt_bmp_t(struct vt_device *vd, const struct vt_window *vw,
const uint8_t *pattern, const uint8_t *mask,
unsigned int width, unsigned int height,
unsigned int x, unsigned int y, term_color_t fg, term_color_t bg);
typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
vm_memattr_t *);
@ -324,6 +328,7 @@ struct vt_driver {
vd_drawrect_t *vd_drawrect;
vd_setpixel_t *vd_setpixel;
vd_bitblt_text_t *vd_bitblt_text;
vd_bitblt_bmp_t *vd_bitblt_bmp;
/* Framebuffer ioctls, if present. */
vd_fb_ioctl_t *vd_fb_ioctl;

View File

@ -1087,8 +1087,9 @@ vtterm_splash(struct vt_device *vd)
switch (vt_logo_depth) {
case 1:
/* XXX: Unhardcode colors! */
vd->vd_driver->vd_bitbltchr(vd, vt_logo_image, NULL, 0,
top, left, vt_logo_width, vt_logo_height, 0xf, 0x0);
vd->vd_driver->vd_bitblt_bmp(vd, vd->vd_curwindow,
vt_logo_image, NULL, vt_logo_width, vt_logo_height,
top, left, TC_WHITE, TC_BLACK);
}
vd->vd_flags |= VDF_SPLASH;
}

View File

@ -77,6 +77,7 @@ static struct vt_driver vt_ps3fb_driver = {
.vd_init = ps3fb_init,
.vd_blank = vt_fb_blank,
.vd_bitblt_text = vt_fb_bitblt_text,
.vd_bitblt_bmp = vt_fb_bitblt_bitmap,
.vd_fb_ioctl = vt_fb_ioctl,
.vd_fb_mmap = vt_fb_mmap,
/* Better than VGA, but still generic driver. */