Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/rasops Code cleanup. Add ri_bswap member to 'struct ...
details: https://anonhg.NetBSD.org/src/rev/a7cefab6acfe
branches: trunk
changeset: 471844:a7cefab6acfe
user: ad <ad%NetBSD.org@localhost>
date: Tue Apr 13 03:02:40 1999 +0000
description:
Code cleanup. Add ri_bswap member to 'struct rasops_info' to indicate that
framebuffer endianness differs from CPU (for 15,16,32-bit displays).
diffstat:
sys/dev/rasops/rasops.c | 16 ++++-
sys/dev/rasops/rasops.h | 12 ++--
sys/dev/rasops/rasops1.c | 124 ++++++++++++---------------------------------
sys/dev/rasops/rasops24.c | 8 +-
4 files changed, 56 insertions(+), 104 deletions(-)
diffs (truncated from 367 to 300 lines):
diff -r e5bb3e5f7935 -r a7cefab6acfe sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c Tue Apr 13 02:15:49 1999 +0000
+++ b/sys/dev/rasops/rasops.c Tue Apr 13 03:02:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.c,v 1.2 1999/04/13 00:40:08 ad Exp $ */
+/* $NetBSD: rasops.c,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad%NetBSD.org@localhost>
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.2 1999/04/13 00:40:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
#include "opt_rasops.h"
@@ -37,6 +37,8 @@
#include <sys/systm.h>
#include <sys/time.h>
+#include <machine/bswap.h>
+
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wsfont/wsfont.h>
@@ -462,7 +464,8 @@
if (dst == src)
return;
- if (row < 0 || row >= ri->ri_rows)
+ /* Catches < 0 case too */
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (src < 0) {
@@ -571,7 +574,12 @@
else
c = (*p++ << (ri->ri_bnum - 8)) << ri->ri_bpos;
- ri->ri_devcmap[i] = c;
+ if (!ri->ri_swab)
+ ri->ri_devcmap[i] = c;
+ else if (ri->ri_depth <= 32)
+ ri->ri_devcmap[i] = bswap32(c);
+ else /* if (ri->ri_depth <= 16) */
+ ri->ri_devcmap[i] = bswap16(c);
}
}
#endif
diff -r e5bb3e5f7935 -r a7cefab6acfe sys/dev/rasops/rasops.h
--- a/sys/dev/rasops/rasops.h Tue Apr 13 02:15:49 1999 +0000
+++ b/sys/dev/rasops/rasops.h Tue Apr 13 03:02:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops.h,v 1.2 1999/04/13 00:40:08 ad Exp $ */
+/* $NetBSD: rasops.h,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad%NetBSD.org@localhost>
@@ -41,11 +41,11 @@
int ri_height; /* height (pels) */
int ri_stride; /* stride in bytes */
- /* These can optionally be left NULL */
- struct wsdisplay_font *ri_font;/* font to use */
- void *ri_priv; /* driver private data */
- u_char ri_forcemono; /* force monochrome operation */
- u_char __pad0;
+ /* These can optionally be left empty */
+ struct wsdisplay_font *ri_font;
+ void *ri_priv; /* driver private data */
+ u_char ri_forcemono; /* force monochrome operation */
+ u_char ri_swab; /* swap bytes for 15/16/32 bit depths? */
/*
* These are optional and will default if zero. Meaningless
diff -r e5bb3e5f7935 -r a7cefab6acfe sys/dev/rasops/rasops1.c
--- a/sys/dev/rasops/rasops1.c Tue Apr 13 02:15:49 1999 +0000
+++ b/sys/dev/rasops/rasops1.c Tue Apr 13 03:02:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops1.c,v 1.2 1999/04/13 00:40:09 ad Exp $ */
+/* $NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad%NetBSD.org@localhost>
@@ -31,7 +31,7 @@
#ifdef RASOPS1
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.2 1999/04/13 00:40:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -40,15 +40,16 @@
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
#include <dev/rasops/rasops.h>
static void rasops1_putchar __P((void *, int, int col, u_int, long));
static void rasops1_putchar8 __P((void *, int, int col, u_int, long));
static void rasops1_putchar16 __P((void *, int, int col, u_int, long));
static void rasops1_copycols __P((void *, int, int, int, int));
-static void rasops1_erasecols __P((void *, int, int, int));
-static void rasops1_erasecols8 __P((void *, int, int, int));
-static void rasops1_eraserows __P((void *, int, int));
+static void rasops1_erasecols __P((void *, int, int, int, long));
+static void rasops1_erasecols8 __P((void *, int, int, int, long));
+static void rasops1_eraserows __P((void *, int, int, long));
static int32_t rasops1_fg_color __P((long));
static int32_t rasops1_bg_color __P((long));
static void rasops1_do_cursor __P((struct rasops_info *));
@@ -162,7 +163,7 @@
long attr;
{
- /* XXX i need implemention */
+ panic("rasops1_putchar: i need implemention");
}
@@ -183,14 +184,15 @@
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
- if (row < 0 || row >= ri->ri_rows)
+ /* Catches 'row < 0' case too */
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
- if (col < 0 || col >= ri->ri_cols)
+ if ((unsigned)col >= (unsigned)ri->ri_cols)
return;
#endif
- rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+ rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
@@ -247,14 +249,15 @@
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
- if (row < 0 || row >= ri->ri_rows)
+ /* Catches 'row < 0' case too */
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
- if (col < 0 || col >= ri->ri_cols)
+ if ((unsigned)col >= (unsigned)ri->ri_cols)
return;
#endif
- rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+ rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
@@ -312,7 +315,7 @@
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
- if (row < 0 || row > ri->ri_rows)
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
@@ -326,8 +329,8 @@
if (num <= 0)
return;
#endif
- col *= ri->ri_fontwidth;
- num *= ri->ri_fontwidth;
+ col *= ri->ri_font->fontwidth;
+ num *= ri->ri_font->fontwidth;
/*
* lmask: mask for leftmost int32
@@ -336,10 +339,10 @@
*/
lmask = leftmask[col & 31];
rmask = rightmask[(col + num) & 31];
- nint = ((col + num) & ~31) - ((col + 31) & ~31) >> 5;
+ nint = (((col + num) & ~31) - ((col + 31) & ~31)) >> 5;
/* Merge both masks if the span is encapsulated within one int32 */
- if (col & ~31 == (col + num) & ~31) {
+ if ((col & ~31) == ((col + num) & ~31)) {
lmask &= rmask;
rmask = 0;
}
@@ -349,8 +352,8 @@
rclr = clr & rmask;
lmask = ~lmask;
rmask = ~rmask;
- height = ri->ri_fontheight;
- rp = ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3);
+ height = ri->ri_font->fontheight;
+ rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
while (height--) {
dp = rp;
@@ -385,7 +388,7 @@
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
- if (row < 0 || row >= ri->ri_rows)
+ if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
@@ -446,25 +449,25 @@
int height, row, col;
row = ri->ri_crow;
- col = ri->ri_ccol * ri->ri_fontwidth;
+ col = ri->ri_ccol * ri->ri_font->fontwidth;
/*
* lmask: mask for leftmost int32
* rmask: mask for rightmost int32
*/
lmask = leftmask[col & 31];
- rmask = rightmask[(col + ri->ri_fontwidth) & 31];
+ rmask = rightmask[(col + ri->ri_font->fontwidth) & 31];
/* Merge both masks if the span is encapsulated within one int32 */
- if (col & ~31 == (col + ri->ri_fontwidth) & ~31) {
+ if ((col & ~31) == ((col + ri->ri_font->fontwidth) & ~31)) {
lmask &= rmask;
rmask = 0;
}
lmask = ~lmask;
rmask = ~rmask;
- height = ri->ri_fontheight;
- rp = ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3);
+ height = ri->ri_font->fontheight;
+ rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
while (height--) {
dp = rp;
@@ -488,8 +491,8 @@
int width, height, cnt;
u_char *dp, *rp;
- height = ri->ri_fontheight;
- width = ri->ri_fontwidth >> 3;
+ height = ri->ri_font->fontheight;
+ width = ri->ri_font->fontwidth >> 3;
rp = ri->ri_bits + ri->ri_crow * ri->ri_yscale +
ri->ri_ccol * ri->ri_xscale;
@@ -504,7 +507,7 @@
/*
- * Erase rows.
+ * Erase rows. This is easy.
*/
static void
rasops1_eraserows(cookie, row, num, attr)
@@ -564,71 +567,12 @@
* a width that's a multiple of 8 pels, otherwise this is used...
*/
static void
-rasops1_copycols(cookie, row, src, src)
+rasops1_copycols(cookie, row, src, dst, num)
void *cookie;
- int row, src, dst;
+ int row, src, dst, num;
{
-#ifdef notyet
- struct rasops_info *ri;
- int32_t *dp, *drp, *sp, *srp, lmask, rmask;
- int nint, height, cnt;
-
- ri = (struct rasops_info *)cookie;
-
-#ifdef RASOPS_CLIPPING
- if (row < 0 || row >= ri->ri_rows)
- return;
-
- if (col < 0) {
- num += col;
- col = 0;
- }
-
- if ((col + num) > ri->ri_cols)
- num = ri->ri_cols - col;
-
- if (num <= 0)
- return;
-#endif
- src *= ri->ri_fontwidth;
- dst *= ri->ri_fontwidth;
Home |
Main Index |
Thread Index |
Old Index