Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops Provide buffer capable of single-row pixels i...
details: https://anonhg.NetBSD.org/src/rev/7b3bdbccf135
branches: trunk
changeset: 462908:7b3bdbccf135
user: rin <rin%NetBSD.org@localhost>
date: Wed Jul 31 04:45:44 2019 +0000
description:
Provide buffer capable of single-row pixels in order to make things simpler.
XXX
Bump kernel version for rasops_info later.
diffstat:
sys/dev/rasops/rasops.c | 135 +++++++++++++-----------------------
sys/dev/rasops/rasops.h | 6 +-
sys/dev/rasops/rasops24.c | 125 +++++++++++++++------------------
sys/dev/rasops/rasops_putchar_aa.h | 14 +---
4 files changed, 112 insertions(+), 168 deletions(-)
diffs (truncated from 475 to 300 lines):
diff -r 94dcfc9353b3 -r 7b3bdbccf135 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Wed Jul 31 02:26:40 2019 +0000
+++ b/sys/dev/rasops/rasops.c Wed Jul 31 04:45:44 2019 +0000
@@ -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 @@
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 @@
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 @@
* 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 @@
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 @@
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;
+
+ num = slop1 + (num << 2) + slop2;
- if (slop2 & 2)
- *(uint16_t *)dp = clr;
-
+ 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 *);
}
}
diff -r 94dcfc9353b3 -r 7b3bdbccf135 sys/dev/rasops/rasops.h
--- a/sys/dev/rasops/rasops.h Wed Jul 31 02:26:40 2019 +0000
+++ b/sys/dev/rasops/rasops.h Wed Jul 31 04:45:44 2019 +0000
@@ -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 @@
/* 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;
diff -r 94dcfc9353b3 -r 7b3bdbccf135 sys/dev/rasops/rasops24.c
--- a/sys/dev/rasops/rasops24.c Wed Jul 31 02:26:40 2019 +0000
+++ b/sys/dev/rasops/rasops24.c Wed Jul 31 04:45:44 2019 +0000
@@ -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 @@
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 @@
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;
+
+ dp = buf;
+
+ for (cnt = full; cnt; cnt--) {
+ dp[0] = stamp[0];
+ dp[1] = stamp[1];
+ dp[2] = stamp[2];
+ dp += 3;
+ }
+
+ for (cnt = 0; cnt < slop; cnt++)
+ *dp++ = stamp[cnt];
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;
- }
-
- for (cnt = n3; 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];
-
Home |
Main Index |
Thread Index |
Old Index