Module Name: src Committed By: rin Date: Wed Aug 7 11:08:44 UTC 2019
Modified Files: src/sys/dev/rasops: rasops.c Log Message: Simplify rasops_do_cursor(): - Use static masks similar to that used in rasops_bitops.h, rather than generating them on the fly. - Use pointer for proper type to avoid unnecessary casts. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/dev/rasops/rasops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/rasops/rasops.c diff -u src/sys/dev/rasops/rasops.c:1.113 src/sys/dev/rasops/rasops.c:1.114 --- src/sys/dev/rasops/rasops.c:1.113 Wed Aug 7 11:03:14 2019 +++ src/sys/dev/rasops/rasops.c Wed Aug 7 11:08:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops.c,v 1.113 2019/08/07 11:03:14 rin Exp $ */ +/* $NetBSD: rasops.c,v 1.114 2019/08/07 11:08:44 rin Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.113 2019/08/07 11:03:14 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.114 2019/08/07 11:08:44 rin Exp $"); #ifdef _KERNEL_OPT #include "opt_rasops.h" @@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1 #define _RASOPS_PRIVATE #include <dev/rasops/rasops.h> +#include <dev/rasops/rasops_masks.h> /* XXX for MBE */ #ifndef _KERNEL #include <errno.h> @@ -72,6 +73,16 @@ struct rasops_matchdata { int ident; }; +static const uint32_t rasops_lmask32[4 + 1] = { + MBE(0x00000000), MBE(0x00ffffff), MBE(0x0000ffff), MBE(0x000000ff), + MBE(0x00000000), +}; + +static const uint32_t rasops_rmask32[4 + 1] = { + MBE(0x00000000), MBE(0xff000000), MBE(0xffff0000), MBE(0xffffff00), + MBE(0xffffffff), +}; + /* ANSI colormap (R,G,B). Upper 8 are high-intensity */ const uint8_t rasops_cmap[256 * 3] = { 0x00, 0x00, 0x00, /* black */ @@ -1055,9 +1066,8 @@ static void rasops_do_cursor(struct rasops_info *ri) { int full, height, cnt, slop1, slop2, row, col; - uint32_t tmp32, msk1, msk2; - uint8_t tmp8; - uint8_t *dp, *rp, *hp; + uint32_t mask1, mask2, *dp; + uint8_t tmp8, *rp, *hp; hp = NULL; /* XXX GCC */ @@ -1121,28 +1131,24 @@ rasops_do_cursor(struct rasops_info *ri) rp = (uint8_t *)((uintptr_t)rp & ~3); hp = (uint8_t *)((uintptr_t)hp & ~3); - msk1 = !slop1 ? 0 : be32toh(0xffffffffU >> (32 - (8 * slop1))); - msk2 = !slop2 ? 0 : be32toh(0xffffffffU << (32 - (8 * slop2))); + mask1 = rasops_lmask32[4 - slop1]; + mask2 = rasops_rmask32[slop2]; while (height--) { - dp = rp; + dp = (uint32_t *)rp; if (slop1) { - tmp32 = *(uint32_t *)dp ^ msk1; - *(uint32_t *)dp = tmp32; - dp += 4; + *dp = *dp ^ mask1; + dp++; } for (cnt = full; cnt; cnt--) { - tmp32 = ~*(uint32_t *)dp; - *(uint32_t *)dp = tmp32; - dp += 4; + *dp = ~*(uint32_t *)dp; + dp++; } - if (slop2) { - tmp32 = *(uint32_t *)dp ^ msk2; - *(uint32_t *)dp = tmp32; - } + if (slop2) + *dp = *dp ^ mask2; if (ri->ri_hwbits) { memcpy(hp, rp, ((slop1 != 0) + full +