From owner-dev-commits-src-all@freebsd.org Tue Mar 9 14:31:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 637625541D0; Tue, 9 Mar 2021 14:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DvyLg2QMfz4Vng; Tue, 9 Mar 2021 14:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4634B1DA38; Tue, 9 Mar 2021 14:31:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 129EV798001888; Tue, 9 Mar 2021 14:31:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 129EV7Gc001887; Tue, 9 Mar 2021 14:31:07 GMT (envelope-from git) Date: Tue, 9 Mar 2021 14:31:07 GMT Message-Id: <202103091431.129EV7Gc001887@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 1ceb3c6c3bdb - releng/13.0 - loader: cursor off should restore display content MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.0 X-Git-Reftype: branch X-Git-Commit: 1ceb3c6c3bdbd0feabe1e071cac1a464bba125b1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2021 14:31:07 -0000 The branch releng/13.0 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=1ceb3c6c3bdbd0feabe1e071cac1a464bba125b1 commit 1ceb3c6c3bdbd0feabe1e071cac1a464bba125b1 Author: Toomas Soome AuthorDate: 2021-03-06 10:19:43 +0000 Commit: Toomas Soome CommitDate: 2021-03-09 14:30:47 +0000 loader: cursor off should restore display content When drawing cursor, we should store original display content because there may be image data we would like to restore when the cursor is removed. PR: 254054 Reported by: Jose Luis Duran Approved by: re (gjb) (cherry picked from commit d708f23ebb06cfc9cf8f96f17a43eb63653b818a) --- stand/common/gfx_fb.c | 38 ++++++++++++++++++++++++++++++++++++++ stand/common/gfx_fb.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 77cf1d39854f..3eae0a3a859e 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -978,6 +978,7 @@ 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) { + unsigned x, y, width, height; const uint8_t *glyph; int idx; @@ -985,10 +986,47 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on) 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; + + /* + * Save original display content to preserve image data. + */ + if (on) { + if (state->tg_cursor_image == NULL || + state->tg_cursor_size != width * height * 4) { + free(state->tg_cursor_image); + state->tg_cursor_size = width * height * 4; + state->tg_cursor_image = malloc(state->tg_cursor_size); + } + if (state->tg_cursor_image != NULL) { + if (gfxfb_blt(state->tg_cursor_image, + GfxFbBltVideoToBltBuffer, x, y, 0, 0, + width, height, 0) != 0) { + free(state->tg_cursor_image); + state->tg_cursor_image = NULL; + } + } + } else { + /* + * Restore display from tg_cursor_image. + * If there is no image, restore char from screen_buffer. + */ + 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; + return; + } + } + 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); + state->tg_cursor = *p; } diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index ac63d7939cef..89b060a02cf9 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -210,6 +210,8 @@ typedef struct teken_gfx { teken_t tg_teken; /* Teken core */ teken_pos_t tg_cursor; /* Where cursor was drawn */ bool tg_cursor_visible; + uint8_t *tg_cursor_image; /* Memory for cursor */ + size_t tg_cursor_size; teken_pos_t tg_tp; /* Terminal dimensions */ teken_pos_t tg_origin; /* Point of origin in pixels */ uint8_t *tg_glyph; /* Memory for glyph */