Date: Thu, 10 May 2018 16:41:47 +0000 (UTC) From: =?UTF-8?Q?Jean-S=c3=a9bastien_P=c3=a9dron?= <dumbbell@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333463 - head/sys/dev/vt/colors Message-ID: <201805101641.w4AGflMU093191@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dumbbell Date: Thu May 10 16:41:47 2018 New Revision: 333463 URL: https://svnweb.freebsd.org/changeset/base/333463 Log: vt(4): Put for() loop outside switch() in vt_generate_cons_palette() This makes it more logical: 1. It checks the requested color format 2. It fills the palette accordingly Also vt_palette_init() is only called when needed (i.e. when the format is `COLOR_FORMAT_RGB`). Modified: head/sys/dev/vt/colors/vt_termcolors.c Modified: head/sys/dev/vt/colors/vt_termcolors.c ============================================================================== --- head/sys/dev/vt/colors/vt_termcolors.c Thu May 10 16:19:41 2018 (r333462) +++ head/sys/dev/vt/colors/vt_termcolors.c Thu May 10 16:41:47 2018 (r333463) @@ -171,21 +171,21 @@ vt_generate_cons_palette(uint32_t *palette, int format { int i; - vt_palette_init(); - -#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset) - for (i = 0; i < NCOLORS; i++) { - switch (format) { - case COLOR_FORMAT_VGA: + switch (format) { + case COLOR_FORMAT_VGA: + for (i = 0; i < NCOLORS; i++) palette[i] = cons_to_vga_colors[i]; - break; - case COLOR_FORMAT_RGB: + break; + case COLOR_FORMAT_RGB: + vt_palette_init(); +#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset) + for (i = 0; i < NCOLORS; i++) palette[i] = CF(r, i) | CF(g, i) | CF(b, i); - break; - default: - return (ENODEV); - } - } #undef CF + break; + default: + return (ENODEV); + } + return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805101641.w4AGflMU093191>