Module Name: src
Committed By: rin
Date: Sat Aug 10 01:24:17 UTC 2019
Modified Files:
src/sys/dev/rasops: rasops.c rasops.h rasops1-4_putchar.h rasops1.c
rasops15.c rasops1_putchar_width.h rasops2.c rasops24.c rasops32.c
rasops4.c rasops8.c rasops_bitops.h rasops_masks.c rasops_masks.h
rasops_putchar.h rasops_putchar_width.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/rasops/rasops.h
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/rasops/rasops1-4_putchar.h
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/rasops/rasops1.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/rasops/rasops15.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/rasops/rasops1_putchar_width.h
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/rasops/rasops2.c
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/rasops/rasops24.c
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/rasops/rasops32.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/rasops/rasops4.c
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/rasops/rasops8.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/rasops/rasops_bitops.h
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/rasops/rasops_masks.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/rasops/rasops_masks.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/rasops/rasops_putchar.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/rasops/rasops_putchar_width.h
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.121 src/sys/dev/rasops/rasops.c:1.122
--- src/sys/dev/rasops/rasops.c:1.121 Sat Aug 10 01:20:47 2019
+++ src/sys/dev/rasops/rasops.c Sat Aug 10 01:24:17 2019
@@ -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"
-#endif
-
#include "rasops_glue.h"
+#endif
#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_color(void *
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 @@ struct rotatedfont {
};
#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 @@ rasops_allocattr_color(void *cookie, int
fg &= 7;
bg &= 7;
#endif
+
if ((flg & WSATTR_BLINK) != 0)
return EINVAL;
@@ -691,8 +688,8 @@ static void
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 @@ rasops_copyrows(void *cookie, int src, i
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 @@ rasops_copyrows(void *cookie, int src, i
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 @@ static void
rasops_copycols(void *cookie, int row, int src, int dst, int num)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- uint8_t *sp, *dp, *hp;
int height;
+ uint8_t *sp, *dp, *hp;
hp = NULL; /* XXX GCC */
@@ -793,9 +788,9 @@ rasops_copycols(void *cookie, int row, i
return;
#endif
- num *= ri->ri_xscale;
- row *= ri->ri_yscale;
height = ri->ri_font->fontheight;
+ row *= ri->ri_yscale;
+ 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 @@ rasops_copycols(void *cookie, int row, i
memcpy(hp, dp, num);
hp += ri->ri_stride;
}
- dp += ri->ri_stride;
sp += ri->ri_stride;
+ dp += ri->ri_stride;
}
}
@@ -829,16 +824,16 @@ rasops_cursor(void *cookie, int on, int
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 @@ rasops_init_devcmap(struct rasops_info *
(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 @@ void
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 @@ rasops_eraserows(void *cookie, int row,
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 @@ rasops_eraserows(void *cookie, int row,
* 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 @@ rasops_eraserows(void *cookie, int row,
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,11 +1069,12 @@ rasops_do_cursor(struct rasops_info *ri)
col = ri->ri_ccol;
}
- rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
- if (ri->ri_hwbits)
- hp = ri->ri_hwbits + 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 + FBOFFSET(ri, row, col);
+
/*
* For ri_xscale = 1:
*
@@ -1088,15 +1083,13 @@ rasops_do_cursor(struct rasops_info *ri)
*/
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 @@ void
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 @@ rasops_erasecols(void *cookie, int row,
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,6 +1182,218 @@ rasops_erasecols(void *cookie, int row,
}
}
+void
+rasops_make_box_chars_16(struct rasops_info *ri)
+{
+ int c, i, mid;
+ uint16_t vert_mask, hmask_left, hmask_right;
+ uint16_t *data = (uint16_t *)ri->ri_optfont.data;
+
+ vert_mask = 0xc000U >> ((ri->ri_font->fontwidth >> 1) - 1);
+ hmask_left = 0xff00U << (8 - (ri->ri_font->fontwidth >> 1));
+ hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
+ mid = (ri->ri_font->fontheight + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_font->fontheight;
+ if (c & 1) {
+ /* upper segment */
+ for (i = 0; i < mid; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 4) {
+ /* lower segment */
+ for (i = mid; i < ri->ri_font->fontheight; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 2) {
+ /* right segment */
+ i = ri->ri_font->fontheight >> 1;
+ data[mid - 1] |= hmask_right;
+ data[mid] |= hmask_right;
+ }
+ if (c & 8) {
+ /* left segment */
+ data[mid - 1] |= hmask_left;
+ data[mid] |= hmask_left;
+ }
+ }
+}
+
+void
+rasops_make_box_chars_8(struct rasops_info *ri)
+{
+ int c, i, mid;
+ uint8_t vert_mask, hmask_left, hmask_right;
+ uint8_t *data = (uint8_t *)ri->ri_optfont.data;
+
+ vert_mask = 0xc0U >> ((ri->ri_font->fontwidth >> 1) - 1);
+ hmask_left = 0xf0U << (4 - (ri->ri_font->fontwidth >> 1));
+ hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
+ mid = (ri->ri_font->fontheight + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_font->fontheight;
+ if (c & 1) {
+ /* upper segment */
+ for (i = 0; i < mid; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 4) {
+ /* lower segment */
+ for (i = mid; i < ri->ri_font->fontheight; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 2) {
+ /* right segment */
+ i = ri->ri_font->fontheight >> 1;
+ data[mid - 1] |= hmask_right;
+ data[mid] |= hmask_right;
+ }
+ if (c & 8) {
+ /* left segment */
+ data[mid - 1] |= hmask_left;
+ data[mid] |= hmask_left;
+ }
+ }
+}
+
+void
+rasops_make_box_chars_32(struct rasops_info *ri)
+{
+ int c, i, mid;
+ uint32_t vert_mask, hmask_left, hmask_right;
+ uint32_t *data = (uint32_t *)ri->ri_optfont.data;
+
+ vert_mask = 0xc0000000U >> ((ri->ri_font->fontwidth >> 1) - 1);
+ hmask_left = 0xffff0000U << (16 - (ri->ri_font->fontwidth >> 1));
+ hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
+ mid = (ri->ri_font->fontheight + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_font->fontheight;
+ if (c & 1) {
+ /* upper segment */
+ for (i = 0; i < mid; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 4) {
+ /* lower segment */
+ for (i = mid; i < ri->ri_font->fontheight; i++)
+ data[i] = vert_mask;
+ }
+ if (c & 2) {
+ /* right segment */
+ i = ri->ri_font->fontheight >> 1;
+ data[mid - 1] |= hmask_right;
+ data[mid] |= hmask_right;
+ }
+ if (c & 8) {
+ /* left segment */
+ data[mid - 1] |= hmask_left;
+ data[mid] |= hmask_left;
+ }
+ }
+}
+
+void
+rasops_make_box_chars_alpha(struct rasops_info *ri)
+{
+ int c, i, hmid, vmid, wi, he;
+ uint8_t *data = (uint8_t *)ri->ri_optfont.data;
+ uint8_t *ddata;
+
+ he = ri->ri_font->fontheight;
+ wi = ri->ri_font->fontwidth;
+
+ vmid = (he + 1) >> 1;
+ hmid = (wi + 1) >> 1;
+
+ /* 0x00 would be empty anyway so don't bother */
+ for (c = 1; c < 16; c++) {
+ data += ri->ri_fontscale;
+ if (c & 1) {
+ /* upper segment */
+ ddata = data + hmid;
+ for (i = 0; i <= vmid; i++) {
+ *ddata = 0xff;
+ ddata += wi;
+ }
+ }
+ if (c & 4) {
+ /* lower segment */
+ ddata = data + wi * vmid + hmid;
+ for (i = vmid; i < he; i++) {
+ *ddata = 0xff;
+ ddata += wi;
+ }
+ }
+ if (c & 2) {
+ /* right segment */
+ ddata = data + wi * vmid + hmid;
+ for (i = hmid; i < wi; i++) {
+ *ddata = 0xff;
+ ddata++;
+ }
+ }
+ if (c & 8) {
+ /* left segment */
+ ddata = data + wi * vmid;
+ for (i = 0; i <= hmid; i++) {
+ *ddata = 0xff;
+ ddata++;
+ }
+ }
+ }
+}
+
+/*
+ * Return a colour map appropriate for the given struct rasops_info in the
+ * same form used by rasops_cmap[]
+ * For now this is either a copy of rasops_cmap[] or an R3G3B2 map, it should
+ * probably be a linear ( or gamma corrected? ) ramp for higher depths.
+ */
+int
+rasops_get_cmap(struct rasops_info *ri, uint8_t *palette, size_t bytes)
+{
+
+ if ((ri->ri_depth == 8) && ((ri->ri_flg & RI_8BIT_IS_RGB) != 0)) {
+ /* generate an R3G3B2 palette */
+ int i, idx = 0;
+ uint8_t tmp;
+
+ if (bytes < 256 * 3)
+ return EINVAL;
+ for (i = 0; i < 256; i++) {
+ tmp = i & 0xe0;
+ /*
+ * replicate bits so 0xe0 maps to a red value of 0xff
+ * in order to make white look actually white
+ */
+ tmp |= (tmp >> 3) | (tmp >> 6);
+ palette[idx] = tmp;
+ idx++;
+
+ tmp = (i & 0x1c) << 3;
+ tmp |= (tmp >> 3) | (tmp >> 6);
+ palette[idx] = tmp;
+ idx++;
+
+ tmp = (i & 0x03) << 6;
+ tmp |= tmp >> 2;
+ tmp |= tmp >> 4;
+ palette[idx] = tmp;
+ idx++;
+ }
+ } else
+ memcpy(palette, rasops_cmap, uimin(bytes, sizeof(rasops_cmap)));
+
+ return 0;
+}
+
#if NRASOPS_ROTATION > 0
/*
* Quarter clockwise rotation routines (originally intended for the
@@ -1232,8 +1438,7 @@ static void
rasops_copychar(void *cookie, int srcrow, int dstrow, int srccol, int dstcol)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int height;
- int r_srcrow, r_dstrow, r_srccol, r_dstcol;
+ int r_srcrow, r_dstrow, r_srccol, r_dstcol, height;
uint8_t *sp, *dp;
r_srcrow = srccol;
@@ -1260,7 +1465,7 @@ rasops_putchar_rotated_cw(void *cookie,
{
struct rasops_info *ri = (struct rasops_info *)cookie;
int height;
- uint8_t *rp;
+ uint16_t fg, *rp;
if (__predict_false((unsigned int)row > ri->ri_rows ||
(unsigned int)col > ri->ri_cols))
@@ -1274,19 +1479,21 @@ rasops_putchar_rotated_cw(void *cookie,
ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc,
attr & ~WSATTR_UNDERLINE);
- /* Do rotated underline */
- rp = ri->ri_bits + col * ri->ri_yscale + (ri->ri_rows - row - 1) *
- ri->ri_xscale;
- height = ri->ri_font->fontheight;
-
- /* XXX this assumes 16-bit color depth */
+ /*
+ * Do rotated underline
+ * XXX this assumes 16-bit color depth
+ */
if ((attr & WSATTR_UNDERLINE) != 0) {
- uint16_t c =
- (uint16_t)ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
+ height = ri->ri_font->fontheight;
+
+ rp = (uint16_t *)(ri->ri_bits + col * ri->ri_yscale +
+ (ri->ri_rows - row - 1) * ri->ri_xscale);
+
+ fg = (uint16_t)ATTR_FG(ri, attr);
while (height--) {
- *(uint16_t *)rp = c;
- rp += ri->ri_stride;
+ *rp = fg;
+ DELTA(rp, ri->ri_stride, uint16_t *);
}
}
}
@@ -1355,7 +1562,7 @@ rasops_copychar_ccw(void *cookie, int sr
int dstcol)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int height, r_srcrow, r_dstrow, r_srccol, r_dstcol;
+ int r_srcrow, r_dstrow, r_srccol, r_dstcol, height;
uint8_t *sp, *dp;
r_srcrow = ri->ri_cols - srccol - 1;
@@ -1382,7 +1589,7 @@ rasops_putchar_rotated_ccw(void *cookie,
{
struct rasops_info *ri = (struct rasops_info *)cookie;
int height;
- uint8_t *rp;
+ uint16_t fg, *rp;
if (__predict_false((unsigned int)row > ri->ri_rows ||
(unsigned int)col > ri->ri_cols))
@@ -1396,20 +1603,23 @@ rasops_putchar_rotated_ccw(void *cookie,
ri->ri_real_ops.putchar(cookie, ri->ri_cols - col - 1, row, uc,
attr & ~WSATTR_UNDERLINE);
- /* Do rotated underline */
- rp = ri->ri_bits + (ri->ri_cols - col - 1) * ri->ri_yscale +
- row * ri->ri_xscale +
- (ri->ri_font->fontwidth - 1) * ri->ri_pelbytes;
- height = ri->ri_font->fontheight;
-
- /* XXX this assumes 16-bit color depth */
+ /*
+ * Do rotated underline
+ * XXX this assumes 16-bit color depth
+ */
if ((attr & WSATTR_UNDERLINE) != 0) {
- uint16_t c =
- (uint16_t)ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
+ height = ri->ri_font->fontheight;
+
+ rp = (uint16_t *)(ri->ri_bits +
+ (ri->ri_cols - col - 1) * ri->ri_yscale +
+ row * ri->ri_xscale +
+ (ri->ri_font->fontwidth - 1) * ri->ri_pelbytes);
+
+ fg = (uint16_t)ATTR_FG(ri, attr);
while (height--) {
- *(uint16_t *)rp = c;
- rp += ri->ri_stride;
+ *rp = fg;
+ DELTA(rp, ri->ri_stride, uint16_t *);
}
}
}
@@ -1448,214 +1658,3 @@ rasops_copycols_rotated_ccw(void *cookie
src + coff, dst + coff);
}
#endif /* NRASOPS_ROTATION */
-
-void
-rasops_make_box_chars_16(struct rasops_info *ri)
-{
- int c, i, mid;
- uint16_t vert_mask, hmask_left, hmask_right;
- uint16_t *data = (uint16_t *)ri->ri_optfont.data;
-
- vert_mask = 0xc000U >> ((ri->ri_font->fontwidth >> 1) - 1);
- hmask_left = 0xff00U << (8 - (ri->ri_font->fontwidth >> 1));
- hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
- mid = (ri->ri_font->fontheight + 1) >> 1;
-
- /* 0x00 would be empty anyway so don't bother */
- for (c = 1; c < 16; c++) {
- data += ri->ri_font->fontheight;
- if (c & 1) {
- /* upper segment */
- for (i = 0; i < mid; i++)
- data[i] = vert_mask;
- }
- if (c & 4) {
- /* lower segment */
- for (i = mid; i < ri->ri_font->fontheight; i++)
- data[i] = vert_mask;
- }
- if (c & 2) {
- /* right segment */
- i = ri->ri_font->fontheight >> 1;
- data[mid - 1] |= hmask_right;
- data[mid] |= hmask_right;
- }
- if (c & 8) {
- /* left segment */
- data[mid - 1] |= hmask_left;
- data[mid] |= hmask_left;
- }
- }
-}
-
-void
-rasops_make_box_chars_8(struct rasops_info *ri)
-{
- int c, i, mid;
- uint8_t vert_mask, hmask_left, hmask_right;
- uint8_t *data = (uint8_t *)ri->ri_optfont.data;
-
- vert_mask = 0xc0U >> ((ri->ri_font->fontwidth >> 1) - 1);
- hmask_left = 0xf0U << (4 - (ri->ri_font->fontwidth >> 1));
- hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
- mid = (ri->ri_font->fontheight + 1) >> 1;
-
- /* 0x00 would be empty anyway so don't bother */
- for (c = 1; c < 16; c++) {
- data += ri->ri_font->fontheight;
- if (c & 1) {
- /* upper segment */
- for (i = 0; i < mid; i++)
- data[i] = vert_mask;
- }
- if (c & 4) {
- /* lower segment */
- for (i = mid; i < ri->ri_font->fontheight; i++)
- data[i] = vert_mask;
- }
- if (c & 2) {
- /* right segment */
- i = ri->ri_font->fontheight >> 1;
- data[mid - 1] |= hmask_right;
- data[mid] |= hmask_right;
- }
- if (c & 8) {
- /* left segment */
- data[mid - 1] |= hmask_left;
- data[mid] |= hmask_left;
- }
- }
-}
-
-void
-rasops_make_box_chars_32(struct rasops_info *ri)
-{
- int c, i, mid;
- uint32_t vert_mask, hmask_left, hmask_right;
- uint32_t *data = (uint32_t *)ri->ri_optfont.data;
-
- vert_mask = 0xc0000000U >> ((ri->ri_font->fontwidth >> 1) - 1);
- hmask_left = 0xffff0000U << (16 - (ri->ri_font->fontwidth >> 1));
- hmask_right = hmask_left >> ((ri->ri_font->fontwidth + 1) >> 1);
- mid = (ri->ri_font->fontheight + 1) >> 1;
-
- /* 0x00 would be empty anyway so don't bother */
- for (c = 1; c < 16; c++) {
- data += ri->ri_font->fontheight;
- if (c & 1) {
- /* upper segment */
- for (i = 0; i < mid; i++)
- data[i] = vert_mask;
- }
- if (c & 4) {
- /* lower segment */
- for (i = mid; i < ri->ri_font->fontheight; i++)
- data[i] = vert_mask;
- }
- if (c & 2) {
- /* right segment */
- i = ri->ri_font->fontheight >> 1;
- data[mid - 1] |= hmask_right;
- data[mid] |= hmask_right;
- }
- if (c & 8) {
- /* left segment */
- data[mid - 1] |= hmask_left;
- data[mid] |= hmask_left;
- }
- }
-}
-
-void
-rasops_make_box_chars_alpha(struct rasops_info *ri)
-{
- int c, i, hmid, vmid, wi, he;
- uint8_t *data = (uint8_t *)ri->ri_optfont.data;
- uint8_t *ddata;
-
- he = ri->ri_font->fontheight;
- wi = ri->ri_font->fontwidth;
-
- vmid = (he + 1) >> 1;
- hmid = (wi + 1) >> 1;
-
- /* 0x00 would be empty anyway so don't bother */
- for (c = 1; c < 16; c++) {
- data += ri->ri_fontscale;
- if (c & 1) {
- /* upper segment */
- ddata = data + hmid;
- for (i = 0; i <= vmid; i++) {
- *ddata = 0xff;
- ddata += wi;
- }
- }
- if (c & 4) {
- /* lower segment */
- ddata = data + wi * vmid + hmid;
- for (i = vmid; i < he; i++) {
- *ddata = 0xff;
- ddata += wi;
- }
- }
- if (c & 2) {
- /* right segment */
- ddata = data + wi * vmid + hmid;
- for (i = hmid; i < wi; i++) {
- *ddata = 0xff;
- ddata++;
- }
- }
- if (c & 8) {
- /* left segment */
- ddata = data + wi * vmid;
- for (i = 0; i <= hmid; i++) {
- *ddata = 0xff;
- ddata++;
- }
- }
- }
-}
-
-/*
- * Return a colour map appropriate for the given struct rasops_info in the
- * same form used by rasops_cmap[]
- * For now this is either a copy of rasops_cmap[] or an R3G3B2 map, it should
- * probably be a linear ( or gamma corrected? ) ramp for higher depths.
- */
-int
-rasops_get_cmap(struct rasops_info *ri, uint8_t *palette, size_t bytes)
-{
-
- if ((ri->ri_depth == 8) && ((ri->ri_flg & RI_8BIT_IS_RGB) != 0)) {
- /* generate an R3G3B2 palette */
- int i, idx = 0;
- uint8_t tmp;
-
- if (bytes < 768)
- return EINVAL;
- for (i = 0; i < 256; i++) {
- tmp = i & 0xe0;
- /*
- * replicate bits so 0xe0 maps to a red value of 0xff
- * in order to make white look actually white
- */
- tmp |= (tmp >> 3) | (tmp >> 6);
- palette[idx] = tmp;
- idx++;
-
- tmp = (i & 0x1c) << 3;
- tmp |= (tmp >> 3) | (tmp >> 6);
- palette[idx] = tmp;
- idx++;
-
- tmp = (i & 0x03) << 6;
- tmp |= tmp >> 2;
- tmp |= tmp >> 4;
- palette[idx] = tmp;
- idx++;
- }
- } else
- memcpy(palette, rasops_cmap, uimin(bytes, sizeof(rasops_cmap)));
- return 0;
-}
Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.46 src/sys/dev/rasops/rasops.h:1.47
--- src/sys/dev/rasops/rasops.h:1.46 Wed Aug 7 16:14:51 2019
+++ src/sys/dev/rasops/rasops.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.h,v 1.46 2019/08/07 16:14:51 rin Exp $ */
+/* $NetBSD: rasops.h,v 1.47 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -155,13 +155,14 @@ struct rasops_info {
#endif
};
-#define CHAR_IN_FONT(c,font) \
- ((c) >= (font)->firstchar && \
- ((c) - (font)->firstchar) < (font)->numchars)
-
-#define PICK_FONT(ri, c) (((c & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT) && \
- (ri->ri_optfont.data != NULL)) ? \
- &ri->ri_optfont : ri->ri_font
+#define CHAR_IN_FONT(c, font) \
+ ((c) >= (font)->firstchar && \
+ (c) - (font)->firstchar < (font)->numchars)
+
+#define PICK_FONT(ri, c) \
+ ((((c) & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT && \
+ (ri)->ri_optfont.data != NULL) ? \
+ &(ri)->ri_optfont : (ri)->ri_font)
/*
* rasops_init().
@@ -199,8 +200,14 @@ void rasops15_init(struct rasops_info *)
void rasops24_init(struct rasops_info *);
void rasops32_init(struct rasops_info *);
+#define ATTR_BG(ri, attr) ((ri)->ri_devcmap[((uint32_t)(attr) >> 16) & 0xf])
+#define ATTR_FG(ri, attr) ((ri)->ri_devcmap[((uint32_t)(attr) >> 24) & 0xf])
+
#define DELTA(p, d, cast) ((p) = (cast)((uint8_t *)(p) + (d)))
+#define FBOFFSET(ri, row, col) \
+ ((row) * (ri)->ri_yscale + (col) * (ri)->ri_xscale)
+
#define FONT_GLYPH(uc, font, ri) \
((uint8_t *)(font)->data + ((uc) - ((font)->firstchar)) * \
(ri)->ri_fontscale)
@@ -245,7 +252,7 @@ rasops_memset32(void *p, uint32_t val, s
}
static __inline uint32_t
-be32uatoh(uint8_t *p)
+rasops_be32uatoh(uint8_t *p)
{
uint32_t u;
Index: src/sys/dev/rasops/rasops1-4_putchar.h
diff -u src/sys/dev/rasops/rasops1-4_putchar.h:1.2 src/sys/dev/rasops/rasops1-4_putchar.h:1.3
--- src/sys/dev/rasops/rasops1-4_putchar.h:1.2 Fri Aug 9 12:05:51 2019
+++ src/sys/dev/rasops/rasops1-4_putchar.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1-4_putchar.h,v 1.2 2019/08/09 12:05:51 rin Exp $ */
+/* $NetBSD: rasops1-4_putchar.h,v 1.3 2019/08/10 01:24:17 rin Exp $ */
/* NetBSD: rasops_bitops.h,v 1.23 2019/08/02 04:39:09 rin Exp */
/*-
@@ -61,13 +61,13 @@
#else
#define PIXEL_OR(tmp) \
do { \
- uint8_t c, av = *fr++; \
- if (av == 0xff) \
+ uint8_t c, w = *fr++; \
+ if (w == 0xff) \
c = clr[1]; \
- else if (av == 0) \
+ else if (w == 0) \
c = clr[0]; \
else \
- c = (av * clr[1] + (0xff - av) * clr[0]) >> 8; \
+ c = (w * clr[1] + (0xff - w) * clr[0]) >> 8; \
(tmp) |= c << (32 - PIXEL_BITS - bit); \
} while (0 /* CONSTCOND */)
#endif
@@ -88,10 +88,9 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
{
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
- int full, cnt, bit;
- uint32_t rs, bg, fg, lmask, rmask, lbg, rbg, clr[2];
- uint32_t height, width;
- uint32_t *rp, *bp, *hp, tmp;
+ int height, width, full, cnt, bit;
+ uint32_t bg, fg, lbg, rbg, clr[2], lmask, rmask, tmp;
+ uint32_t *rp, *bp, *hp;
uint8_t *fr;
bool space;
@@ -109,19 +108,20 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
return;
#endif
+ height = font->fontheight;
width = font->fontwidth << PIXEL_SHIFT;
col *= width;
- height = font->fontheight;
+
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale +
((col >> 3) & ~3));
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
((col >> 3) & ~3));
+
col &= 31;
- rs = ri->ri_stride;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
+ bg = ATTR_BG(ri, attr);
+ fg = ATTR_FG(ri, attr);
/* If fg and bg match this becomes a space character */
if (uc == ' ' || __predict_false(fg == bg)) {
@@ -134,7 +134,6 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
if (col + width <= 32) {
/* Single word, only one mask */
-
rmask = rasops_pmask[col][width & 31];
lmask = ~rmask;
@@ -143,18 +142,19 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
while (height--) {
tmp = (*rp & lmask) | bg;
*rp = tmp;
- DELTA(rp, rs, uint32_t *);
if (ri->ri_hwbits) {
*hp = tmp;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
} else {
clr[0] = bg & COLOR_MASK;
clr[1] = fg & COLOR_MASK;
+
while (height--) {
#ifndef RASOPS_AA
- uint32_t fb = be32uatoh(fr);
+ uint32_t fb = rasops_be32uatoh(fr);
fr += ri->ri_font->stride;
#endif
@@ -167,10 +167,10 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
if (ri->ri_hwbits) {
*hp = tmp;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
- DELTA(rp, rs, uint32_t *);
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
}
@@ -196,12 +196,12 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
}
/* Word boundary, two masks needed */
-
lmask = ~rasops_lmask[col];
rmask = ~rasops_rmask[(col + width) & 31];
if (lmask != -1)
width -= 32 - col;
+
full = width / 32;
width -= full * 32;
@@ -226,10 +226,10 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
if (ri->ri_hwbits) {
memcpy(hp, rp, ((lmask != -1) + full +
(rmask != -1)) << 2);
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
- DELTA(rp, rs, uint32_t *);
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
} else {
clr[0] = bg & COLOR_MASK;
@@ -239,7 +239,7 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
bp = rp;
#ifndef RASOPS_AA
- uint32_t fb = be32uatoh(fr);
+ uint32_t fb = rasops_be32uatoh(fr);
fr += ri->ri_font->stride;
#endif
@@ -268,10 +268,10 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
if (ri->ri_hwbits) {
memcpy(hp, rp, ((lmask != -1) + full +
(rmask != -1)) << 2);
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
- DELTA(rp, rs, uint32_t *);
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
}
Index: src/sys/dev/rasops/rasops1.c
diff -u src/sys/dev/rasops/rasops1.c:1.36 src/sys/dev/rasops/rasops1.c:1.37
--- src/sys/dev/rasops/rasops1.c:1.36 Fri Aug 9 12:05:51 2019
+++ src/sys/dev/rasops/rasops1.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1.c,v 1.36 2019/08/09 12:05:51 rin Exp $ */
+/* $NetBSD: rasops1.c,v 1.37 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.36 2019/08/09 12:05:51 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.37 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
+
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
@@ -92,9 +93,9 @@ rasops1_putchar(void *cookie, int row, i
{
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
- uint32_t fs, rs, fb, bg, fg, lmask, rmask;
- uint32_t height, width;
- uint32_t *rp, *hp, tmp, tmp0, tmp1;
+ int height, width;
+ uint32_t bg, fg, lbg, rbg, fb, lmask, rmask, tmp, tmp0, tmp1;
+ uint32_t *rp, *hp;
uint8_t *fr;
bool space;
@@ -112,34 +113,32 @@ rasops1_putchar(void *cookie, int row, i
return;
#endif
- col *= ri->ri_font->fontwidth;
+ height = font->fontheight;
+ width = font->fontwidth;
+ col *= width;
+
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale +
((col >> 3) & ~3));
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
((col >> 3) & ~3));
- height = font->fontheight;
- width = font->fontwidth;
+
col &= 31;
- rs = ri->ri_stride;
- bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
- fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
+ bg = ATTR_BG(ri, attr);
+ fg = ATTR_FG(ri, attr);
/* If fg and bg match this becomes a space character */
- if (uc == ' ' || fg == bg) {
+ if (uc == ' ' || __predict_false(fg == bg)) {
space = true;
fr = NULL; /* XXX GCC */
- fs = 0; /* XXX GCC */
} else {
space = false;
fr = FONT_GLYPH(uc, font, ri);
- fs = font->stride;
}
if (col + width <= 32) {
/* Single word, only one mask */
-
rmask = rasops_pmask[col][width & 31];
lmask = ~rmask;
@@ -148,26 +147,29 @@ rasops1_putchar(void *cookie, int row, i
while (height--) {
tmp = (*rp & lmask) | bg;
*rp = tmp;
- DELTA(rp, rs, uint32_t *);
if (ri->ri_hwbits) {
*hp = tmp;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
} else {
while (height--) {
- tmp = *rp & lmask;
- fb = be32uatoh(fr);
- fr += fs;
+ fb = rasops_be32uatoh(fr);
+ fr += font->stride;
if (bg)
fb = ~fb;
+
+ tmp = *rp & lmask;
tmp |= (MBE(fb >> col) & rmask);
*rp = tmp;
- DELTA(rp, rs, uint32_t *);
+
if (ri->ri_hwbits) {
*hp = tmp;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
+
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
}
@@ -177,6 +179,7 @@ rasops1_putchar(void *cookie, int row, i
if (ri->ri_hwbits)
DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
uint32_t *);
+
for (height = ri->ri_ul.height; height; height--) {
DELTA(rp, - ri->ri_stride, uint32_t *);
tmp = (*rp & lmask) | (fg & rmask);
@@ -189,44 +192,53 @@ rasops1_putchar(void *cookie, int row, i
}
} else {
/* Word boundary, two masks needed */
-
lmask = ~rasops_lmask[col];
rmask = ~rasops_rmask[(col + width) & 31];
if (space) {
- width = bg & ~rmask;
- bg = bg & ~lmask;
+ lbg = bg & ~lmask;
+ rbg = bg & ~rmask;
+
while (height--) {
- tmp0 = (rp[0] & lmask) | bg;
- tmp1 = (rp[1] & rmask) | width;
+ tmp0 = (rp[0] & lmask) | lbg;
+ tmp1 = (rp[1] & rmask) | rbg;
+
rp[0] = tmp0;
rp[1] = tmp1;
- DELTA(rp, rs, uint32_t *);
+
if (ri->ri_hwbits) {
hp[0] = tmp0;
hp[1] = tmp1;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
+
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
} else {
width = 32 - col;
+
while (height--) {
- tmp0 = rp[0] & lmask;
- tmp1 = rp[1] & rmask;
- fb = be32uatoh(fr);
- fr += fs;
+ fb = rasops_be32uatoh(fr);
+ fr += font->stride;
if (bg)
fb = ~fb;
+
+ tmp0 = rp[0] & lmask;
tmp0 |= MBE(fb >> col);
+
+ tmp1 = rp[1] & rmask;
tmp1 |= (MBE(fb << width) & ~rmask);
+
rp[0] = tmp0;
rp[1] = tmp1;
- DELTA(rp, rs, uint32_t *);
+
if (ri->ri_hwbits) {
hp[0] = tmp0;
hp[1] = tmp1;
- DELTA(hp, rs, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
+
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
}
@@ -236,6 +248,7 @@ rasops1_putchar(void *cookie, int row, i
if (ri->ri_hwbits)
DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
uint32_t *);
+
for (height = ri->ri_ul.height; height; height--) {
DELTA(rp, - ri->ri_stride, uint32_t *);
tmp0 = (rp[0] & lmask) | (fg & ~lmask);
@@ -253,13 +266,15 @@ rasops1_putchar(void *cookie, int row, i
}
#ifndef RASOPS_SMALL
-
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops1_putchar_width.h"
+#include <dev/rasops/rasops1_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops1_putchar_width.h"
+#include <dev/rasops/rasops1_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
Index: src/sys/dev/rasops/rasops15.c
diff -u src/sys/dev/rasops/rasops15.c:1.37 src/sys/dev/rasops/rasops15.c:1.38
--- src/sys/dev/rasops/rasops15.c:1.37 Wed Aug 7 12:33:48 2019
+++ src/sys/dev/rasops/rasops15.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops15.c,v 1.37 2019/08/07 12:33:48 rin Exp $ */
+/* $NetBSD: rasops15.c,v 1.38 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.37 2019/08/07 12:33:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.38 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@@ -55,7 +55,7 @@ static void rasops15_makestamp(struct ra
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint32_t stamp[32];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -114,11 +114,13 @@ rasops15_init(struct rasops_info *ri)
#endif
}
+/* rasops15_putchar */
#undef RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
+/* rasops15_putchar_aa */
#define RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
#undef RASOPS_AA
#ifndef RASOPS_SMALL
@@ -128,14 +130,14 @@ rasops15_init(struct rasops_info *ri)
static void
rasops15_makestamp(struct rasops_info *ri, long attr)
{
- uint32_t fg, bg;
int i;
+ uint32_t bg, fg;
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xffff;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffff;
+ bg = ATTR_BG(ri, attr) & 0xffff;
+ fg = ATTR_FG(ri, attr) & 0xffff;
for (i = 0; i < 32; i += 2) {
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -152,16 +154,19 @@ rasops15_makestamp(struct rasops_info *r
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
Index: src/sys/dev/rasops/rasops1_putchar_width.h
diff -u src/sys/dev/rasops/rasops1_putchar_width.h:1.5 src/sys/dev/rasops/rasops1_putchar_width.h:1.6
--- src/sys/dev/rasops/rasops1_putchar_width.h:1.5 Fri Aug 9 12:05:51 2019
+++ src/sys/dev/rasops/rasops1_putchar_width.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1_putchar_width.h,v 1.5 2019/08/09 12:05:51 rin Exp $ */
+/* $NetBSD: rasops1_putchar_width.h,v 1.6 2019/08/10 01:24:17 rin Exp $ */
/* NetBSD: rasops1.c,v 1.28 2019/07/25 03:02:44 rin Exp */
/*-
@@ -34,12 +34,9 @@
#error "Width not supported"
#endif
-#define PUTCHAR_WIDTH1(width) rasops1_putchar ## width
-#define PUTCHAR_WIDTH(width) PUTCHAR_WIDTH1(width)
-
#if RASOPS_WIDTH == 8
-#define COPY_UNIT uint8_t
-#define GET_GLYPH tmp = fr[0]
+#define SUBST_UNIT uint8_t
+#define GET_GLYPH(fr) (fr)[0]
#endif
#if RASOPS_WIDTH == 16
@@ -47,25 +44,29 @@
* rp and hp are always half-word aligned, whereas
* fr may not be aligned in half-word boundary.
*/
-#define COPY_UNIT uint16_t
+#define SUBST_UNIT uint16_t
# if BYTE_ORDER == BIG_ENDIAN
-#define GET_GLYPH tmp = (fr[0] << 8) | fr[1]
+#define GET_GLYPH(fr) ((fr)[0] << 8) | (fr)[1]
# else
-#define GET_GLYPH tmp = fr[0] | (fr[1] << 8)
+#define GET_GLYPH(fr) (fr)[0] | ((fr)[1] << 8)
# endif
#endif /* RASOPS_WIDTH == 16 */
+#define NAME(width) NAME1(width)
+#define NAME1(width) rasops1_putchar ## width
+
/*
* Width-optimized putchar function.
*/
static void
-PUTCHAR_WIDTH(RASOPS_WIDTH)(void *cookie, int row, int col, u_int uc, long attr)
+NAME(RASOPS_WIDTH)(void *cookie, int row, int col, u_int uc, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
- int height, fs, rs, bg, fg;
+ int height;
+ uint32_t bg, fg;
uint8_t *fr;
- COPY_UNIT *rp, *hp, tmp;
+ SUBST_UNIT tmp, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -81,63 +82,67 @@ PUTCHAR_WIDTH(RASOPS_WIDTH)(void *cookie
return;
#endif
- rp = (COPY_UNIT *)(ri->ri_bits + row * ri->ri_yscale +
- col * sizeof(COPY_UNIT));
- if (ri->ri_hwbits)
- hp = (COPY_UNIT *)(ri->ri_hwbits + row * ri->ri_yscale +
- col * sizeof(COPY_UNIT));
height = font->fontheight;
- rs = ri->ri_stride;
- bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
- fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
+ rp = (SUBST_UNIT *)(ri->ri_bits + row * ri->ri_yscale +
+ col * sizeof(SUBST_UNIT));
+ if (ri->ri_hwbits)
+ hp = (SUBST_UNIT *)(ri->ri_hwbits + row * ri->ri_yscale +
+ col * sizeof(SUBST_UNIT));
+
+ bg = ATTR_BG(ri, attr);
+ fg = ATTR_FG(ri, attr);
/* If fg and bg match this becomes a space character */
- if (uc == ' ' || fg == bg) {
+ if (uc == ' ' || __predict_false(fg == bg)) {
while (height--) {
*rp = bg;
- DELTA(rp, rs, COPY_UNIT *);
if (ri->ri_hwbits) {
*hp = bg;
- DELTA(hp, rs, COPY_UNIT *);
+ DELTA(hp, ri->ri_stride, SUBST_UNIT *);
}
+ DELTA(rp, ri->ri_stride, SUBST_UNIT *);
}
} else {
fr = FONT_GLYPH(uc, font, ri);
- fs = font->stride;
while (height--) {
- GET_GLYPH;
+ tmp = GET_GLYPH(fr);
+ fr += font->stride;
if (bg)
tmp = ~tmp;
+
*rp = tmp;
- DELTA(rp, rs, COPY_UNIT *);
+
if (ri->ri_hwbits) {
*hp = tmp;
- DELTA(hp, rs, COPY_UNIT *);
+ DELTA(hp, ri->ri_stride, SUBST_UNIT *);
}
- fr += fs;
+
+ DELTA(rp, ri->ri_stride, SUBST_UNIT *);
}
}
/* Do underline */
if ((attr & WSATTR_UNDERLINE) != 0) {
- DELTA(rp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *);
+ DELTA(rp, - ri->ri_stride * ri->ri_ul.off, SUBST_UNIT *);
if (ri->ri_hwbits)
- DELTA(hp, - ri->ri_stride * ri->ri_ul.off, COPY_UNIT *);
+ DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
+ SUBST_UNIT *);
+
for (height = ri->ri_ul.height; height; height--) {
- DELTA(rp, - ri->ri_stride, COPY_UNIT *);
+ DELTA(rp, - ri->ri_stride, SUBST_UNIT *);
*rp = fg;
if (ri->ri_hwbits) {
- DELTA(hp, - ri->ri_stride, COPY_UNIT *);
+ DELTA(hp, - ri->ri_stride, SUBST_UNIT *);
*hp = fg;
}
}
}
}
-#undef PUTCHAR_WIDTH1
-#undef PUTCHAR_WIDTH
-
-#undef COPY_UNIT
+#undef SUBST_UNIT
#undef GET_GLYPH
+
+#undef NAME
+#undef NAME1
Index: src/sys/dev/rasops/rasops2.c
diff -u src/sys/dev/rasops/rasops2.c:1.31 src/sys/dev/rasops/rasops2.c:1.32
--- src/sys/dev/rasops/rasops2.c:1.31 Wed Aug 7 12:36:36 2019
+++ src/sys/dev/rasops/rasops2.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops2.c,v 1.31 2019/08/07 12:36:36 rin Exp $ */
+/* $NetBSD: rasops2.c,v 1.32 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.31 2019/08/07 12:36:36 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.32 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
+
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
@@ -60,7 +61,7 @@ static void rasops2_makestamp(struct ras
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint8_t stamp[16];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -122,21 +123,22 @@ rasops2_init(struct rasops_info *ri)
static void
rasops2_makestamp(struct rasops_info *ri, long attr)
{
- int i, fg, bg;
+ int i;
+ uint32_t bg, fg;
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 3;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 3;
+ bg = ATTR_BG(ri, attr) & 3;
+ fg = ATTR_FG(ri, attr) & 3;
for (i = 0; i < 16; i++) {
-#if BYTE_ORDER == BIG_ENDIAN
-#define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
+#if BYTE_ORDER == LITTLE_ENDIAN
+ if ((ri->ri_flg & RI_BSWAP) == 0)
#else
-#define NEED_LITTLE_ENDIAN_STAMP 0
+ if ((ri->ri_flg & RI_BSWAP) != 0)
#endif
- if ((ri->ri_flg & RI_BSWAP) == NEED_LITTLE_ENDIAN_STAMP) {
+ {
/* littel endian */
stamp[i] = (i & 8 ? fg : bg);
stamp[i] |= (i & 4 ? fg : bg) << 2;
@@ -152,28 +154,33 @@ rasops2_makestamp(struct rasops_info *ri
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
-/*
- * Grab routines common to depths where (bpp < 8)
- */
+/* rasops2_putchar */
#undef RASOPS_AA
-#include "rasops1-4_putchar.h"
+#include <dev/rasops/rasops1-4_putchar.h>
+/* rasops2_putchar_aa */
#define RASOPS_AA
-#include "rasops1-4_putchar.h"
+#include <dev/rasops/rasops1-4_putchar.h>
#undef RASOPS_AA
+/*
+ * Grab routines common to depths where (bpp < 8)
+ */
#include <dev/rasops/rasops_bitops.h>
Index: src/sys/dev/rasops/rasops24.c
diff -u src/sys/dev/rasops/rasops24.c:1.48 src/sys/dev/rasops/rasops24.c:1.49
--- src/sys/dev/rasops/rasops24.c:1.48 Wed Aug 7 12:33:48 2019
+++ src/sys/dev/rasops/rasops24.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops24.c,v 1.48 2019/08/07 12:33:48 rin Exp $ */
+/* $NetBSD: rasops24.c,v 1.49 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,16 +30,16 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.48 2019/08/07 12:33:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.49 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
+#include <sys/bswap.h>
#include <machine/endian.h>
-#include <sys/bswap.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@@ -63,7 +63,7 @@ static void rasops24_makestamp(struct ra
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint32_t stamp[64];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -125,11 +125,13 @@ rasops24_init(struct rasops_info *ri)
#endif
}
+/* rasops24_putchar */
#undef RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
+/* rasops24_putchar_aa */
#define RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
#undef RASOPS_AA
static __inline void
@@ -160,14 +162,14 @@ rasops24_makestamp1(struct rasops_info *
static void
rasops24_makestamp(struct rasops_info *ri, long attr)
{
- uint32_t fg, bg, c1, c2, c3, c4;
int i;
+ uint32_t bg, fg, c1, c2, c3, c4;
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xffffff;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
+ bg = ATTR_BG(ri, attr) & 0xffffff;
+ fg = ATTR_FG(ri, attr) & 0xffffff;
for (i = 0; i < 64; i += 4) {
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -185,16 +187,19 @@ rasops24_makestamp(struct rasops_info *r
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
@@ -206,8 +211,9 @@ static void
rasops24_eraserows(void *cookie, int row, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int full, slop, cnt, stride;
- uint32_t *rp, *dp, *hp, clr, xstamp[3];
+ int bytes, full, slop, cnt;
+ uint32_t bg, xstamp[3];
+ uint32_t *dp, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -233,8 +239,8 @@ rasops24_eraserows(void *cookie, int row
return;
#endif
- clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
- rasops24_makestamp1(ri, xstamp, clr, clr, clr, clr);
+ bg = ATTR_BG(ri, attr) & 0xffffff;
+ rasops24_makestamp1(ri, xstamp, bg, bg, bg, bg);
/*
* XXX the wsdisplay_emulops interface seems a little deficient in
@@ -243,35 +249,37 @@ rasops24_eraserows(void *cookie, int row
* 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);
}
- full = stride / (4 * 3);
- slop = (stride - full * (4 * 3)) / 4;
+ full = bytes / (4 * 3);
+ slop = (bytes - full * (4 * 3)) / 4;
while (num--) {
dp = rp;
+
for (cnt = full; cnt; cnt--) {
dp[0] = xstamp[0];
dp[1] = xstamp[1];
dp[2] = xstamp[2];
dp += 3;
}
+
for (cnt = 0; cnt < slop; cnt++)
*dp++ = xstamp[cnt];
if (ri->ri_hwbits) {
- memcpy(hp, rp, stride);
+ memcpy(hp, rp, bytes);
DELTA(hp, ri->ri_stride, uint32_t *);
}
@@ -286,9 +294,10 @@ static void
rasops24_erasecols(void *cookie, int row, int col, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int height, cnt, slop1, slop2, full;
- uint32_t clr, xstamp[3], *dp;
- uint8_t *rp, *hp, *dbp;
+ int height, slop1, slop2, full, cnt;
+ uint32_t bg, xstamp[3];
+ uint32_t *dp;
+ uint8_t *bp, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -318,15 +327,15 @@ rasops24_erasecols(void *cookie, int row
return;
#endif
+ height = ri->ri_font->fontheight;
+ num *= ri->ri_xscale;
+
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
if (ri->ri_hwbits)
hp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
- num *= ri->ri_xscale;
- height = ri->ri_font->fontheight;
-
- clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
- rasops24_makestamp1(ri, xstamp, clr, clr, clr, clr);
+ bg = ATTR_BG(ri, attr) & 0xffffff;
+ rasops24_makestamp1(ri, xstamp, bg, bg, bg, bg);
/*
* Align to word boundary by 24-bit-wise operations:
@@ -349,15 +358,15 @@ rasops24_erasecols(void *cookie, int row
while (height--) {
/* Align to word boundary */
- dbp = rp;
+ bp = rp;
for (cnt = slop1; cnt; cnt -= 3) {
- *dbp++ = (clr >> 16);
- *dbp++ = (clr >> 8);
- *dbp++ = clr;
+ *bp++ = (bg >> 16);
+ *bp++ = (bg >> 8);
+ *bp++ = bg;
}
/* 4 pels per loop */
- dp = (uint32_t *)dbp;
+ dp = (uint32_t *)bp;
for (cnt = full; cnt; cnt--) {
dp[0] = xstamp[0];
dp[1] = xstamp[1];
@@ -366,11 +375,11 @@ rasops24_erasecols(void *cookie, int row
}
/* Trailing slop */
- dbp = (uint8_t *)dp;
+ bp = (uint8_t *)dp;
for (cnt = slop2; cnt; cnt -= 3) {
- *dbp++ = (clr >> 16);
- *dbp++ = (clr >> 8);
- *dbp++ = clr;
+ *bp++ = (bg >> 16);
+ *bp++ = (bg >> 8);
+ *bp++ = bg;
}
if (ri->ri_hwbits) {
Index: src/sys/dev/rasops/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.44 src/sys/dev/rasops/rasops32.c:1.45
--- src/sys/dev/rasops/rasops32.c:1.44 Wed Aug 7 12:33:48 2019
+++ src/sys/dev/rasops/rasops32.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops32.c,v 1.44 2019/08/07 12:33:48 rin Exp $ */
+/* $NetBSD: rasops32.c,v 1.45 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.44 2019/08/07 12:33:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.45 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@@ -55,7 +55,7 @@ static void rasops32_makestamp(struct ra
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint32_t stamp[64];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -115,11 +115,13 @@ rasops32_init(struct rasops_info *ri)
#endif
}
+/* rasops32_putchar */
#undef RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
+/* rasops32_putchar_aa */
#define RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
#undef RASOPS_AA
#ifndef RASOPS_SMALL
@@ -135,8 +137,8 @@ rasops32_makestamp(struct rasops_info *r
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
+ bg = ATTR_BG(ri, attr);
+ fg = ATTR_FG(ri, attr);
for (i = 0; i < 64; i += 4) {
stamp[i + 0] = i & 32 ? fg : bg;
@@ -146,16 +148,19 @@ rasops32_makestamp(struct rasops_info *r
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
Index: src/sys/dev/rasops/rasops4.c
diff -u src/sys/dev/rasops/rasops4.c:1.26 src/sys/dev/rasops/rasops4.c:1.27
--- src/sys/dev/rasops/rasops4.c:1.26 Wed Aug 7 12:36:36 2019
+++ src/sys/dev/rasops/rasops4.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops4.c,v 1.26 2019/08/07 12:36:36 rin Exp $ */
+/* $NetBSD: rasops4.c,v 1.27 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.26 2019/08/07 12:36:36 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.27 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
+
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
@@ -59,7 +60,7 @@ static void rasops4_makestamp(struct ras
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint16_t stamp[16];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -116,21 +117,22 @@ rasops4_init(struct rasops_info *ri)
static void
rasops4_makestamp(struct rasops_info *ri, long attr)
{
- int i, fg, bg;
+ int i;
+ uint32_t bg, fg;
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xf;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xf;
+ bg = ATTR_BG(ri, attr) & 0xf;
+ fg = ATTR_FG(ri, attr) & 0xf;
for (i = 0; i < 16; i++) {
-#if BYTE_ORDER == BIG_ENDIAN
-#define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
+#if BYTE_ORDER == LITTLE_ENDIAN
+ if ((ri->ri_flg & RI_BSWAP) == 0)
#else
-#define NEED_LITTLE_ENDIAN_STAMP 0
+ if ((ri->ri_flg & RI_BSWAP) != 0)
#endif
- if ((ri->ri_flg & RI_BSWAP) == NEED_LITTLE_ENDIAN_STAMP) {
+ {
/* little endian */
stamp[i] = (i & 1 ? fg : bg) << 12;
stamp[i] |= (i & 2 ? fg : bg) << 8;
@@ -146,24 +148,28 @@ rasops4_makestamp(struct rasops_info *ri
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#endif /* !RASOPS_SMALL */
+/* rasops4_putchar */
+#undef RASOPS_AA
+#include <dev/rasops/rasops1-4_putchar.h>
+
/*
* Grab routines common to depths where (bpp < 8)
*/
-#undef RASOPS_AA
-#include "rasops1-4_putchar.h"
-
#include <dev/rasops/rasops_bitops.h>
Index: src/sys/dev/rasops/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.49 src/sys/dev/rasops/rasops8.c:1.50
--- src/sys/dev/rasops/rasops8.c:1.49 Wed Aug 7 12:33:48 2019
+++ src/sys/dev/rasops/rasops8.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops8.c,v 1.49 2019/08/07 12:33:48 rin Exp $ */
+/* $NetBSD: rasops8.c,v 1.50 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,13 +30,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.49 2019/08/07 12:33:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.50 2019/08/10 01:24:17 rin Exp $");
+#ifdef _KERNEL_OPT
#include "opt_rasops.h"
+#endif
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@@ -55,7 +55,7 @@ static void rasops8_makestamp(struct ras
#endif
#ifndef RASOPS_SMALL
-/* 4x1 stamp for optimized character blitting */
+/* stamp for optimized character blitting */
static uint32_t stamp[16];
static long stamp_attr;
static struct rasops_info *stamp_ri;
@@ -113,36 +113,38 @@ rasops8_init(struct rasops_info *ri)
#endif
}
+/* rasops8_putchar */
#undef RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
+/* rasops8_putchar_aa */
#define RASOPS_AA
-#include "rasops_putchar.h"
+#include <dev/rasops/rasops_putchar.h>
#undef RASOPS_AA
#ifndef RASOPS_SMALL
/*
- * Recompute the 4x1 blitting stamp.
+ * Recompute the blitting stamp.
*/
static void
rasops8_makestamp(struct rasops_info *ri, long attr)
{
- uint32_t fg, bg;
int i;
+ uint32_t bg, fg;
stamp_attr = attr;
stamp_ri = ri;
- fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xff;
- bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xff;
+ bg = ATTR_BG(ri, attr) & 0xff;
+ fg = ATTR_FG(ri, attr) & 0xff;
for (i = 0; i < 16; i++) {
-#if BYTE_ORDER == BIG_ENDIAN
-#define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
+#if BYTE_ORDER == LITTLE_ENDIAN
+ if ((ri->ri_flg & RI_BSWAP) == 0)
#else
-#define NEED_LITTLE_ENDIAN_STAMP 0
+ if ((ri->ri_flg & RI_BSWAP) != 0)
#endif
- if ((ri->ri_flg & RI_BSWAP) == NEED_LITTLE_ENDIAN_STAMP) {
+ {
/* little endian */
stamp[i] = (i & 8 ? fg : bg);
stamp[i] |= (i & 4 ? fg : bg) << 8;
@@ -158,16 +160,19 @@ rasops8_makestamp(struct rasops_info *ri
}
}
+/*
+ * Width-optimized putchar functions
+ */
#define RASOPS_WIDTH 8
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 12
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
#define RASOPS_WIDTH 16
-#include "rasops_putchar_width.h"
+#include <dev/rasops/rasops_putchar_width.h>
#undef RASOPS_WIDTH
-#endif
+#endif /* !RASOPS_SMALL */
Index: src/sys/dev/rasops/rasops_bitops.h
diff -u src/sys/dev/rasops/rasops_bitops.h:1.24 src/sys/dev/rasops/rasops_bitops.h:1.25
--- src/sys/dev/rasops/rasops_bitops.h:1.24 Wed Aug 7 12:36:36 2019
+++ src/sys/dev/rasops/rasops_bitops.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_bitops.h,v 1.24 2019/08/07 12:36:36 rin Exp $ */
+/* $NetBSD: rasops_bitops.h,v 1.25 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -53,9 +53,9 @@ static void
NAME(erasecols)(void *cookie, int row, int col, int num, long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- uint32_t lclr, rclr, clr;
- uint32_t *dp, *rp, *hp, tmp, lmask, rmask;
int height, cnt;
+ uint32_t bg, lbg, rbg, lmask, rmask, tmp;
+ uint32_t *dp, *rp, *hp;
hp = NULL; /* XXX GCC */
@@ -75,30 +75,33 @@ NAME(erasecols)(void *cookie, int row, i
return;
#endif
+ height = ri->ri_font->fontheight;
col *= ri->ri_font->fontwidth << PIXEL_SHIFT;
num *= ri->ri_font->fontwidth << PIXEL_SHIFT;
- height = ri->ri_font->fontheight;
- clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
+
rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
((col >> 3) & ~3));
+
col &= 31;
+ bg = ATTR_BG(ri, attr);
+
if (col + num <= 32) {
lmask = ~rasops_pmask[col][num & 31];
- lclr = clr & ~lmask;
+ bg &= ~lmask;
while (height--) {
- dp = rp;
- DELTA(rp, ri->ri_stride, uint32_t *);
+ tmp = (*rp & lmask) | bg;
+ *rp = tmp;
- tmp = (*dp & lmask) | lclr;
- *dp = tmp;
if (ri->ri_hwbits) {
*hp = tmp;
DELTA(hp, ri->ri_stride, uint32_t *);
}
+
+ DELTA(rp, ri->ri_stride, uint32_t *);
}
} else {
lmask = rasops_rmask[col];
@@ -109,28 +112,29 @@ NAME(erasecols)(void *cookie, int row, i
else
num = num >> 5;
- lclr = clr & ~lmask;
- rclr = clr & ~rmask;
+ lbg = bg & ~lmask;
+ rbg = bg & ~rmask;
while (height--) {
dp = rp;
if (lmask) {
- *dp = (*dp & lmask) | lclr;
+ *dp = (*dp & lmask) | lbg;
dp++;
}
for (cnt = num; cnt > 0; cnt--)
- *dp++ = clr;
+ *dp++ = bg;
if (rmask)
- *dp = (*dp & rmask) | rclr;
+ *dp = (*dp & rmask) | rbg;
if (ri->ri_hwbits) {
memcpy(hp, rp, ((lmask != 0) + num +
(rmask != 0)) << 2);
DELTA(hp, ri->ri_stride, uint32_t *);
}
+
DELTA(rp, ri->ri_stride, uint32_t *);
}
}
@@ -142,24 +146,28 @@ NAME(erasecols)(void *cookie, int row, i
static void
NAME(do_cursor)(struct rasops_info *ri)
{
- int height, row, col, num, cnt;
- uint32_t *dp, *rp, *hp, tmp, lmask, rmask;
+ int row, col, height, width, cnt;
+ uint32_t lmask, rmask, tmp;
+ uint32_t *dp, *rp, *hp;
hp = NULL; /* XXX GCC */
row = ri->ri_crow;
col = ri->ri_ccol * ri->ri_font->fontwidth << PIXEL_SHIFT;
+
height = ri->ri_font->fontheight;
- num = ri->ri_font->fontwidth << PIXEL_SHIFT;
+ width = ri->ri_font->fontwidth << PIXEL_SHIFT;
+
rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale +
((col >> 3) & ~3));
if (ri->ri_hwbits)
hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
((col >> 3) & ~3));
+
col &= 31;
- if (col + num <= 32) {
- lmask = rasops_pmask[col][num & 31];
+ if (col + width <= 32) {
+ lmask = rasops_pmask[col][width & 31];
while (height--) {
tmp = *rp ^ lmask;
@@ -172,31 +180,29 @@ NAME(do_cursor)(struct rasops_info *ri)
}
} else {
lmask = ~rasops_rmask[col];
- rmask = ~rasops_lmask[(col + num) & 31];
+ rmask = ~rasops_lmask[(col + width) & 31];
if (lmask != -1)
- num = (num - (32 - col)) >> 5;
+ width = (width - (32 - col)) >> 5;
else
- num = num >> 5;
+ width = width >> 5;
while (height--) {
dp = rp;
- if (lmask != -1) {
- *dp = *dp ^ lmask;
- dp++;
- }
+ if (lmask != -1)
+ *dp++ ^= lmask;
- for (cnt = num; cnt; cnt--) {
+ for (cnt = width; cnt; cnt--) {
*dp = ~*dp;
dp++;
}
if (rmask != -1)
- *dp = *dp ^ rmask;
+ *dp ^= rmask;
if (ri->ri_hwbits) {
- memcpy(hp, rp, ((lmask != -1) + num +
+ memcpy(hp, rp, ((lmask != -1) + width +
(rmask != -1)) << 2);
DELTA(hp, ri->ri_stride, uint32_t *);
}
@@ -213,16 +219,17 @@ static void
NAME(copycols)(void *cookie, int row, int src, int dst, int num)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
- int height, lnum, rnum, sb, db, cnt, full;
- uint32_t tmp, lmask, rmask;
- uint32_t *sp, *dp, *srp, *drp, *dhp, *hp;
+ int height, width, lnum, rnum, sb, db, full, cnt, sboff;
+ uint32_t lmask, rmask, tmp;
+ uint32_t *sp, *dp, *srp, *drp, *hp;
+ bool sbover;
- dhp = hp = NULL; /* XXX GCC */
+ hp = NULL; /* XXX GCC */
-#ifdef RASOPS_CLIPPING
- if (dst == src)
+ if (__predict_false(dst == src))
return;
+#ifdef RASOPS_CLIPPING
/* Catches < 0 case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
@@ -247,12 +254,16 @@ NAME(copycols)(void *cookie, int row, in
return;
#endif
- cnt = ri->ri_font->fontwidth << PIXEL_SHIFT;
- src *= cnt;
- dst *= cnt;
- num *= cnt;
- row *= ri->ri_yscale;
height = ri->ri_font->fontheight;
+ width = ri->ri_font->fontwidth << PIXEL_SHIFT;
+
+ row *= ri->ri_yscale;
+
+ src *= width;
+ dst *= width;
+ num *= width;
+
+ sb = src & 31;
db = dst & 31;
if (db + num <= 32) {
@@ -260,16 +271,15 @@ NAME(copycols)(void *cookie, int row, in
srp = (uint32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (uint32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
if (ri->ri_hwbits)
- dhp = (uint32_t *)(ri->ri_hwbits + row +
+ hp = (uint32_t *)(ri->ri_hwbits + row +
((dst >> 3) & ~3));
- sb = src & 31;
while (height--) {
GETBITS(srp, sb, num, tmp);
PUTBITS(tmp, db, num, drp);
if (ri->ri_hwbits) {
- PUTBITS(tmp, db, num, dhp);
- DELTA(dhp, ri->ri_stride, uint32_t *);
+ *hp = *drp;
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
DELTA(srp, ri->ri_stride, uint32_t *);
DELTA(drp, ri->ri_stride, uint32_t *);
@@ -283,27 +293,25 @@ NAME(copycols)(void *cookie, int row, in
lnum = (32 - db) & 31;
rnum = (dst + num) & 31;
- if (lmask)
+ if (lmask != 0)
full = (num - lnum) >> 5;
else
full = num >> 5;
if (src < dst && src + num > dst) {
/* Copy right-to-left */
- bool sbover;
- int sboff;
-
srp = (uint32_t *)(ri->ri_bits + row +
(((src + num) >> 3) & ~3));
drp = (uint32_t *)(ri->ri_bits + row +
(((dst + num) >> 3) & ~3));
- if (ri->ri_hwbits)
- dhp = (uint32_t *)(ri->ri_hwbits + row +
+ if (ri->ri_hwbits) {
+ hp = (uint32_t *)(ri->ri_hwbits + row +
(((dst + num) >> 3) & ~3));
+ hp -= (lmask != 0) + full;
+ }
- sb = src & 31;
- sbover = (sb + lnum) >= 32;
sboff = (src + num) & 31;
+ sbover = sb + lnum >= 32;
if ((sboff -= rnum) < 0) {
srp--;
sboff += 32;
@@ -313,7 +321,7 @@ NAME(copycols)(void *cookie, int row, in
sp = srp;
dp = drp;
- if (rnum) {
+ if (rmask != 0) {
GETBITS(sp, sboff, rnum, tmp);
PUTBITS(tmp, 0, rnum, dp);
}
@@ -326,7 +334,7 @@ NAME(copycols)(void *cookie, int row, in
*dp = tmp;
}
- if (lmask) {
+ if (lmask != 0) {
if (sbover)
--sp;
--dp;
@@ -335,11 +343,9 @@ NAME(copycols)(void *cookie, int row, in
}
if (ri->ri_hwbits) {
- hp = dhp;
- hp -= (lmask != 0) + full;
memcpy(hp, dp, ((lmask != 0) + full +
- (rnum != 0)) << 2);
- DELTA(dhp, ri->ri_stride, uint32_t *);
+ (rmask != 0)) << 2);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
DELTA(srp, ri->ri_stride, uint32_t *);
@@ -350,41 +356,41 @@ NAME(copycols)(void *cookie, int row, in
srp = (uint32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (uint32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
if (ri->ri_hwbits)
- dhp = (uint32_t *)(ri->ri_hwbits + row +
+ hp = (uint32_t *)(ri->ri_hwbits + row +
((dst >> 3) & ~3));
while (height--) {
- sb = src & 31;
sp = srp;
dp = drp;
- if (lmask) {
- GETBITS(sp, sb, lnum, tmp);
+ sboff = sb;
+
+ if (lmask != 0) {
+ GETBITS(sp, sboff, lnum, tmp);
PUTBITS(tmp, db, lnum, dp);
dp++;
- sb += lnum;
- if (sb > 31) {
+ if ((sboff += lnum) > 31) {
sp++;
- sb -= 32;
+ sboff -= 32;
}
}
/* Now aligned to 32-bits wrt dp */
for (cnt = full; cnt; cnt--, sp++) {
- GETBITS(sp, sb, 32, tmp);
+ GETBITS(sp, sboff, 32, tmp);
*dp++ = tmp;
}
- if (rmask) {
- GETBITS(sp, sb, rnum, tmp);
+ if (rmask != 0) {
+ GETBITS(sp, sboff, rnum, tmp);
PUTBITS(tmp, 0, rnum, dp);
}
if (ri->ri_hwbits) {
- memcpy(dhp, drp, ((lmask != 0) + full +
+ memcpy(hp, drp, ((lmask != 0) + full +
(rmask != 0)) << 2);
- DELTA(dhp, ri->ri_stride, uint32_t *);
+ DELTA(hp, ri->ri_stride, uint32_t *);
}
DELTA(srp, ri->ri_stride, uint32_t *);
Index: src/sys/dev/rasops/rasops_masks.c
diff -u src/sys/dev/rasops/rasops_masks.c:1.9 src/sys/dev/rasops/rasops_masks.c:1.10
--- src/sys/dev/rasops/rasops_masks.c:1.9 Mon Dec 2 14:05:51 2013
+++ src/sys/dev/rasops/rasops_masks.c Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_masks.c,v 1.9 2013/12/02 14:05:51 tsutsui Exp $ */
+/* $NetBSD: rasops_masks.c,v 1.10 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops_masks.c,v 1.9 2013/12/02 14:05:51 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops_masks.c,v 1.10 2019/08/10 01:24:17 rin Exp $");
-#include "rasops_masks.h"
+#include <dev/rasops/rasops_masks.h>
/* `ragged edge' bitmasks */
-const uint32_t rasops_lmask[32+1] = {
+const uint32_t rasops_lmask[32 + 1] = {
MBE(0x00000000), MBE(0x7fffffff), MBE(0x3fffffff), MBE(0x1fffffff),
MBE(0x0fffffff), MBE(0x07ffffff), MBE(0x03ffffff), MBE(0x01ffffff),
MBE(0x00ffffff), MBE(0x007fffff), MBE(0x003fffff), MBE(0x001fffff),
@@ -47,7 +47,7 @@ const uint32_t rasops_lmask[32+1] = {
MBE(0x00000000)
};
-const uint32_t rasops_rmask[32+1] = {
+const uint32_t rasops_rmask[32 + 1] = {
MBE(0x00000000), MBE(0x80000000), MBE(0xc0000000), MBE(0xe0000000),
MBE(0xf0000000), MBE(0xf8000000), MBE(0xfc000000), MBE(0xfe000000),
MBE(0xff000000), MBE(0xff800000), MBE(0xffc00000), MBE(0xffe00000),
Index: src/sys/dev/rasops/rasops_masks.h
diff -u src/sys/dev/rasops/rasops_masks.h:1.8 src/sys/dev/rasops/rasops_masks.h:1.9
--- src/sys/dev/rasops/rasops_masks.h:1.8 Mon Dec 2 14:05:51 2013
+++ src/sys/dev/rasops/rasops_masks.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_masks.h,v 1.8 2013/12/02 14:05:51 tsutsui Exp $ */
+/* $NetBSD: rasops_masks.h,v 1.9 2019/08/10 01:24:17 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,6 +33,7 @@
#define _RASOPS_MASKS_H_ 1
#include <sys/types.h>
+
#include <machine/endian.h>
/*
@@ -71,25 +72,24 @@
dw = MBL(*(sp), (x)); \
if (((x) + (w)) > 32) \
dw |= (MBR((sp)[1], 32 - (x))); \
-} while(0);
+} while (0 /* CONSTCOND */)
/* Put a number of bits ( <= 32 ) from sw to *dp */
#define PUTBITS(sw, x, w, dp) do { \
int n = (x) + (w) - 32; \
- \
if (n <= 0) { \
- n = rasops_pmask[x & 31][w & 31]; \
- *(dp) = (*(dp) & ~n) | (MBR(sw, x) & n); \
+ uint32_t mask = rasops_pmask[(x) & 31][(w) & 31]; \
+ *(dp) = (*(dp) & ~mask) | (MBR(sw, x) & mask); \
} else { \
- *(dp) = (*(dp) & rasops_rmask[x]) | (MBR((sw), x)); \
+ *(dp) = (*(dp) & rasops_rmask[x]) | (MBR(sw, x)); \
(dp)[1] = ((dp)[1] & rasops_rmask[n]) | \
(MBL(sw, 32-(x)) & rasops_lmask[n]); \
} \
-} while(0);
+} while (0 /* CONSTCOND */)
/* rasops_masks.c */
-extern const uint32_t rasops_lmask[32+1];
-extern const uint32_t rasops_rmask[32+1];
+extern const uint32_t rasops_lmask[32 + 1];
+extern const uint32_t rasops_rmask[32 + 1];
extern const uint32_t rasops_pmask[32][32];
#endif /* _RASOPS_MASKS_H_ */
Index: src/sys/dev/rasops/rasops_putchar.h
diff -u src/sys/dev/rasops/rasops_putchar.h:1.7 src/sys/dev/rasops/rasops_putchar.h:1.8
--- src/sys/dev/rasops/rasops_putchar.h:1.7 Fri Aug 9 12:05:51 2019
+++ src/sys/dev/rasops/rasops_putchar.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_putchar.h,v 1.7 2019/08/09 12:05:51 rin Exp $ */
+/* $NetBSD: rasops_putchar.h,v 1.8 2019/08/10 01:24:17 rin Exp $ */
/* NetBSD: rasops8.c,v 1.41 2019/07/25 03:02:44 rin Exp */
/*-
@@ -46,7 +46,7 @@
#if RASOPS_DEPTH != 24
#define PIXEL_TYPE COLOR_TYPE
#define PIXEL_BYTES sizeof(PIXEL_TYPE)
-#define SET_PIXEL(p, index) *(p)++ = clr[index]
+#define SET_COLOR(p, index) *(p)++ = clr[index]
#define SET_RGB(p, r, g, b) \
*(p)++ = (((r) >> (8 - ri->ri_rnum)) << ri->ri_rpos) | \
(((g) >> (8 - ri->ri_gnum)) << ri->ri_gpos) | \
@@ -56,7 +56,7 @@
#if RASOPS_DEPTH == 24
#define PIXEL_TYPE uint8_t
#define PIXEL_BYTES 3
-#define SET_PIXEL(p, index) \
+#define SET_COLOR(p, index) \
do { \
COLOR_TYPE c = clr[index]; \
*(p)++ = c >> 16; \
@@ -100,9 +100,9 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
int height, width, cnt;
+ uint8_t *fr;
COLOR_TYPE clr[2];
PIXEL_TYPE *dp, *rp, *hp;
- uint8_t *fr;
hp = NULL; /* XXX GCC */
@@ -118,23 +118,21 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
return;
#endif
- rp = (PIXEL_TYPE *)(ri->ri_bits + row * ri->ri_yscale +
- col * ri->ri_xscale);
- if (ri->ri_hwbits)
- hp = (PIXEL_TYPE *)(ri->ri_hwbits + row * ri->ri_yscale +
- col * ri->ri_xscale);
-
height = font->fontheight;
width = font->fontwidth;
- clr[0] = (COLOR_TYPE)ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
- clr[1] = (COLOR_TYPE)ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
+ rp = (PIXEL_TYPE *)(ri->ri_bits + FBOFFSET(ri, row, col));
+ if (ri->ri_hwbits)
+ hp = (PIXEL_TYPE *)(ri->ri_hwbits + FBOFFSET(ri, row, col));
+
+ clr[0] = (COLOR_TYPE)ATTR_BG(ri, attr);
+ clr[1] = (COLOR_TYPE)ATTR_FG(ri, attr);
if (uc == ' ') {
while (height--) {
dp = rp;
for (cnt = width; cnt; cnt--)
- SET_PIXEL(dp, 0);
+ SET_COLOR(dp, 0);
if (ri->ri_hwbits) {
uint16_t bytes = width * PIXEL_BYTES;
/* XXX GCC */
@@ -168,23 +166,20 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
dp = rp;
#ifndef RASOPS_AA
- uint32_t fb = be32uatoh(fr);
+ uint32_t fb = rasops_be32uatoh(fr);
fr += ri->ri_font->stride;
-#endif
- for (cnt = width; cnt; cnt--)
-#ifndef RASOPS_AA
- {
- SET_PIXEL(dp, (fb >> 31) & 1);
+ for (cnt = width; cnt; cnt--) {
+ SET_COLOR(dp, (fb >> 31) & 1);
fb <<= 1;
}
-#else
- {
+#else /* RASOPS_AA */
+ for (cnt = width; cnt; cnt--) {
int w = *fr++;
if (w == 0xff)
- SET_PIXEL(dp, 1);
+ SET_COLOR(dp, 1);
else if (w == 0)
- SET_PIXEL(dp, 0);
+ SET_COLOR(dp, 0);
else
SET_RGB(dp,
AV(r, w), AV(g, w), AV(b, w));
@@ -206,11 +201,12 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
if (ri->ri_hwbits)
DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
PIXEL_TYPE *);
+
for (height = ri->ri_ul.height; height; height--) {
DELTA(rp, - ri->ri_stride, PIXEL_TYPE *);
dp = rp;
for (cnt = width; cnt; cnt--)
- SET_PIXEL(dp, 1);
+ SET_COLOR(dp, 1);
if (ri->ri_hwbits) {
DELTA(hp, - ri->ri_stride, PIXEL_TYPE *);
uint16_t bytes = width * PIXEL_BYTES;
@@ -225,7 +221,7 @@ NAME(RASOPS_DEPTH)(void *cookie, int row
#undef PIXEL_TYPE
#undef PIXEL_BYTES
-#undef SET_PIXEL
+#undef SET_COLOR
#undef SET_RGB
#undef AV
Index: src/sys/dev/rasops/rasops_putchar_width.h
diff -u src/sys/dev/rasops/rasops_putchar_width.h:1.13 src/sys/dev/rasops/rasops_putchar_width.h:1.14
--- src/sys/dev/rasops/rasops_putchar_width.h:1.13 Fri Aug 9 12:05:51 2019
+++ src/sys/dev/rasops/rasops_putchar_width.h Sat Aug 10 01:24:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_putchar_width.h,v 1.13 2019/08/09 12:05:51 rin Exp $ */
+/* $NetBSD: rasops_putchar_width.h,v 1.14 2019/08/10 01:24:17 rin Exp $ */
/* NetBSD: rasops8.c,v 1.41 2019/07/25 03:02:44 rin Exp */
/*-
@@ -39,15 +39,6 @@
#error "Width not supported"
#endif
-#define PUTCHAR_WIDTH1(depth, width) rasops ## depth ## _putchar ## width
-#define PUTCHAR_WIDTH(depth, width) PUTCHAR_WIDTH1(depth, width)
-
-#define PUTCHAR1(depth) rasops ## depth ## _putchar
-#define PUTCHAR(depth) PUTCHAR1(depth)
-
-#define MAKESTAMP1(depth) rasops ## depth ## _makestamp
-#define MAKESTAMP(depth) MAKESTAMP1(depth)
-
#if RASOPS_DEPTH == 2
#define STAMP_TYPE uint8_t
#elif RASOPS_DEPTH == 4
@@ -172,6 +163,8 @@
} while (0 /* CONSTCOND */)
#endif
+/* ################################################################### */
+
#if RASOPS_WIDTH == 8
#define SUBST_GLYPH \
do { \
@@ -195,21 +188,36 @@
} while (0 /* CONSTCOND */)
#endif
+/* ################################################################### */
+
+#define NAME(depth, width) NAME1(depth, width)
+#define NAME1(depth, width) rasops ## depth ## _putchar ## width
+
+#define PUTCHAR(depth) PUTCHAR1(depth)
+#define PUTCHAR1(depth) rasops ## depth ## _putchar
+
+#define MAKESTAMP(depth) MAKESTAMP1(depth)
+#define MAKESTAMP1(depth) rasops ## depth ## _makestamp
+
/*
* Width-optimized putchar function.
*/
static void
-PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH)(void *cookie, int row, int col,
- u_int uc, long attr)
+NAME(RASOPS_DEPTH, RASOPS_WIDTH)(void *cookie, int row, int col, u_int uc,
+ long attr)
{
struct rasops_info *ri = (struct rasops_info *)cookie;
struct wsdisplay_font *font = PICK_FONT(ri, uc);
- int height, fs;
+ int height;
uint8_t *fr;
STAMP_TYPE *rp, *hp;
hp = NULL; /* XXX GCC */
+ /* check if character fits into font limits */
+ if (__predict_false(!CHAR_IN_FONT(uc, font)))
+ return;
+
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
@@ -219,22 +227,16 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
return;
#endif
- /* check if character fits into font limits */
- if (__predict_false(!CHAR_IN_FONT(uc, font)))
- return;
-
/* Recompute stamp? */
if (attr != stamp_attr || __predict_false(ri != stamp_ri))
MAKESTAMP(RASOPS_DEPTH)(ri, attr);
- rp = (STAMP_TYPE *)(ri->ri_bits + row * ri->ri_yscale +
- col * ri->ri_xscale);
- if (ri->ri_hwbits)
- hp = (STAMP_TYPE *)(ri->ri_hwbits + row * ri->ri_yscale +
- col * ri->ri_xscale);
-
height = font->fontheight;
+ rp = (STAMP_TYPE *)(ri->ri_bits + FBOFFSET(ri, row, col));
+ if (ri->ri_hwbits)
+ hp = (STAMP_TYPE *)(ri->ri_hwbits + FBOFFSET(ri, row, col));
+
if (uc == ' ') {
while (height--) {
SUBST_STAMP(0);
@@ -246,11 +248,9 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
}
} else {
fr = FONT_GLYPH(uc, font, ri);
- fs = font->stride;
-
while (height--) {
SUBST_GLYPH;
- fr += fs;
+ fr += font->stride;
if (ri->ri_hwbits) {
memcpy(hp, rp, SUBST_BYTES);
DELTA(hp, ri->ri_stride, STAMP_TYPE *);
@@ -265,6 +265,7 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
if (ri->ri_hwbits)
DELTA(hp, - ri->ri_stride * ri->ri_ul.off,
STAMP_TYPE *);
+
for (height = ri->ri_ul.height; height; height--) {
DELTA(rp, - ri->ri_stride, STAMP_TYPE *);
SUBST_STAMP(FILLED_STAMP);
@@ -283,17 +284,17 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
#undef FILLED_STAMP
-#undef PUTCHAR_WIDTH1
-#undef PUTCHAR_WIDTH
-
-#undef PUTCHAR1
-#undef PUTCHAR
-
-#undef MAKESTAMP1
-#undef MAKESTAMP
-
#undef SUBST_STAMP1
#undef SUBST_STAMP
#undef SUBST_GLYPH1
#undef SUBST_GLYPH
+
+#undef NAME
+#undef NAME1
+
+#undef PUTCHAR
+#undef PUTCHAR1
+
+#undef MAKESTAMP
+#undef MAKESTAMP1