Add two new vt(9) driver methods: vd_drawrect and vd_setpixel.
Implement vd_drawrect and vd_setpixel for vt_fb driver. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
0205ddeb44
commit
9e497e7b04
@ -45,11 +45,16 @@ static int vt_fb_ioctl(struct vt_device *vd, u_long cmd, caddr_t data,
|
|||||||
struct thread *td);
|
struct thread *td);
|
||||||
static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset,
|
static int vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset,
|
||||||
vm_paddr_t *paddr, int prot, vm_memattr_t *memattr);
|
vm_paddr_t *paddr, int prot, vm_memattr_t *memattr);
|
||||||
|
void vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2,
|
||||||
|
int fill, term_color_t color);
|
||||||
|
void vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color);
|
||||||
|
|
||||||
static struct vt_driver vt_fb_driver = {
|
static struct vt_driver vt_fb_driver = {
|
||||||
.vd_init = vt_fb_init,
|
.vd_init = vt_fb_init,
|
||||||
.vd_blank = vt_fb_blank,
|
.vd_blank = vt_fb_blank,
|
||||||
.vd_bitbltchr = vt_fb_bitbltchr,
|
.vd_bitbltchr = vt_fb_bitbltchr,
|
||||||
|
.vd_drawrect = vt_fb_drawrect,
|
||||||
|
.vd_setpixel = vt_fb_setpixel,
|
||||||
.vd_postswitch = vt_fb_postswitch,
|
.vd_postswitch = vt_fb_postswitch,
|
||||||
.vd_priority = VD_PRIORITY_GENERIC+10,
|
.vd_priority = VD_PRIORITY_GENERIC+10,
|
||||||
.vd_fb_ioctl = vt_fb_ioctl,
|
.vd_fb_ioctl = vt_fb_ioctl,
|
||||||
@ -83,6 +88,56 @@ vt_fb_mmap(struct vt_device *vd, vm_ooffset_t offset, vm_paddr_t *paddr,
|
|||||||
return (info->fb_mmap(info->fb_cdev, offset, paddr, prot, memattr));
|
return (info->fb_mmap(info->fb_cdev, offset, paddr, prot, memattr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vt_fb_setpixel(struct vt_device *vd, int x, int y, term_color_t color)
|
||||||
|
{
|
||||||
|
struct fb_info *info;
|
||||||
|
uint32_t c;
|
||||||
|
u_int o;
|
||||||
|
|
||||||
|
info = vd->vd_softc;
|
||||||
|
c = info->fb_cmap[color];
|
||||||
|
o = info->fb_stride * y + x * FBTYPE_GET_BYTESPP(info);
|
||||||
|
|
||||||
|
switch (FBTYPE_GET_BYTESPP(info)) {
|
||||||
|
case 1:
|
||||||
|
info->wr1(info, o, c);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
info->wr2(info, o, c);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
info->wr1(info, o, (c >> 16) & 0xff);
|
||||||
|
info->wr1(info, o + 1, (c >> 8) & 0xff);
|
||||||
|
info->wr1(info, o + 2, c & 0xff);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
info->wr4(info, o, c);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* panic? */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vt_fb_drawrect(struct vt_device *vd, int x1, int y1, int x2, int y2, int fill,
|
||||||
|
term_color_t color)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
for (y = y1; y <= y2; y++) {
|
||||||
|
if (fill || (y == y1) || (y == y2)) {
|
||||||
|
for (x = x1; x <= x2; x++)
|
||||||
|
vt_fb_setpixel(vd, x, y, color);
|
||||||
|
} else {
|
||||||
|
vt_fb_setpixel(vd, x1, y, color);
|
||||||
|
vt_fb_setpixel(vd, x2, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vt_fb_blank(struct vt_device *vd, term_color_t color)
|
vt_fb_blank(struct vt_device *vd, term_color_t color)
|
||||||
{
|
{
|
||||||
|
@ -287,6 +287,9 @@ typedef void vd_putchar_t(struct vt_device *vd, term_char_t,
|
|||||||
typedef int vd_fb_ioctl_t(struct vt_device *, u_long, caddr_t, struct thread *);
|
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,
|
typedef int vd_fb_mmap_t(struct vt_device *, vm_ooffset_t, vm_paddr_t *, int,
|
||||||
vm_memattr_t *);
|
vm_memattr_t *);
|
||||||
|
typedef void vd_drawrect_t(struct vt_device *, int, int, int, int, int,
|
||||||
|
term_color_t);
|
||||||
|
typedef void vd_setpixel_t(struct vt_device *, int, int, term_color_t);
|
||||||
|
|
||||||
struct vt_driver {
|
struct vt_driver {
|
||||||
/* Console attachment. */
|
/* Console attachment. */
|
||||||
@ -295,6 +298,8 @@ struct vt_driver {
|
|||||||
/* Drawing. */
|
/* Drawing. */
|
||||||
vd_blank_t *vd_blank;
|
vd_blank_t *vd_blank;
|
||||||
vd_bitbltchr_t *vd_bitbltchr;
|
vd_bitbltchr_t *vd_bitbltchr;
|
||||||
|
vd_drawrect_t *vd_drawrect;
|
||||||
|
vd_setpixel_t *vd_setpixel;
|
||||||
|
|
||||||
/* Framebuffer ioctls, if present. */
|
/* Framebuffer ioctls, if present. */
|
||||||
vd_fb_ioctl_t *vd_fb_ioctl;
|
vd_fb_ioctl_t *vd_fb_ioctl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user