git: d54fdcd59e23 - stable/13 - loader: FB console does leave garbage on screen while scrolling

Toomas Soome tsoome at FreeBSD.org
Sat Aug 28 05:44:37 UTC 2021


The branch stable/13 has been updated by tsoome:

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

commit d54fdcd59e23defaf5f6b458701c360c9b2a5dd8
Author:     Toomas Soome <tsoome at FreeBSD.org>
AuthorDate: 2021-08-21 11:25:36 +0000
Commit:     Toomas Soome <tsoome at FreeBSD.org>
CommitDate: 2021-08-28 05:37:03 +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.
    
    (cherry picked from commit e5a50b03297fa09652b3cf319bc6e863392554e0)
---
 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 92af49913748..71c162a77f27 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


More information about the dev-commits-src-all mailing list