Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 May 2021 08:23:05 GMT
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3dc9f92a0d3d - stable/13 - loader: gfx_fb_drawrect should use GfxFbBltVideoFill
Message-ID:  <202105230823.14N8N5Gc023621@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tsoome:

URL: https://cgit.FreeBSD.org/src/commit/?id=3dc9f92a0d3dbe0d56201d8806cd9e93e4676cc4

commit 3dc9f92a0d3dbe0d56201d8806cd9e93e4676cc4
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2021-05-11 18:05:12 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2021-05-23 00:46:51 +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
    
    (cherry picked from commit 5365af662c78d7bded3bf83c7271d6bff17229a9)
    
    Reviewed by:    yuripv
---
 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);
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105230823.14N8N5Gc023621>