Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Aug 2021 16:18:08 GMT
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e5a50b03297f - main - loader: FB console does leave garbage on screen while scrolling
Message-ID:  <202108211618.17LGI8w1075747@gitrepo.freebsd.org>

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

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

commit e5a50b03297fa09652b3cf319bc6e863392554e0
Author:     Toomas Soome <tsoome@FreeBSD.org>
AuthorDate: 2021-08-21 11:25:36 +0000
Commit:     Toomas Soome <tsoome@FreeBSD.org>
CommitDate: 2021-08-21 16:17:25 +0000

    loader: FB console does leave garbage on screen while scrolling
    
    Scrolling screen will leave "trail" of chars from first column.
    Apparently caused by cursor location mismanagement.
    Make sure we do not [attempt to] set cursor out of the screen.
    
    MFC after:      1 week
---
 stand/common/gfx_fb.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c
index 522c70327425..45d0072bd858 100644
--- a/stand/common/gfx_fb.c
+++ b/stand/common/gfx_fb.c
@@ -976,20 +976,26 @@ gfx_fb_fill(void *arg, const teken_rect_t *r, teken_char_t c,
 }
 
 static void
-gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
+gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *pos, bool on)
 {
 	unsigned x, y, width, height;
 	const uint8_t *glyph;
+	teken_pos_t p;
 	int idx;
 
-	idx = p->tp_col + p->tp_row * state->tg_tp.tp_col;
+	p = *pos;
+	if (p.tp_col >= state->tg_tp.tp_col)
+		p.tp_col = state->tg_tp.tp_col - 1;
+	if (p.tp_row >= state->tg_tp.tp_row)
+		p.tp_row = state->tg_tp.tp_row - 1;
+	idx = p.tp_col + p.tp_row * state->tg_tp.tp_col;
 	if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row)
 		return;
 
 	width = state->tg_font.vf_width;
 	height = state->tg_font.vf_height;
-	x = state->tg_origin.tp_col + p->tp_col * width;
-	y = state->tg_origin.tp_row + p->tp_row * height;
+	x = state->tg_origin.tp_col + p.tp_col * width;
+	y = state->tg_origin.tp_row + p.tp_row * height;
 
 	/*
 	 * Save original display content to preserve image data.
@@ -1017,7 +1023,7 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
 		if (state->tg_cursor_image != NULL &&
 		    gfxfb_blt(state->tg_cursor_image, GfxFbBltBufferToVideo,
 		    0, 0, x, y, width, height, 0) == 0) {
-			state->tg_cursor = *p;
+			state->tg_cursor = p;
 			return;
 		}
 	}
@@ -1025,9 +1031,9 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
 	glyph = font_lookup(&state->tg_font, screen_buffer[idx].c,
 	    &screen_buffer[idx].a);
 	gfx_bitblt_bitmap(state, glyph, &screen_buffer[idx].a, 0xff, on);
-	gfx_fb_printchar(state, p);
+	gfx_fb_printchar(state, &p);
 
-	state->tg_cursor = *p;
+	state->tg_cursor = p;
 }
 
 void



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