Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops Misc style clean up's.
details: https://anonhg.NetBSD.org/src/rev/700cdfee10af
branches: trunk
changeset: 1002665:700cdfee10af
user: rin <rin%NetBSD.org@localhost>
date: Sat Aug 10 01:24:17 2019 +0000
description:
Misc style clean up's.
- Introduce and use proper macros.
- Use not ambiguous variable names.
- Unify similar functions as possible as I can.
- G/C unused headers.
- Use #include <dev/rasops/foo.h> instead of "foo.h"
No particular functional changes intended.
diffstat:
sys/dev/rasops/rasops.c | 631 ++++++++++++++++----------------
sys/dev/rasops/rasops.h | 23 +-
sys/dev/rasops/rasops1-4_putchar.h | 50 +-
sys/dev/rasops/rasops1.c | 95 ++--
sys/dev/rasops/rasops15.c | 31 +-
sys/dev/rasops/rasops1_putchar_width.h | 77 ++-
sys/dev/rasops/rasops2.c | 51 +-
sys/dev/rasops/rasops24.c | 89 ++--
sys/dev/rasops/rasops32.c | 29 +-
sys/dev/rasops/rasops4.c | 42 +-
sys/dev/rasops/rasops8.c | 43 +-
sys/dev/rasops/rasops_bitops.h | 150 ++++---
sys/dev/rasops/rasops_masks.c | 10 +-
sys/dev/rasops/rasops_masks.h | 18 +-
sys/dev/rasops/rasops_putchar.h | 46 +-
sys/dev/rasops/rasops_putchar_width.h | 71 +-
16 files changed, 761 insertions(+), 695 deletions(-)
diffs (truncated from 2875 to 300 lines):
diff -r a8b7d32a80c8 -r 700cdfee10af sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Sat Aug 10 01:20:47 2019 +0000
+++ b/sys/dev/rasops/rasops.c Sat Aug 10 01:24:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.c,v 1.121 2019/08/10 01:20:47 rin Exp $ */
+/* $NetBSD: rasops.c,v 1.122 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,20 +30,17 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.121 2019/08/10 01:20:47 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.122 2019/08/10 01:24:17 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_rasops.h"
#include "opt_wsmsgattrs.h"
+#include "rasops_glue.h"
#endif
-#include "rasops_glue.h"
-
#include <sys/param.h>
#include <sys/bswap.h>
#include <sys/kmem.h>
-#include <sys/systm.h>
-#include <sys/time.h>
#include <machine/endian.h>
@@ -202,6 +199,10 @@
static int rasops_allocattr_mono(void *, int, int, int, long *);
static void rasops_do_cursor(struct rasops_info *);
static void rasops_init_devcmap(struct rasops_info *);
+static void rasops_make_box_chars_8(struct rasops_info *);
+static void rasops_make_box_chars_16(struct rasops_info *);
+static void rasops_make_box_chars_32(struct rasops_info *);
+static void rasops_make_box_chars_alpha(struct rasops_info *);
#if NRASOPS_ROTATION > 0
static void rasops_rotate_font(int *, int);
@@ -233,11 +234,6 @@
};
#endif /* NRASOPS_ROTATION > 0 */
-void rasops_make_box_chars_8(struct rasops_info *);
-void rasops_make_box_chars_16(struct rasops_info *);
-void rasops_make_box_chars_32(struct rasops_info *);
-void rasops_make_box_chars_alpha(struct rasops_info *);
-
/*
* Initialize a 'rasops_info' descriptor.
*/
@@ -623,6 +619,7 @@
fg &= 7;
bg &= 7;
#endif
+
if ((flg & WSATTR_BLINK) != 0)
return EINVAL;
@@ -691,8 +688,8 @@
rasops_copyrows(void *cookie, int src, int dst, int num)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
+ int stride;
uint8_t *sp, *dp, *hp;
- int n, stride;
hp = NULL; /* XXX GCC */
@@ -720,12 +717,10 @@
return;
#endif
- num *= ri->ri_font->fontheight;
- n = ri->ri_emustride;
- stride = ri->ri_stride;
-
src *= ri->ri_yscale;
dst *= ri->ri_yscale;
+ num *= ri->ri_font->fontheight;
+ stride = ri->ri_stride;
if (src < dst) {
/* backward copy */
@@ -740,12 +735,12 @@
hp = ri->ri_hwbits + dst;
while (num--) {
- memcpy(dp, sp, n);
- sp += stride;
+ memcpy(dp, sp, ri->ri_emustride);
if (ri->ri_hwbits) {
- memcpy(hp, dp, n);
+ memcpy(hp, dp, ri->ri_emustride);
hp += stride;
}
+ sp += stride;
dp += stride;
}
}
@@ -760,8 +755,8 @@
rasops_copycols(void *cookie, int row, int src, int dst, int num)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
+ int height;
uint8_t *sp, *dp, *hp;
- int height;
hp = NULL; /* XXX GCC */
@@ -793,9 +788,9 @@
return;
#endif
- num *= ri->ri_xscale;
+ height = ri->ri_font->fontheight;
row *= ri->ri_yscale;
- height = ri->ri_font->fontheight;
+ num *= ri->ri_xscale;
sp = ri->ri_bits + row + src * ri->ri_xscale;
dp = ri->ri_bits + row + dst * ri->ri_xscale;
@@ -808,8 +803,8 @@
memcpy(hp, dp, num);
hp += ri->ri_stride;
}
+ sp += ri->ri_stride;
dp += ri->ri_stride;
- sp += ri->ri_stride;
}
}
@@ -829,16 +824,16 @@
ri->ri_do_cursor(ri);
/* Select new cursor */
+ ri->ri_crow = row;
+ ri->ri_ccol = col;
+
#ifdef RASOPS_CLIPPING
ri->ri_flg &= ~RI_CURSORCLIP;
-
if (row < 0 || row >= ri->ri_rows)
ri->ri_flg |= RI_CURSORCLIP;
else if (col < 0 || col >= ri->ri_cols)
ri->ri_flg |= RI_CURSORCLIP;
#endif
- ri->ri_crow = row;
- ri->ri_ccol = col;
if (on) {
ri->ri_flg |= RI_CURSOR;
@@ -954,7 +949,6 @@
(c & 0x00ff00) |
(c & 0xff0000) >> 16;
}
-
/*
* No worries, we use generic routines only for
* gray colors, where all 3 bytes are same.
@@ -991,8 +985,8 @@
rasops_eraserows(void *cookie, int row, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- uint32_t *rp, *hp, clr;
- int stride;
+ int bytes;
+ uint32_t bg, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -1009,8 +1003,6 @@
return;
#endif
- clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
-
/*
* XXX The wsdisplay_emulops interface seems a little deficient in
* that there is no way to clear the *entire* screen. We provide a
@@ -1018,23 +1010,25 @@
* the RI_FULLCLEAR flag is set, clear the entire display.
*/
if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR) != 0) {
- stride = ri->ri_stride;
+ bytes = ri->ri_stride;
num = ri->ri_height;
rp = (uint32_t *)ri->ri_origbits;
if (ri->ri_hwbits)
hp = (uint32_t *)ri->ri_hworigbits;
} else {
- stride = ri->ri_emustride;
+ bytes = ri->ri_emustride;
num *= ri->ri_font->fontheight;
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale);
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale);
}
+ bg = ATTR_BG(ri, attr);
+
while (num--) {
- rasops_memset32(rp, clr, stride);
+ rasops_memset32(rp, bg, bytes);
if (ri->ri_hwbits) {
- memcpy(hp, rp, stride);
+ memcpy(hp, rp, bytes);
DELTA(hp, ri->ri_stride, uint32_t *);
}
DELTA(rp, ri->ri_stride, uint32_t *);
@@ -1048,9 +1042,9 @@
static void
rasops_do_cursor(struct rasops_info *ri)
{
- int full, height, cnt, slop1, slop2, row, col;
+ int row, col, height, slop1, slop2, full, cnt;
uint32_t mask1, mask2, *dp;
- uint8_t tmp8, *rp, *hp;
+ uint8_t tmp, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -1075,10 +1069,11 @@
col = ri->ri_ccol;
}
- rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
+ height = ri->ri_font->fontheight;
+
+ rp = ri->ri_bits + FBOFFSET(ri, row, col);
if (ri->ri_hwbits)
- hp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
- height = ri->ri_font->fontheight;
+ hp = ri->ri_hwbits + FBOFFSET(ri, row, col);
/*
* For ri_xscale = 1:
@@ -1088,15 +1083,13 @@
*/
if (ri->ri_xscale == 1) {
while (height--) {
- tmp8 = ~*rp;
-
- *rp = tmp8;
- rp += ri->ri_stride;
-
+ tmp = ~*rp;
+ *rp = tmp;
if (ri->ri_hwbits) {
- *hp = tmp8;
+ *hp = tmp;
hp += ri->ri_stride;
}
+ rp += ri->ri_stride;
}
return;
}
@@ -1149,8 +1142,8 @@
rasops_erasecols(void *cookie, int row, int col, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int height, clr;
- uint32_t *rp, *hp;
+ int height;
+ uint32_t bg, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -1170,16 +1163,17 @@
return;
#endif
+ height = ri->ri_font->fontheight;
num *= ri->ri_xscale;
- rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+
+ rp = (uint32_t *)(ri->ri_bits + FBOFFSET(ri, row, col));
if (ri->ri_hwbits)
- hp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
- col*ri->ri_xscale);
- height = ri->ri_font->fontheight;
- clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
+ hp = (uint32_t *)(ri->ri_hwbits + FBOFFSET(ri, row, col));
+
+ bg = ATTR_BG(ri, attr);
while (height--) {
- rasops_memset32(rp, clr, num);
+ rasops_memset32(rp, bg, num);
if (ri->ri_hwbits) {
memcpy(hp, rp, num);
DELTA(hp, ri->ri_stride, uint32_t *);
@@ -1188,267 +1182,6 @@
}
}
Home |
Main Index |
Thread Index |
Old Index