Module Name: src Committed By: rin Date: Wed Jul 31 04:45:44 UTC 2019
Modified Files: src/sys/dev/rasops: rasops.c rasops.h rasops24.c rasops_putchar_aa.h Log Message: Provide buffer capable of single-row pixels in order to make things simpler. XXX Bump kernel version for rasops_info later. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/dev/rasops/rasops.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/rasops/rasops.h \ src/sys/dev/rasops/rasops24.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/rasops/rasops_putchar_aa.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.104 src/sys/dev/rasops/rasops.c:1.105 --- src/sys/dev/rasops/rasops.c:1.104 Wed Jul 31 02:09:02 2019 +++ src/sys/dev/rasops/rasops.c Wed Jul 31 04:45:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops.c,v 1.104 2019/07/31 02:09:02 rin Exp $ */ +/* $NetBSD: rasops.c,v 1.105 2019/07/31 04:45: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.104 2019/07/31 02:09:02 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.105 2019/07/31 04:45:44 rin Exp $"); #include "opt_rasops.h" #include "rasops_glue.h" @@ -482,6 +482,14 @@ rasops_reconfig(struct rasops_info *ri, WSSCREEN_WSCOLORS | WSSCREEN_REVERSE; } + if (ri->ri_buf != NULL) { + kmem_free(ri->ri_buf, ri->ri_buflen); + ri->ri_buf = NULL; + } + len = (ri->ri_flg & RI_FULLCLEAR) ? ri->ri_stride : ri->ri_emustride; + ri->ri_buflen = len; + ri->ri_buf = kmem_alloc(len, KM_SLEEP); + #ifndef RASOPS_SMALL if (ri->ri_stamp != NULL) { kmem_free(ri->ri_stamp, ri->ri_stamp_len); @@ -949,8 +957,9 @@ void rasops_eraserows(void *cookie, int row, int num, long attr) { struct rasops_info *ri = (struct rasops_info *)cookie; - uint32_t *rp, *dp, *hp, clr; - int n, cnt; + uint32_t *buf = (uint32_t *)ri->ri_buf; + uint32_t *rp, *hp, clr; + int stride, cnt; hp = NULL; /* XXX GCC */ @@ -976,25 +985,26 @@ 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) { - n = ri->ri_stride >> 2; + stride = ri->ri_stride; num = ri->ri_height; rp = (uint32_t *)ri->ri_origbits; if (ri->ri_hwbits) hp = (uint32_t *)ri->ri_hworigbits; } else { - n = ri->ri_emustride >> 2; + stride = 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); } + for (cnt = 0; cnt < stride >> 2; cnt++) + buf[cnt] = clr; + while (num--) { - dp = rp; - for (cnt = n; cnt; cnt--) - *dp++ = clr; + memcpy(rp, buf, stride); if (ri->ri_hwbits) { - memcpy(hp, rp, n << 2); + memcpy(hp, buf, stride); DELTA(hp, ri->ri_stride, uint32_t *); } DELTA(rp, ri->ri_stride, uint32_t *); @@ -1114,8 +1124,9 @@ void rasops_erasecols(void *cookie, int row, int col, int num, long attr) { struct rasops_info *ri = (struct rasops_info *)cookie; + void *buf = ri->ri_buf; int height, cnt, slop1, slop2, clr; - uint32_t *rp, *dp, *hp; + uint32_t *dp, *rp, *hp; hp = NULL; /* XXX GCC */ @@ -1143,95 +1154,45 @@ rasops_erasecols(void *cookie, int row, height = ri->ri_font->fontheight; clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf]; - /* Don't bother using the full loop for <= 32 pels */ - if (num <= 32) { - if (((num | ri->ri_xscale) & 3) == 0) { - /* Word aligned blt */ - num >>= 2; - - while (height--) { - dp = rp; - for (cnt = num; cnt; cnt--) - *dp++ = clr; - if (ri->ri_hwbits) { - memcpy(hp, rp, num << 2); - DELTA(hp, ri->ri_stride, uint32_t *); - } - DELTA(rp, ri->ri_stride, uint32_t *); - } - } else if (((num | ri->ri_xscale) & 1) == 0) { - /* - * Halfword aligned blt. This is needed so the - * 15/16 bit ops can use this function. - */ - num >>= 1; - - while (height--) { - dp = rp; - for (cnt = num; cnt; cnt--) { - *(uint16_t *)dp = clr; - DELTA(dp, 2, uint32_t *); - } - if (ri->ri_hwbits) { - memcpy(hp, rp, num << 1); - DELTA(hp, ri->ri_stride, uint32_t *); - } - DELTA(rp, ri->ri_stride, uint32_t *); - } - } else { - while (height--) { - dp = rp; - for (cnt = num; cnt; cnt--) { - *(uint8_t *)dp = clr; - DELTA(dp, 1, uint32_t *); - } - if (ri->ri_hwbits) { - memcpy(hp, rp, num); - DELTA(hp, ri->ri_stride, uint32_t *); - } - DELTA(rp, ri->ri_stride, uint32_t *); - } - } - - return; - } + dp = buf; slop1 = (4 - ((uintptr_t)rp & 3)) & 3; slop2 = (num - slop1) & 3; num = (num - slop1 /* - slop2 */) >> 2; - while (height--) { - dp = rp; + /* Align span to 4 bytes */ + if (slop1 & 1) { + *(uint8_t *)dp = clr; + DELTA(dp, 1, uint32_t *); + } - /* Align span to 4 bytes */ - if (slop1 & 1) { - *(uint8_t *)dp = clr; - DELTA(dp, 1, uint32_t *); - } + if (slop1 & 2) { + *(uint16_t *)dp = clr; + DELTA(dp, 2, uint32_t *); + } - if (slop1 & 2) { - *(uint16_t *)dp = clr; - DELTA(dp, 2, uint32_t *); - } + /* Write 4 bytes per loop */ + for (cnt = num; cnt; cnt--) + *dp++ = clr; - /* Write 4 bytes per loop */ - for (cnt = num; cnt; cnt--) - *dp++ = clr; + /* Write unaligned trailing slop */ + if (slop2 & 1) { + *(uint8_t *)dp = clr; + DELTA(dp, 1, uint32_t *); + } - /* Write unaligned trailing slop */ - if (slop2 & 1) { - *(uint8_t *)dp = clr; - DELTA(dp, 1, uint32_t *); - } + if (slop2 & 2) + *(uint16_t *)dp = clr; - if (slop2 & 2) - *(uint16_t *)dp = clr; + num = slop1 + (num << 2) + slop2; + while (height--) { + memcpy(rp, buf, num); + DELTA(rp, ri->ri_stride, uint32_t *); if (ri->ri_hwbits) { - memcpy(hp, rp, slop1 + (num << 2) + slop2); + memcpy(hp, buf, num); DELTA(hp, ri->ri_stride, uint32_t *); } - DELTA(rp, ri->ri_stride, uint32_t *); } } Index: src/sys/dev/rasops/rasops.h diff -u src/sys/dev/rasops/rasops.h:1.41 src/sys/dev/rasops/rasops.h:1.42 --- src/sys/dev/rasops/rasops.h:1.41 Wed Jul 31 02:09:02 2019 +++ src/sys/dev/rasops/rasops.h Wed Jul 31 04:45:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops.h,v 1.41 2019/07/31 02:09:02 rin Exp $ */ +/* $NetBSD: rasops.h,v 1.42 2019/07/31 04:45:44 rin Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -131,6 +131,10 @@ struct rasops_info { /* Callbacks so we can share some code */ void (*ri_do_cursor)(struct rasops_info *); + /* buffer capable of single-row pixels */ + void *ri_buf; + size_t ri_buflen; + /* 4x1 stamp for optimized character blitting */ void *ri_stamp; long ri_stamp_attr; Index: src/sys/dev/rasops/rasops24.c diff -u src/sys/dev/rasops/rasops24.c:1.41 src/sys/dev/rasops/rasops24.c:1.42 --- src/sys/dev/rasops/rasops24.c:1.41 Wed Jul 31 02:04:14 2019 +++ src/sys/dev/rasops/rasops24.c Wed Jul 31 04:45:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops24.c,v 1.41 2019/07/31 02:04:14 rin Exp $ */ +/* $NetBSD: rasops24.c,v 1.42 2019/07/31 04:45:44 rin Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.41 2019/07/31 02:04:14 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.42 2019/07/31 04:45:44 rin Exp $"); #include "opt_rasops.h" @@ -181,7 +181,8 @@ static void rasops24_eraserows(void *cookie, int row, int num, long attr) { struct rasops_info *ri = (struct rasops_info *)cookie; - int n9, n3, n1, cnt, stride; + uint32_t *buf = (uint32_t *)ri->ri_buf; + int full, slop, cnt, stride; uint32_t *rp, *dp, *hp, clr, stamp[3]; hp = NULL; /* XXX GCC */ @@ -243,34 +244,28 @@ rasops24_eraserows(void *cookie, int row hp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale); } - n9 = stride / (4 * 9); - cnt = n9 * (4 * 9); - n3 = (stride - cnt) / (4 * 3); - cnt += n3 * (4 * 3); - n1 = (stride - cnt) / 4; + full = stride / (4 * 3); + slop = (stride - full * (4 * 3)) / 4; - while (num--) { - dp = rp; - for (cnt = n9; cnt; cnt--) { - dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2]; - dp[3] = stamp[0]; dp[4] = stamp[1]; dp[5] = stamp[2]; - dp[6] = stamp[0]; dp[7] = stamp[1]; dp[8] = stamp[2]; - dp += 9; - } + dp = buf; - for (cnt = n3; cnt; cnt--) { - dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2]; - dp += 3; - } + for (cnt = full; cnt; cnt--) { + dp[0] = stamp[0]; + dp[1] = stamp[1]; + dp[2] = stamp[2]; + dp += 3; + } - for (cnt = 0; cnt < n1; cnt++) - *dp++ = stamp[cnt]; + for (cnt = 0; cnt < slop; cnt++) + *dp++ = stamp[cnt]; + while (num--) { + memcpy(rp, buf, stride); + DELTA(rp, ri->ri_stride, uint32_t *); if (ri->ri_hwbits) { - memcpy(hp, rp, stride); + memcpy(hp, buf, stride); DELTA(hp, ri->ri_stride, uint32_t *); } - DELTA(rp, ri->ri_stride, uint32_t *); } } @@ -281,7 +276,8 @@ static void rasops24_erasecols(void *cookie, int row, int col, int num, long attr) { struct rasops_info *ri = (struct rasops_info *)cookie; - int n12, n4, height, cnt, slop1, slop2, clr, stamp[3]; + uint8_t *buf = (uint8_t *)ri->ri_buf; + int height, cnt, full, slop1, slop2, clr, stamp[3]; uint32_t *dp; uint8_t *rp, *hp, *dbp; @@ -346,52 +342,45 @@ rasops24_erasecols(void *cookie, int row */ slop1 = (uintptr_t)rp & 3; cnt = slop1; - n12 = (num - cnt) / 12; - cnt += n12 * 12; - n4 = (num - cnt) / 4; - cnt += n4 * 4; + full = (num /* - cnt */) / 4; + cnt += full * 4; slop2 = num - cnt; - while (height--) { - dbp = rp; - - /* Align to 4 bytes */ - /* XXX handle with masks, bring under control of RI_BSWAP */ - for (cnt = slop1; cnt; cnt--) { - *dbp++ = (clr >> 16); - *dbp++ = (clr >> 8); - *dbp++ = clr; - } - - dp = (uint32_t *)dbp; - - /* 12 pels per loop */ - for (cnt = n12; cnt; cnt--) { - dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2]; - dp[3] = stamp[0]; dp[4] = stamp[1]; dp[5] = stamp[2]; - dp[6] = stamp[0]; dp[7] = stamp[1]; dp[8] = stamp[2]; - dp += 9; - } - - /* 4 pels per loop */ - for (cnt = n4; cnt; cnt--) { - dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2]; - dp += 3; - } + /* Align to 4 bytes */ + /* XXX handle with masks, bring under control of RI_BSWAP */ + dbp = buf; + for (cnt = slop1; cnt; cnt--) { + *dbp++ = (clr >> 16); + *dbp++ = (clr >> 8); + *dbp++ = clr; + } + + /* 4 pels per loop */ + dp = (uint32_t *)dbp; + for (cnt = full; cnt; cnt--) { + dp[0] = stamp[0]; + dp[1] = stamp[1]; + dp[2] = stamp[2]; + dp += 3; + } + + /* Trailing slop */ + /* XXX handle with masks, bring under control of RI_BSWAP */ + dbp = (uint8_t *)dp; + for (cnt = slop2; cnt; cnt--) { + *dbp++ = (clr >> 16); + *dbp++ = (clr >> 8); + *dbp++ = clr; + } - /* Trailing slop */ - /* XXX handle with masks, bring under control of RI_BSWAP */ - dbp = (uint8_t *)dp; - for (cnt = slop2; cnt; cnt--) { - *dbp++ = (clr >> 16); - *dbp++ = (clr >> 8); - *dbp++ = clr; - } + num *= 3; + while (height--) { + memcpy(rp, buf, num); + rp += ri->ri_stride; if (ri->ri_hwbits) { - memcpy(hp, rp, num * 3); + memcpy(hp, buf, num); hp += ri->ri_stride; } - rp += ri->ri_stride; } } Index: src/sys/dev/rasops/rasops_putchar_aa.h diff -u src/sys/dev/rasops/rasops_putchar_aa.h:1.5 src/sys/dev/rasops/rasops_putchar_aa.h:1.6 --- src/sys/dev/rasops/rasops_putchar_aa.h:1.5 Wed Jul 31 02:26:40 2019 +++ src/sys/dev/rasops/rasops_putchar_aa.h Wed Jul 31 04:45:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rasops_putchar_aa.h,v 1.5 2019/07/31 02:26:40 rin Exp $ */ +/* $NetBSD: rasops_putchar_aa.h,v 1.6 2019/07/31 04:45:44 rin Exp $ */ /* NetBSD: rasops8.c,v 1.43 2019/07/28 12:06:10 rin Exp */ /*- @@ -38,8 +38,6 @@ #define PUTCHAR_AA(depth) PUTCHAR_AA1(depth) #define PUTCHAR_AA1(depth) rasops ## depth ## _putchar_aa -#define MAX_WIDTH 64 /* XXX */ - #if RASOPS_DEPTH == 8 #define PIXEL_TYPE uint8_t #elif RASOPS_DEPTH == 15 @@ -53,14 +51,12 @@ #if RASOPS_DEPTH != 24 #define COLOR_TYPE PIXEL_TYPE #define PIXEL_BYTES sizeof(PIXEL_TYPE) -#define BUF_LEN MAX_WIDTH #define SET_PIXEL(p, x, c) (p)[x] = clr[c] #endif #if RASOPS_DEPTH == 24 #define COLOR_TYPE uint32_t #define PIXEL_BYTES 3 -#define BUF_LEN (MAX_WIDTH * 3) #define SET_PIXEL(p, x, c) \ do { \ (p)[3 * x + 0] = clr[c] >> 16; \ @@ -80,11 +76,11 @@ PUTCHAR_AA(RASOPS_DEPTH)(void *cookie, i { struct rasops_info *ri = (struct rasops_info *)cookie; struct wsdisplay_font *font = PICK_FONT(ri, uc); + PIXEL_TYPE *buf = (PIXEL_TYPE *)ri->ri_buf; int height, width, x, y, off[2]; uint16_t r[2], g[2], b[2]; uint8_t *fr, aval; PIXEL_TYPE *rp, *hp, R, G, B; - PIXEL_TYPE buf[BUF_LEN] __attribute__ ((aligned(8))); /* XXX */ COLOR_TYPE clr[2]; hp = NULL; /* XXX GCC */ @@ -108,11 +104,7 @@ PUTCHAR_AA(RASOPS_DEPTH)(void *cookie, i col * ri->ri_xscale); height = font->fontheight; - - /* XXX */ width = font->fontwidth; - if (__predict_false(width > MAX_WIDTH)) - width = MAX_WIDTH; clr[0] = (COLOR_TYPE)ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf]; clr[1] = (COLOR_TYPE)ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf]; @@ -208,8 +200,6 @@ PUTCHAR_AA(RASOPS_DEPTH)(void *cookie, i #undef PUTCHAR_AA #undef PUTCHAR_AA1 -#undef MAX_WIDTH - #undef PIXEL_TYPE #undef COLOR_TYPE #undef PIXEL_BYTES