Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops Add general putchar functions for 2 and 4bpp.
details: https://anonhg.NetBSD.org/src/rev/5108f07c41b0
branches: trunk
changeset: 453211:5108f07c41b0
user: rin <rin%NetBSD.org@localhost>
date: Fri Aug 02 04:39:09 2019 +0000
description:
Add general putchar functions for 2 and 4bpp.
Note that 1bpp continues to use its local version in rasops1.c,
which is much faster and simpler.
diffstat:
sys/dev/rasops/rasops1.c | 8 +-
sys/dev/rasops/rasops2.c | 21 +---
sys/dev/rasops/rasops24.c | 6 +-
sys/dev/rasops/rasops4.c | 21 +---
sys/dev/rasops/rasops_bitops.h | 233 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 244 insertions(+), 45 deletions(-)
diffs (truncated from 456 to 300 lines):
diff -r 749d9fb43dc7 -r 5108f07c41b0 sys/dev/rasops/rasops1.c
--- a/sys/dev/rasops/rasops1.c Fri Aug 02 04:35:54 2019 +0000
+++ b/sys/dev/rasops/rasops1.c Fri Aug 02 04:39:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1.c,v 1.33 2019/08/02 04:23:20 rin Exp $ */
+/* $NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.33 2019/08/02 04:23:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.34 2019/08/02 04:39:09 rin Exp $");
#include "opt_rasops.h"
@@ -43,6 +43,7 @@
#include <dev/wscons/wsconsio.h>
#define _RASOPS_PRIVATE
+#define RASOPS_DEPTH 1
#include <dev/rasops/rasops.h>
#include <dev/rasops/rasops_masks.h>
@@ -251,7 +252,4 @@
/*
* Grab routines common to depths where (bpp < 8)
*/
-#define NAME(ident) rasops1_##ident
-#define PIXEL_SHIFT 0
-
#include <dev/rasops/rasops_bitops.h>
diff -r 749d9fb43dc7 -r 5108f07c41b0 sys/dev/rasops/rasops2.c
--- a/sys/dev/rasops/rasops2.c Fri Aug 02 04:35:54 2019 +0000
+++ b/sys/dev/rasops/rasops2.c Fri Aug 02 04:39:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops2.c,v 1.28 2019/07/31 02:04:14 rin Exp $ */
+/* $NetBSD: rasops2.c,v 1.29 2019/08/02 04:39:09 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.28 2019/07/31 02:04:14 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.29 2019/08/02 04:39:09 rin Exp $");
#include "opt_rasops.h"
@@ -43,6 +43,7 @@
#include <dev/wscons/wsconsio.h>
#define _RASOPS_PRIVATE
+#define RASOPS_DEPTH 2
#include <dev/rasops/rasops.h>
#include <dev/rasops/rasops_masks.h>
@@ -91,7 +92,6 @@
break;
#endif /* !RASOPS_SMALL */
default:
- panic("fontwidth not 8/12/16 or RASOPS_SMALL - fixme!");
ri->ri_ops.putchar = rasops2_putchar;
return;
}
@@ -101,16 +101,6 @@
#endif
}
-/*
- * Put a single character. This is the generic version.
- */
-static void
-rasops2_putchar(void *cookie, int row, int col, u_int uc, long attr)
-{
-
- /* XXX punt */
-}
-
#ifndef RASOPS_SMALL
/*
* Recompute the blitting stamp.
@@ -147,8 +137,6 @@
}
}
-#define RASOPS_DEPTH 2
-
#define RASOPS_WIDTH 8
#include "rasops_putchar_width.h"
#undef RASOPS_WIDTH
@@ -166,7 +154,4 @@
/*
* Grab routines common to depths where (bpp < 8)
*/
-#define NAME(ident) rasops2_##ident
-#define PIXEL_SHIFT 1
-
#include <dev/rasops/rasops_bitops.h>
diff -r 749d9fb43dc7 -r 5108f07c41b0 sys/dev/rasops/rasops24.c
--- a/sys/dev/rasops/rasops24.c Fri Aug 02 04:35:54 2019 +0000
+++ b/sys/dev/rasops/rasops24.c Fri Aug 02 04:39:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops24.c,v 1.43 2019/07/31 05:08:10 rin Exp $ */
+/* $NetBSD: rasops24.c,v 1.44 2019/08/02 04:39:09 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.43 2019/07/31 05:08:10 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.44 2019/08/02 04:39:09 rin Exp $");
#include "opt_rasops.h"
@@ -45,6 +45,7 @@
#include <dev/wscons/wsconsio.h>
#define _RASOPS_PRIVATE
+#define RASOPS_DEPTH 24
#include <dev/rasops/rasops.h>
static void rasops24_erasecols(void *, int, int, int, long);
@@ -116,7 +117,6 @@
#endif
}
-#define RASOPS_DEPTH 24
#include "rasops_putchar.h"
#include "rasops_putchar_aa.h"
diff -r 749d9fb43dc7 -r 5108f07c41b0 sys/dev/rasops/rasops4.c
--- a/sys/dev/rasops/rasops4.c Fri Aug 02 04:35:54 2019 +0000
+++ b/sys/dev/rasops/rasops4.c Fri Aug 02 04:39:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops4.c,v 1.23 2019/08/01 03:38:12 rin Exp $ */
+/* $NetBSD: rasops4.c,v 1.24 2019/08/02 04:39:09 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.23 2019/08/01 03:38:12 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.24 2019/08/02 04:39:09 rin Exp $");
#include "opt_rasops.h"
@@ -43,6 +43,7 @@
#include <dev/wscons/wsconsio.h>
#define _RASOPS_PRIVATE
+#define RASOPS_DEPTH 4
#include <dev/rasops/rasops.h>
#include <dev/rasops/rasops_masks.h>
@@ -91,7 +92,6 @@
break;
#endif /* !RASOPS_SMALL */
default:
- panic("fontwidth not 8/12/16 or RASOPS_SMALL - fixme!");
ri->ri_ops.putchar = rasops4_putchar;
return;
}
@@ -101,16 +101,6 @@
#endif
}
-/*
- * Put a single character. This is the generic version.
- */
-static void
-rasops4_putchar(void *cookie, int row, int col, u_int uc, long attr)
-{
-
- /* XXX punt */
-}
-
#ifndef RASOPS_SMALL
/*
* Recompute the blitting stamp.
@@ -147,8 +137,6 @@
}
}
-#define RASOPS_DEPTH 4
-
#define RASOPS_WIDTH 8
#include "rasops_putchar_width.h"
#undef RASOPS_WIDTH
@@ -166,7 +154,4 @@
/*
* Grab routines common to depths where (bpp < 8)
*/
-#define NAME(ident) rasops4_##ident
-#define PIXEL_SHIFT 2
-
#include <dev/rasops/rasops_bitops.h>
diff -r 749d9fb43dc7 -r 5108f07c41b0 sys/dev/rasops/rasops_bitops.h
--- a/sys/dev/rasops/rasops_bitops.h Fri Aug 02 04:35:54 2019 +0000
+++ b/sys/dev/rasops/rasops_bitops.h Fri Aug 02 04:39:09 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_bitops.h,v 1.22 2019/08/02 04:35:54 rin Exp $ */
+/* $NetBSD: rasops_bitops.h,v 1.23 2019/08/02 04:39:09 rin Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -32,6 +32,233 @@
#ifndef _RASOPS_BITOPS_H_
#define _RASOPS_BITOPS_H_ 1
+#define NAME(name) NAME1(RASOPS_DEPTH, name)
+#define NAME1(depth, name) NAME2(depth, name)
+#define NAME2(depth, name) rasops ## depth ## _ ## name
+
+#if RASOPS_DEPTH == 1
+#define PIXEL_SHIFT 0
+#elif RASOPS_DEPTH == 2
+#define PIXEL_SHIFT 1
+#elif RASOPS_DEPTH == 4
+#define PIXEL_SHIFT 2
+#else
+#error "Depth not supported"
+#endif
+
+#define PIXEL_BITS RASOPS_DEPTH
+#define COLOR_MASK __BITS(32 - PIXEL_BITS, 31)
+
+#if RASOPS_DEPTH != 1
+/*
+ * Paint a single character. This function is also applicable to
+ * monochrome, but that in rasops1.c is much simpler and faster.
+ */
+static void
+NAME(putchar)(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 full, cnt, bit;
+ uint32_t fs, rs, fb, bg, fg, lmask, rmask, lbg, rbg, clr[2];
+ uint32_t height, width;
+ uint32_t *rp, *bp, *hp, tmp;
+ uint8_t *fr;
+ bool space;
+
+ hp = NULL; /* XXX GCC */
+
+#ifdef RASOPS_CLIPPING
+ /* Catches 'row < 0' case too */
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
+ return;
+
+ if ((unsigned)col >= (unsigned)ri->ri_cols)
+ return;
+#endif
+
+ 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];
+
+ /* If fg and bg match this becomes a space character */
+ 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;
+
+ if (space) {
+ bg &= rmask;
+ while (height--) {
+ tmp = (*rp & lmask) | bg;
+ *rp = tmp;
+ DELTA(rp, rs, uint32_t *);
+ if (ri->ri_hwbits) {
Home |
Main Index |
Thread Index |
Old Index