CVS commit: src/sys/dev/rasops

2020-07-02 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Jul  2 07:49:44 UTC 2020

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
Remove pointless cast; dp is already uint32_t *.
No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/rasops/rasops.c

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.122 src/sys/dev/rasops/rasops.c:1.123
--- src/sys/dev/rasops/rasops.c:1.122	Sat Aug 10 01:24:17 2019
+++ src/sys/dev/rasops/rasops.c	Thu Jul  2 07:49:44 2020
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.122 2019/08/10 01:24:17 rin Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.123 2020/07/02 07:49:44 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.122 2019/08/10 01:24:17 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.123 2020/07/02 07:49:44 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_rasops.h"
@@ -1119,7 +1119,7 @@ rasops_do_cursor(struct rasops_info *ri)
 		}
 
 		for (cnt = full; cnt; cnt--) {
-			*dp = ~*(uint32_t *)dp;
+			*dp = ~*dp;
 			dp++;
 		}
 



CVS commit: src/sys/dev/rasops

2019-03-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Mar  1 23:20:13 UTC 2019

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
Fix whitespace.  (In the source code, not in the functionality.)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.31 src/sys/dev/rasops/rasops32.c:1.32
--- src/sys/dev/rasops/rasops32.c:1.31	Fri Mar  1 23:17:05 2019
+++ src/sys/dev/rasops/rasops32.c	Fri Mar  1 23:20:13 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.31 2019/03/01 23:17:05 jakllsch Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.32 2019/03/01 23:20:13 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.31 2019/03/01 23:17:05 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.32 2019/03/01 23:20:13 jakllsch Exp $");
 
 #include "opt_rasops.h"
 
