git: 5365af662c78 - main - loader: gfx_fb_drawrect should use GfxFbBltVideoFill
Toomas Soome
tsoome at FreeBSD.org
Sun May 16 09:13:19 UTC 2021
The branch main has been updated by tsoome:
URL: https://cgit.FreeBSD.org/src/commit/?id=5365af662c78d7bded3bf83c7271d6bff17229a9
commit 5365af662c78d7bded3bf83c7271d6bff17229a9
Author: Toomas Soome <tsoome at FreeBSD.org>
AuthorDate: 2021-05-11 18:05:12 +0000
Commit: Toomas Soome <tsoome at FreeBSD.org>
CommitDate: 2021-05-16 08:22:37 +0000
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
---
stand/common/gfx_fb.c | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c
index 3eae0a3a859e..92af49913748 100644
--- a/stand/common/gfx_fb.c
+++ b/stand/common/gfx_fb.c
@@ -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);
}
}
More information about the dev-commits-src-main
mailing list