loader: gfx_fb_drawrect should use GfxFbBltVideoFill

The gfx_fb_drawrect() is drawing rectangle by pixels, this can be very
slow on some systems. Use Blt() video fill primitive instead.

Testing done: Tested on mac mini 2012 where the issue was revealed

Reviewed by:	yuripv
MFC after:	1 week
This commit is contained in:
Toomas Soome 2021-05-11 21:05:12 +03:00
parent 80ba60f643
commit 5365af662c

View File

@ -1357,16 +1357,12 @@ isqrt(int num)
return (res);
}
/* set pixel in framebuffer using gfx coordinates */
void
gfx_fb_setpixel(uint32_t x, uint32_t y)
static uint32_t
gfx_fb_getcolor(void)
{
uint32_t c;
const teken_attr_t *ap;
if (gfx_state.tg_fb_type == FB_TEXT)
return;
ap = teken_get_curattr(&gfx_state.tg_teken);
if (ap->ta_format & TF_REVERSE) {
c = ap->ta_bgcolor;
@ -1378,7 +1374,19 @@ gfx_fb_setpixel(uint32_t x, uint32_t y)
c |= TC_LIGHT;
}
c = gfx_fb_color_map(c);
return (gfx_fb_color_map(c));
}
/* set pixel in framebuffer using gfx coordinates */
void
gfx_fb_setpixel(uint32_t x, uint32_t y)
{
uint32_t c;
if (gfx_state.tg_fb_type == FB_TEXT)
return;
c = gfx_fb_getcolor();
if (x >= gfx_state.tg_fb.fb_width ||
y >= gfx_state.tg_fb.fb_height)
@ -1389,25 +1397,26 @@ gfx_fb_setpixel(uint32_t x, uint32_t y)
/*
* draw rectangle in framebuffer using gfx coordinates.
* The function is borrowed from vt_fb.c
*/
void
gfx_fb_drawrect(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2,
uint32_t fill)
{
uint32_t x, y;
uint32_t c;
if (gfx_state.tg_fb_type == FB_TEXT)
return;
for (y = y1; y <= y2; y++) {
if (fill || (y == y1) || (y == y2)) {
for (x = x1; x <= x2; x++)
gfx_fb_setpixel(x, y);
} else {
gfx_fb_setpixel(x1, y);
gfx_fb_setpixel(x2, y);
}
c = gfx_fb_getcolor();
if (fill != 0) {
gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1,
y2 - y1, 0);
} else {
gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, x2 - x1, 1, 0);
gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y2, x2 - x1, 1, 0);
gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x1, y1, 1, y2 - y1, 0);
gfxfb_blt(&c, GfxFbBltVideoFill, 0, 0, x2, y1, 1, y2 - y1, 0);
}
}