From patchwork Sun Dec 15 10:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851522 Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F02F614D29D for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259524; cv=none; b=sBLL/Tk1IcmEHW7FY3aAWUEB4z2aZns70jV5Bomq6TE4Ozdu6vTldKg/jvNMjNhmC335jSmLT/M/mDu4OAjEbdauKaNBZpf9B7jmQFOpps3XnSocY1e5+K/aTnOw9CoUnzdRwK7FerthP7qSVPNvYUH2C/L9GXLaB2X3KphXM8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259524; c=relaxed/simple; bh=FmgQ42YtLyKcr56iqUTHMUlg13/S6R2hBOvTLAu4C08=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S+Bk7adZiDm+9df8t+6CzjAzei82b0rQ9R5bT0lh5MtFtxnLIPYtYszg0nGLP9PqEXJlVCKNAPWzFQHStmMNJYwv0OgBRg8TzrUBa9TRPWUfaVDlYXljYe1MgkXE0M2GlNs0xBDDWIWvc/9uNyNJuR6IjFVQHr8QkwXTb+atp84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by andre.telenet-ops.be with cmsmtp id oylD2D00P4qjdAp01ylDUM; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kj3-0G; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlH-EU; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 01/17] Add support for exporting virtual test images Date: Sun, 15 Dec 2024 11:44:52 +0100 Message-Id: <20241215104508.191237-2-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for operating on a virtual buffer in RAM instead of on a real frame buffer device, and exporting the result as a PPM image. The size of the virtual buffer is configurable, but for now the format is fixed to Truecolor 8:8:8:0. This is useful for e.g. testing drawing algorithms on screen sizes not supported by your hardware. Signed-off-by: Geert Uytterhoeven --- export.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++ fb.c | 9 +++ include/export.h | 14 ++++ include/util.h | 1 + main.c | 33 ++++++--- tests.c | 3 + util.c | 6 ++ 7 files changed, 233 insertions(+), 9 deletions(-) create mode 100644 export.c create mode 100644 include/export.h diff --git a/export.c b/export.c new file mode 100644 index 0000000000000000..ddf24518cadceaf3 --- /dev/null +++ b/export.c @@ -0,0 +1,176 @@ + +/* + * Virtual Frame Buffer Export + * + * (C) Copyright 2024 Glider bv + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive for + * more details. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include + +#include "types.h" +#include "export.h" +#include "fb.h" +#include "util.h" + + +static const char *export_prefix; +static unsigned int export_xres = DEFAULT_EXPORT_XRES; +static unsigned int export_yres = DEFAULT_EXPORT_YRES; + +static void export_setup(void) +{ + const char *param = Opt_Export; + char *end; + + /* Prefix */ + end = strchr(param, ','); + if (end) + *end++ = '\0'; + + export_prefix = param; + Debug("export_prefix = %s\n", export_prefix); + + /* Optional horizontal resolution */ + param = end; + if (!param) + return; + + end = strchr(param, ','); + if (end) + *end++ = '\0'; + + export_xres = atoi(param); + Debug("export_xres = %u\n", export_xres); + + /* Optional vertical resolution */ + param = end; + if (!param) + return; + + end = strchr(param, ','); + if (end) + *end++ = '\0'; + + export_yres = atoi(param); + Debug("export_yres = %u\n", export_yres); +} + +void export_init(void) +{ + export_setup(); + + fb_var.xres = export_xres; + fb_var.yres = export_yres; + fb_var.xres_virtual = export_xres; + fb_var.yres_virtual = export_yres; + fb_var.xoffset = 0; + fb_var.yoffset = 0; + fb_var.bits_per_pixel = 32; + fb_var.grayscale = 0; + fb_var.red.offset = 16; + fb_var.red.length = 8; + fb_var.red.msb_right = 0; + fb_var.green.offset = 8; + fb_var.green.length = 8; + fb_var.green.msb_right = 0; + fb_var.blue.offset = 0; + fb_var.blue.length = 8; + fb_var.blue.msb_right = 0; + fb_var.transp.offset = 0; + fb_var.transp.length = 0; + fb_var.transp.msb_right = 0; + fb_var.nonstd = 0; + fb_var.activate = 0; + fb_var.height = fb_var.xres / 4; + fb_var.width = fb_var.yres / 4; + fb_var.accel_flags = 0; + fb_var.pixclock = 0; + fb_var.left_margin = 0; + fb_var.right_margin = 0; + fb_var.upper_margin = 0; + fb_var.lower_margin = 0; + fb_var.hsync_len = 0; + fb_var.vsync_len = 0; + fb_var.sync = 0; + fb_var.vmode = FB_VMODE_NONINTERLACED; + fb_var.rotate = 0; + fb_var.colorspace = 0; + fb_var.reserved[0] = 0; + fb_var.reserved[1] = 0; + fb_var.reserved[2] = 0; + fb_var.reserved[3] = 0; + + strcpy(fb_fix.id, "fbtest"); + fb_fix.smem_start = 0; + fb_fix.smem_len = fb_var.xres * fb_var.yres * 4; + fb_fix.type = FB_TYPE_PACKED_PIXELS; + fb_fix.type_aux = 0; + fb_fix.visual = FB_VISUAL_TRUECOLOR; + fb_fix.xpanstep = 0; + fb_fix.ypanstep = 0; + fb_fix.ywrapstep = 0; + fb_fix.line_length = fb_var.xres * 4; + fb_fix.mmio_start = 0; + fb_fix.mmio_len = 0; + fb_fix.accel = FB_ACCEL_NONE; + fb_fix.capabilities = 0; + fb_fix.reserved[0] = 0; + fb_fix.reserved[1] = 0; + + fb = malloc(fb_fix.smem_len); + if (!fb) + Fatal("malloc %u: %s\n", fb_fix.smem_len, strerror(errno)); +} + +void export_fb(const char *name) +{ + unsigned int x, y; + u32 *src, pixel; + char *filename; + u8 *line, *dst; + FILE *stream; + int res; + + res = asprintf(&filename, "%s%s.ppm", export_prefix, name); + if (res < 0) + Fatal("asprintf: %s\n", strerror(errno)); + + line = malloc(fb_var.xres * 3); + if (!line) + Fatal("malloc %u: %s\n", fb_var.xres * 3, strerror(errno)); + + Debug("Exporting to %s\n", filename); + stream = fopen(filename, "w"); + if (!stream) + Fatal("fopen %s: %s\n", filename, strerror(errno)); + + fputs("P6\n", stream); + fprintf(stream, "%u %u 255\n", fb_var.xres, fb_var.yres); + + src = (u32 *)fb; + for (y = 0; y < fb_var.yres; y++) { + dst = line; + for (x = 0; x < fb_var.xres; x++) { + pixel = *src++; + *dst++ = (pixel >> fb_var.red.offset) & 0xff; + *dst++ = (pixel >> fb_var.green.offset) & 0xff; + *dst++ = (pixel >> fb_var.blue.offset) & 0xff; + } + res = fwrite(line, 3, fb_var.xres, stream); + if (res < fb_var.xres) + Fatal("fwrite: %s\n", strerror(errno)); + } + + fclose(stream); + free(line); + free(filename); +} diff --git a/fb.c b/fb.c index c22bdece6dfeb654..ab351d15c82e09d9 100644 --- a/fb.c +++ b/fb.c @@ -20,6 +20,7 @@ #include #include "types.h" +#include "export.h" #include "fb.h" #include "util.h" #include "colormap.h" @@ -429,6 +430,11 @@ static void var_fix_validate(void) void fb_init(void) { + if (Opt_Export) { + export_init(); + return; + } + Debug("fb_init()\n"); fb_open(); fb_get_var(); @@ -490,6 +496,9 @@ void fb_init(void) void fb_cleanup(void) { + if (Opt_Export) + return; + Debug("fb_cleanup()\n"); if (saved_fb) fb_restore(); diff --git a/include/export.h b/include/export.h new file mode 100644 index 0000000000000000..e3ef18b7b8e3ec14 --- /dev/null +++ b/include/export.h @@ -0,0 +1,14 @@ + +/* + * (C) Copyright 2024 Glider bv + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive for + * more details. + */ + +#define DEFAULT_EXPORT_XRES 640 +#define DEFAULT_EXPORT_YRES 480 + +extern void export_init(void); +extern void export_fb(const char *name); diff --git a/include/util.h b/include/util.h index 64d810448d5779e4..5a6b5ab40d383d5a 100644 --- a/include/util.h +++ b/include/util.h @@ -103,6 +103,7 @@ extern double benchmark(void (*func)(unsigned long n, void *data), void *data); * Command line options */ +extern const char *Opt_Export; extern const char *Opt_Fbdev; extern int Opt_Debug; extern int Opt_List; diff --git a/main.c b/main.c index a13c80078543c7d1..9887fbd6936ecc1c 100644 --- a/main.c +++ b/main.c @@ -16,6 +16,7 @@ #include "types.h" #include "util.h" +#include "export.h" #include "fb.h" #include "drawops.h" #include "visual.h" @@ -28,6 +29,7 @@ const char *ProgramName; const char *Opt_Fbdev = DEFAULT_FBDEV; +const char *Opt_Export; int Opt_Debug = 0; int Opt_List = 0; int Opt_Quiet = 0; @@ -42,16 +44,21 @@ static void Usage(void) __attribute__ ((noreturn)); static void Usage(void) { - printf("%s: [options] [test ...]\n\n" + printf("%s: [options] [ ...]\n\n" "Valid options are:\n" - " -h, --help Display this usage information\n" - " -f, --fbdev dev Specify frame buffer device (default: %s)\n" - " -d, --debug Enable debug mode\n" - " -l, --list List tests only, don't run them\n" - " -q, --quiet Suppress messages\n" - " -v, --verbose Enable verbose mode\n" + " -h, --help Display this usage information\n" + " -e, --export [,[,]]\n" + " Do not use a frame buffer device, but operate on a\n" + " virtual buffer in RAM, and export the result as a PPM\n" + " image in .ppm (default size: %ux%u)\n" + " -f, --fbdev Specify frame buffer device (default: %s)\n" + " -d, --debug Enable debug mode\n" + " -l, --list List tests only, don't run them\n" + " -q, --quiet Suppress messages\n" + " -v, --verbose Enable verbose mode\n" "\n", - ProgramName, DEFAULT_FBDEV); + ProgramName, DEFAULT_EXPORT_XRES, DEFAULT_EXPORT_YRES, + DEFAULT_FBDEV); exit(1); } @@ -78,7 +85,15 @@ int main(int argc, char *argv[]) while (argc > 1 && argv[1][0] == '-') { if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) Usage(); - else if (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--fbdev")) { + else if (!strcmp(argv[1], "-e") || !strcmp(argv[1], "--export")) { + if (argc <= 2) + Usage(); + else { + Opt_Export = argv[2]; + argv += 2; + argc -= 2; + } + } else if (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--fbdev")) { if (argc <= 2) Usage(); else { diff --git a/tests.c b/tests.c index 6f6f818ac4ade8b3..c92236f869f41594 100644 --- a/tests.c +++ b/tests.c @@ -12,6 +12,7 @@ #include #include +#include "export.h" #include "types.h" #include "fb.h" #include "visual.h" @@ -81,6 +82,8 @@ static void run_one_test(const struct test *test) switch (res) { case TEST_OK: Message("%s: PASSED\n", test->name); + if (Opt_Export) + export_fb(test->name); break; case TEST_FAIL: diff --git a/util.c b/util.c index f199ace3501b0362..a946c12091f608f0 100644 --- a/util.c +++ b/util.c @@ -125,6 +125,9 @@ void Fatal(const char *fmt, ...) void wait_for_key(int timeout) { + if (Opt_Export) + return; + /* FIXME: no keypress handling yet */ sleep(2); } @@ -138,6 +141,9 @@ void wait_ms(int ms) { struct timespec req; + if (Opt_Export) + return; + req.tv_sec = ms/1000; req.tv_nsec = (ms % 1000)*1000000; nanosleep(&req, NULL); From patchwork Sun Dec 15 10:44:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851090 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B80DB1494A8 for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.89 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; cv=none; b=LOt/QbVf8Uq0qNhVWB08uunHgG2Rritp43Hp48CcXhQharo15XZAi0orjB+l1/5ZqWI6jazV/UyuQHU2PBiPaFUwgd8zZ4LNQAqpKpdQLnZ4F+gr2JAszQwzx0FGpO4eOAlCgjahuYfhjjXKF1/5tjkyHt2S/V8wuzX3t6PMcHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; c=relaxed/simple; bh=0dbe42JMI18o2S+1bATwPcLi67ZrJlFvinIYsXH026k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D2hH2V8CmbBRC5u8rncB+IgjKJdqs6L7U2SIzl+f/MMQgopcycQFWYy/vnXKk6ix5c7PJYA9/qpb6FKYTLUR93Yx6OvJsnYsoFEtgf3IplkK+mJiXdakIkh01HEMSeKRGyRcDWqX28qaE4k8ZzzmMiNpLQQNGg3kauGb77WLiI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by laurent.telenet-ops.be with cmsmtp id oylD2D00N4qjdAp01ylDAY; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kj5-0r; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlL-FK; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 02/17] tests: Print test description in debug mode Date: Sun, 15 Dec 2024 11:44:53 +0100 Message-Id: <20241215104508.191237-3-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Print not only the test name, but also the test description. Signed-off-by: Geert Uytterhoeven --- tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.c b/tests.c index c92236f869f41594..b1573032372e8090 100644 --- a/tests.c +++ b/tests.c @@ -55,7 +55,7 @@ static void run_one_test(const struct test *test) { enum test_res res; - Debug("Running test %s\n", test->name); + Debug("Running test %s (%s)\n", test->name, test->desc); if (test->visual != VISUAL_NONE && !visual_set(test->visual)) { Debug("Visual %d not supported\n", test->visual); From patchwork Sun Dec 15 10:44:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851088 Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC9AB1494D8 for ; Sun, 15 Dec 2024 10:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; cv=none; b=PqMdBOU9vtACczNaxrtgJLbuRKN7tvML3HAqinHBT6Ub1SK9BLjq9ZFlOzLNKAHhTZF3XfZymZEQqGwDQ9xBqdcizPZGgSTVnLe8VUSvtay3fhbw/J7QDhoBuUbwdIY1xjExmbzUEE5Zuzna0MYoRbRgE/G4xjD5VCqUo2K3bTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; c=relaxed/simple; bh=Ki95VsDGPnVdCe6KW17Ff1vZgtvjH5m/lJTod8Jdr0U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jXLP20S5enBOrsMdtVIej4ed/CPsnMimvSCiy/UHwKs8mCr2ZjHNVqzayUE1QIlft+S2IRcTw5vhRfiMKarcHLTBJ93oTgCRqv1xWlMZfB0JvfQOWzOF4XnfC/JbIV2YbjDGTlTc1toTnZp9U49H7cWvKiGuQv2f8Sj5SZYmz1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4YB08d3PlMz4wxLF for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by michel.telenet-ops.be with cmsmtp id oylD2D00T4qjdAp06ylDnj; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjA-2Q; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlP-Ft; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 03/17] Test002: Fix test description Date: Sun, 15 Dec 2024 11:44:54 +0100 Message-Id: <20241215104508.191237-4-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The test does not draw circles, but ellipses. Signed-off-by: Geert Uytterhoeven --- tests/test002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test002.c b/tests/test002.c index 8f7cab0537535fcb..e24f0b3c629cf369 100644 --- a/tests/test002.c +++ b/tests/test002.c @@ -49,7 +49,7 @@ static enum test_res test002_func(void) const struct test test002 = { .name = "test002", - .desc = "Draw a grid and some circles", + .desc = "Draw a grid and some ellipses", .visual = VISUAL_MONO, .func = test002_func, }; From patchwork Sun Dec 15 10:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851521 Received: from albert.telenet-ops.be (albert.telenet-ops.be [195.130.137.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F28D214D2BD for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; cv=none; b=ApBQgmVdS6g7fxqADf0pvSid7AtSZgGKQfdVWfajL4nLN3s8YiTvoEZFmCLUKd0DcosYFZr/Rqpq6Uxi456PTd42x41tn1qY2/CmEuib2p0FVy6dDoGlJgHb6aw1fT5SDjudMW5K8Z1nBPooPwZwrYr7hbA5zkPNy/VCSOAifRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; c=relaxed/simple; bh=ckgLCKZhlosLPfVF6woguPYpvmGpa8ywmnfGusgamBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SncAyOqsa4HM8zKYdqOtw787tcUbmlztYhj9tqFGt+J1D4vGIUNFAB/sJR4Z11Hh984/8JD9WWigt051F4+j5T/+4Oa/U+PcwxCgBjhbEo34UyWVYCTwtXAYJcxuPgZNgJfsRLf/LRXLdd1iMDsXKq9flTH9Y/A8RbOs+PdB8qY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by albert.telenet-ops.be with cmsmtp id oylD2D00T4qjdAp06ylDsd; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjF-2m; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlT-GX; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 04/17] drawops: Extract do_circle() Date: Sun, 15 Dec 2024 11:44:55 +0100 Message-Id: <20241215104508.191237-5-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 generic_draw_circle() and generic_fill_circle() are very similar. Reimplement them as wrappers around a common helper function. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 51 +++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index b2543b877a3a6154..9fd8aafb69a868a2 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -209,35 +209,6 @@ static void draw_circle_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) } } -void generic_draw_circle(u32 x, u32 y, u32 r, pixel_t pixel) -{ - u32 x1 = 0; - u32 y1 = r; - int d = 1-r; - int de = 3; - int dse = -2*r+5; - - do { - draw_circle_points(x, y, x1, y1, pixel); - if (d < 0) { // Select E - d += de; - de += 2; - dse += 2; - } else { // Select SE - d += dse; - de += 2; - dse += 4; - y1--; - } - x1++; - } while (x1 <= y1); -} - - - /* - * Draw a filled circle - */ - static void fill_circle_points_x(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) { if (x == 0) { @@ -259,7 +230,10 @@ static void fill_circle_points_y(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) } } -void generic_fill_circle(u32 x, u32 y, u32 r, pixel_t pixel) +typedef void (*draw_func_t)(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel); + +static void do_circle(u32 x, u32 y, u32 r, pixel_t pixel, draw_func_t draw_x, + draw_func_t draw_y) { u32 x1 = 0; u32 y1 = r; @@ -268,7 +242,7 @@ void generic_fill_circle(u32 x, u32 y, u32 r, pixel_t pixel) int dse = -2*r+5; do { - fill_circle_points_y(x, y, x1, y1, pixel); + draw_y(x, y, x1, y1, pixel); if (d < 0) { // Select E d += de; de += 2; @@ -277,14 +251,25 @@ void generic_fill_circle(u32 x, u32 y, u32 r, pixel_t pixel) d += dse; de += 2; dse += 4; - if (x1 != y1) - fill_circle_points_x(x, y, x1, y1, pixel); + if (draw_x && x1 != y1) + draw_x(x, y, x1, y1, pixel); y1--; } x1++; } while (x1 <= y1); } +void generic_draw_circle(u32 x, u32 y, u32 r, pixel_t pixel) +{ + do_circle(x, y, r, pixel, NULL, draw_circle_points); +} + + +void generic_fill_circle(u32 x, u32 y, u32 r, pixel_t pixel) +{ + do_circle(x, y, r, pixel, fill_circle_points_x, fill_circle_points_y); +} + /* * Draw an ellipse using a differential version of the Bresenham algorithm From patchwork Sun Dec 15 10:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851086 Received: from riemann.telenet-ops.be (riemann.telenet-ops.be [195.130.137.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C85212DD95 for ; Sun, 15 Dec 2024 10:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259993; cv=none; b=b1P2ZydEPxUHmzDAUvsZt/8NTMUi1nB5A3eRpNN5GSZQFH9fL6y8FSjc4eQCp4GicZOzgdSNIRQW3fbT7Fc9PNIdo22V5uicA/QwJmEpDE+dQdu7Bsm50p/KwuKGFogVnw/Kt1v8zkErM4vyQ/lerCNVonWDzV8NmrsnZp3OXNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259993; c=relaxed/simple; bh=pprltnKf/0+GmnJpn7dCFkr63bC2wJJ+2CpKRtD9PvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ar+Rep9c23+Nwzy2r8iTBCDfGT+hFRetn9d5VxcsyE0GA5cwYNW+1K5TjezdnE+h0xWgCbANftIllDSFA0uK2ZxQ9pIYBgvTLNRNJo055x1Os6yJVMMiIM6bLEELqpPpGebVa/8QuB6oqMeAR9/pJd9IryHifI9KUOlcgjiirSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by riemann.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2rd0z4wx6m for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by baptiste.telenet-ops.be with cmsmtp id oylD2D00R4qjdAp01ylDME; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjJ-3K; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlX-Hm; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 05/17] drawops: Use "y == 0" in draw_ellipse_points() Date: Sun, 15 Dec 2024 11:44:56 +0100 Message-Id: <20241215104508.191237-6-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace the rare "0 == y" check by the more common "y == 0" check. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drawops/generic.c b/drawops/generic.c index 9fd8aafb69a868a2..ba8154b7ee34ca18 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -281,7 +281,7 @@ static void draw_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) if (x == 0) { set_pixel(cx, cy-y, pixel); set_pixel(cx, cy+y, pixel); - } else if (0 == y) { + } else if (y == 0) { set_pixel(cx-x, cy, pixel); set_pixel(cx+x, cy, pixel); } else { From patchwork Sun Dec 15 10:44:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851515 Received: from weierstrass.telenet-ops.be (weierstrass.telenet-ops.be [195.130.137.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38DA012DD95 for ; Sun, 15 Dec 2024 10:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260003; cv=none; b=uI22W/FuDWLSNMMGxOkVfJfRrAszhra94nJOZZON2InPW9vwhq6BfxP6urQ6F4IkWsDJ1v9yQ8Gry1qhvfkNa8n4FcIWaD/rsOH1Z9Jrt2PJ0UIyo/nEZ2XRXGf9XUiXZimBeiLrL+wffu8+xITibkMW5J1jK5wjfOTiq7dr4as= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260003; c=relaxed/simple; bh=gWOlCwo033U3BeyaBw8VE5a5osE6PQ6ubCLjTkchrbg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sUPwHcxRMX/Rds5+qkt9iQBEQd1N+XJM+WCCcp4TNvG1kKcN3MumD/6wx1v+PLNT8VhbocuIkr4FhsXt67xEFlhx9dDO/kH6Vq4vJRPy4HcTodjpzMPBsShBokElF6puPw/wD0aZK629plBKGC0w4hiJBIitCTtgTUq7jHtxh3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by weierstrass.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2zf7z4wwhR for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by baptiste.telenet-ops.be with cmsmtp id oylD2D00S4qjdAp01ylDMF; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjM-3n; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nle-IR; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 06/17] drawops: Remove always-false check in generic_fill_ellipse() Date: Sun, 15 Dec 2024 11:44:57 +0100 Message-Id: <20241215104508.191237-7-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 x1 is u32, so it can never be negative. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index ba8154b7ee34ca18..e81dea1ba23d6595 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -467,8 +467,6 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) dS2 += 4*b2; dT2 += 4*b2; x1--; - if (x1 < 0) - break; y1++; fill_ellipse_points(x, y, x1, y1, pixel); } else { From patchwork Sun Dec 15 10:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851519 Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F27139D for ; Sun, 15 Dec 2024 10:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; cv=none; b=So3fwFK4WgAmg5WOQ+raV9DWIMKRhPdNWZ6ZwBlVc8/L6qoOC0Da/V2Jq8Ycs+PJpSj/KIyhD6D1uwaMcznpYSwGSS/3/JG4+i1klGMdhvJg1KSXC+pjxShcTuXDYNf1vLahM2EiQDu09ufSKRtOhrpFCGxfDPZdtvwHFZYBNak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; c=relaxed/simple; bh=xa/5Pvv+6jmIZuNlaDgSnuHxLFolDf+phO1ADj2xxTs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a8nBkMkvRUt0NYjQ/uLU8+OZZnhr6pSuNoeJOBvNElbCgsknaGW1S+RYXz+VsQTPDartDmbNqtudkkh1UQw5ANEuC3QauYZ5OK7QVxWP6tYuhaJcG/rri4+9FaehFpXitTr5WjVNNDrJ7fpSMG/3x/Ki6eXiRJSVHlZuCTAOkdc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2kHqz4wxK5 for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by baptiste.telenet-ops.be with cmsmtp id oylD2D00U4qjdAp01ylDMH; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjR-4T; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nli-J3; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 07/17] drawops: Refactor generic_draw_ellipse() Date: Sun, 15 Dec 2024 11:44:58 +0100 Message-Id: <20241215104508.191237-8-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make generic_draw_ellipse() more similar to generic_fill_ellipse(). Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index e81dea1ba23d6595..4b64c20cc0fe68bc 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -309,15 +309,18 @@ void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) int dS2 = -4*a2*(b-1); int dT2 = dS2+2*a2; - draw_ellipse_points(x, y, x1, y1, pixel); - do { + while (1) { if (S < 0) { + draw_ellipse_points(x, y, x1, y1, pixel); S += dS1; T += dT1; dS1 += 4*b2; dT1 += 4*b2; x1++; } else if (T < 0) { + draw_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; S += dS1+dS2; T += dT1+dT2; dS1 += 4*b2; @@ -327,14 +330,16 @@ void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) x1++; y1--; } else { + draw_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; S += dS2; T += dT2; dS2 += 4*a2; dT2 += 4*a2; y1--; } - draw_ellipse_points(x, y, x1, y1, pixel); - } while (y1 > 0); + } } else { u32 x1 = a; u32 y1 = 0; @@ -353,6 +358,7 @@ void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) dS1 += 4*a2; dT1 += 4*a2; y1++; + draw_ellipse_points(x, y, x1, y1, pixel); } else if (T < 0) { S += dS1+dS2; T += dT1+dT2; @@ -362,14 +368,15 @@ void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) dT2 += 4*b2; x1--; y1++; + draw_ellipse_points(x, y, x1, y1, pixel); } else { S += dS2; T += dT2; dS2 += 4*b2; dT2 += 4*b2; x1--; + draw_ellipse_points(x, y, x1, y1, pixel); } - draw_ellipse_points(x, y, x1, y1, pixel); } while (x1 > 0); } } From patchwork Sun Dec 15 10:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851085 Received: from weierstrass.telenet-ops.be (weierstrass.telenet-ops.be [195.130.137.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38E2E14D2BD for ; Sun, 15 Dec 2024 10:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260003; cv=none; b=AnnbVv/rIfZqF5+VsWol0MS6OsBFSVJBEivbww7dDFWHigpd9YY9edXjwSZ1jDtZyju4NKE5BDccsGWMHzXq1yZXO0x2EnvFXEmT655cPFk1q0Sv0u6h2budfaew6A9Y2xdhmXMlXED3vqH8SEDNfkFqgixDGTePnxSayECm15Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260003; c=relaxed/simple; bh=RiSYV2u/rXGtvrBA9gxQ450GsKzspJ1QWTJ+kPHzw84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cco0wGymq10L6i2KJ5Pk7gNxH7VVRac1hJtLffU2VXnPRr3ZAJy8u/9rhhtybyJwXkarrw02KXXlPYHZm1dBALlqOrQFbNxBR58JuzchI/Ndqd6H/TCn0dpVQ5lVSW7nQiWGh710jidF/Ji1oZAqmVsE8SZDVzEIsVG39uuuSOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by weierstrass.telenet-ops.be (Postfix) with ESMTPS id 4YB08d3KMyz4wwsB for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by xavier.telenet-ops.be with cmsmtp id oylD2D00P4qjdAp01ylDEm; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjT-51; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlm-Jd; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 08/17] drawops: Return early in generic_{draw,fill}_ellipse() Date: Sun, 15 Dec 2024 11:44:59 +0100 Message-Id: <20241215104508.191237-9-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This reduces indentation in the largest branches. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 324 +++++++++++++++++++++++----------------------- 1 file changed, 162 insertions(+), 162 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index 4b64c20cc0fe68bc..471aefe38d43aaa4 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -295,90 +295,90 @@ static void draw_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) { if (a == b) - draw_circle(x, y, a, pixel); - else { - u32 a2 = a*a; - u32 b2 = b*b; - if (a <= b) { - u32 x1 = 0; - u32 y1 = b; - int S = a2*(1-2*b)+2*b2; - int T = b2-2*a2*(2*b-1); - int dT1 = 4*b2; - int dS1 = dT1+2*b2; - int dS2 = -4*a2*(b-1); - int dT2 = dS2+2*a2; - - while (1) { - if (S < 0) { - draw_ellipse_points(x, y, x1, y1, pixel); - S += dS1; - T += dT1; - dS1 += 4*b2; - dT1 += 4*b2; - x1++; - } else if (T < 0) { - draw_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*b2; - dT1 += 4*b2; - dS2 += 4*a2; - dT2 += 4*a2; - x1++; - y1--; - } else { - draw_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS2; - T += dT2; - dS2 += 4*a2; - dT2 += 4*a2; - y1--; - } + return draw_circle(x, y, a, pixel); + + u32 a2 = a*a; + u32 b2 = b*b; + + if (a <= b) { + u32 x1 = 0; + u32 y1 = b; + int S = a2*(1-2*b)+2*b2; + int T = b2-2*a2*(2*b-1); + int dT1 = 4*b2; + int dS1 = dT1+2*b2; + int dS2 = -4*a2*(b-1); + int dT2 = dS2+2*a2; + + while (1) { + if (S < 0) { + draw_ellipse_points(x, y, x1, y1, pixel); + S += dS1; + T += dT1; + dS1 += 4*b2; + dT1 += 4*b2; + x1++; + } else if (T < 0) { + draw_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*b2; + dT1 += 4*b2; + dS2 += 4*a2; + dT2 += 4*a2; + x1++; + y1--; + } else { + draw_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS2; + T += dT2; + dS2 += 4*a2; + dT2 += 4*a2; + y1--; } - } else { - u32 x1 = a; - u32 y1 = 0; - int S = b2*(1-2*a)+2*a2; - int T = a2-2*b2*(2*a-1); - int dT1 = 4*a2; - int dS1 = dT1+2*a2; - int dS2 = -4*b2*(a-1); - int dT2 = dS2+2*b2; - - draw_ellipse_points(x, y, x1, y1, pixel); - do { - if (S < 0) { - S += dS1; - T += dT1; - dS1 += 4*a2; - dT1 += 4*a2; - y1++; - draw_ellipse_points(x, y, x1, y1, pixel); - } else if (T < 0) { - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*a2; - dT1 += 4*a2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - y1++; - draw_ellipse_points(x, y, x1, y1, pixel); - } else { - S += dS2; - T += dT2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - draw_ellipse_points(x, y, x1, y1, pixel); - } - } while (x1 > 0); } + } else { + u32 x1 = a; + u32 y1 = 0; + int S = b2*(1-2*a)+2*a2; + int T = a2-2*b2*(2*a-1); + int dT1 = 4*a2; + int dS1 = dT1+2*a2; + int dS2 = -4*b2*(a-1); + int dT2 = dS2+2*b2; + + draw_ellipse_points(x, y, x1, y1, pixel); + do { + if (S < 0) { + S += dS1; + T += dT1; + dS1 += 4*a2; + dT1 += 4*a2; + y1++; + draw_ellipse_points(x, y, x1, y1, pixel); + } else if (T < 0) { + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*a2; + dT1 += 4*a2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + y1++; + draw_ellipse_points(x, y, x1, y1, pixel); + } else { + S += dS2; + T += dT2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + draw_ellipse_points(x, y, x1, y1, pixel); + } + } while (x1 > 0); } } @@ -403,88 +403,88 @@ static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) { if (a == b) - fill_circle(x, y, a, pixel); - else { - u32 a2 = a*a; - u32 b2 = b*b; - if (a <= b) { - u32 x1 = 0; - u32 y1 = b; - int S = a2*(1-2*b)+2*b2; - int T = b2-2*a2*(2*b-1); - int dT1 = 4*b2; - int dS1 = dT1+2*b2; - int dS2 = -4*a2*(b-1); - int dT2 = dS2+2*a2; - - while (1) { - if (S < 0) { - S += dS1; - T += dT1; - dS1 += 4*b2; - dT1 += 4*b2; - x1++; - } else if (T < 0) { - fill_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*b2; - dT1 += 4*b2; - dS2 += 4*a2; - dT2 += 4*a2; - x1++; - y1--; - } else { - fill_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS2; - T += dT2; - dS2 += 4*a2; - dT2 += 4*a2; - y1--; - } + return fill_circle(x, y, a, pixel); + + u32 a2 = a*a; + u32 b2 = b*b; + + if (a <= b) { + u32 x1 = 0; + u32 y1 = b; + int S = a2*(1-2*b)+2*b2; + int T = b2-2*a2*(2*b-1); + int dT1 = 4*b2; + int dS1 = dT1+2*b2; + int dS2 = -4*a2*(b-1); + int dT2 = dS2+2*a2; + + while (1) { + if (S < 0) { + S += dS1; + T += dT1; + dS1 += 4*b2; + dT1 += 4*b2; + x1++; + } else if (T < 0) { + fill_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*b2; + dT1 += 4*b2; + dS2 += 4*a2; + dT2 += 4*a2; + x1++; + y1--; + } else { + fill_ellipse_points(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS2; + T += dT2; + dS2 += 4*a2; + dT2 += 4*a2; + y1--; } - } else { - u32 x1 = a; - u32 y1 = 0; - int S = b2*(1-2*a)+2*a2; - int T = a2-2*b2*(2*a-1); - int dT1 = 4*a2; - int dS1 = dT1+2*a2; - int dS2 = -4*b2*(a-1); - int dT2 = dS2+2*b2; - - fill_ellipse_points(x, y, x1, y1, pixel); - do { - if (S < 0) { - S += dS1; - T += dT1; - dS1 += 4*a2; - dT1 += 4*a2; - y1++; - fill_ellipse_points(x, y, x1, y1, pixel); - } else if (T < 0) { - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*a2; - dT1 += 4*a2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - y1++; - fill_ellipse_points(x, y, x1, y1, pixel); - } else { - S += dS2; - T += dT2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - } - } while (x1 > 0); } + } else { + u32 x1 = a; + u32 y1 = 0; + int S = b2*(1-2*a)+2*a2; + int T = a2-2*b2*(2*a-1); + int dT1 = 4*a2; + int dS1 = dT1+2*a2; + int dS2 = -4*b2*(a-1); + int dT2 = dS2+2*b2; + + fill_ellipse_points(x, y, x1, y1, pixel); + do { + if (S < 0) { + S += dS1; + T += dT1; + dS1 += 4*a2; + dT1 += 4*a2; + y1++; + fill_ellipse_points(x, y, x1, y1, pixel); + } else if (T < 0) { + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*a2; + dT1 += 4*a2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + y1++; + fill_ellipse_points(x, y, x1, y1, pixel); + } else { + S += dS2; + T += dT2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + } + } while (x1 > 0); } } From patchwork Sun Dec 15 10:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851091 Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8FED14A4F9 for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259524; cv=none; b=rEDynYVDT7Qn8MijSpoVY23aE0v5GKqj0+YaCAw7n7mYpQ1F+szcRMiMKmnaDUkarvr2REfhC6fYt7cyr7cm1DV1vG+RXkz5fxi8r2KBqJ682fkllhMdWDoT1V6jSxISK97Y4niRn+Qp0D8HSf9joZpQkxPh+8kOORGQhnVqVKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259524; c=relaxed/simple; bh=h6gTcNt0Kq5jy2CZ1jMUbozvqiXQG7WvxI04IQh5eVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HaRbhefj14hGt/GyI0/iMXJn5WTCOe+KcGSKUiEWzFZvU+rqfmP0yfo3mOrCLsc9Hhfp3X6lHzVYP3WA0bHiBizhVu4OzjyyR5LeNxvRsWEQChqJxXKsDRdYfAi5C7Po/7sOsWGhVhnJuOfeBBku0IOUZHUhjN3TE1L5aJnGC3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by andre.telenet-ops.be with cmsmtp id oylD2D00Y4qjdAp01ylDUQ; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjX-5e; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlr-KG; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 09/17] drawops: Extract do_ellipse() Date: Sun, 15 Dec 2024 11:45:00 +0100 Message-Id: <20241215104508.191237-10-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 generic_draw_ellipse() and generic_fill_ellipse() are very similar. Reimplement them as wrappers around a common helper function. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 132 ++++++++++------------------------------------ 1 file changed, 28 insertions(+), 104 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index 471aefe38d43aaa4..b3218f50d86c6d4c 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -292,101 +292,6 @@ static void draw_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) } } -void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) -{ - if (a == b) - return draw_circle(x, y, a, pixel); - - u32 a2 = a*a; - u32 b2 = b*b; - - if (a <= b) { - u32 x1 = 0; - u32 y1 = b; - int S = a2*(1-2*b)+2*b2; - int T = b2-2*a2*(2*b-1); - int dT1 = 4*b2; - int dS1 = dT1+2*b2; - int dS2 = -4*a2*(b-1); - int dT2 = dS2+2*a2; - - while (1) { - if (S < 0) { - draw_ellipse_points(x, y, x1, y1, pixel); - S += dS1; - T += dT1; - dS1 += 4*b2; - dT1 += 4*b2; - x1++; - } else if (T < 0) { - draw_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*b2; - dT1 += 4*b2; - dS2 += 4*a2; - dT2 += 4*a2; - x1++; - y1--; - } else { - draw_ellipse_points(x, y, x1, y1, pixel); - if (y1 == 0) - break; - S += dS2; - T += dT2; - dS2 += 4*a2; - dT2 += 4*a2; - y1--; - } - } - } else { - u32 x1 = a; - u32 y1 = 0; - int S = b2*(1-2*a)+2*a2; - int T = a2-2*b2*(2*a-1); - int dT1 = 4*a2; - int dS1 = dT1+2*a2; - int dS2 = -4*b2*(a-1); - int dT2 = dS2+2*b2; - - draw_ellipse_points(x, y, x1, y1, pixel); - do { - if (S < 0) { - S += dS1; - T += dT1; - dS1 += 4*a2; - dT1 += 4*a2; - y1++; - draw_ellipse_points(x, y, x1, y1, pixel); - } else if (T < 0) { - S += dS1+dS2; - T += dT1+dT2; - dS1 += 4*a2; - dT1 += 4*a2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - y1++; - draw_ellipse_points(x, y, x1, y1, pixel); - } else { - S += dS2; - T += dT2; - dS2 += 4*b2; - dT2 += 4*b2; - x1--; - draw_ellipse_points(x, y, x1, y1, pixel); - } - } while (x1 > 0); - } -} - - - /* - * Draw a filled ellipse - */ - static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) { if (x == 0) { @@ -400,11 +305,9 @@ static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) } } -void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) +static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, + draw_func_t draw_inner, draw_func_t draw_outer) { - if (a == b) - return fill_circle(x, y, a, pixel); - u32 a2 = a*a; u32 b2 = b*b; @@ -420,13 +323,15 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) while (1) { if (S < 0) { + if (draw_inner) + draw_inner(x, y, x1, y1, pixel); S += dS1; T += dT1; dS1 += 4*b2; dT1 += 4*b2; x1++; } else if (T < 0) { - fill_ellipse_points(x, y, x1, y1, pixel); + draw_outer(x, y, x1, y1, pixel); if (y1 == 0) break; S += dS1+dS2; @@ -438,7 +343,7 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) x1++; y1--; } else { - fill_ellipse_points(x, y, x1, y1, pixel); + draw_outer(x, y, x1, y1, pixel); if (y1 == 0) break; S += dS2; @@ -458,7 +363,7 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) int dS2 = -4*b2*(a-1); int dT2 = dS2+2*b2; - fill_ellipse_points(x, y, x1, y1, pixel); + draw_outer(x, y, x1, y1, pixel); do { if (S < 0) { S += dS1; @@ -466,7 +371,7 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) dS1 += 4*a2; dT1 += 4*a2; y1++; - fill_ellipse_points(x, y, x1, y1, pixel); + draw_outer(x, y, x1, y1, pixel); } else if (T < 0) { S += dS1+dS2; T += dT1+dT2; @@ -476,18 +381,37 @@ void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) dT2 += 4*b2; x1--; y1++; - fill_ellipse_points(x, y, x1, y1, pixel); + draw_outer(x, y, x1, y1, pixel); } else { S += dS2; T += dT2; dS2 += 4*b2; dT2 += 4*b2; x1--; + if (draw_inner) + draw_inner(x, y, x1, y1, pixel); } } while (x1 > 0); } } +void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) +{ + if (a == b) + draw_circle(x, y, a, pixel); + else + do_ellipse(x, y, a, b, pixel, draw_ellipse_points, + draw_ellipse_points); +} + +void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) +{ + if (a == b) + fill_circle(x, y, a, pixel); + else + do_ellipse(x, y, a, b, pixel, NULL, fill_ellipse_points); +} + /* * Copy a rectangular area From patchwork Sun Dec 15 10:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851517 Received: from riemann.telenet-ops.be (riemann.telenet-ops.be [195.130.137.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C801C13D for ; Sun, 15 Dec 2024 10:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.80 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259992; cv=none; b=kOtFj60TdUlkb4Xcop8a6KJDdflao2eY7lWeMPlnD/Lna8ILv3KxrqT6lqJl4oMFmIBUSTRXnemq1tAzppJyGKMcMZojPR/Q2dMdtivCpsHff0R87ajXo7qobsc/JxUI2j9zu+BSlBSiVJVVxMQiegBJ277NR9F5FKze2+izLno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259992; c=relaxed/simple; bh=Zi84ZlNKfGwmW6Vmr/as83nRkDAii5SOWttr8XntV8I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FRwlAhyELjnkL3ZeIMRGlL56hRT0rFtd5mbhtkpFsbYbKrURj6FFiahXGuwP03OivLpp7qELCgS3n3kE2izr1RolAlToWdcVUR563t75elB5kBbLRHSjt0EnShICmc1qjCyigZfhgrzDtDBmrjC8Q03Qxbf/1CH6EQF4WiVBAOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by riemann.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2lp6z4wwxQ for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by michel.telenet-ops.be with cmsmtp id oylD2D00X4qjdAp06ylDnq; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001KjZ-6H; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nlw-Kr; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 10/17] drawops: Make de in do_circle() unsigned Date: Sun, 15 Dec 2024 11:45:01 +0100 Message-Id: <20241215104508.191237-11-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 "de" is never negative, so it should be unsigned. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drawops/generic.c b/drawops/generic.c index b3218f50d86c6d4c..5c068e10d28fbdfe 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -238,7 +238,7 @@ static void do_circle(u32 x, u32 y, u32 r, pixel_t pixel, draw_func_t draw_x, u32 x1 = 0; u32 y1 = r; int d = 1-r; - int de = 3; + unsigned int de = 3; int dse = -2*r+5; do { From patchwork Sun Dec 15 10:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851089 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7FF78BE5 for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.89 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259526; cv=none; b=NMIALN530ESlkq5S/tHUVKY6XeDtk34OsGWs74YzPddd6uWCul/Yk+XzO4kaWnDSIpgv6rHBS6vnyNIQ6/ACruqWtPmL0BjS1Ax7Xj0IiZu+Ycw61VuP74DgZBQb8vBwe3B6Xjg8NeDnjXXRvVL74/YyvQNEqR0o7VJ3u+NA6XE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259526; c=relaxed/simple; bh=xnfxFYhkZY7KQ5iXeY1f39w5olq7txFZ2Nl2KlnICCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=evlmHb/p1e2w4/qIGZ6AHhNyUqd2xcB+Vi4G0khbYKE/iYih9P/FcWkwtll9GAEAYUWYxfrrGlsCJszeyMuY9SJUE5WlXgQtPQ3rUrJPLYgQoY62aZ4C9G0XK+12v5VW+xrsvYNJoZ4JcuN+/muYx0vCosEyR8izJ17augqToG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by laurent.telenet-ops.be with cmsmtp id oylD2D00X4qjdAp01ylDAh; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kjb-6o; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nm1-LR; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 11/17] drawops: Make dT1 and dS1 in do_ellipse() unsigned Date: Sun, 15 Dec 2024 11:45:02 +0100 Message-Id: <20241215104508.191237-12-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 "dT1" and "dS1" are never negative, so they should be unsigned. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index 5c068e10d28fbdfe..5fd971b59bc698fe 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -316,8 +316,8 @@ static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, u32 y1 = b; int S = a2*(1-2*b)+2*b2; int T = b2-2*a2*(2*b-1); - int dT1 = 4*b2; - int dS1 = dT1+2*b2; + unsigned int dT1 = 4*b2; + unsigned int dS1 = dT1+2*b2; int dS2 = -4*a2*(b-1); int dT2 = dS2+2*a2; @@ -358,8 +358,8 @@ static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, u32 y1 = 0; int S = b2*(1-2*a)+2*a2; int T = a2-2*b2*(2*a-1); - int dT1 = 4*a2; - int dS1 = dT1+2*a2; + unsigned int dT1 = 4*a2; + unsigned int dS1 = dT1+2*a2; int dS2 = -4*b2*(a-1); int dT2 = dS2+2*b2; From patchwork Sun Dec 15 10:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851514 Received: from cantor.telenet-ops.be (cantor.telenet-ops.be [195.130.132.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E754E13C9D9 for ; Sun, 15 Dec 2024 10:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260030; cv=none; b=HXh4UfMG3aOVUhTIhAe/4M6yj9M1iCmjSRAKsj/ecAmwiiMMzyYx5294FezzaYVsOXQEIh/HAZfi9u4kxa1yCE+knWuDp8NmcYVj37QrNsPjZ0cjbwUuHTVypuPR5nu3gvwNLdZEsLdkSd7ALoHCCmHRVa94Ldabg84I3Kc4gy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260030; c=relaxed/simple; bh=q5OADPiwPmkPJafYpfCEBKSAdjM3jUcJrAwHrVYTmzk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mM5JiFXWkgdpOIAZoETaZtXuPAnVDt7EkOop6QTGCBzHZqRX81GlzEhbXq3GE32Kb9C61O0qBe+C1dIjSuF1lPQhFH9YXb5msZVmRYVyEaCDQr3FoXfuiiK2FaGqgOSm0rxcd5aJf4UlhCRpGm4JdvgmZXzV7+kDPj04WYOZmBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by cantor.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2thBz4wwr1 for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by baptiste.telenet-ops.be with cmsmtp id oylD2D00W4qjdAp01ylDMK; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kji-7N; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nm6-M1; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 12/17] drawops: Fix crash when drawing large ellipses Date: Sun, 15 Dec 2024 11:45:03 +0100 Message-Id: <20241215104508.191237-13-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 "test002" crashes when run with a display resolution of e.g. 2560x1440 pixels, due to 32-bit overflow in the ellipse drawing routine. Fix this by creating a copy that uses 64-bit arithmetic. Use a heuristic to pick either the 32-bit or the 64-bit version, to avoid the overhead of the 64-bit version on small systems with small displays. Replace (unsigned) int by u32/s32 in the 32-bit version for clarity. Signed-off-by: Geert Uytterhoeven --- drawops/generic.c | 127 +++++++++++++++++++++++++++++++++++++++++----- include/types.h | 3 ++ 2 files changed, 116 insertions(+), 14 deletions(-) diff --git a/drawops/generic.c b/drawops/generic.c index 5fd971b59bc698fe..c4cfad3223773a23 100644 --- a/drawops/generic.c +++ b/drawops/generic.c @@ -305,8 +305,98 @@ static void fill_ellipse_points(u32 cx, u32 cy, u32 x, u32 y, pixel_t pixel) } } -static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, - draw_func_t draw_inner, draw_func_t draw_outer) +static void do_ellipse_32(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, + draw_func_t draw_inner, draw_func_t draw_outer) +{ + u32 a2 = a*a; + u32 b2 = b*b; + + if (a <= b) { + u32 x1 = 0; + u32 y1 = b; + s32 S = a2*(1-2*b)+2*b2; + s32 T = b2-2*a2*(2*b-1); + u32 dT1 = 4*b2; + u32 dS1 = dT1+2*b2; + s32 dS2 = -4*a2*(b-1); + s32 dT2 = dS2+2*a2; + + while (1) { + if (S < 0) { + if (draw_inner) + draw_inner(x, y, x1, y1, pixel); + S += dS1; + T += dT1; + dS1 += 4*b2; + dT1 += 4*b2; + x1++; + } else if (T < 0) { + draw_outer(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*b2; + dT1 += 4*b2; + dS2 += 4*a2; + dT2 += 4*a2; + x1++; + y1--; + } else { + draw_outer(x, y, x1, y1, pixel); + if (y1 == 0) + break; + S += dS2; + T += dT2; + dS2 += 4*a2; + dT2 += 4*a2; + y1--; + } + } + } else { + u32 x1 = a; + u32 y1 = 0; + s32 S = b2*(1-2*a)+2*a2; + s32 T = a2-2*b2*(2*a-1); + u32 dT1 = 4*a2; + u32 dS1 = dT1+2*a2; + s32 dS2 = -4*b2*(a-1); + s32 dT2 = dS2+2*b2; + + draw_outer(x, y, x1, y1, pixel); + do { + if (S < 0) { + S += dS1; + T += dT1; + dS1 += 4*a2; + dT1 += 4*a2; + y1++; + draw_outer(x, y, x1, y1, pixel); + } else if (T < 0) { + S += dS1+dS2; + T += dT1+dT2; + dS1 += 4*a2; + dT1 += 4*a2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + y1++; + draw_outer(x, y, x1, y1, pixel); + } else { + S += dS2; + T += dT2; + dS2 += 4*b2; + dT2 += 4*b2; + x1--; + if (draw_inner) + draw_inner(x, y, x1, y1, pixel); + } + } while (x1 > 0); + } +} + +static void do_ellipse_64(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, + draw_func_t draw_inner, draw_func_t draw_outer) { u32 a2 = a*a; u32 b2 = b*b; @@ -314,12 +404,12 @@ static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, if (a <= b) { u32 x1 = 0; u32 y1 = b; - int S = a2*(1-2*b)+2*b2; - int T = b2-2*a2*(2*b-1); - unsigned int dT1 = 4*b2; - unsigned int dS1 = dT1+2*b2; - int dS2 = -4*a2*(b-1); - int dT2 = dS2+2*a2; + s64 S = a2*(1-2LL*b)+2LL*b2; + s64 T = b2-2LL*a2*(2LL*b-1); + u64 dT1 = 4*b2; + u64 dS1 = dT1+2*b2; + s64 dS2 = -4LL*a2*(b-1); + s64 dT2 = dS2+2*a2; while (1) { if (S < 0) { @@ -356,12 +446,12 @@ static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, } else { u32 x1 = a; u32 y1 = 0; - int S = b2*(1-2*a)+2*a2; - int T = a2-2*b2*(2*a-1); - unsigned int dT1 = 4*a2; - unsigned int dS1 = dT1+2*a2; - int dS2 = -4*b2*(a-1); - int dT2 = dS2+2*b2; + s64 S = b2*(1-2LL*a)+2LL*a2; + s64 T = a2-2LL*b2*(2LL*a-1); + u64 dT1 = 4*a2; + u64 dS1 = dT1+2*a2; + s64 dS2 = -4LL*b2*(a-1); + s64 dT2 = dS2+2*b2; draw_outer(x, y, x1, y1, pixel); do { @@ -395,6 +485,15 @@ static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, } } +static void do_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel, + draw_func_t draw_inner, draw_func_t draw_outer) +{ + if ((a + 576) * (b + 576) < 1440000) + do_ellipse_32(x, y, a, b, pixel, draw_inner, draw_outer); + else + do_ellipse_64(x, y, a, b, pixel, draw_inner, draw_outer); +} + void generic_draw_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel) { if (a == b) diff --git a/include/types.h b/include/types.h index 9112ba6855b61eaa..0e3c76521469912f 100644 --- a/include/types.h +++ b/include/types.h @@ -21,6 +21,9 @@ typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; +typedef int s32; +typedef long long s64; + #if defined(__LP64__) || defined(__alpha__) || defined(__ia64__) || \ defined(__mips64__) || defined(__powerpc64__) || defined(__s390x__) || \ defined(__sparc64__) || defined(__x86_64__) || defined(__hppa64__) From patchwork Sun Dec 15 10:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851520 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B809B12EBE7 for ; Sun, 15 Dec 2024 10:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.89 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; cv=none; b=YbHz3ue6L0E6oaTv1jtYF85g/7+6pGk41AWYtqc6I4CmO/PgtJ6i2YdeTCZCygaoteRSCJraYkz6bc0nWUXfE90VoPbbK88IOtfO/4zf7Upqyl0LEg9YdWiktudm77C77fkpC6Y1ONkKBky/TmlGTmSVoDJJ7ySvvcbP6sU6T3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259525; c=relaxed/simple; bh=uqGcQiJ0YuNKzx4exfxPzynZ3B/NFqehpjdxfOrL/BE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d/wwofRohDHYXVWoxwn09MekQFilEEA3o4491WUkEO8f1nzDnmyFbztYwm3z3SikF1QyuafZg00G1A9ciJ2Hm2+ngK+SdEtliwlmcYhhON4WcrzB2VjkbSBn4/hSmDFOLFgkXm1E9eFr/A1OnWpRQOkGKs0MKSih724/Gu7cpUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by laurent.telenet-ops.be with cmsmtp id oylD2D00Z4qjdAp01ylDAj; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kjn-7z; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nmA-Ma; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 13/17] tests: Clear frame buffer before each test Date: Sun, 15 Dec 2024 11:45:04 +0100 Message-Id: <20241215104508.191237-14-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make sure the frame buffer is cleared before each test, to avoid leftover artifacts from a previous test. Signed-off-by: Geert Uytterhoeven --- include/fb.h | 1 + tests.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/fb.h b/include/fb.h index 1df4e48311b6c1e9..6506ec120aa962ae 100644 --- a/include/fb.h +++ b/include/fb.h @@ -28,6 +28,7 @@ extern int fb_set_cmap(void); extern int fb_pan(u32 xoffset, u32 yoffset); extern void fb_map(void); extern void fb_unmap(void); +extern void fb_clear(void); /* diff --git a/tests.c b/tests.c index b1573032372e8090..22a8a0f489c2bc06 100644 --- a/tests.c +++ b/tests.c @@ -78,6 +78,8 @@ static void run_one_test(const struct test *test) } } + fb_clear(); + res = test->func(); switch (res) { case TEST_OK: From patchwork Sun Dec 15 10:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851084 Received: from cantor.telenet-ops.be (cantor.telenet-ops.be [195.130.132.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33D321514CE for ; Sun, 15 Dec 2024 10:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260029; cv=none; b=nFNpmTZai3/zPi04908yndD1h65g09qohjYNsTfTAleImYx38p7BBe3cMZd5xxHJ8bfsEGRcKGBUsbBCliQD7aiskcvlzYhxx8n3KM2trroGxKirCX5R+SnzKKHXCBbk0cEsS8epQS6iO0X5gb9qeEH9OZjYrcTSQHY3NzUM+zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260029; c=relaxed/simple; bh=B6rfUtml/IU5+gicbUixfbGqsfOS3EevXNf+RGshW+s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nun5iDju1uCZXULHf33CU1vYPonDzCEGWRP0ryyYRmqzb4NRCRJykbKtWv1ss0zYzRWdWNjoRIy0OvgReCGfv0cZIrB6HqnMAYucU8/4sBXxVPchYZRED8boIcBzWTJpGZDKtM1fULUTGViLP3r2bUsz7gfxmL9zW1k35+eypq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by cantor.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2dzLz4wwdK for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by xavier.telenet-ops.be with cmsmtp id oylD2D00T4qjdAp01ylDEn; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kjs-8e; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nmE-N9; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 14/17] Make variables that are never negative unsigned Date: Sun, 15 Dec 2024 11:45:05 +0100 Message-Id: <20241215104508.191237-15-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Geert Uytterhoeven --- console.c | 2 +- fb.c | 2 +- pixmap.c | 6 +++--- tests/test004.c | 2 +- tests/test006.c | 2 +- tests/test007.c | 2 +- tests/test009.c | 2 +- tests/test010.c | 2 +- visual.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/console.c b/console.c index 0ed858e25f52c9d5..adcc78cd1d725f37 100644 --- a/console.c +++ b/console.c @@ -118,7 +118,7 @@ static void con_store_char(unsigned char c) { const unsigned char *src; unsigned char *dst; - int y; + unsigned int y; if (bitmap_width+con_font->width > bitmap_max_width) con_flush(); diff --git a/fb.c b/fb.c index ab351d15c82e09d9..4bc6d785e3e9070a 100644 --- a/fb.c +++ b/fb.c @@ -533,7 +533,7 @@ void fb_cleanup(void) static void fb_dump_cmap(void) { - int i; + unsigned int i; Debug("Colormap start = %d len = %d\n", fb_cmap.start, fb_cmap.len); for (i = 0; i < fb_cmap.len; i++) diff --git a/pixmap.c b/pixmap.c index 8cd21a62ff5235a8..a7c11909f2d5255d 100644 --- a/pixmap.c +++ b/pixmap.c @@ -71,7 +71,7 @@ static void image_bw_to_pixmap(const struct image *image, pixel_t *pixmap) pixel_t black, white; const unsigned char *src; pixel_t *dst; - int i, j, k; + unsigned int i, j, k; black = match_color(&clut_mono[0]); white = match_color(&clut_mono[1]); @@ -101,7 +101,7 @@ static void image_lut256_to_pixmap(const struct image *image, pixel_t *pixmap) rgba_t color; const unsigned char *src; pixel_t *dst; - int i; + unsigned int i; color.a = 65535; if (image->type == IMAGE_GREY256) { @@ -135,7 +135,7 @@ static void image_rgb888_to_pixmap(const struct image *image, pixel_t *pixmap) const unsigned char *src; pixel_t *dst; rgba_t color; - int i; + unsigned int i; src = image->data; dst = pixmap; diff --git a/tests/test004.c b/tests/test004.c index 9b1e79ef9077219d..308c1ee60899e5a9 100644 --- a/tests/test004.c +++ b/tests/test004.c @@ -27,7 +27,7 @@ static enum test_res test004_func(void) { const struct image *image; pixel_t *pixmap; - int x, y, width, height, i; + unsigned int x, y, width, height, i; image = &penguin; pixmap = create_pixmap(image); diff --git a/tests/test006.c b/tests/test006.c index 20ba90963ea10797..c3b6722fafbeaf3c 100644 --- a/tests/test006.c +++ b/tests/test006.c @@ -23,7 +23,7 @@ static enum test_res test006_func(void) { - int i, j; + unsigned int i, j; pixel_t pixels[2]; u32 x0, x1, y0, y1; diff --git a/tests/test007.c b/tests/test007.c index d6e7864c5b36d2bb..8fd1613c8b23cfb2 100644 --- a/tests/test007.c +++ b/tests/test007.c @@ -51,7 +51,7 @@ static void increase_level(int *component) static enum test_res test007_func(void) { - int i; + unsigned int i; fill_rect(0, 0, fb_var.xres, fb_var.yres, black_pixel); for (i = 0; i < red_len; i++) diff --git a/tests/test009.c b/tests/test009.c index 4f36950737c811df..a62724ff547c04ea 100644 --- a/tests/test009.c +++ b/tests/test009.c @@ -27,7 +27,7 @@ static enum test_res test009_func(void) { const struct image *image; pixel_t *pixmap; - int x, y, width, height; + unsigned int x, y, width, height; image = &penguin; pixmap = create_pixmap(image); diff --git a/tests/test010.c b/tests/test010.c index 6ed97e8e51bfb77e..5b26b773e873eeec 100644 --- a/tests/test010.c +++ b/tests/test010.c @@ -24,7 +24,7 @@ static enum test_res test010_func(void) { - int i, j; + unsigned int i, j; con_init(&FONT); con_puts("Hello, world!\n"); diff --git a/visual.c b/visual.c index e8782950df62178a..c5dbed3095d85e54 100644 --- a/visual.c +++ b/visual.c @@ -91,7 +91,7 @@ static u32 reverse32(u32 x) pixel_t *create_component_table(u32 size, u32 offset, int msb_right, u32 bpp) { pixel_t *table, pixel; - int i; + unsigned int i; if (!size) return NULL; From patchwork Sun Dec 15 10:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851518 Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92312C13D for ; Sun, 15 Dec 2024 10:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; cv=none; b=rtjUrvmTKSXcn5wvEZ8Cz2tPsckndu28KvUv0ndoRTmcxIkN7sLLK3ENCUqS0eYqWlimi2Q+l5X4xJmg2JE6D86deDW6tPlTDOLcDwXGvXwGTWCWrUdt48J25+87fCl8XJoRD6HEhvVoIGTAhedUXNhfgL93Wu2LoObpJAeOtu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259877; c=relaxed/simple; bh=zyj3ShxJQNX6ijMzXKQxlqR8dPw34gmFSlk84FsF/Bg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X7Vjvc2PeFLy/LyNhqYtHL8jazmVBGMFCNE/HR7S7ORYN2JQUQV+Opjlnr1mf4Py221WX5lacRXlyTAKnKWTDE6NEeL5JgufpfKrfBmwa1Y5FUDFYzsLl7bCnbEB3nuZOE7ZHekW8KbonZGaW9c1o0TPv558pF/cMDQbMsv/LXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2sBBz4wxL4 for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by michel.telenet-ops.be with cmsmtp id oylD2D00d4qjdAp06ylDnu; Sun, 15 Dec 2024 11:45:13 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kjx-9L; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nmI-Nq; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 15/17] test013: Fix off-by-one error in maximum circle calculation Date: Sun, 15 Dec 2024 11:45:06 +0100 Message-Id: <20241215104508.191237-16-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A circle with radius R has an actual diameter of 2*R+1 instead of 2*R. Signed-off-by: Geert Uytterhoeven --- tests/test013.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test013.c b/tests/test013.c index 96fc1cd216b81b0a..25904270901eaded 100644 --- a/tests/test013.c +++ b/tests/test013.c @@ -63,10 +63,10 @@ static enum test_res test013_func(void) while (1) for (i = 0; i < sizeof(sizes)/sizeof(*sizes); i++) { - size = sizes[i]; + size = sizes[i] + 1; if (size > fb_var.xres_virtual || size > fb_var.yres_virtual) goto out; - benchmark_circles(size/2); + benchmark_circles(sizes[i]/2); sizes[i] *= 10; } From patchwork Sun Dec 15 10:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851516 Received: from weierstrass.telenet-ops.be (weierstrass.telenet-ops.be [195.130.137.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38DED14D29D for ; Sun, 15 Dec 2024 10:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.81 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260002; cv=none; b=VjVj2L7I/gTJfGc0RItYbRtAo3DObs4eNr+hRElDk1k38ZYjFGPeb2HStc3j4QICGbnzoXczfFT731DLMrIH/qPnrmEDRk+/BlSyGbFTg+vTQYEF0KwnlIz3tQ9Cc+W1Gf326MvO57gsrztazLW0QPYWcSBW6dVfT0Np5d+ABic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734260002; c=relaxed/simple; bh=dF5aHEI9yltbH4AVdIEng2CdNqCOM9IJTlvYoaNgtZc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nN+ARS3x9kKnfmrG2q5+7dTU11DF44OtQkIqkAZ/FOQNaKtKN1ca04PYqPJr7+BQAp2Lz+LcNxwe4MyB9CQ/OFcPmSvjYjJaPJ1eDe9CyejtPis2lhIslP7OLdVwT0WLaDcxlgGryxRuD1/xOd5hycaxOeg94CD6Ocmxy2Wn4aM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by weierstrass.telenet-ops.be (Postfix) with ESMTPS id 4YB08d2yhfz4wwdX for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by xavier.telenet-ops.be with cmsmtp id oylD2D00Y4qjdAp01ylDEq; Sun, 15 Dec 2024 11:45:14 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kk3-BC; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nmQ-OR; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 16/17] visops: Mark fall-through switch case Date: Sun, 15 Dec 2024 11:45:07 +0100 Message-Id: <20241215104508.191237-17-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Geert Uytterhoeven --- visops/pseudocolor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/visops/pseudocolor.c b/visops/pseudocolor.c index 2c3f4d9ac29b7b5e..112e2144979afbf3 100644 --- a/visops/pseudocolor.c +++ b/visops/pseudocolor.c @@ -50,6 +50,7 @@ void pseudocolor_create_tables(u32 bpp) switch (bpp % 3) { case 2: red_bits++; + __attribute__ ((fallthrough)); case 1: green_bits++; } From patchwork Sun Dec 15 10:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 851087 Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6FEE12DD95 for ; Sun, 15 Dec 2024 10:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259878; cv=none; b=dxuzJiohIgP5yf/jjEg9EsHZ+IhP+YsWYgkRapnR7I2ocpfv0vw3munfoAf/6A5aENyLKhn+cOecWcg0g4B2bOJqY225lq7j4WFVabjyuN8b8hcX7iMjqpzKdZeCIcOzuSwoCHq6/REr4VFem5gHIXzMLAij0oO8OqjitHb2zRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734259878; c=relaxed/simple; bh=39oQ6eKrXrfbE7a6soyOQ3GtZarT7COYWib9oOhqYAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PM4qBDwdLcLno6JVQ4CeSviD+peeDRdrIU3Zp1qSdGRkmAMnDy9Pe7M/AhIjKfBFsENT0zE7ag3X3DE7cc/+cYLp4yk5rKsIWq+jAEuexVJwmC/nXhYsgXASNu21WXnEkYZ384Iiqd6d0V3sjqfvA2v8vORm3Al9OQlclMzeHwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.132.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4YB08d3Jt5z4wxL6 for ; Sun, 15 Dec 2024 11:45:21 +0100 (CET) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:8e92:9273:64e7:a1e1]) by michel.telenet-ops.be with cmsmtp id oylD2D00j4qjdAp06ylDo0; Sun, 15 Dec 2024 11:45:14 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1tMm7a-001Kk4-Bh; Sun, 15 Dec 2024 11:45:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1tMm7d-000nmV-P9; Sun, 15 Dec 2024 11:45:13 +0100 From: Geert Uytterhoeven To: linux-fbdev@vger.kernel.org Cc: Geert Uytterhoeven Subject: [PATCH fbtest 17/17] util: Use __attribute__ Date: Sun, 15 Dec 2024 11:45:08 +0100 Message-Id: <20241215104508.191237-18-geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241215104508.191237-1-geert@linux-m68k.org> References: <20241215104508.191237-1-geert@linux-m68k.org> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace the rare __attribute by the more common __attribute__. Signed-off-by: Geert Uytterhoeven --- include/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/util.h b/include/util.h index 5a6b5ab40d383d5a..1433b87b8dbefcfc 100644 --- a/include/util.h +++ b/include/util.h @@ -40,7 +40,7 @@ extern void Warning(const char *fmt, ...) extern void Error(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void Fatal(const char *fmt, ...) - __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); + __attribute__ ((noreturn)) __attribute__ ((format (printf, 1, 2))); extern void Debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));