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 <sys/cdefs.h>
-__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->ri_stride << 1), int32_t *);
+ hrp[0] = tmp;
+ hrp[1] = tmp2;
+ }
}
}
}
@@ -233,7 +282,7 @@
{
int height, fs, rs, bg, fg;
struct rasops_info *ri;
- u_char *fr, *rp;
+ u_char *fr, *rp, *hrp = NULL;
ri = (struct rasops_info *)cookie;
@@ -247,6 +296,8 @@
#endif
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;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
@@ -258,6 +309,10 @@
while (height--) {
*rp = bg;
rp += rs;
+ if (ri->ri_hwbits) {
+ *hrp = bg;
+ hrp += rs;
+ }
}
} else {
uc -= ri->ri_font->firstchar;
@@ -268,14 +323,23 @@
if (bg) {
while (height--) {
*rp = ~*fr;
- fr += fs;
rp += rs;
+ if (ri->ri_hwbits) {
+ *hrp = ~*fr;
+ hrp += rs;
+ }
+ fr += fs;
+
}
} else {
while (height--) {
*rp = *fr;
- fr += fs;
rp += rs;
+ if (ri->ri_hwbits) {
+ *hrp = *fr;
+ hrp += rs;
+ }
+ fr += fs;
}
}
@@ -284,6 +348,8 @@
/* Do underline */
if ((attr & 1) != 0)
rp[-(ri->ri_stride << 1)] = fg;
+ if (ri->ri_hwbits)
+ hrp[-(ri->ri_stride << 1)] = fg;
}
/*
@@ -294,7 +360,7 @@
{
int height, fs, rs, bg, fg;
struct rasops_info *ri;
- u_char *fr, *rp;
+ u_char *fr, *rp, *hrp = NULL;
ri = (struct rasops_info *)cookie;
@@ -308,6 +374,8 @@
#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 = ri->ri_font->fontheight;
rs = ri->ri_stride;
@@ -317,8 +385,13 @@
/* If fg and bg match this becomes a space character */
if (fg == bg || uc == ' ') {
while (height--) {
+ /* XXX alignment?! */
*(int16_t *)rp = bg;
rp += rs;
+ if (ri->ri_hwbits) {
+ *(int16_t *)hrp = bg;
+ hrp += rs;
+ }
}
} else {
uc -= ri->ri_font->firstchar;
@@ -330,22 +403,35 @@
while (height--) {
rp[0] = ~fr[0];
rp[1] = ~fr[1];
- fr += fs;
rp += rs;
+ if (ri->ri_hwbits) {
+ hrp[0] = ~fr[0];
+ hrp[1] = ~fr[1];
+ hrp += rs;
+ }
+ fr += fs;
}
} else {
while (height--) {
rp[0] = fr[0];
rp[1] = fr[1];
- fr += fs;
rp += rs;
+ if (ri->ri_hwbits) {
+ hrp[0] = fr[0];
+ hrp[1] = fr[1];
+ hrp += rs;
+ }
+ fr += fs;
}
}
}
/* Do underline */
if ((attr & 1) != 0)
+ /* XXX alignment?! */
*(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
+ if (ri->ri_hwbits)
+ *(int16_t *)(hrp - (ri->ri_stride << 1)) = fg;
}
#endif /* !RASOPS_SMALL */
Index: src/sys/dev/rasops/rasops_bitops.h
diff -u src/sys/dev/rasops/rasops_bitops.h:1.11 src/sys/dev/rasops/rasops_bitops.h:1.12
--- src/sys/dev/rasops/rasops_bitops.h:1.11 Sun Mar 15 21:29:15 2009
+++ src/sys/dev/rasops/rasops_bitops.h Thu Apr 8 16:45:53 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_bitops.h,v 1.11 2009/03/15 21:29:15 cegger Exp $ */
+/* $NetBSD: rasops_bitops.h,v 1.12 2010/04/08 16:45:53 macallan Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
{
int lmask, rmask, lclr, rclr, clr;
struct rasops_info *ri;
- int32_t *dp, *rp;
+ int32_t *dp, *rp, *hrp = NULL, *hp = NULL, tmp;
int height, cnt;
ri = (struct rasops_info *)cookie;
@@ -65,7 +65,9 @@
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));
-
+ if (ri->ri_hwbits)
+ hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
+ ((col >> 3) & ~3));
if ((col & 31) + num <= 32) {
lmask = ~rasops_pmask[col & 31][num];
lclr = clr & ~lmask;
@@ -74,7 +76,12 @@
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
- *dp = (*dp & lmask) | lclr;
+ tmp = (*dp & lmask) | lclr;
+ *dp = tmp;
+ if (ri->ri_hwbits) {
+ *hrp = tmp;
+ DELTA(hrp, ri->ri_stride, int32_t *);
+ }
}
} else {
lmask = rasops_rmask[col & 31];
@@ -91,17 +98,34 @@
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
+ if (ri->ri_hwbits) {
+ hp = hrp;
+ DELTA(hrp, ri->ri_stride, int32_t *);
+ }
if (lmask) {
- *dp = (*dp & lmask) | lclr;
+ tmp = (*dp & lmask) | lclr;
+ *dp = tmp;
dp++;
+ if (ri->ri_hwbits) {
+ *hp = tmp;
+ hp++;
+ }
}
for (cnt = num; cnt > 0; cnt--)
*dp++ = clr;
+ if (ri->ri_hwbits) {
+ for (cnt = num; cnt > 0; cnt--)
+ *hp++ = clr;
+ }
- if (rmask)
- *dp = (*dp & rmask) | rclr;
+ if (rmask) {
+ tmp = (*dp & rmask) | rclr;
+ *dp = tmp;
+ if (ri->ri_hwbits)
+ *hp = tmp;
+ }
}
}
}
@@ -113,13 +137,16 @@
NAME(do_cursor)(struct rasops_info *ri)
{
int lmask, rmask, height, row, col, num;
- int32_t *dp, *rp;
+ int32_t *dp, *rp, *hp = NULL, *hrp = NULL, tmp;
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));
+ if (ri->ri_hwbits)
+ hrp = (int32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
+ ((col >> 3) & ~3));
if ((col & 31) + num <= 32) {
lmask = rasops_pmask[col & 31][num];
@@ -129,6 +156,14 @@
DELTA(rp, ri->ri_stride, int32_t *);
*dp ^= lmask;
}
+ if (ri->ri_hwbits) {
+ height = ri->ri_font->fontheight;
+ while (height--) {
+ hp = hrp;
+ DELTA(hrp, ri->ri_stride, int32_t *);
+ *hp ^= lmask;
+ }
+ }
} else {
lmask = ~rasops_rmask[col & 31];
rmask = ~rasops_lmask[(col + num) & 31];
@@ -136,12 +171,26 @@
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
+ if (ri->ri_hwbits) {
+ hp = hrp;
+ DELTA(hrp, ri->ri_stride, int32_t *);
+ }
+ if (lmask != -1) {
+ tmp = *dp ^ lmask;
+ *dp = tmp;
+ dp++;
+ if (ri->ri_hwbits) {
+ *hp = tmp;
+ hp++;
+ }
+ }
- if (lmask != -1)
- *dp++ ^= lmask;
-
- if (rmask != -1)
- *dp ^= rmask;
+ if (rmask != -1) {
+ tmp = *dp ^ rmask;
+ *dp = tmp;
+ if (ri->ri_hwbits)
+ *hp = tmp;
+ }
}
}
}
@@ -153,7 +202,7 @@
NAME(copycols)(void *cookie, int row, int src, int dst, int num)
{
int tmp, lmask, rmask, height, lnum, rnum, sb, db, cnt, full;
- int32_t *sp, *dp, *srp, *drp;
+ int32_t *sp, *dp, *srp, *drp, *dhp = NULL, *hp = NULL;
struct rasops_info *ri;
sp = NULL; /* XXX gcc */
@@ -200,11 +249,18 @@
/* Destination is contained within a single word */
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
+ if (ri->ri_hwbits)
+ dhp = (int32_t *)(ri->ri_hwbits + row +
+ ((dst >> 3) & ~3));
sb = src & 31;
while (height--) {
GETBITS(srp, sb, num, tmp);
PUTBITS(tmp, db, num, drp);
+ if (ri->ri_hwbits) {
+ PUTBITS(tmp, db, num, dhp);
+ DELTA(dhp, ri->ri_stride, int32_t *);
+ }
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
}
@@ -229,6 +285,9 @@
dst = dst + num;
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
+ if (ri->ri_hwbits)
+ dhp = (int32_t *)(ri->ri_hwbits + row +
+ ((dst >> 3) & ~3));
src = src & 31;
rnum = 32 - lnum;
@@ -242,12 +301,20 @@
while (height--) {
sp = srp;
dp = drp;
+ if (ri->ri_hwbits) {
+ hp = dhp;
+ DELTA(dhp, ri->ri_stride, int32_t *);
+ }
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
if (db) {
GETBITS(sp, src, db, tmp);
PUTBITS(tmp, 0, db, dp);
+ if (ri->ri_hwbits) {
+ PUTBITS(tmp, 0, db, hp);
+ hp++;
+ }
dp--;
sp--;
}
@@ -256,6 +323,8 @@
for (cnt = full; cnt; cnt--, sp--) {
GETBITS(sp, src, 32, tmp);
*dp-- = tmp;
+ if (ri->ri_hwbits)
+ *hp-- = tmp;
}
if (lmask) {
@@ -265,18 +334,27 @@
#endif
GETBITS(sp, sb, lnum, tmp);
PUTBITS(tmp, rnum, lnum, dp);
+ if (ri->ri_hwbits)
+ PUTBITS(tmp, rnum, lnum, hp);
}
}
} else {
/* Copy left-to-right */
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
+ if (ri->ri_hwbits)
+ dhp = (int32_t *)(ri->ri_hwbits + row +
+ ((dst >> 3) & ~3));
db = dst & 31;
while (height--) {
sb = src & 31;
sp = srp;
dp = drp;
+ if (ri->ri_hwbits) {
+ hp = dhp;
+ DELTA(dhp, ri->ri_stride, int32_t *);
+ }
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
@@ -284,6 +362,10 @@
GETBITS(sp, sb, lnum, tmp);
PUTBITS(tmp, db, lnum, dp);
dp++;
+ if (ri->ri_hwbits) {
+ PUTBITS(tmp, db, lnum, hp);
+ hp++;
+ }
if ((sb += lnum) > 31) {
sp++;
@@ -295,11 +377,15 @@
for (cnt = full; cnt; cnt--, sp++) {
GETBITS(sp, sb, 32, tmp);
*dp++ = tmp;
+ if (ri->ri_hwbits)
+ *hp++ = tmp;
}
if (rmask) {
GETBITS(sp, sb, rnum, tmp);
PUTBITS(tmp, 0, rnum, dp);
+ if (ri->ri_hwbits)
+ PUTBITS(tmp, 0, rnum, hp);
}
}
}