From patchwork Mon Sep 15 12:28:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 317 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939378; bh=RCWyKyUl3Qu/pZnYF0Sk4n3SwZtcFp89OtuI/PIllqA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Qr0+0PaychKUT4iDI+1OfzpVwlLgtZqyFNTF1H5g7uatKNhXPYPE3948TPkCILke/ JfuD5X6U1xwAqdyUUtkVs6uizGLHxML5VML7vP5rgiNGOaQHwYqPMRzwVU1w8ifBID cNvVaziRY/L5HPa+4areOF4wc+84KedDZv0GC1ElnlKQFJMiSO5xftpuLLYawBdQvt M/MIW/cZYuTU0EbxVPCaxATh0gC0k7SdyLyOlqD5y5dFLPu1YVhvYGoByFAvTi84jm EwEMZuWlF6bUR/NGH1OIvDSv6WebyedxdXD4xtdVvtRpwcArEDmahu3SFibGeD9b+U Z1hwau2UXuwcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E77767BCE for ; Mon, 15 Sep 2025 06:29:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id C-Ea2xkQnexA for ; Mon, 15 Sep 2025 06:29:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939378; bh=RCWyKyUl3Qu/pZnYF0Sk4n3SwZtcFp89OtuI/PIllqA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Qr0+0PaychKUT4iDI+1OfzpVwlLgtZqyFNTF1H5g7uatKNhXPYPE3948TPkCILke/ JfuD5X6U1xwAqdyUUtkVs6uizGLHxML5VML7vP5rgiNGOaQHwYqPMRzwVU1w8ifBID cNvVaziRY/L5HPa+4areOF4wc+84KedDZv0GC1ElnlKQFJMiSO5xftpuLLYawBdQvt M/MIW/cZYuTU0EbxVPCaxATh0gC0k7SdyLyOlqD5y5dFLPu1YVhvYGoByFAvTi84jm EwEMZuWlF6bUR/NGH1OIvDSv6WebyedxdXD4xtdVvtRpwcArEDmahu3SFibGeD9b+U Z1hwau2UXuwcA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CB2C67BCB for ; Mon, 15 Sep 2025 06:29:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939375; bh=mBBpkA9FnX4Tqi65539WXhKIwnaDadHjl2jqbODxAE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WdLVbJ+E8xw2dH5AWV1gqOLC6/iy8pEOaNAIDGrLJHQ0Ij4rdqmCcMwkjDgXzRnBB nVxHCT8Y/q374nocoaXdqyyCj2F770XGTwQDdniQNVFQvsQsmCKglHJHrdWgBQCA8E 2cF6fhgQiypvpoG/D3mo5ySJhgucp6MEgFykjmC7LgZSHmg+PiAM8wF8o7sMnwS8WN tIXTHpCI7VaEvJAdBD4azxrdo7d/24NVVwYYQ3yx5Wfp6ZkESmWJA03TO/QgjDR6xO IcRj+tD78o1t7Of5jEnXvmE1QSgBkmyW7++8UuVje5YXrcuHJ7hiMbGKP79qG47Ubs 5eexq05DxCmNw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5ADAB67B45; Mon, 15 Sep 2025 06:29:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id jM58kOB09SMj; Mon, 15 Sep 2025 06:29:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939365; bh=PqFCuyBRpUYSmPFRlkD+S6q4c1D5PuJcifCgSdmgj2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAvqk6KYPnIaL5L26WUWnq8H4axM8+nTCWXsIASOb4Meq8BnNn5/gB+anxlQYqoOI SL6JqIV50GTYiCTpXK4hMhgHa+salkZ5ruxCgD+mwGwoBuThjFbe7pnqrT9MwrIvCK b4AOsEBiWlP72VTDjZGcjfFu0CwU45l5kK3JZ5oYKz4KLG7xZVN/VKvFLNKQI3W6ui 3JjU9Rnw8ywVXdFGm0veZtbw4OanAJfqS29aZpZwkhJcZaCBTpEPOhre7fwGhnuGW5 Glfbl7T4dY06yGLIFZwYpInAz7mxuhcjR3ItFn71h3SLF9FJ9dJx7VvqwHwQWd6821 WO3ql0tV28spw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9001C67B3C; Mon, 15 Sep 2025 06:29:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 06:28:35 -0600 Message-ID: <20250915122905.1217249-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915122905.1217249-1-sjg@u-boot.org> References: <20250915122905.1217249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UJQPXQNZQXLVTIQCXOO5W4WQESATKUM4 X-Message-ID-Hash: UJQPXQNZQXLVTIQCXOO5W4WQESATKUM4 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/23] video: Support drawing filled boxes List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass At present only an outline boxes is supported, albeit with a thickness parameter. Provide a way to draw a filled rectangle. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/scene.c | 2 +- drivers/video/video-uclass.c | 27 +++++++++++++++++---------- include/video.h | 3 ++- test/dm/video.c | 17 +++++++++++++---- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 5d2d6617491..564037b0e1a 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -681,7 +681,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) struct scene_obj_box *box = (struct scene_obj_box *)obj; video_draw_box(dev, obj->bbox.x0, obj->bbox.y0, obj->bbox.x1, - obj->bbox.y1, box->width, vid_priv->colour_fg); + obj->bbox.y1, box->width, vid_priv->colour_fg, false); break; } case SCENEOBJT_TEXTEDIT: { diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index c02fd9bb958..324817aa5ce 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -218,7 +218,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, } int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1, - int width, u32 colour) + int width, u32 colour, bool fill) { struct video_priv *priv = dev_get_uclass_priv(dev); int pbytes = VNBYTES(priv->bpix); @@ -233,17 +233,24 @@ int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1, void *ptr = line; int i; - for (i = 0; i < width; i++) - fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes); - if (row < y0 + width || row >= y1 - width) { - for (i = 0; i < pixels - width * 2; i++) - fill_pixel_and_goto_next(&ptr, colour, pbytes, - pbytes); + if (fill) { + /* fill the entire row */ + for (i = 0; i < pixels; i++) + fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes); } else { - ptr += (pixels - width * 2) * pbytes; + /* draw outline only */ + for (i = 0; i < width; i++) + fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes); + if (row < y0 + width || row >= y1 - width) { + for (i = 0; i < pixels - width * 2; i++) + fill_pixel_and_goto_next(&ptr, colour, pbytes, + pbytes); + } else { + ptr += (pixels - width * 2) * pbytes; + } + for (i = 0; i < width; i++) + fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes); } - for (i = 0; i < width; i++) - fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes); line += priv->line_length; } video_damage(dev, x0, y0, x1 - x0, y1 - y0); diff --git a/include/video.h b/include/video.h index b2eaecf5866..9f891cf9d30 100644 --- a/include/video.h +++ b/include/video.h @@ -277,10 +277,11 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, * @y1: Y end position in pixels from the top * @width: width in pixels * @colour: Value to write + * @fill: true to fill the box, false to draw outline only * Return: 0 if OK, -ENOSYS if the display depth is not supported */ int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1, - int width, u32 colour); + int width, u32 colour, bool fill); /** * video_sync() - Sync a device's frame buffer with its hardware diff --git a/test/dm/video.c b/test/dm/video.c index e48f6b078c7..8fc1a4d8b0d 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -911,14 +911,23 @@ static int dm_test_video_box(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); priv = dev_get_uclass_priv(dev); + + /* test outline boxes */ video_draw_box(dev, 100, 100, 200, 200, 3, - video_index_to_colour(priv, VID_LIGHT_BLUE)); + video_index_to_colour(priv, VID_LIGHT_BLUE), false); video_draw_box(dev, 300, 100, 400, 200, 1, - video_index_to_colour(priv, VID_MAGENTA)); + video_index_to_colour(priv, VID_MAGENTA), false); video_draw_box(dev, 500, 100, 600, 200, 20, - video_index_to_colour(priv, VID_LIGHT_RED)); + video_index_to_colour(priv, VID_LIGHT_RED), false); ut_asserteq(133, video_compress_fb(uts, dev, false)); - ut_assertok(video_check_copy_fb(uts, dev)); + + /* test filled boxes */ + video_draw_box(dev, 150, 250, 200, 300, 0, + video_index_to_colour(priv, VID_GREEN), true); + video_draw_box(dev, 350, 250, 400, 300, 0, + video_index_to_colour(priv, VID_YELLOW), true); + + ut_asserteq(175, video_compress_fb(uts, dev, false)); return 0; }