@@ -195,8 +195,8 @@ rasops32_putchar_aa(void *cookie, int ro
 	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
 
 	if (uc == ' ') {
-	for (cnt = 0; cnt < width; cnt++)
-	buffer[cnt] = clr[0];
+		for (cnt = 0; cnt < width; cnt++)
+			buffer[cnt] = clr[0];
 		while (height--) {
 			dp = rp;
 			DELTA(rp, ri->ri_stride, int32_t *);
@@ -224,8 +224,8 @@ rasops32_putchar_aa(void *cookie, int ro
 	r = aval * r1 + (255 - aval) * r0;
 	g = aval * g1 + (255 - aval) * g0;
 	b = aval * b1 + (255 - aval) * b0;
-	buffer[x] = (r & 0xff00) << 8 | 
-	  (g & 0xff00) | 
+	buffer[x] = (r & 0xff00) << 8 |
+	  (g & 0xff00) |
 	  (b & 0xff00) >> 8;
 }
 fr++;
@@ -236,7 +236,7 @@ rasops32_putchar_aa(void *cookie, int ro
 
 	/* Do underline */
 	if ((attr & WSATTR_UNDERLINE) != 0) {
-	rp = (uint32_t *)rrp; 
+		rp = (uint32_t *)rrp;
 		height = font->fontheight;
 		DELTA(rp, (ri->ri_stride * (height - 2)), int32_t *);
 		while (width--)



CVS commit: src/sys/dev/rasops

2019-03-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Mar  1 23:17:05 UTC 2019

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
Underline when the attribute say underline, not when it says to reverse.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.30 src/sys/dev/rasops/rasops32.c:1.31
--- src/sys/dev/rasops/rasops32.c:1.30	Fri Mar  1 23:14:13 2019
+++ src/sys/dev/rasops/rasops32.c	Fri Mar  1 23:17:05 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.30 2019/03/01 23:14:13 jakllsch Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.31 2019/03/01 23:17:05 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.30 2019/03/01 23:14:13 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.31 2019/03/01 23:17:05 jakllsch Exp $");
 
 #include "opt_rasops.h"
 
@@ -146,7 +146,7 @@ rasops32_putchar(void *cookie, int row, 
 	}
 
 	/* Do underline */
-	if ((attr & 1) != 0) {
+	if ((attr & WSATTR_UNDERLINE) != 0) {
 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
 		if (ri->ri_hwbits)
 			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
@@ -235,7 +235,7 @@ rasops32_putchar_aa(void *cookie, int ro
 	}
 
 	/* Do underline */
-	if ((attr & 1) != 0) {
+	if ((attr & WSATTR_UNDERLINE) != 0) {
 	rp = (uint32_t *)rrp; 
 		height = font->fontheight;
 		DELTA(rp, (ri->ri_stride * (height - 2)), int32_t *);



CVS commit: src/sys/dev/rasops

2019-03-01 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Mar  1 23:14:13 UTC 2019

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
Reset 'height' before underlining in rasops32_putchar_aa().

Prevents segfault when underlining whitespace in the upper left cell.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.29 src/sys/dev/rasops/rasops32.c:1.30
--- src/sys/dev/rasops/rasops32.c:1.29	Sun Sep 15 09:39:47 2013
+++ src/sys/dev/rasops/rasops32.c	Fri Mar  1 23:14:13 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.29 2013/09/15 09:39:47 martin Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.30 2019/03/01 23:14:13 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.29 2013/09/15 09:39:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.30 2019/03/01 23:14:13 jakllsch Exp $");
 
 #include "opt_rasops.h"
 
@@ -237,6 +237,7 @@ rasops32_putchar_aa(void *cookie, int ro
 	/* Do underline */
 	if ((attr & 1) != 0) {
 	rp = (uint32_t *)rrp; 
+		height = font->fontheight;
 		DELTA(rp, (ri->ri_stride * (height - 2)), int32_t *);
 		while (width--)
 			*rp++ = clr[1];



CVS commit: src/sys/dev/rasops

2018-12-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Dec  5 05:52:23 UTC 2018

Modified Files:
src/sys/dev/rasops: rasops4.c

Log Message:
It's WSATTR_UNDERLINE, not WS_UNDERLINE.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/rasops/rasops4.c

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/rasops4.c
diff -u src/sys/dev/rasops/rasops4.c:1.12 src/sys/dev/rasops/rasops4.c:1.13
--- src/sys/dev/rasops/rasops4.c:1.12	Tue Dec  4 09:27:59 2018
+++ src/sys/dev/rasops/rasops4.c	Wed Dec  5 05:52:23 2018
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops4.c,v 1.12 2018/12/04 09:27:59 mlelstv Exp $	*/
+/* 	$NetBSD: rasops4.c,v 1.13 2018/12/05 05:52:23 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.12 2018/12/04 09:27:59 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.13 2018/12/05 05:52:23 mlelstv Exp $");
 
 #include "opt_rasops.h"
 
@@ -159,7 +159,7 @@ rasops4_putchar(void *cookie, int row, i
 		}
 
 		/* Do underline */
-		if (attr & WS_UNDERLINE) {
+		if (attr & WSATTR_UNDERLINE) {
 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
 			*rp = (*rp & lmask) | (fg & rmask);
 		}
@@ -196,7 +196,7 @@ rasops4_putchar(void *cookie, int row, i
 		}
 
 		/* Do underline */
-		if (attr & WS_UNDERLINE) {
+		if (attr & WSATTR_UNDERLINE) {
 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
 			rp[0] = (rp[0] & lmask) | (fg & ~lmask);
 			rp[1] = (rp[1] & rmask) | (fg & ~rmask);
@@ -311,7 +311,7 @@ rasops4_putchar8(void *cookie, int row, 
 	}
 
 	/* Do underline */
-	if ((attr & WS_UNDERLINE) != 0) {
+	if ((attr & WSATTR_UNDERLINE) != 0) {
 		rp -= (rs << 1);
 		rp[0] = stamp[15];
 		rp[1] = stamp[15];
@@ -383,7 +383,7 @@ rasops4_putchar12(void *cookie, int row,
 	}
 
 	/* Do underline */
-	if ((attr & WS_UNDERLINE) != 0) {
+	if ((attr & WSATTR_UNDERLINE) != 0) {
 		rp -= (rs << 1);
 		rp[0] = stamp[15];
 		rp[1] = stamp[15];
@@ -458,7 +458,7 @@ rasops4_putchar16(void *cookie, int row,
 	}
 
 	/* Do underline */
-	if ((attr & WS_UNDERLINE) != 0) {
+	if ((attr & WSATTR_UNDERLINE) != 0) {
 		rp -= (rs << 1);
 		rp[0] = stamp[15];
 		rp[1] = stamp[15];



CVS commit: src/sys/dev/rasops

2018-11-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Nov 29 23:44:50 UTC 2018

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
rasops_do_cursor():
- simplify & sanitize the unaligned case
- use only 32bit accesses
... no longer crash with odd sized fonts in 8bit


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/rasops/rasops.c

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.77 src/sys/dev/rasops/rasops.c:1.78
--- src/sys/dev/rasops/rasops.c:1.77	Thu Jun  1 02:45:11 2017
+++ src/sys/dev/rasops/rasops.c	Thu Nov 29 23:44:50 2018
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.77 2017/06/01 02:45:11 chs Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.78 2018/11/29 23:44:50 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.77 2017/06/01 02:45:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.78 2018/11/29 23:44:50 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -995,7 +995,7 @@ static void
 rasops_do_cursor(struct rasops_info *ri)
 {
 	int full1, height, cnt, slop1, slop2, row, col;
-	u_char *dp, *rp, *hrp, *hp, tmp = 0;
+	u_char *dp, *rp, *hrp, *hp;
 
 	hrp = hp = NULL;
 
@@ -1055,33 +1055,26 @@ rasops_do_cursor(struct rasops_info *ri)
 			}
 		}
 	} else {
-		uint16_t tmp16;
-		uint32_t tmp32;
-		/* XXX this is stupid.. use masks instead */
+		uint32_t tmp32, msk1, msk2;
+
+		msk1 = be32toh(0x >> (32 - (8 * slop1)));
+		msk2 = be32toh(0x << (32 - (8 * slop2)));
+
 		while (height--) {
-			dp = rp;
+			dp = (u_char *)((uintptr_t)rp & ~3);
 			rp += ri->ri_stride;
 			if (ri->ri_hwbits) {
-hp = hrp;
+hp = (u_char *)((uintptr_t)hrp & ~3);
 hrp += ri->ri_stride;
 			}
 
-			if (slop1 & 1) {
-tmp = *dp ^ ~0;
-*dp = tmp;
-dp++;
-if (ri->ri_hwbits) {
-	*hp++ = tmp;
-}
-			}
-
-			if (slop1 & 2) {
-tmp16 = *(int16_t *)dp ^ ~0;
-*(uint16_t *)dp = tmp16;
-dp += 2;
+			if (msk1 != 0) {
+tmp32 = *(int32_t *)dp ^ msk1;
+*(uint32_t *)dp = tmp32;
+dp += 4;
 if (ri->ri_hwbits) {
-	*(int16_t *)hp = tmp16;
-	hp += 2;
+	*(int32_t *)hp = tmp32;
+	hp += 4;
 }
 			}
 
@@ -1095,19 +1088,11 @@ rasops_do_cursor(struct rasops_info *ri)
 }
 			}
 
-			if (slop2 & 1) {
-tmp = *dp ^ ~0;
-*dp = tmp;
-dp++;
-if (ri->ri_hwbits)
-	*hp++ = tmp;
-			}
-
-			if (slop2 & 2) {
-tmp16 = *(int16_t *)dp ^ ~0;
-*(uint16_t *)dp = tmp16;
+			if (msk2 != 0) {
+tmp32 = *(int32_t *)dp ^ msk2;
+*(uint32_t *)dp = tmp32;
 if (ri->ri_hwbits)
-	*(int16_t *)hp = tmp16;
+	*(int32_t *)hp = tmp32;
 			}
 		}
 	}



CVS commit: src/sys/dev/rasops

2017-05-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri May 12 00:41:25 UTC 2017

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
rasops_reconfig(): don't clear flags we won't set here


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/rasops/rasops.c

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.75 src/sys/dev/rasops/rasops.c:1.76
--- src/sys/dev/rasops/rasops.c:1.75	Sat Apr 22 15:05:02 2017
+++ src/sys/dev/rasops/rasops.c	Fri May 12 00:41:25 2017
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.75 2017/04/22 15:05:02 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.76 2017/05/12 00:41:25 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.75 2017/04/22 15:05:02 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.76 2017/05/12 00:41:25 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -415,12 +415,14 @@ rasops_reconfig(struct rasops_info *ri, 
 	ri->ri_ops.cursor = rasops_cursor;
 	ri->ri_do_cursor = rasops_do_cursor;
 
+	ri->ri_caps &= ~(WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
+		WSSCREEN_WSCOLORS | WSSCREEN_REVERSE);
 	if (ri->ri_depth < 8 || (ri->ri_flg & RI_FORCEMONO) != 0) {
 		ri->ri_ops.allocattr = rasops_allocattr_mono;
-		ri->ri_caps = WSSCREEN_UNDERLINE | WSSCREEN_REVERSE;
+		ri->ri_caps |= WSSCREEN_UNDERLINE | WSSCREEN_REVERSE;
 	} else {
 		ri->ri_ops.allocattr = rasops_allocattr_color;
-		ri->ri_caps = WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
+		ri->ri_caps |= WSSCREEN_UNDERLINE | WSSCREEN_HILIT |
 		WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
 	}
 



CVS commit: src/sys/dev/rasops

2017-04-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 22 15:05:03 UTC 2017

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h

Log Message:
add RI_PREFER_ALPHA flag, for drivers that can draw such fonts by hardware


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/rasops/rasops.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.74 src/sys/dev/rasops/rasops.c:1.75
--- src/sys/dev/rasops/rasops.c:1.74	Thu Feb 23 12:16:30 2017
+++ src/sys/dev/rasops/rasops.c	Sat Apr 22 15:05:02 2017
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.74 2017/02/23 12:16:30 nonaka Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.75 2017/04/22 15:05:02 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.74 2017/02/23 12:16:30 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.75 2017/04/22 15:05:02 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -208,7 +208,8 @@ rasops_init(struct rasops_info *ri, int 
 		flags = WSFONT_FIND_BESTWIDTH | WSFONT_FIND_BITMAP;
 		if ((ri->ri_flg & RI_ENABLE_ALPHA) != 0)
 			flags |= WSFONT_FIND_ALPHA;
-
+		if ((ri->ri_flg & RI_PREFER_ALPHA) != 0)
+			flags |= WSFONT_PREFER_ALPHA;
 		cookie = wsfont_find(NULL,
 			ri->ri_width / wantcols,
 			0,
@@ -376,14 +377,14 @@ rasops_reconfig(struct rasops_info *ri, 
 	if ((ri->ri_delta & 3) != 0)
 		panic("rasops_init: ri_delta not aligned on 32-bit boundary");
 #endif
+	ri->ri_origbits = ri->ri_bits;
+	ri->ri_hworigbits = ri->ri_hwbits;
+
 	/* Clear the entire display */
 	if ((ri->ri_flg & RI_CLEAR) != 0)
 		memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
 
 	/* Now centre our window if needs be */
-	ri->ri_origbits = ri->ri_bits;
-	ri->ri_hworigbits = ri->ri_hwbits;
-
 	if ((ri->ri_flg & RI_CENTER) != 0) {
 		ri->ri_bits += (((ri->ri_width * bpp >> 3) -
 		ri->ri_emustride) >> 1) & ~3;
@@ -1727,7 +1728,7 @@ rasops_make_box_chars_alpha(struct rasop
 		}
 	}
 }
-
+ 
 /*
  * Return a colour map appropriate for the given struct rasops_info in the
  * same form used by rasops_cmap[]

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.31 src/sys/dev/rasops/rasops.h:1.32
--- src/sys/dev/rasops/rasops.h:1.31	Thu Apr 19 06:57:39 2012
+++ src/sys/dev/rasops/rasops.h	Sat Apr 22 15:05:02 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.31 2012/04/19 06:57:39 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.32 2017/04/22 15:05:02 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -63,6 +63,11 @@
 #define RI_ENABLE_ALPHA	0x1000
 /* set this in order to use r3g3b2 'true' colour in 8 bit */ 
 #define RI_8BIT_IS_RGB	0x2000
+/*
+ * drivers can set this to tell the font selection code that they'd rather
+ * use alpha fonts
+ */ 
+#define RI_PREFER_ALPHA	0x4000
 
 struct rasops_info {
 	/* These must be filled in by the caller */



CVS commit: src/sys/dev/rasops

2017-02-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb 23 12:16:30 UTC 2017

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
reset ri->ri_hwbits too if RI_CFGDONE is set.

prevent ri->ri_hwbits from moving to center every time rasops_reconfig() is
called when RI_CENTER is set.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/rasops/rasops.c

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.73 src/sys/dev/rasops/rasops.c:1.74
--- src/sys/dev/rasops/rasops.c:1.73	Sat Apr 18 11:23:58 2015
+++ src/sys/dev/rasops/rasops.c	Thu Feb 23 12:16:30 2017
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.73 2015/04/18 11:23:58 mlelstv Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.74 2017/02/23 12:16:30 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.73 2015/04/18 11:23:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.74 2017/02/23 12:16:30 nonaka Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -325,8 +325,10 @@ rasops_reconfig(struct rasops_info *ri, 
 	/* Need this to frob the setup below */
 	bpp = (ri->ri_depth == 15 ? 16 : ri->ri_depth);
 
-	if ((ri->ri_flg & RI_CFGDONE) != 0)
+	if ((ri->ri_flg & RI_CFGDONE) != 0) {
 		ri->ri_bits = ri->ri_origbits;
+		ri->ri_hwbits = ri->ri_hworigbits;
+	}
 
 	/* Don't care if the caller wants a hideously small console */
 	if (wantrows < 10)



CVS commit: src/sys/dev/rasops

2017-01-25 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Jan 25 14:53:43 UTC 2017

Modified Files:
src/sys/dev/rasops: rasops15.c

Log Message:
Add rasops15_putchar_aa() for greyscale fonts.

Based on rasops8_putchar_aa() and rasops32_putchar_aa().


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/rasops/rasops15.c

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/rasops15.c
diff -u src/sys/dev/rasops/rasops15.c:1.20 src/sys/dev/rasops/rasops15.c:1.21
--- src/sys/dev/rasops/rasops15.c:1.20	Tue Apr 17 12:06:25 2012
+++ src/sys/dev/rasops/rasops15.c	Wed Jan 25 14:53:43 2017
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops15.c,v 1.20 2012/04/17 12:06:25 macallan Exp $	*/
+/* 	$NetBSD: rasops15.c,v 1.21 2017/01/25 14:53:43 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.20 2012/04/17 12:06:25 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.21 2017/01/25 14:53:43 jakllsch Exp $");
 
 #include "opt_rasops.h"
 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: rasops15.c,v
 #include 
 
 static void 	rasops15_putchar(void *, int, int, u_int, long attr);
+static void 	rasops15_putchar_aa(void *, int, int, u_int, long attr);
 #ifndef RASOPS_SMALL
 static void 	rasops15_putchar8(void *, int, int, u_int, long attr);
 static void 	rasops15_putchar12(void *, int, int, u_int, long attr);
@@ -78,23 +79,27 @@ void
 rasops15_init(struct rasops_info *ri)
 {
 
-	switch (ri->ri_font->fontwidth) {
+	if (FONT_IS_ALPHA(ri->ri_font)) {
+		ri->ri_ops.putchar = rasops15_putchar_aa;
+	} else {
+		switch (ri->ri_font->fontwidth) {
 #ifndef RASOPS_SMALL
-	case 8:
-		ri->ri_ops.putchar = rasops15_putchar8;
-		break;
-
-	case 12:
-		ri->ri_ops.putchar = rasops15_putchar12;
-		break;
-
-	case 16:
-		ri->ri_ops.putchar = rasops15_putchar16;
-		break;
+		case 8:
+			ri->ri_ops.putchar = rasops15_putchar8;
+			break;
+
+		case 12:
+			ri->ri_ops.putchar = rasops15_putchar12;
+			break;
+
+		case 16:
+			ri->ri_ops.putchar = rasops15_putchar16;
+			break;
 #endif	/* !RASOPS_SMALL */
-	default:
-		ri->ri_ops.putchar = rasops15_putchar;
-		break;
+		default:
+			ri->ri_ops.putchar = rasops15_putchar;
+			break;
+		}
 	}
 
 	if (ri->ri_rnum == 0) {
@@ -203,6 +208,98 @@ rasops15_putchar(void *cookie, int row, 
 	}
 }
 
+static void
+rasops15_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
+{
+	int width, height, cnt, clr[2];
+	struct rasops_info *ri = (struct rasops_info *)cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, uc);
+	int16_t *dp, *rp;
+	uint8_t *rrp;
+	u_char *fr;
+	uint16_t buffer[64]; /* XXX */
+	int x, y, r, g, b, aval;
+	int r1, g1, b1, r0, g0, b0, fgo, bgo;
+
+
+#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
+
+	/* check if character fits into font limits */
+	if (!CHAR_IN_FONT(uc, font))
+		return;
+
+	rrp = (ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+	rp = (int16_t *)rrp;
+
+	height = font->fontheight;
+	width = font->fontwidth;
+
+	clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
+	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
+
+	if (uc == ' ') {
+	for (cnt = 0; cnt < width; cnt++)
+	buffer[cnt] = clr[0];
+		while (height--) {
+			dp = rp;
+			DELTA(rp, ri->ri_stride, int16_t *);
+			memcpy(dp, buffer, width << 1);
+		}
+	} else {
+		fr = WSFONT_GLYPH(uc, font);
+
+		fgo = ((attr >> 24) & 0xf) * 3;
+		bgo = ((attr >> 16) & 0xf) * 3;
+
+		r0 = rasops_cmap[bgo];
+		r1 = rasops_cmap[fgo];
+		g0 = rasops_cmap[bgo + 1];
+		g1 = rasops_cmap[fgo + 1];
+		b0 = rasops_cmap[bgo + 2];
+		b1 = rasops_cmap[fgo + 2];
+
+		for (y = 0; y < height; y++) {
+			dp = (uint16_t *)(rrp + ri->ri_stride * y);
+			for (x = 0; x < width; x++) {
+aval = *fr;
+if (aval == 0) {
+	buffer[x] = clr[0];
+} else if (aval == 255) {
+	buffer[x] = clr[1];
+} else {
+	r = aval * r1 + (255 - aval) * r0;
+	g = aval * g1 + (255 - aval) * g0;
+	b = aval * b1 + (255 - aval) * b0;
+	buffer[x] =
+	((r >> (16 - ri->ri_rnum)) <<
+		ri->ri_rpos) |
+	((g >> (16 - ri->ri_gnum)) <<
+	ri->ri_gpos) |
+	((b >> (16 - ri->ri_bnum)) <<
+		ri->ri_bpos);
+}
+fr++;
+			}
+			memcpy(dp, buffer, width << 1);
+		}
+	}
+
+	/* Do underline */
+	if ((attr & 1) != 0) {
+	rp = (uint16_t *)rrp;
+		DELTA(rp, (ri->ri_stride * (height - 2)), int16_t *);
+		while (width--)
+			*rp++ = clr[1];
+	}
+}
+
 #ifndef RASOPS_SMALL
 /*
  * Recompute the (2x2)x1 blitting stamp.



CVS commit: src/sys/dev/rasops

2014-08-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Aug 18 03:59:27 UTC 2014

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
Don't leak f on failure.  Noted by maxv@.

Compile-tested only, with zaurus.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/rasops/rasops.c

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.71 src/sys/dev/rasops/rasops.c:1.72
--- src/sys/dev/rasops/rasops.c:1.71	Thu Apr 19 06:57:39 2012
+++ src/sys/dev/rasops/rasops.c	Mon Aug 18 03:59:27 2014
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.71 2012/04/19 06:57:39 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.72 2014/08/18 03:59:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.71 2012/04/19 06:57:39 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.72 2014/08/18 03:59:27 riastradh Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -1351,16 +1351,21 @@ rasops_rotate_font(int *cookie, int rota
 
 	f = malloc(sizeof(struct rotatedfont), M_DEVBUF, M_WAITOK);
 	if (f == NULL)
-		return;
+		goto fail0;
 
 	if ((ncookie = wsfont_rotate(*cookie, rotate)) == -1)
-		return;
+		goto fail1;
 
 	f->rf_cookie = *cookie;
 	f->rf_rotated = ncookie;
 	SLIST_INSERT_HEAD(&rotatedfonts, f, rf_next);
 
 	*cookie = ncookie;
+	return;
+
+fail1:	free(f, M_DEVBUF);
+fail0:	/* Just use the existing font, I guess...  */
+	return;
 }
 
 static void



CVS commit: src/sys/dev/rasops

2013-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Dec  2 14:05:51 UTC 2013

Modified Files:
src/sys/dev/rasops: README rasops_bitops.h rasops_masks.c
rasops_masks.h

Log Message:
Fix 1 bpp rasops copycols() op:

 - fix inverted shift direction in MBL() and MBR() macro in BE case
   (used by GETBITS() and PUTBITS() in copycols() function in rasops_bitops.h)
 - make all bitmask values unsigned and use proper uint32_t types for
   bitmap variables (to avoid arithmetic right shift)
 - fix various botches in right-to-left copy op (logic is taken from hp300)

Tested on bwtwo(4) on NetBSD/sparc.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/rasops/README
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/rasops/rasops_bitops.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/rasops/rasops_masks.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/rasops/rasops_masks.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/README
diff -u src/sys/dev/rasops/README:1.5 src/sys/dev/rasops/README:1.6
--- src/sys/dev/rasops/README:1.5	Mon Jan  7 00:25:19 2008
+++ src/sys/dev/rasops/README	Mon Dec  2 14:05:51 2013
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.5 2008/01/07 00:25:19 bjs Exp $
+$NetBSD: README,v 1.6 2013/12/02 14:05:51 tsutsui Exp $
 
 This directory contains `rasops', a set of raster operations intended to
 replace the dev/rcons/raster stuff for both wscons and rcons. It yields
@@ -8,7 +8,6 @@ Issues/TODO:
 
 - There is no generic `putchar' function for 2bpp
 - Color handling for 2bpp is broken
-- copycols() from rasops_bitops.h is broken in right->left case
 - 64-bit types are not used on machines that are 64-bit
 - We should never be doing reads/writes of less than 32-bits
 - Flags in attribute values are hardcoded

Index: src/sys/dev/rasops/rasops_bitops.h
diff -u src/sys/dev/rasops/rasops_bitops.h:1.14 src/sys/dev/rasops/rasops_bitops.h:1.15
--- src/sys/dev/rasops/rasops_bitops.h:1.14	Tue May 21 15:57:21 2013
+++ src/sys/dev/rasops/rasops_bitops.h	Mon Dec  2 14:05:51 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops_bitops.h,v 1.14 2013/05/21 15:57:21 tsutsui Exp $	*/
+/* 	$NetBSD: rasops_bitops.h,v 1.15 2013/12/02 14:05:51 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -38,9 +38,9 @@
 static void
 NAME(erasecols)(void *cookie, int row, int col, int num, long attr)
 {
-	int lmask, rmask, lclr, rclr, clr;
+	int lclr, rclr, clr;
 	struct rasops_info *ri;
-	int32_t *dp, *rp, *hrp = NULL, *hp = NULL, tmp;
+	uint32_t *dp, *rp, *hrp = NULL, *hp = NULL, tmp, lmask, rmask;
 	int height, cnt;
 
 	ri = (struct rasops_info *)cookie;
@@ -64,9 +64,9 @@ NAME(erasecols)(void *cookie, int row, i
 	num *= ri->ri_font->fontwidth << PIXEL_SHIFT;
 	height = ri->ri_font->fontheight;
 	clr = ri->ri_devcmap[(attr >> 16) & 0xf];
-	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
+	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
 	if (ri->ri_hwbits)
-		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
+		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
 		((col >> 3) & ~3));
 	if ((col & 31) + num <= 32) {
 		lmask = ~rasops_pmask[col & 31][num];
@@ -74,13 +74,13 @@ NAME(erasecols)(void *cookie, int row, i
 
 		while (height--) {
 			dp = rp;
-			DELTA(rp, ri->ri_stride, int32_t *);
+			DELTA(rp, ri->ri_stride, uint32_t *);
 
 			tmp = (*dp & lmask) | lclr;
 			*dp = tmp;
 			if (ri->ri_hwbits) {
 *hrp = tmp;
-DELTA(hrp, ri->ri_stride, int32_t *);
+DELTA(hrp, ri->ri_stride, uint32_t *);
 			}
 		}
 	} else {
@@ -97,10 +97,10 @@ NAME(erasecols)(void *cookie, int row, i
 
 		while (height--) {
 			dp = rp;
-			DELTA(rp, ri->ri_stride, int32_t *);
+			DELTA(rp, ri->ri_stride, uint32_t *);
 			if (ri->ri_hwbits) {
 hp = hrp;
-DELTA(hrp, ri->ri_stride, int32_t *);
+DELTA(hrp, ri->ri_stride, uint32_t *);
 			}
 
 			if (lmask) {
@@ -136,16 +136,16 @@ NAME(erasecols)(void *cookie, int row, i
 static void
 NAME(do_cursor)(struct rasops_info *ri)
 {
-	int lmask, rmask, height, row, col, num;
-	int32_t *dp, *rp, *hp = NULL, *hrp = NULL, tmp;
+	int height, row, col, num;
+	uint32_t *dp, *rp, *hp = NULL, *hrp = NULL, tmp, lmask, rmask;
 
 	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;
-	rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
+	rp = (uint32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
 	if (ri->ri_hwbits)
-		hrp = (int32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
+		hrp = (uint32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
 		((col >> 3) & ~3));
 
 	if ((col & 31) + num <= 32) {
@@ -153,14 +153,14 @@ NAME(do_cursor)(struct rasops_info *ri)
 
 		while (height--) {
 			dp = rp;
-			DELTA(rp, ri->ri_stride, int32_t *);
+			DELTA(rp, ri->ri_stride, uint32_t

CVS commit: src/sys/dev/rasops

2013-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 15 09:41:55 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops8.c

Log Message:
Remove unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/rasops/rasops8.c

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/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.33 src/sys/dev/rasops/rasops8.c:1.34
--- src/sys/dev/rasops/rasops8.c:1.33	Thu Mar 21 21:00:12 2013
+++ src/sys/dev/rasops/rasops8.c	Sun Sep 15 09:41:55 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.33 2013/03/21 21:00:12 martin Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.34 2013/09/15 09:41:55 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.33 2013/03/21 21:00:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.34 2013/09/15 09:41:55 martin Exp $");
 
 #include "opt_rasops.h"
 
@@ -193,15 +193,15 @@ rasops8_putchar(void *cookie, int row, i
 static void
 rasops8_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
 {
-	int width, height, fs;
-	u_char *dp, *rp, *hp, *hrp, *fr, bg, fg, pixel;
+	int width, height;
+	u_char *rp, *hrp, *fr, bg, fg, pixel;
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int x, y, r, g, b, aval;
 	int r1, g1, b1, r0, g0, b0, fgo, bgo;
 	uint8_t scanline[32] __attribute__ ((aligned(8)));
 
-	hp = hrp = NULL;
+	hrp = NULL;
 
 	if (!CHAR_IN_FONT(uc, font))
 		return;
@@ -236,7 +236,6 @@ rasops8_putchar_aa(void *cookie, int row
 		}
 	} else {
 		fr = WSFONT_GLYPH(uc, font);
-		fs = font->stride;
 		/*
 		 * we need the RGB colours here, get offsets into rasops_cmap
 		 */
@@ -251,7 +250,6 @@ rasops8_putchar_aa(void *cookie, int row
 		b1 = rasops_cmap[fgo + 2];
 
 		for (y = 0; y < height; y++) {
-			dp = rp;
 			for (x = 0; x < width; x++) {
 aval = *fr;
 fr++;



CVS commit: src/sys/dev/rasops

2013-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 15 09:39:48 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
Remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.28 src/sys/dev/rasops/rasops32.c:1.29
--- src/sys/dev/rasops/rasops32.c:1.28	Wed Jul 31 19:58:23 2013
+++ src/sys/dev/rasops/rasops32.c	Sun Sep 15 09:39:47 2013
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.28 2013/07/31 19:58:23 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.29 2013/09/15 09:39:47 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.28 2013/07/31 19:58:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.29 2013/09/15 09:39:47 martin Exp $");
 
 #include "opt_rasops.h"
 
@@ -162,7 +162,7 @@ rasops32_putchar(void *cookie, int row, 
 static void
 rasops32_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
 {
-	int width, height, cnt, fs, clr[2];
+	int width, height, cnt, clr[2];
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int32_t *dp, *rp;
@@ -204,7 +204,6 @@ rasops32_putchar_aa(void *cookie, int ro
 		}
 	} else {
 		fr = WSFONT_GLYPH(uc, font);
-		fs = font->stride;
 
 		r0 = (clr[0] >> 16) & 0xff;
 		r1 = (clr[1] >> 16) & 0xff;



CVS commit: src/sys/dev/rasops

2013-07-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 31 19:58:23 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
rasops32_putchar_aa():
- underline the right characters
- make drawing slightly less horribly inefficient
- don't pretend to support a shadow fb


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.27 src/sys/dev/rasops/rasops32.c:1.28
--- src/sys/dev/rasops/rasops32.c:1.27	Thu Mar 21 21:01:10 2013
+++ src/sys/dev/rasops/rasops32.c	Wed Jul 31 19:58:23 2013
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.27 2013/03/21 21:01:10 martin Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.28 2013/07/31 19:58:23 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.27 2013/03/21 21:01:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.28 2013/07/31 19:58:23 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -165,14 +165,13 @@ rasops32_putchar_aa(void *cookie, int ro
 	int width, height, cnt, fs, clr[2];
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
-	int32_t *dp, *rp, *hp, *hrp;
+	int32_t *dp, *rp;
 	uint8_t *rrp;
 	u_char *fr;
+	uint32_t buffer[64]; /* XXX */
 	int x, y, r, g, b, aval;
 	int r1, g1, b1, r0, g0, b0;
 
-	hp = hrp = NULL;
-
 #ifdef RASOPS_CLIPPING
 	/* Catches 'row < 0' case too */
 	if ((unsigned)row >= (unsigned)ri->ri_rows)
@@ -188,9 +187,6 @@ rasops32_putchar_aa(void *cookie, int ro
 
 	rrp = (ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
 	rp = (int32_t *)rrp;
-	if (ri->ri_hwbits)
-		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
-		col*ri->ri_xscale);
 
 	height = font->fontheight;
 	width = font->fontwidth;
@@ -199,19 +195,12 @@ rasops32_putchar_aa(void *cookie, int ro
 	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
 
 	if (uc == ' ') {
+	for (cnt = 0; cnt < width; cnt++)
+	buffer[cnt] = clr[0];
 		while (height--) {
 			dp = rp;
 			DELTA(rp, ri->ri_stride, int32_t *);
-			if (ri->ri_hwbits) {
-hp = hrp;
-DELTA(hrp, ri->ri_stride, int32_t *);
-			}
-
-			for (cnt = width; cnt; cnt--) {
-*dp++ = clr[0];
-if (ri->ri_hwbits)
-	*hp++ = clr[0];
-			}
+			memcpy(dp, buffer, width << 2);
 		}
 	} else {
 		fr = WSFONT_GLYPH(uc, font);
@@ -229,33 +218,28 @@ rasops32_putchar_aa(void *cookie, int ro
 			for (x = 0; x < width; x++) {
 aval = *fr;
 if (aval == 0) {
-	*dp = clr[0];
+	buffer[x] = clr[0];
 } else if (aval == 255) {
-	*dp = clr[1];
+	buffer[x] = clr[1];
 } else {
 	r = aval * r1 + (255 - aval) * r0;
 	g = aval * g1 + (255 - aval) * g0;
 	b = aval * b1 + (255 - aval) * b0;
-	*dp = (r & 0xff00) << 8 | 
+	buffer[x] = (r & 0xff00) << 8 | 
 	  (g & 0xff00) | 
 	  (b & 0xff00) >> 8;
 }
-dp++;
 fr++;
 			}
+			memcpy(dp, buffer, width << 2);
 		}
 	}
 
 	/* Do underline */
 	if ((attr & 1) != 0) {
-		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
-		if (ri->ri_hwbits)
-			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
-
-		while (width--) {
+	rp = (uint32_t *)rrp; 
+		DELTA(rp, (ri->ri_stride * (height - 2)), int32_t *);
+		while (width--)
 			*rp++ = clr[1];
-			if (ri->ri_hwbits)
-*hrp++ = clr[1];
-		}
 	}
 }



CVS commit: src/sys/dev/rasops

2013-05-21 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue May 21 15:57:21 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops_bitops.h

Log Message:
Fix another typo which causes decrement against a NULL pointer.

Also revert rev 1.9, which shut up gcc's "uninitialized variable"
warning that actually pointed out the typo correctly.  Oh well.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/rasops/rasops_bitops.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_bitops.h
diff -u src/sys/dev/rasops/rasops_bitops.h:1.13 src/sys/dev/rasops/rasops_bitops.h:1.14
--- src/sys/dev/rasops/rasops_bitops.h:1.13	Tue May 21 15:50:09 2013
+++ src/sys/dev/rasops/rasops_bitops.h	Tue May 21 15:57:21 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops_bitops.h,v 1.13 2013/05/21 15:50:09 tsutsui Exp $	*/
+/* 	$NetBSD: rasops_bitops.h,v 1.14 2013/05/21 15:57:21 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -205,8 +205,6 @@ NAME(copycols)(void *cookie, int row, in
 	int32_t *sp, *dp, *srp, *drp, *dhp = NULL, *hp = NULL;
 	struct rasops_info *ri;
 
-	sp = NULL;	/* XXX gcc */
-
 	ri = (struct rasops_info *)cookie;
 
 #ifdef RASOPS_CLIPPING
@@ -294,7 +292,7 @@ NAME(copycols)(void *cookie, int row, in
 		db = dst & 31;
 
 		if ((src -= db) < 0) {
-			sp--;
+			srp--;
 			src += 32;
 		}
 



CVS commit: src/sys/dev/rasops

2013-05-21 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue May 21 15:50:09 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops_bitops.h

Log Message:
Fix fatal (but probably unused) typo in ri->ri_hwbits case in copycols.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/rasops/rasops_bitops.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_bitops.h
diff -u src/sys/dev/rasops/rasops_bitops.h:1.12 src/sys/dev/rasops/rasops_bitops.h:1.13
--- src/sys/dev/rasops/rasops_bitops.h:1.12	Thu Apr  8 16:45:53 2010
+++ src/sys/dev/rasops/rasops_bitops.h	Tue May 21 15:50:09 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops_bitops.h,v 1.12 2010/04/08 16:45:53 macallan Exp $	*/
+/* 	$NetBSD: rasops_bitops.h,v 1.13 2013/05/21 15:50:09 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -313,7 +313,7 @@ NAME(copycols)(void *cookie, int row, in
 PUTBITS(tmp, 0, db, dp);
 if (ri->ri_hwbits) {
 	PUTBITS(tmp, 0, db, hp);
-	hp++;
+	hp--;
 }
 dp--;
 sp--;



CVS commit: src/sys/dev/rasops

2013-04-20 Thread KIYOHARA Takashi
Module Name:src
Committed By:   kiyohara
Date:   Sun Apr 21 04:28:05 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops2.c rasops4.c

Log Message:
Support little endian makestamp.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/rasops/rasops2.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/rasops/rasops4.c

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/rasops2.c
diff -u src/sys/dev/rasops/rasops2.c:1.17 src/sys/dev/rasops/rasops2.c:1.18
--- src/sys/dev/rasops/rasops2.c:1.17	Tue May  4 19:16:22 2010
+++ src/sys/dev/rasops/rasops2.c	Sun Apr 21 04:28:05 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops2.c,v 1.17 2010/05/04 19:16:22 macallan Exp $	*/
+/* 	$NetBSD: rasops2.c,v 1.18 2013/04/21 04:28:05 kiyohara Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.17 2010/05/04 19:16:22 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.18 2013/04/21 04:28:05 kiyohara Exp $");
 
 #include "opt_rasops.h"
 
@@ -229,10 +229,24 @@ rasops2_makestamp(struct rasops_info *ri
 	stamp_attr = attr;
 
 	for (i = 0; i < 16; i++) {
-		stamp[i] = (i & 1 ? fg : bg);
-		stamp[i] |= (i & 2 ? fg : bg) << 2;
-		stamp[i] |= (i & 4 ? fg : bg) << 4;
-		stamp[i] |= (i & 8 ? fg : bg) << 6;
+#if BYTE_ORDER == BIG_ENDIAN
+#define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
+#else
+#define NEED_LITTLE_ENDIAN_STAMP 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;
+			stamp[i] |= (i & 2 ? fg : bg) << 4;
+			stamp[i] |= (i & 1 ? fg : bg) << 6;
+		} else {
+			/* big endian */
+			stamp[i] = (i & 1 ? fg : bg);
+			stamp[i] |= (i & 2 ? fg : bg) << 2;
+			stamp[i] |= (i & 4 ? fg : bg) << 4;
+			stamp[i] |= (i & 8 ? fg : bg) << 6;
+		}
 	}
 }
 

Index: src/sys/dev/rasops/rasops4.c
diff -u src/sys/dev/rasops/rasops4.c:1.10 src/sys/dev/rasops/rasops4.c:1.11
--- src/sys/dev/rasops/rasops4.c:1.10	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops4.c	Sun Apr 21 04:28:05 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops4.c,v 1.10 2010/05/04 04:57:34 macallan Exp $	*/
+/* 	$NetBSD: rasops4.c,v 1.11 2013/04/21 04:28:05 kiyohara Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.10 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.11 2013/04/21 04:28:05 kiyohara Exp $");
 
 #include "opt_rasops.h"
 
@@ -229,10 +229,24 @@ rasops4_makestamp(struct rasops_info *ri
 	stamp_attr = attr;
 
 	for (i = 0; i < 16; i++) {
-		stamp[i] =  (i & 1 ? fg : bg) << 8;
-		stamp[i] |= (i & 2 ? fg : bg) << 12;
-		stamp[i] |= (i & 4 ? fg : bg) << 0;
-		stamp[i] |= (i & 8 ? fg : bg) << 4;
+#if BYTE_ORDER == BIG_ENDIAN
+#define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
+#else
+#define NEED_LITTLE_ENDIAN_STAMP 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;
+			stamp[i] |= (i & 4 ? fg : bg) << 4;
+			stamp[i] |= (i & 8 ? fg : bg) << 0;
+		} else {
+			/* big endian */
+			stamp[i] =  (i & 1 ? fg : bg) << 8;
+			stamp[i] |= (i & 2 ? fg : bg) << 12;
+			stamp[i] |= (i & 4 ? fg : bg) << 0;
+			stamp[i] |= (i & 8 ? fg : bg) << 4;
+		}
 	}
 }
 



CVS commit: src/sys/dev/rasops

2013-03-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar 21 21:01:10 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
Ooops, backout local change not intended to be commited with the last change


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.26 src/sys/dev/rasops/rasops32.c:1.27
--- src/sys/dev/rasops/rasops32.c:1.26	Thu Mar 21 21:00:12 2013
+++ src/sys/dev/rasops/rasops32.c	Thu Mar 21 21:01:10 2013
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.26 2013/03/21 21:00:12 martin Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.27 2013/03/21 21:01:10 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.26 2013/03/21 21:00:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.27 2013/03/21 21:01:10 martin Exp $");
 
 #include "opt_rasops.h"
 
@@ -61,9 +61,9 @@ rasops32_init(struct rasops_info *ri)
 		ri->ri_bpos = 16;
 	}
 
-//	if (FONT_IS_ALPHA(ri->ri_font)) {
-//		ri->ri_ops.putchar = rasops32_putchar_aa;
-//	} else
+	if (FONT_IS_ALPHA(ri->ri_font)) {
+		ri->ri_ops.putchar = rasops32_putchar_aa;
+	} else
 		ri->ri_ops.putchar = rasops32_putchar;
 }
 



CVS commit: src/sys/dev/rasops

2013-03-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar 21 21:00:12 UTC 2013

Modified Files:
src/sys/dev/rasops: rasops32.c rasops8.c

Log Message:
Add syntatic sugar to avoid hurting my eyes


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/rasops/rasops32.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/rasops/rasops8.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.25 src/sys/dev/rasops/rasops32.c:1.26
--- src/sys/dev/rasops/rasops32.c:1.25	Tue Oct 23 15:12:59 2012
+++ src/sys/dev/rasops/rasops32.c	Thu Mar 21 21:00:12 2013
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.25 2012/10/23 15:12:59 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.26 2013/03/21 21:00:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.25 2012/10/23 15:12:59 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.26 2013/03/21 21:00:12 martin Exp $");
 
 #include "opt_rasops.h"
 
@@ -61,9 +61,9 @@ rasops32_init(struct rasops_info *ri)
 		ri->ri_bpos = 16;
 	}
 
-	if (FONT_IS_ALPHA(ri->ri_font)) {
-		ri->ri_ops.putchar = rasops32_putchar_aa;
-	} else
+//	if (FONT_IS_ALPHA(ri->ri_font)) {
+//		ri->ri_ops.putchar = rasops32_putchar_aa;
+//	} else
 		ri->ri_ops.putchar = rasops32_putchar;
 }
 

Index: src/sys/dev/rasops/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.32 src/sys/dev/rasops/rasops8.c:1.33
--- src/sys/dev/rasops/rasops8.c:1.32	Wed Jan 25 20:18:04 2012
+++ src/sys/dev/rasops/rasops8.c	Thu Mar 21 21:00:12 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.32 2012/01/25 20:18:04 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.33 2013/03/21 21:00:12 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.32 2012/01/25 20:18:04 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.33 2013/03/21 21:00:12 martin Exp $");
 
 #include "opt_rasops.h"
 
@@ -76,7 +76,7 @@ void
 rasops8_init(struct rasops_info *ri)
 {
 
-	if FONT_IS_ALPHA(ri->ri_font) {
+	if (FONT_IS_ALPHA(ri->ri_font)) {
 		ri->ri_ops.putchar = rasops8_putchar_aa;
 	} else {
 		switch (ri->ri_font->fontwidth) {



CVS commit: src/sys/dev/rasops

2012-10-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Oct 23 15:12:59 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
make anti-aliased character drawing work on hardware where stride != width * 
bytes per pixel


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.24 src/sys/dev/rasops/rasops32.c:1.25
--- src/sys/dev/rasops/rasops32.c:1.24	Wed Jan  4 17:01:52 2012
+++ src/sys/dev/rasops/rasops32.c	Tue Oct 23 15:12:59 2012
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.24 2012/01/04 17:01:52 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.25 2012/10/23 15:12:59 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.24 2012/01/04 17:01:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.25 2012/10/23 15:12:59 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -166,6 +166,7 @@ rasops32_putchar_aa(void *cookie, int ro
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int32_t *dp, *rp, *hp, *hrp;
+	uint8_t *rrp;
 	u_char *fr;
 	int x, y, r, g, b, aval;
 	int r1, g1, b1, r0, g0, b0;
@@ -185,7 +186,8 @@ rasops32_putchar_aa(void *cookie, int ro
 	if (!CHAR_IN_FONT(uc, font))
 		return;
 
-	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+	rrp = (ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+	rp = (int32_t *)rrp;
 	if (ri->ri_hwbits)
 		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
 		col*ri->ri_xscale);
@@ -223,7 +225,7 @@ rasops32_putchar_aa(void *cookie, int ro
 		b1 =  clr[1] & 0xff;
 
 		for (y = 0; y < height; y++) {
-			dp = rp + ri->ri_width * y;
+			dp = (uint32_t *)(rrp + ri->ri_stride * y);
 			for (x = 0; x < width; x++) {
 aval = *fr;
 if (aval == 0) {



CVS commit: src/sys/dev/rasops

2012-04-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 19 06:57:39 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h

Log Message:
add another convenience function:
rasops_get_cmap() which returns either the ANSI map or an R3G3B2 map,
depending on the rasops_info handed to it so drivers don't have to
duplicate this particular code snippet


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/rasops/rasops.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.70 src/sys/dev/rasops/rasops.c:1.71
--- src/sys/dev/rasops/rasops.c:1.70	Wed Jan 11 15:52:32 2012
+++ src/sys/dev/rasops/rasops.c	Thu Apr 19 06:57:39 2012
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.70 2012/01/11 15:52:32 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.71 2012/04/19 06:57:39 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.70 2012/01/11 15:52:32 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.71 2012/04/19 06:57:39 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -1759,3 +1759,47 @@ rasops_make_box_chars_alpha(struct rasop
 		}
 	}
 }
+
+/*
+ * 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, MIN(bytes, sizeof(rasops_cmap)));
+	}
+	return 0;
+}

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.30 src/sys/dev/rasops/rasops.h:1.31
--- src/sys/dev/rasops/rasops.h:1.30	Wed Jan 11 15:52:32 2012
+++ src/sys/dev/rasops/rasops.h	Thu Apr 19 06:57:39 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.30 2012/01/11 15:52:32 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.31 2012/04/19 06:57:39 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -176,6 +176,8 @@ void	rasops_unpack_attr(long, int *, int
 void	rasops_eraserows(void *, int, int, long);
 void	rasops_erasecols(void *, int, int, int, long);
 void	rasops_copycols(void *, int, int, int, int);
+int	rasops_get_cmap(struct rasops_info *, uint8_t *, size_t);
+
 
 extern const u_char	rasops_isgray[16];
 extern const u_char	rasops_cmap[256*3];



CVS commit: src/sys/dev/rasops

2012-04-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Apr 17 12:06:25 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops15.c

Log Message:
fix what has to be a thinko - I doubt there's much hardware out there that
uses BGR in 15/16 bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/rasops/rasops15.c

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/rasops15.c
diff -u src/sys/dev/rasops/rasops15.c:1.19 src/sys/dev/rasops/rasops15.c:1.20
--- src/sys/dev/rasops/rasops15.c:1.19	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops15.c	Tue Apr 17 12:06:25 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops15.c,v 1.19 2010/05/04 04:57:34 macallan Exp $	*/
+/* 	$NetBSD: rasops15.c,v 1.20 2012/04/17 12:06:25 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.19 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.20 2012/04/17 12:06:25 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -99,11 +99,11 @@ rasops15_init(struct rasops_info *ri)
 
 	if (ri->ri_rnum == 0) {
 		ri->ri_rnum = 5;
-		ri->ri_rpos = 0;
+		ri->ri_rpos = 10 + (ri->ri_depth == 16);
 		ri->ri_gnum = 5 + (ri->ri_depth == 16);
 		ri->ri_gpos = 5;
 		ri->ri_bnum = 5;
-		ri->ri_bpos = 10 + (ri->ri_depth == 16);
+		ri->ri_bpos = 0;
 	}
 }
 



CVS commit: src/sys/dev/rasops

2012-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 25 20:18:05 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops8.c

Log Message:
use memset() to clear character cells instead of being terribly slow


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/rasops/rasops8.c

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/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.31 src/sys/dev/rasops/rasops8.c:1.32
--- src/sys/dev/rasops/rasops8.c:1.31	Wed Jan 25 16:38:27 2012
+++ src/sys/dev/rasops/rasops8.c	Wed Jan 25 20:18:04 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.31 2012/01/25 16:38:27 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.32 2012/01/25 20:18:04 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.31 2012/01/25 16:38:27 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.32 2012/01/25 20:18:04 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -144,18 +144,12 @@ rasops8_putchar(void *cookie, int row, i
 		u_char c = clr[0];
 
 		while (height--) {
-			dp = rp;
-			rp += ri->ri_stride;
+			memset(rp, c, width);
 			if (ri->ri_hwbits) {
-hp = hrp;
+memset(hrp, c, width);
 hrp += ri->ri_stride;
 			}
-
-			for (cnt = width; cnt; cnt--) {
-*dp++ = c;
-if (ri->ri_hwbits)
-	*hp++ = c;
-			}
+			rp += ri->ri_stride;
 		}
 	} else {
 		fr = WSFONT_GLYPH(uc, font);
@@ -199,7 +193,7 @@ rasops8_putchar(void *cookie, int row, i
 static void
 rasops8_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
 {
-	int width, height, cnt, fs;
+	int width, height, fs;
 	u_char *dp, *rp, *hp, *hrp, *fr, bg, fg, pixel;
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
@@ -233,18 +227,12 @@ rasops8_putchar_aa(void *cookie, int row
 	if (uc == ' ') {
 
 		while (height--) {
-			dp = rp;
-			rp += ri->ri_stride;
+			memset(rp, bg, width);
 			if (ri->ri_hwbits) {
-hp = hrp;
+memset(hrp, bg, width);
 hrp += ri->ri_stride;
 			}
-
-			for (cnt = width; cnt; cnt--) {
-*dp++ = bg;
-if (ri->ri_hwbits)
-	*hp++ = bg;
-			}
+			rp += ri->ri_stride;
 		}
 	} else {
 		fr = WSFONT_GLYPH(uc, font);



CVS commit: src/sys/dev/rasops

2012-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 25 16:38:27 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops8.c

Log Message:
rasops8_putchar_aa():
render glyphs scanline by scanline into a 64bit-aligned buffer, then memcpy()
it into video memory instead of writing directly.
This gives >10% speedup even on valkyriefb, likely more on PCIe framebuffers.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/rasops/rasops8.c

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/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.30 src/sys/dev/rasops/rasops8.c:1.31
--- src/sys/dev/rasops/rasops8.c:1.30	Wed Jan  4 20:16:20 2012
+++ src/sys/dev/rasops/rasops8.c	Wed Jan 25 16:38:27 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.30 2012/01/04 20:16:20 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.31 2012/01/25 16:38:27 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.30 2012/01/04 20:16:20 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.31 2012/01/25 16:38:27 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -205,6 +205,7 @@ rasops8_putchar_aa(void *cookie, int row
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int x, y, r, g, b, aval;
 	int r1, g1, b1, r0, g0, b0, fgo, bgo;
+	uint8_t scanline[32] __attribute__ ((aligned(8)));
 
 	hp = hrp = NULL;
 
@@ -278,11 +279,11 @@ rasops8_putchar_aa(void *cookie, int row
 		((g & 0xe000) >> 11) |
 		((b & 0xc000) >> 14);
 }
-*dp = pixel;
-dp++;
+scanline[x] = pixel;
 			}
+			memcpy(rp, scanline, width);
 			if (ri->ri_hwbits) {
-memcpy(rp, hrp, width);
+memcpy(hrp, scanline, width);
 hrp += ri->ri_stride;
 			}
 			rp += ri->ri_stride;



CVS commit: src/sys/dev/rasops

2012-01-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan  4 20:17:06 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
rasops8 expects the colour value replicated in every byte in devcmap[], so
fix that for r3g3b2


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/rasops/rasops.c

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.68 src/sys/dev/rasops/rasops.c:1.69
--- src/sys/dev/rasops/rasops.c:1.68	Wed Dec 28 08:36:46 2011
+++ src/sys/dev/rasops/rasops.c	Wed Jan  4 20:17:05 2012
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.68 2011/12/28 08:36:46 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.69 2012/01/04 20:17:05 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.68 2011/12/28 08:36:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.69 2012/01/04 20:17:05 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -841,7 +841,10 @@ rasops_init_devcmap(struct rasops_info *
 		/* Fill the word for generic routines, which want this */
 		if (ri->ri_depth == 24)
 			c = c | ((c & 0xff) << 24);
-		else if (ri->ri_depth <= 16)
+		else if (ri->ri_depth == 8) {
+			c = c | (c << 8);
+			c |= c << 16;
+		} else if (ri->ri_depth <= 16)
 			c = c | (c << 16);
 
 		/* 24bpp does bswap on the fly. {32,16,15}bpp do it here. */



CVS commit: src/sys/dev/rasops

2012-01-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan  4 20:16:20 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops8.c

Log Message:
add support for anti-aliased fonts in r3g3b2


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/rasops/rasops8.c

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/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.29 src/sys/dev/rasops/rasops8.c:1.30
--- src/sys/dev/rasops/rasops8.c:1.29	Wed Jan  4 17:01:52 2012
+++ src/sys/dev/rasops/rasops8.c	Wed Jan  4 20:16:20 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.29 2012/01/04 17:01:52 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.30 2012/01/04 20:16:20 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.29 2012/01/04 17:01:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.30 2012/01/04 20:16:20 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 
 #include 
 
 static void 	rasops8_putchar(void *, int, int, u_int, long attr);
+static void 	rasops8_putchar_aa(void *, int, int, u_int, long attr);
 #ifndef RASOPS_SMALL
 static void 	rasops8_putchar8(void *, int, int, u_int, long attr);
 static void 	rasops8_putchar12(void *, int, int, u_int, long attr);
@@ -75,21 +76,25 @@ void
 rasops8_init(struct rasops_info *ri)
 {
 
-	switch (ri->ri_font->fontwidth) {
+	if FONT_IS_ALPHA(ri->ri_font) {
+		ri->ri_ops.putchar = rasops8_putchar_aa;
+	} else {
+		switch (ri->ri_font->fontwidth) {
 #ifndef RASOPS_SMALL
-	case 8:
-		ri->ri_ops.putchar = rasops8_putchar8;
-		break;
-	case 12:
-		ri->ri_ops.putchar = rasops8_putchar12;
-		break;
-	case 16:
-		ri->ri_ops.putchar = rasops8_putchar16;
-		break;
+		case 8:
+			ri->ri_ops.putchar = rasops8_putchar8;
+			break;
+		case 12:
+			ri->ri_ops.putchar = rasops8_putchar12;
+			break;
+		case 16:
+			ri->ri_ops.putchar = rasops8_putchar16;
+			break;
 #endif /* !RASOPS_SMALL */
-	default:
-		ri->ri_ops.putchar = rasops8_putchar;
-		break;
+		default:
+			ri->ri_ops.putchar = rasops8_putchar;
+			break;
+		}
 	}
 	if (ri->ri_flg & RI_8BIT_IS_RGB) {
 		ri->ri_rnum = 3;
@@ -191,6 +196,115 @@ rasops8_putchar(void *cookie, int row, i
 	}
 }
 
+static void
+rasops8_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
+{
+	int width, height, cnt, fs;
+	u_char *dp, *rp, *hp, *hrp, *fr, bg, fg, pixel;
+	struct rasops_info *ri = (struct rasops_info *)cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, uc);
+	int x, y, r, g, b, aval;
+	int r1, g1, b1, r0, g0, b0, fgo, bgo;
+
+	hp = hrp = NULL;
+
+	if (!CHAR_IN_FONT(uc, font))
+		return;
+
+#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
+	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
+	if (ri->ri_hwbits)
+		hrp = ri->ri_hwbits + row * ri->ri_yscale + col *
+		ri->ri_xscale;
+
+	height = font->fontheight;
+	width = font->fontwidth;
+	bg = (u_char)ri->ri_devcmap[(attr >> 16) & 0xf];
+	fg = (u_char)ri->ri_devcmap[(attr >> 24) & 0xf];
+
+	if (uc == ' ') {
+
+		while (height--) {
+			dp = rp;
+			rp += ri->ri_stride;
+			if (ri->ri_hwbits) {
+hp = hrp;
+hrp += ri->ri_stride;
+			}
+
+			for (cnt = width; cnt; cnt--) {
+*dp++ = bg;
+if (ri->ri_hwbits)
+	*hp++ = bg;
+			}
+		}
+	} else {
+		fr = WSFONT_GLYPH(uc, font);
+		fs = font->stride;
+		/*
+		 * we need the RGB colours here, get offsets into rasops_cmap
+		 */
+		fgo = ((attr >> 24) & 0xf) * 3;
+		bgo = ((attr >> 16) & 0xf) * 3;
+
+		r0 = rasops_cmap[bgo];
+		r1 = rasops_cmap[fgo];
+		g0 = rasops_cmap[bgo + 1];
+		g1 = rasops_cmap[fgo + 1];
+		b0 = rasops_cmap[bgo + 2];
+		b1 = rasops_cmap[fgo + 2];
+
+		for (y = 0; y < height; y++) {
+			dp = rp;
+			for (x = 0; x < width; x++) {
+aval = *fr;
+fr++;
+if (aval == 0) {
+	pixel = bg;
+} else if (aval == 255) {
+	pixel = fg;
+} else {
+	r = aval * r1 + (255 - aval) * r0;
+	g = aval * g1 + (255 - aval) * g0;
+	b = aval * b1 + (255 - aval) * b0;
+	pixel = ((r & 0xe000) >> 8) |
+		((g & 0xe000) >> 11) |
+		((b & 0xc000) >> 14);
+}
+*dp = pixel;
+dp++;
+			}
+			if (ri->ri_hwbits) {
+memcpy(rp, hrp, width);
+hrp += ri->ri_stride;
+			}
+			rp += ri->ri_stride;
+
+		}
+	}
+
+	/* Do underline */
+	if ((attr & 1) != 0) {
+
+		rp -= (ri->ri_stride << 1);
+		if (ri->ri_hwbits)
+			hrp -= (ri->ri_stride << 1);
+
+		while (width--) {
+			*rp++ = fg;
+			if (ri->ri_hwbits)
+*hrp++ = fg;
+		}
+	}
+}
+
 #ifndef RASOPS_SMALL
 /*
  * Recompute the 4x1 blitting stamp.



CVS commit: src/sys/dev/rasops

2012-01-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan  4 17:01:52 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops32.c rasops8.c

Log Message:
use CHAR_IN_FONT() and WSFONT_GLYPH() macros


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/rasops/rasops32.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/rasops/rasops8.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.23 src/sys/dev/rasops/rasops32.c:1.24
--- src/sys/dev/rasops/rasops32.c:1.23	Tue Jan  3 23:15:11 2012
+++ src/sys/dev/rasops/rasops32.c	Wed Jan  4 17:01:52 2012
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.23 2012/01/03 23:15:11 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.24 2012/01/04 17:01:52 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.23 2012/01/03 23:15:11 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.24 2012/01/04 17:01:52 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -92,9 +92,8 @@ rasops32_putchar(void *cookie, int row, 
 #endif
 
 	/* check if character fits into font limits */
-	if (uc < font->firstchar ||
-	(uc - font->firstchar) >= font->numchars)
-	return;
+	if (!CHAR_IN_FONT(uc, font))
+		return;
 
 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
 	if (ri->ri_hwbits)
@@ -123,8 +122,7 @@ rasops32_putchar(void *cookie, int row, 
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		while (height--) {
@@ -184,9 +182,8 @@ rasops32_putchar_aa(void *cookie, int ro
 #endif
 
 	/* check if character fits into font limits */
-	if (uc < font->firstchar ||
-	(uc - font->firstchar) >= font->numchars)
-	return;
+	if (!CHAR_IN_FONT(uc, font))
+		return;
 
 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
 	if (ri->ri_hwbits)
@@ -215,8 +212,7 @@ rasops32_putchar_aa(void *cookie, int ro
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		r0 = (clr[0] >> 16) & 0xff;

Index: src/sys/dev/rasops/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.28 src/sys/dev/rasops/rasops8.c:1.29
--- src/sys/dev/rasops/rasops8.c:1.28	Wed Dec 28 08:36:46 2011
+++ src/sys/dev/rasops/rasops8.c	Wed Jan  4 17:01:52 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.28 2011/12/28 08:36:46 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.29 2012/01/04 17:01:52 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.28 2011/12/28 08:36:46 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.29 2012/01/04 17:01:52 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -153,8 +153,7 @@ rasops8_putchar(void *cookie, int row, i
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		while (height--) {
@@ -285,8 +284,7 @@ rasops8_putchar8(void *cookie, int row, 
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		while (height--) {
@@ -380,8 +378,7 @@ rasops8_putchar12(void *cookie, int row,
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		while (height--) {
@@ -474,8 +471,7 @@ rasops8_putchar16(void *cookie, int row,
 			}
 		}
 	} else {
-		uc -= font->firstchar;
-		fr = (u_char *)font->data + uc * ri->ri_fontscale;
+		fr = WSFONT_GLYPH(uc, font);
 		fs = font->stride;
 
 		while (height--) {



CVS commit: src/sys/dev/rasops

2012-01-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jan  3 23:15:11 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
split putchar method into one for alpha fonts and one for bitmap fonts


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.22 src/sys/dev/rasops/rasops32.c:1.23
--- src/sys/dev/rasops/rasops32.c:1.22	Tue Dec 27 06:24:40 2011
+++ src/sys/dev/rasops/rasops32.c	Tue Jan  3 23:15:11 2012
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.22 2011/12/27 06:24:40 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.23 2012/01/03 23:15:11 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.22 2011/12/27 06:24:40 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.23 2012/01/03 23:15:11 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: rasops32.c,v
 #include 
 
 static void 	rasops32_putchar(void *, int, int, u_int, long attr);
+static void 	rasops32_putchar_aa(void *, int, int, u_int, long attr);
 
 /*
  * Initialize a 'rasops_info' descriptor for this depth.
@@ -60,12 +61,16 @@ rasops32_init(struct rasops_info *ri)
 		ri->ri_bpos = 16;
 	}
 
-	ri->ri_ops.putchar = rasops32_putchar;
+	if (FONT_IS_ALPHA(ri->ri_font)) {
+		ri->ri_ops.putchar = rasops32_putchar_aa;
+	} else
+		ri->ri_ops.putchar = rasops32_putchar;
 }
 
 /*
  * Paint a single character.
  */
+
 static void
 rasops32_putchar(void *cookie, int row, int col, u_int uc, long attr)
 {
@@ -122,60 +127,123 @@ rasops32_putchar(void *cookie, int row, 
 		fr = (u_char *)font->data + uc * ri->ri_fontscale;
 		fs = font->stride;
 
-		if (font->stride < width) {
-			/* this is a mono font */
-			while (height--) {
-dp = rp;
-fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
-(fr[0] << 24);
-fr += fs;
-DELTA(rp, ri->ri_stride, int32_t *);
-if (ri->ri_hwbits) {
-	hp = hrp;
-	DELTA(hrp, ri->ri_stride, int32_t *);
-}
+		while (height--) {
+			dp = rp;
+			fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
+			(fr[0] << 24);
+			fr += fs;
+			DELTA(rp, ri->ri_stride, int32_t *);
+			if (ri->ri_hwbits) {
+hp = hrp;
+DELTA(hrp, ri->ri_stride, int32_t *);
+			}
 
-for (cnt = width; cnt; cnt--) {
-	*dp++ = clr[(fb >> 31) & 1];
-	if (ri->ri_hwbits)
-		*hp++ = clr[(fb >> 31) & 1];
-	fb <<= 1;
-}
+			for (cnt = width; cnt; cnt--) {
+*dp++ = clr[(fb >> 31) & 1];
+if (ri->ri_hwbits)
+	*hp++ = clr[(fb >> 31) & 1];
+fb <<= 1;
 			}
-		} else {
-			/* this is an alpha map */
-			int x, y, r, g, b, aval;
-			int r1, g1, b1, r0, g0, b0;
-
-			r0 = (clr[0] >> 16) & 0xff;
-			r1 = (clr[1] >> 16) & 0xff;
-			g0 = (clr[0] >> 8) & 0xff;
-			g1 = (clr[1] >> 8) & 0xff;
-			b0 =  clr[0] & 0xff;
-			b1 =  clr[1] & 0xff;
-
-			for (y = 0; y < height; y++) {
-dp = rp + ri->ri_width * y;
-for (x = 0; x < width; x++) {
-	aval = *fr;
-	if (aval == 0) {
-		*dp = clr[0];
-	} else if (aval == 255) {
-		*dp = clr[1];
-	} else {
-		r = aval * r1 +
-		(255 - aval) * r0;
-		g = aval * g1 +
-		(255 - aval) * g0;
-		b = aval * b1 +
-		(255 - aval) * b0;
-		*dp = (r & 0xff00) << 8 | 
-		  (g & 0xff00) | 
-		  (b & 0xff00) >> 8;
-	}
-	dp++;
-	fr++;
+		}
+	}
+
+	/* Do underline */
+	if ((attr & 1) != 0) {
+		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
+		if (ri->ri_hwbits)
+			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
+
+		while (width--) {
+			*rp++ = clr[1];
+			if (ri->ri_hwbits)
+*hrp++ = clr[1];
+		}
+	}
+}
+
+static void
+rasops32_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
+{
+	int width, height, cnt, fs, clr[2];
+	struct rasops_info *ri = (struct rasops_info *)cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, uc);
+	int32_t *dp, *rp, *hp, *hrp;
+	u_char *fr;
+	int x, y, r, g, b, aval;
+	int r1, g1, b1, r0, g0, b0;
+
+	hp = hrp = NULL;
+
+#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
+
+	/* check if character fits into font limits */
+	if (uc < font->firstchar ||
+	(uc - font->firstchar) >= font->numchars)
+	return;
+
+	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
+	if (ri->ri_hwbits)
+		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
+		col*ri->ri_xscale);
+
+	height = font->fontheight;
+	width = font->fontwidth;
+
+	clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
+	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
+
+	if (uc == ' ') {
+		while (height--) {
+			dp = rp;
+			DELTA(r

CVS commit: src/sys/dev/rasops

2012-01-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jan  3 23:13:59 UTC 2012

Modified Files:
src/sys/dev/rasops: rasops.h

Log Message:
add a macro to identify alpha fonts


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/rasops/rasops.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.h
diff -u src/sys/dev/rasops/rasops.h:1.28 src/sys/dev/rasops/rasops.h:1.29
--- src/sys/dev/rasops/rasops.h:1.28	Wed Dec 28 08:36:46 2011
+++ src/sys/dev/rasops/rasops.h	Tue Jan  3 23:13:59 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.28 2011/12/28 08:36:46 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.29 2012/01/03 23:13:59 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -143,6 +143,7 @@ struct rasops_info {
 			  (ri->ri_optfont.data != NULL)) ? \
 			 &ri->ri_optfont : ri->ri_font
 
+#define FONT_IS_ALPHA(f) ((f)->fontwidth <= (f)->stride)
 /*
  * rasops_init().
  *



CVS commit: src/sys/dev/rasops

2011-12-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec 28 08:36:46 UTC 2011

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h rasops8.c

Log Message:
add a new flag for ri_flg to allow drivers to request an r3g3b2 devcmap
in 8 bit colour. Drivers are still responsible to generate an appropriate
colour map for the actual hardware.
For use with alpha blending which needs some sort of 'true' colour.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/rasops/rasops.h \
src/sys/dev/rasops/rasops8.c

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.67 src/sys/dev/rasops/rasops.c:1.68
--- src/sys/dev/rasops/rasops.c:1.67	Thu Dec 22 04:52:45 2011
+++ src/sys/dev/rasops/rasops.c	Wed Dec 28 08:36:46 2011
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.67 2011/12/22 04:52:45 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.68 2011/12/28 08:36:46 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.67 2011/12/22 04:52:45 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.68 2011/12/28 08:36:46 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -809,9 +809,12 @@ rasops_init_devcmap(struct rasops_info *
 		return;
 
 	case 8:
-		for (i = 0; i < 16; i++)
-			ri->ri_devcmap[i] = i | (i<<8) | (i<<16) | (i<<24);
-		return;
+		if ((ri->ri_flg & RI_8BIT_IS_RGB) == 0) {
+			for (i = 0; i < 16; i++)
+ri->ri_devcmap[i] =
+i | (i<<8) | (i<<16) | (i<<24);
+			return;
+		}
 	}
 
 	p = rasops_cmap;

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.27 src/sys/dev/rasops/rasops.h:1.28
--- src/sys/dev/rasops/rasops.h:1.27	Thu Dec 22 04:52:45 2011
+++ src/sys/dev/rasops/rasops.h	Wed Dec 28 08:36:46 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.27 2011/12/22 04:52:45 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.28 2011/12/28 08:36:46 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -61,6 +61,8 @@
  * monochrome bitmap fonts. 
  */
 #define RI_ENABLE_ALPHA	0x1000
+/* set this in order to use r3g3b2 'true' colour in 8 bit */ 
+#define RI_8BIT_IS_RGB	0x2000
 
 struct rasops_info {
 	/* These must be filled in by the caller */
Index: src/sys/dev/rasops/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.27 src/sys/dev/rasops/rasops8.c:1.28
--- src/sys/dev/rasops/rasops8.c:1.27	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops8.c	Wed Dec 28 08:36:46 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.27 2010/05/04 04:57:34 macallan Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.28 2011/12/28 08:36:46 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.27 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.28 2011/12/28 08:36:46 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -91,6 +91,14 @@ rasops8_init(struct rasops_info *ri)
 		ri->ri_ops.putchar = rasops8_putchar;
 		break;
 	}
+	if (ri->ri_flg & RI_8BIT_IS_RGB) {
+		ri->ri_rnum = 3;
+		ri->ri_rpos = 5;
+		ri->ri_gnum = 3;
+		ri->ri_gpos = 2;
+		ri->ri_bnum = 2;
+		ri->ri_bpos = 0;
+	}
 }
 
 /*



CVS commit: src/sys/dev/rasops

2011-12-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Dec 27 06:24:40 UTC 2011

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
skip the multiplications for alpha values of 0 and 255, just use background
and foreground colours there


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.21 src/sys/dev/rasops/rasops32.c:1.22
--- src/sys/dev/rasops/rasops32.c:1.21	Sat Dec 24 02:13:21 2011
+++ src/sys/dev/rasops/rasops32.c	Tue Dec 27 06:24:40 2011
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.21 2011/12/24 02:13:21 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.22 2011/12/27 06:24:40 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.21 2011/12/24 02:13:21 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.22 2011/12/27 06:24:40 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -158,12 +158,21 @@ rasops32_putchar(void *cookie, int row, 
 dp = rp + ri->ri_width * y;
 for (x = 0; x < width; x++) {
 	aval = *fr;
-	r = aval * r1 + (255 - aval) * r0;
-	g = aval * g1 + (255 - aval) * g0;
-	b = aval * b1 + (255 - aval) * b0;
-	*dp = (r & 0xff00) << 8 | 
-	  (g & 0xff00) | 
-	  (b & 0xff00) >> 8;
+	if (aval == 0) {
+		*dp = clr[0];
+	} else if (aval == 255) {
+		*dp = clr[1];
+	} else {
+		r = aval * r1 +
+		(255 - aval) * r0;
+		g = aval * g1 +
+		(255 - aval) * g0;
+		b = aval * b1 +
+		(255 - aval) * b0;
+		*dp = (r & 0xff00) << 8 | 
+		  (g & 0xff00) | 
+		  (b & 0xff00) >> 8;
+	}
 	dp++;
 	fr++;
 }



CVS commit: src/sys/dev/rasops

2011-12-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Dec 24 02:13:21 UTC 2011

Modified Files:
src/sys/dev/rasops: rasops32.c

Log Message:
rename alpha variable to avoid conflict with a platform macro on alpha


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/rasops/rasops32.c

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/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.20 src/sys/dev/rasops/rasops32.c:1.21
--- src/sys/dev/rasops/rasops32.c:1.20	Thu Dec 22 04:52:45 2011
+++ src/sys/dev/rasops/rasops32.c	Sat Dec 24 02:13:21 2011
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.20 2011/12/22 04:52:45 macallan Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.21 2011/12/24 02:13:21 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.20 2011/12/22 04:52:45 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.21 2011/12/24 02:13:21 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -144,7 +144,7 @@ rasops32_putchar(void *cookie, int row, 
 			}
 		} else {
 			/* this is an alpha map */
-			int x, y, r, g, b, alpha;
+			int x, y, r, g, b, aval;
 			int r1, g1, b1, r0, g0, b0;
 
 			r0 = (clr[0] >> 16) & 0xff;
@@ -157,10 +157,10 @@ rasops32_putchar(void *cookie, int row, 
 			for (y = 0; y < height; y++) {
 dp = rp + ri->ri_width * y;
 for (x = 0; x < width; x++) {
-	alpha = *fr;
-	r = alpha * r1 + (255 - alpha) * r0;
-	g = alpha * g1 + (255 - alpha) * g0;
-	b = alpha * b1 + (255 - alpha) * b0;
+	aval = *fr;
+	r = aval * r1 + (255 - aval) * r0;
+	g = aval * g1 + (255 - aval) * g0;
+	b = aval * b1 + (255 - aval) * b0;
 	*dp = (r & 0xff00) << 8 | 
 	  (g & 0xff00) | 
 	  (b & 0xff00) >> 8;



CVS commit: src/sys/dev/rasops

2011-12-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Dec 22 04:52:45 UTC 2011

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h rasops32.c

Log Message:
support anti-aliased fonts ( as in, pre-rendered alpha maps ), for now only
in rasops32 although adding support in 15, 16 and 24 would be trivial.
Enabled only if the driver explicitly requests it by setting the
RI_ENABLE_ALPHA flag.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/rasops/rasops.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/rasops/rasops32.c

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.66 src/sys/dev/rasops/rasops.c:1.67
--- src/sys/dev/rasops/rasops.c:1.66	Wed Jul 21 12:12:58 2010
+++ src/sys/dev/rasops/rasops.c	Thu Dec 22 04:52:45 2011
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.66 2010/07/21 12:12:58 tsutsui Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.67 2011/12/22 04:52:45 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.66 2010/07/21 12:12:58 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.67 2011/12/22 04:52:45 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -162,6 +162,7 @@ struct rotatedfont {
 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 *);
 
 extern int cold;
 
@@ -176,13 +177,20 @@ rasops_init(struct rasops_info *ri, int 
 #ifdef _KERNEL
 	/* Select a font if the caller doesn't care */
 	if (ri->ri_font == NULL) {
-		int cookie;
+		int cookie = -1;
 
 		wsfont_init();
 
-		/* Want 8 pixel wide, don't care about aesthetics */
-		cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_L2R,
-		WSDISPLAY_FONTORDER_L2R);
+		if (ri->ri_flg & RI_ENABLE_ALPHA) {
+			/* try finding an AA font first */
+			cookie = wsfont_find_aa(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_L2R,
+			WSDISPLAY_FONTORDER_L2R);
+		}
+		if (cookie == -1) {
+			/* Want 8 pixel wide, don't care about aesthetics */
+			cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_L2R,
+			WSDISPLAY_FONTORDER_L2R);
+		}
 		if (cookie <= 0)
 			cookie = wsfont_find(NULL, 0, 0, 0,
 			WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R);
@@ -263,17 +271,20 @@ rasops_reconfig(struct rasops_info *ri, 
 	if (((ri->ri_flg & RI_NO_AUTO) == 0) && 
 	  ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL)) {
 
-	
-		switch (ri->ri_optfont.stride) {
-		case 1:
-			rasops_make_box_chars_8(ri);
-			break;
-		case 2:
-			rasops_make_box_chars_16(ri);
-			break;
-		case 4:
-			rasops_make_box_chars_32(ri);
-			break;
+		if (ri->ri_optfont.stride < ri->ri_optfont.fontwidth) {
+			switch (ri->ri_optfont.stride) {
+			case 1:
+rasops_make_box_chars_8(ri);
+break;
+			case 2:
+rasops_make_box_chars_16(ri);
+break;
+			case 4:
+rasops_make_box_chars_32(ri);
+break;
+			}
+		} else {
+			rasops_make_box_chars_alpha(ri);
 		}
 	} else
 		memset(&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
@@ -1622,3 +1633,54 @@ rasops_make_box_chars_32(struct rasops_i
 		}
 	}
 }
+
+void
+rasops_make_box_chars_alpha(struct rasops_info *ri)
+{
+	uint8_t *data = (uint8_t *)ri->ri_optfont.data;
+	uint8_t *ddata;
+	int c, i, hmid, vmid, wi, he;
+
+	wi = ri->ri_font->fontwidth;
+	he = ri->ri_font->fontheight;
+	
+	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++;
+			}
+		}
+	}
+}

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.26 src/sys/dev/rasops/rasops.h:1.27
--- src/sys/dev/rasops/rasops.h:1.26	Thu May  6 04:30:18 2010
+++ src/sys/dev/rasops/rasops.h	Thu Dec 22 04:52:45 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.26 2010/05/06 04:30:18 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.27 2011/12/22 04:52:45 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -55,6 +55,12 @@
  * box drawing characters
  */
 #define	RI_NO_AUTO	0x800	/* do not generate box drawing characters */
+

CVS commit: src/sys/dev/rasops

2011-07-25 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Jul 25 18:02:47 UTC 2011

Modified Files:
src/sys/dev/rasops: rasops24.c

Log Message:
Fix RASOPS_SMALL build


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/rasops/rasops24.c

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/rasops24.c
diff -u src/sys/dev/rasops/rasops24.c:1.28 src/sys/dev/rasops/rasops24.c:1.29
--- src/sys/dev/rasops/rasops24.c:1.28	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops24.c	Mon Jul 25 18:02:47 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops24.c,v 1.28 2010/05/04 04:57:34 macallan Exp $	*/
+/* 	$NetBSD: rasops24.c,v 1.29 2011/07/25 18:02:47 njoly Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.28 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.29 2011/07/25 18:02:47 njoly Exp $");
 
 #include "opt_rasops.h"
 
@@ -53,7 +53,6 @@
 static void 	rasops24_putchar12(void *, int, int, u_int, long attr);
 static void 	rasops24_putchar16(void *, int, int, u_int, long attr);
 static void	rasops24_makestamp(struct rasops_info *, long);
-#endif
 
 /*
  * 4x1 stamp for optimized character blitting
@@ -61,6 +60,7 @@
 static int32_t	stamp[64];
 static long	stamp_attr;
 static int	stamp_mutex;	/* XXX see note in readme */
+#endif
 
 /*
  * XXX this confuses the hell out of gcc2 (not egcs) which always insists



CVS commit: src/sys/dev/rasops

2010-07-21 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Jul 21 12:12:58 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/rasops/rasops.c

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.65 src/sys/dev/rasops/rasops.c:1.66
--- src/sys/dev/rasops/rasops.c:1.65	Sun Jun 13 01:55:24 2010
+++ src/sys/dev/rasops/rasops.c	Wed Jul 21 12:12:58 2010
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.65 2010/06/13 01:55:24 tsutsui Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.66 2010/07/21 12:12:58 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.65 2010/06/13 01:55:24 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.66 2010/07/21 12:12:58 tsutsui Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -180,7 +180,7 @@
 
 		wsfont_init();
 
-		/* Want 8 pixel wide, don't care about aestethics */
+		/* Want 8 pixel wide, don't care about aesthetics */
 		cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_L2R,
 		WSDISPLAY_FONTORDER_L2R);
 		if (cookie <= 0)



CVS commit: src/sys/dev/rasops

2010-06-12 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jun 13 01:55:24 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops.c

Log Message:
Put underline properly (not upperline) on CCW screen.
Tested on hpcarm WS003SH.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/rasops/rasops.c

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.64 src/sys/dev/rasops/rasops.c:1.65
--- src/sys/dev/rasops/rasops.c:1.64	Thu May  6 04:30:18 2010
+++ src/sys/dev/rasops/rasops.c	Sun Jun 13 01:55:24 2010
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.65 2010/06/13 01:55:24 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.65 2010/06/13 01:55:24 tsutsui Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -1456,7 +1456,8 @@
 
 	/* Do rotated underline */
 	rp = ri->ri_bits + (ri->ri_cols - col - 1) * ri->ri_yscale +
-	row * ri->ri_xscale;
+	row * ri->ri_xscale +
+	(ri->ri_font->fontwidth - 1) * ri->ri_pelbytes;
 	height = ri->ri_font->fontheight;
 
 	/* XXX this assumes 16-bit color depth */



CVS commit: src/sys/dev/rasops

2010-05-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May  6 04:30:18 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h

Log Message:
Introduce a new flag for rasops_info to keep rasops_reconfig() from trying
to allocate memory. Use this when calling rasops_reconfig() before it is safe
to call kmem_alloc().


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/rasops/rasops.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.63 src/sys/dev/rasops/rasops.c:1.64
--- src/sys/dev/rasops/rasops.c:1.63	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops.c	Thu May  6 04:30:18 2010
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.64 2010/05/06 04:30:18 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -163,6 +163,8 @@
 void	rasops_make_box_chars_16(struct rasops_info *);
 void	rasops_make_box_chars_32(struct rasops_info *);
 
+extern int cold;
+
 /*
  * Initialize a 'rasops_info' descriptor.
  */
@@ -250,15 +252,18 @@
 	}
 
 	/* autogenerate box drawing characters */
+	ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
+	ri->ri_optfont.numchars = 16;
 	ri->ri_optfont.fontwidth = ri->ri_font->fontwidth;
 	ri->ri_optfont.fontheight = ri->ri_font->fontheight;
 	ri->ri_optfont.stride = ri->ri_font->stride;
-	ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
-	ri->ri_optfont.numchars = 16;
-	
 	len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
-	  ri->ri_optfont.numchars; 
-	if ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL) {
+		  ri->ri_optfont.numchars; 
+
+	if (((ri->ri_flg & RI_NO_AUTO) == 0) && 
+	  ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL)) {
+
+	
 		switch (ri->ri_optfont.stride) {
 		case 1:
 			rasops_make_box_chars_8(ri);
@@ -270,7 +275,8 @@
 			rasops_make_box_chars_32(ri);
 			break;
 		}
-	}
+	} else
+		memset(&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
 
 	if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4)
 		panic("rasops_init: fontwidth assumptions botched!");

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.25 src/sys/dev/rasops/rasops.h:1.26
--- src/sys/dev/rasops/rasops.h:1.25	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops.h	Thu May  6 04:30:18 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.25 2010/05/04 04:57:34 macallan Exp $ */
+/* 	$NetBSD: rasops.h,v 1.26 2010/05/06 04:30:18 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -48,6 +48,13 @@
 #define RI_ROTATE_CCW	0x200	/* display is rotated, quarter counter-clockwise */
 #define RI_ROTATE_UD	0x400	/* display is rotated, upside-down */
 #define RI_ROTATE_MASK	0x700
+/*
+ * if you call rasops_init() or rasops_reconfig() in a context where it is not
+ * safe to call kmem_alloc(), like early on during kernel startup, you MUST set
+ * RI_NO_AUTO to keep rasops from trying to allocate memory for autogenerated
+ * box drawing characters
+ */
+#define	RI_NO_AUTO	0x800	/* do not generate box drawing characters */
 
 struct rasops_info {
 	/* These must be filled in by the caller */
@@ -124,7 +131,8 @@
((c) >= (font)->firstchar && \
 	((c) - (font)->firstchar) < (font)->numchars)
 
-#define PICK_FONT(ri, c) ((c & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT) ? \
+#define PICK_FONT(ri, c) (((c & WSFONT_FLAGS_MASK) == WSFONT_FLAG_OPT) && \
+			  (ri->ri_optfont.data != NULL)) ? \
 			 &ri->ri_optfont : ri->ri_font
 
 /*



CVS commit: src/sys/dev/rasops

2010-05-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  4 19:16:22 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops2.c

Log Message:
remove now redundant ri = ... lines in putchar() methods
Looks like none of my usual test builds used rasops2.c


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/rasops/rasops2.c

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/rasops2.c
diff -u src/sys/dev/rasops/rasops2.c:1.16 src/sys/dev/rasops/rasops2.c:1.17
--- src/sys/dev/rasops/rasops2.c:1.16	Tue May  4 12:36:37 2010
+++ src/sys/dev/rasops/rasops2.c	Tue May  4 19:16:22 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops2.c,v 1.16 2010/05/04 12:36:37 nonaka Exp $	*/
+/* 	$NetBSD: rasops2.c,v 1.17 2010/05/04 19:16:22 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.16 2010/05/04 12:36:37 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.17 2010/05/04 19:16:22 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -107,8 +107,6 @@
 	int32_t *rp;
 	u_char *fr;
 
-	ri = (struct rasops_info *)cookie;
-
 #ifdef RASOPS_CLIPPING
 	/* Catches 'row < 0' case too */
 	if ((unsigned)row >= (unsigned)ri->ri_rows)
@@ -256,8 +254,6 @@
 		return;
 	}
 
-	ri = (struct rasops_info *)cookie;
-
 #ifdef RASOPS_CLIPPING
 	/* Catches 'row < 0' case too */
 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
@@ -323,8 +319,6 @@
 		return;
 	}
 
-	ri = (struct rasops_info *)cookie;
-
 #ifdef RASOPS_CLIPPING
 	/* Catches 'row < 0' case too */
 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
@@ -393,8 +387,6 @@
 		return;
 	}
 
-	ri = (struct rasops_info *)cookie;
-
 #ifdef RASOPS_CLIPPING
 	/* Catches 'row < 0' case too */
 	if ((unsigned)row >= (unsigned)ri->ri_rows) {



CVS commit: src/sys/dev/rasops

2010-05-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue May  4 12:36:37 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops2.c

Log Message:
fix compile failure.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/rasops/rasops2.c

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/rasops2.c
diff -u src/sys/dev/rasops/rasops2.c:1.15 src/sys/dev/rasops/rasops2.c:1.16
--- src/sys/dev/rasops/rasops2.c:1.15	Tue May  4 04:57:34 2010
+++ src/sys/dev/rasops/rasops2.c	Tue May  4 12:36:37 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops2.c,v 1.15 2010/05/04 04:57:34 macallan Exp $	*/
+/* 	$NetBSD: rasops2.c,v 1.16 2010/05/04 12:36:37 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.15 2010/05/04 04:57:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.16 2010/05/04 12:36:37 nonaka Exp $");
 
 #include "opt_rasops.h"
 
@@ -102,7 +102,7 @@
 rasops2_putchar(void *cookie, int row, int col, u_int uc, long attr)
 {
 	int height, width, fs, rs, fb, bg, fg, lmask, rmask;
-	struct rasops_info *ri;
+	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int32_t *rp;
 	u_char *fr;
@@ -244,7 +244,7 @@
 static void
 rasops2_putchar8(void *cookie, int row, int col, u_int uc, long attr)
 {
-	struct rasops_info *ri;
+	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int height, fs, rs;
 	u_char *fr, *rp;
@@ -311,7 +311,7 @@
 static void
 rasops2_putchar12(void *cookie, int row, int col, u_int uc, long attr)
 {
-	struct rasops_info *ri;
+	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int height, fs, rs;
 	u_char *fr, *rp;
@@ -381,7 +381,7 @@
 static void
 rasops2_putchar16(void *cookie, int row, int col, u_int uc, long attr)
 {
-	struct rasops_info *ri;
+	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	int height, fs, rs;
 	u_char *fr, *rp;



CVS commit: src/sys/dev/rasops

2010-05-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May  4 04:57:35 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h rasops1.c rasops15.c rasops2.c
rasops24.c rasops32.c rasops4.c rasops8.c

Log Message:
autogenerate box drawing characters for fonts that don't have them, put them
into an alternate font pointed at by the recently added mappings in wsfont,
adapt all putchar() methods except the rotated ones to use them
XXX no attempt has been made to make this work with rotation


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/rasops/rasops.h
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/rasops/rasops1.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/rasops/rasops15.c \
src/sys/dev/rasops/rasops32.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/rasops/rasops2.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/rasops/rasops24.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/rasops/rasops4.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/rasops/rasops8.c

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.62 src/sys/dev/rasops/rasops.c:1.63
--- src/sys/dev/rasops/rasops.c:1.62	Sat Apr 17 13:36:22 2010
+++ src/sys/dev/rasops/rasops.c	Tue May  4 04:57:34 2010
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.62 2010/04/17 13:36:22 nonaka Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.62 2010/04/17 13:36:22 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.63 2010/05/04 04:57:34 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -158,6 +159,10 @@
 };
 #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 *);
+
 /*
  * Initialize a 'rasops_info' descriptor.
  */
@@ -165,6 +170,7 @@
 rasops_init(struct rasops_info *ri, int wantrows, int wantcols)
 {
 
+	memset (&ri->ri_optfont, 0, sizeof(ri->ri_optfont));
 #ifdef _KERNEL
 	/* Select a font if the caller doesn't care */
 	if (ri->ri_font == NULL) {
@@ -232,10 +238,40 @@
 int
 rasops_reconfig(struct rasops_info *ri, int wantrows, int wantcols)
 {
-	int bpp, s;
+	int bpp, s, len;
 
 	s = splhigh();
 
+	/* throw away old line drawing character bitmaps, if we have any */
+	if (ri->ri_optfont.data != NULL) {
+		kmem_free(ri->ri_optfont.data, ri->ri_optfont.stride * 
+		ri->ri_optfont.fontheight * ri->ri_optfont.numchars);
+		ri->ri_optfont.data = NULL;
+	}
+
+	/* autogenerate box drawing characters */
+	ri->ri_optfont.fontwidth = ri->ri_font->fontwidth;
+	ri->ri_optfont.fontheight = ri->ri_font->fontheight;
+	ri->ri_optfont.stride = ri->ri_font->stride;
+	ri->ri_optfont.firstchar = WSFONT_FLAG_OPT;
+	ri->ri_optfont.numchars = 16;
+	
+	len = ri->ri_optfont.fontheight * ri->ri_optfont.stride *
+	  ri->ri_optfont.numchars; 
+	if ((ri->ri_optfont.data = kmem_zalloc(len, KM_SLEEP)) != NULL) {
+		switch (ri->ri_optfont.stride) {
+		case 1:
+			rasops_make_box_chars_8(ri);
+			break;
+		case 2:
+			rasops_make_box_chars_16(ri);
+			break;
+		case 4:
+			rasops_make_box_chars_32(ri);
+			break;
+		}
+	}
+
 	if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4)
 		panic("rasops_init: fontwidth assumptions botched!");
 
@@ -421,12 +457,9 @@
 		panic("rasops_mapchar: no font selected");
 #endif
 
-	if (ri->ri_font->encoding != WSDISPLAY_FONTENC_ISO) {
-		if ( (c = wsfont_map_unichar(ri->ri_font, c)) < 0) {
-			*cp = ' ';
-			return (0);
-
-		}
+	if ( (c = wsfont_map_unichar(ri->ri_font, c)) < 0) {
+		*cp = ' ';
+		return (0);
 	}
 
 	if (c < ri->ri_font->firstchar) {
@@ -434,11 +467,12 @@
 		return (0);
 	}
 
+#if 0
 	if (c - ri->ri_font->firstchar >= ri->ri_font->numchars) {
 		*cp = ' ';
 		return (0);
 	}
-
+#endif
 	*cp = c;
 	return (5);
 }
@@ -904,7 +938,7 @@
 rasops_do_cursor(struct rasops_info *ri)
 {
 	int full1, height, cnt, slop1, slop2, row, col;
-	u_char *dp, *rp, *hrp, *hp;
+	u_char *dp, *rp, *hrp, *hp, tmp = 0;
 
 	hrp = hp = NULL;
 
@@ -943,6 +977,7 @@
 	full1 = (ri->ri_xscale - slop1 - slop2) >> 2;
 
 	if ((slop1 | slop2) == 0) {
+		uint32_t tmp32;
 		/* A common case */
 		while (height--) {
 			dp = rp;
@@ -953,17 +988,18 @@
 			}
 
 			for (cnt = full1; cnt; cnt--) {
-*(int32_t *)dp ^= ~0;
+tmp32 = *(int32_t *)dp ^ ~0;
+*(int32_t *)dp = tmp32;
 dp += 4;
 if (ri->ri_hwbits) {
-	dp -= 4;
-	*(int32_t *)hp = *(int32_t *)dp;
+	*(int32_t *)hp = tmp32;
 	hp += 4;
-	dp += 4;
 }
 			}
 		}
 	} else {
+		uint16_t tmp16;
+		uint32_t tmp32;
 		/* XXX this is stupid.. use mask

CVS commit: src/sys/dev/rasops

2010-04-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Apr 13 20:10:38 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops1.c

Log Message:
fix a bunch of typos, now 8 bit fonts work properly


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/rasops/rasops1.c

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/rasops1.c
diff -u src/sys/dev/rasops/rasops1.c:1.21 src/sys/dev/rasops/rasops1.c:1.22
--- src/sys/dev/rasops/rasops1.c:1.21	Thu Apr  8 16:45:53 2010
+++ src/sys/dev/rasops/rasops1.c	Tue Apr 13 20:10:38 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops1.c,v 1.21 2010/04/08 16:45:53 macallan Exp $	*/
+/* 	$NetBSD: rasops1.c,v 1.22 2010/04/13 20:10:38 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.21 2010/04/08 16:45:53 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.22 2010/04/13 20:10:38 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -297,7 +297,7 @@
 
 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
 	if (ri->ri_hwbits)
-		hrp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
+		hrp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
 	height = ri->ri_font->fontheight;
 	rs = ri->ri_stride;
 
@@ -346,10 +346,12 @@
 	}
 
 	/* Do underline */
-	if ((attr & 1) != 0)
+	if ((attr & 1) != 0) {
 		rp[-(ri->ri_stride << 1)] = fg;
-		if (ri->ri_hwbits)
-			hrp[-(ri->ri_stride << 1)] = fg;		
+		if (ri->ri_hwbits) {
+			hrp[-(ri->ri_stride << 1)] = fg;
+		}
+	}
 }
 
 /*



CVS commit: src/sys/dev/rasops

2010-04-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr  8 16:45:53 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops1.c rasops_bitops.h

Log Message:
add support for shadow framebuffers
tested on sparc with a cg12


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/rasops/rasops1.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/rasops/rasops_bitops.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/rasops1.c
diff -u src/sys/dev/rasops/rasops1.c:1.20 src/sys/dev/rasops/rasops1.c:1.21
--- src/sys/dev/rasops/rasops1.c:1.20	Sat Mar 14 21:04:22 2009
+++ src/sys/dev/rasops/rasops1.c	Thu Apr  8 16:45:53 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops1.c,v 1.20 2009/03/14 21:04:22 dsl Exp $	*/
+/* 	$NetBSD: rasops1.c,v 1.21 2010/04/08 16:45:53 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.20 2009/03/14 21:04:22 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.21 2010/04/08 16:45:53 macallan Exp $");
 
 #include "opt_rasops.h"
 
@@ -90,7 +90,7 @@
 	u_int fs, rs, fb, bg, fg, lmask, rmask;
 	u_int32_t height, width;
 	struct rasops_info *ri;
-	int32_t *rp;
+	int32_t *rp, *hrp = NULL, tmp, tmp2;
 	u_char *fr;
 
 	ri = (struct rasops_info *)cookie;
@@ -106,6 +106,9 @@
 
 	col *= ri->ri_font->fontwidth;
 	rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
+	if (ri->ri_hwbits)
+		hrp = (int32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
+		((col >> 3) & ~3));
 	height = ri->ri_font->fontheight;
 	width = ri->ri_font->fontwidth;
 	col = col & 31;
@@ -134,8 +137,13 @@
 			bg &= rmask;
 
 			while (height--) {
-*rp = (*rp & lmask) | bg;
+tmp = (*rp & lmask) | bg;
+*rp = tmp;
 DELTA(rp, rs, int32_t *);
+if (ri->ri_hwbits) {
+	*hrp = tmp;
+	DELTA(hrp, rs, int32_t *);
+}
 			}
 		} else {
 			/* NOT fontbits if bg is white */
@@ -143,21 +151,31 @@
 while (height--) {
 	fb = ~(fr[3] | (fr[2] << 8) |
 	(fr[1] << 16) | (fr[0] << 24));
-	*rp = (*rp & lmask)
+	tmp = (*rp & lmask)
 	| (MBE(fb >> col) & rmask);
+	*rp = tmp;
 
 	fr += fs;
 	DELTA(rp, rs, int32_t *);
+	if (ri->ri_hwbits) {
+		*hrp = tmp;
+		DELTA(hrp, rs, int32_t *);
+	}
 }
 			} else {
 while (height--) {
 	fb = (fr[3] | (fr[2] << 8) |
 	(fr[1] << 16) | (fr[0] << 24));
-	*rp = (*rp & lmask)
+	tmp = (*rp & lmask)
 	| (MBE(fb >> col) & rmask);
+	*rp = tmp;
 
 	fr += fs;
 	DELTA(rp, rs, int32_t *);
+	if (ri->ri_hwbits) {
+		*hrp = tmp;
+		DELTA(hrp, rs, int32_t *);
+	}
 }
 			}
 		}
@@ -165,7 +183,12 @@
 		/* Do underline */
 		if ((attr & 1) != 0) {
 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
-			*rp = (*rp & lmask) | (fg & rmask);
+			tmp = (*rp & lmask) | (fg & rmask);
+			*rp = tmp;
+			if (ri->ri_hwbits) {
+DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
+*hrp = tmp;
+			}
 		}
 	} else {
 		lmask = ~rasops_lmask[col];
@@ -176,9 +199,16 @@
 			bg = bg & ~lmask;
 
 			while (height--) {
-rp[0] = (rp[0] & lmask) | bg;
-rp[1] = (rp[1] & rmask) | width;
+tmp = (rp[0] & lmask) | bg;
+tmp2 = (rp[1] & rmask) | width;
+rp[0] = tmp;
+rp[1] = tmp2;
 DELTA(rp, rs, int32_t *);
+if (ri->ri_hwbits) {
+	hrp[0] = tmp;
+	hrp[1] = tmp2;
+	DELTA(hrp, rs, int32_t *);
+}
 			}
 		} else {
 			width = 32 - col;
@@ -189,28 +219,40 @@
 	fb = ~(fr[3] | (fr[2] << 8) |
 	(fr[1] << 16) | (fr[0] << 24));
 
-	rp[0] = (rp[0] & lmask)
+	tmp = (rp[0] & lmask)
 	| MBE((u_int)fb >> col);
 
-	rp[1] = (rp[1] & rmask)
+	tmp2 = (rp[1] & rmask)
 	| (MBE((u_int)fb << width) & ~rmask);
-
+	rp[0] = tmp;
+	rp[1] = tmp2;
 	fr += fs;
 	DELTA(rp, rs, int32_t *);
+	if (ri->ri_hwbits) {
+		hrp[0] = tmp;
+		hrp[1] = tmp2;
+		DELTA(hrp, rs, int32_t *);
+	}
 }
 			} else {
 while (height--) {
 	fb = (fr[3] | (fr[2] << 8) |
 	(fr[1] << 16) | (fr[0] << 24));
 
-	rp[0] = (rp[0] & lmask)
+	tmp = (rp[0] & lmask)
 	| MBE(fb >> col);
 
-	rp[1] = (rp[1] & rmask)
+	tmp2 = (rp[1] & rmask)
 	| (MBE(fb << width) & ~rmask);
-
+	rp[0] = tmp;
+	rp[1] = tmp2;
 	fr += fs;
 	DELTA(rp, rs, int32_t *);
+	if (ri->ri_hwbits) {
+		hrp[0] = tmp;
+		hrp[1] = tmp2;
+		DELTA(hrp, rs, int32_t *);
+	}
 }
 			}
 		}
@@ -218,8 +260,15 @@
 		/* Do underline */
 		if ((attr & 1) != 0) {
 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
-			rp[0] = (rp[0] & lmask) | (fg & ~lmask);
-			rp[1] = (rp[1] & rmask) | (fg & ~rmask);
+			tmp = (rp[0] & lmask) | (fg & ~lmask);
+			tmp2 = (rp[1] & rmask) | (fg & ~rmask);
+			rp[0] = tmp;
+			rp[1] = tmp2;
+			if (ri->ri_hwbits) {
+DELTA(hrp, -(ri->

CVS commit: src/sys/dev/rasops

2010-01-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 21 05:32:18 UTC 2010

Modified Files:
src/sys/dev/rasops: rasops.c rasops.h

Log Message:
make RI_CENTER and RI_FULLCLEAR work with a shadow framebuffer


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/rasops/rasops.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.60 src/sys/dev/rasops/rasops.c:1.61
--- src/sys/dev/rasops/rasops.c:1.60	Sat Mar 14 21:04:22 2009
+++ src/sys/dev/rasops/rasops.c	Thu Jan 21 05:32:18 2010
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.60 2009/03/14 21:04:22 dsl Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.61 2010/01/21 05:32:18 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.60 2009/03/14 21:04:22 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.61 2010/01/21 05:32:18 macallan Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -283,13 +283,19 @@
 
 	/* Now centre our window if needs be */
 	ri->ri_origbits = ri->ri_bits;
+	ri->ri_hworigbits = ri->ri_hwbits;
 
 	if ((ri->ri_flg & RI_CENTER) != 0) {
 		ri->ri_bits += (((ri->ri_width * bpp >> 3) -
 		ri->ri_emustride) >> 1) & ~3;
 		ri->ri_bits += ((ri->ri_height - ri->ri_emuheight) >> 1) *
 		ri->ri_stride;
-
+		if (ri->ri_hwbits != NULL) {
+			ri->ri_hwbits += (((ri->ri_width * bpp >> 3) -
+			ri->ri_emustride) >> 1) & ~3;
+			ri->ri_hwbits += ((ri->ri_height - ri->ri_emuheight) >> 1) *
+			ri->ri_stride;
+		}
 		ri->ri_yorigin = (int)(ri->ri_bits - ri->ri_origbits)
 		   / ri->ri_stride;
 		ri->ri_xorigin = (((int)(ri->ri_bits - ri->ri_origbits)
@@ -827,7 +833,7 @@
 		num = ri->ri_height;
 		dp = (int32_t *)ri->ri_origbits;
 		if (ri->ri_hwbits)
-			hp = (int32_t *)ri->ri_hwbits;
+			hp = (int32_t *)ri->ri_hworigbits;
 		delta = 0;
 	} else {
 		np = ri->ri_emustride >> 5;

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.22 src/sys/dev/rasops/rasops.h:1.23
--- src/sys/dev/rasops/rasops.h:1.22	Mon Apr 28 20:23:56 2008
+++ src/sys/dev/rasops/rasops.h	Thu Jan 21 05:32:18 2010
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.22 2008/04/28 20:23:56 martin Exp $ */
+/* 	$NetBSD: rasops.h,v 1.23 2010/01/21 05:32:18 macallan Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -94,6 +94,7 @@
 	int	ri_xscale;	/* fontwidth * pelbytes */
 	int	ri_yscale;	/* fontheight * stride */
 	u_char  *ri_origbits;	/* where screen bits actually start */
+	u_char  *ri_hworigbits;	/* where hw bits actually start */
 	int	ri_xorigin;	/* where ri_bits begins (x) */
 	int	ri_yorigin;	/* where ri_bits begins (y) */
 	int32_t	ri_devcmap[16]; /* color -> framebuffer data */