Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/rasops Initial import of 'rasops', the new raster op...



details:   https://anonhg.NetBSD.org/src/rev/5f529990cfb7
branches:  trunk
changeset: 471839:5f529990cfb7
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Apr 13 00:17:57 1999 +0000

description:
Initial import of 'rasops', the new raster operations set for wscons/rcons.

diffstat:

 sys/dev/rasops/Makefile     |    7 +
 sys/dev/rasops/README       |   21 +
 sys/dev/rasops/files.rasops |   11 +
 sys/dev/rasops/rasops.c     |  600 ++++++++++++++++++++++++++++++++++++++++
 sys/dev/rasops/rasops.h     |  123 ++++++++
 sys/dev/rasops/rasops1.c    |  642 +++++++++++++++++++++++++++++++++++++++++++
 sys/dev/rasops/rasops15.c   |  646 ++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/rasops/rasops24.c   |  449 ++++++++++++++++++++++++++++++
 sys/dev/rasops/rasops32.c   |  324 ++++++++++++++++++++++
 sys/dev/rasops/rasops8.c    |  634 +++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 3457 insertions(+), 0 deletions(-)

diffs (truncated from 3497 to 300 lines):

diff -r 4f07948ba73c -r 5f529990cfb7 sys/dev/rasops/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/rasops/Makefile   Tue Apr 13 00:17:57 1999 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: Makefile,v 1.1 1999/04/13 00:17:57 ad Exp $
+
+INCSDIR= /usr/include/dev/rasops
+
+INCS=  rasops.h
+
+.include <bsd.kinc.mk>
diff -r 4f07948ba73c -r 5f529990cfb7 sys/dev/rasops/README
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/rasops/README     Tue Apr 13 00:17:57 1999 +0000
@@ -0,0 +1,21 @@
+$NetBSD: README,v 1.1 1999/04/13 00:17:57 ad 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
+significantly improved performance, supports multiple depths and color.
+
+The stamp_mutex used by some of the colordepths is not fully atomic. It's
+designed to stop stamp corruption in the event that text is printed at
+interrupt time. Even if it fails, >99% of the time text will be white on
+black, so it doesn't really matter. Going to splhigh for each character is
+a Bad Thing.
+
+Status of the various depths. Feel free to complete/test:
+
+       8       tested, complete
+       15/16   untested, complete (endainness issues exist?)
+       32      untested, complete (endainness issues exist?)
+       1       untested, incomplete for non 8,16 pel fonts
+       24      untested, incomplete, assumes RGB order
+
+- Andy Doran <ad%NetBSD.org@localhost>, April 1999
diff -r 4f07948ba73c -r 5f529990cfb7 sys/dev/rasops/files.rasops
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/rasops/files.rasops       Tue Apr 13 00:17:57 1999 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: files.rasops,v 1.1 1999/04/13 00:17:58 ad Exp $
+
+file dev/rasops/rasops.c       rasterconsole
+file dev/rasops/rasops1.c      rasterconsole
+file dev/rasops/rasops8.c      rasterconsole
+file dev/rasops/rasops15.c     rasterconsole
+file dev/rasops/rasops24.c     rasterconsole
+file dev/rasops/rasops32.c     rasterconsole
+
+defopt opt_rasops.h    RASOPS1 RASOPS8 RASOPS15 RASOPS16 RASOPS24 RASOPS32
+                       RASOPS_CLIPPING
diff -r 4f07948ba73c -r 5f529990cfb7 sys/dev/rasops/rasops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/rasops/rasops.c   Tue Apr 13 00:17:57 1999 +0000
@@ -0,0 +1,600 @@
+/* $NetBSD: rasops.c,v 1.1 1999/04/13 00:17:58 ad Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andy Doran <ad%NetBSD.org@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.1 1999/04/13 00:17:58 ad Exp $");
+
+#include "opt_rasops.h"
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/time.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+
+/* ANSI colormap (R,G,B). Upper 8 are high-intensity */
+u_char rasops_cmap[256*3] = {
+       0x00, 0x00, 0x00, /* black */
+       0x7f, 0x00, 0x00, /* red */
+       0x00, 0x7f, 0x00, /* green */
+       0x7f, 0x7f, 0x00, /* brown */
+       0x00, 0x00, 0x7f, /* blue */
+       0x7f, 0x00, 0x7f, /* magenta */
+       0x00, 0x7f, 0x7f, /* cyan */
+       0xc7, 0xc7, 0xc7, /* white - XXX too dim? */
+
+       0x7f, 0x7f, 0x7f, /* black */
+       0xff, 0x00, 0x00, /* red */
+       0x00, 0xff, 0x00, /* green */
+       0xff, 0xff, 0x00, /* brown */
+       0x00, 0x00, 0xff, /* blue */
+       0xff, 0x00, 0xff, /* magenta */
+       0x00, 0xff, 0xff, /* cyan */
+       0xff, 0xff, 0xff, /* white */
+};
+
+/* True if color is gray */
+u_char rasops_isgray[16] = { 
+       1, 0, 0, 0, 
+       0, 0, 0, 1,
+       1, 0, 0, 0,
+       0, 0, 0, 1
+};
+
+/* Common functions */
+static void    rasops_copycols __P((void *, int, int, int, int));
+static void    rasops_copyrows __P((void *, int, int, int));
+static int     rasops_mapchar __P((void *, int, u_int *));
+static void    rasops_cursor __P((void *, int, int, int));
+static int     rasops_alloc_cattr __P((void *, int, int, int, long *));
+static int     rasops_alloc_mattr __P((void *, int, int, int, long *));
+
+/* Per-depth initalization functions */
+void   rasops1_init __P((struct rasops_info *));
+void   rasops8_init __P((struct rasops_info *));
+void   rasops15_init __P((struct rasops_info *));
+void   rasops24_init __P((struct rasops_info *));
+void   rasops32_init __P((struct rasops_info *));
+
+/*
+ * Initalize a 'rasops_info' descriptor.
+ */
+int
+rasops_init(ri, wantrows, wantcols, clear, center)
+       struct rasops_info *ri;
+       int wantrows, wantcols, clear, center;
+{
+       
+       /* Select a font if the caller doesn't care */
+       if (ri->ri_font == NULL) {
+               int cookie;
+               
+               wsfont_init();
+
+               /* Want 8 pixel wide, don't care about aestethics */
+               if ((cookie = wsfont_find(NULL, 8, 0, 0)) < 0)
+                       cookie = wsfont_find(NULL, 0, 0, 0);
+
+               if (cookie < 0) {
+                       printf("rasops_init: font table is empty\n");
+                       return (-1);
+               }
+               
+               if (wsfont_lock(cookie, &ri->ri_font, 
+                   WSFONT_LITTLE, WSFONT_LITTLE) < 0) {
+                       printf("rasops_init: couldn't lock font\n");
+                       return (-1);
+               }
+       }
+       
+       /* This should never happen in reality... */
+#ifdef DEBUG
+       if ((int)ri->ri_bits & 3) {
+               printf("rasops_init: bits not aligned on 32-bit boundary\n");
+               return (-1);
+       }
+
+       if ((int)ri->ri_stride & 3) {
+               printf("rasops_init: stride not aligned on 32-bit boundary\n");
+               return (-1);
+       }
+               
+       if (ri->ri_font->fontwidth > 32) {
+               printf("rasops_init: fontwidth > 32\n");
+               return (-1);
+       }
+#endif
+       
+       /* Fix color palette. We need this for the cursor to work. */
+       rasops_cmap[255*3+0] = 0xff;
+       rasops_cmap[255*3+1] = 0xff;
+       rasops_cmap[255*3+2] = 0xff;
+       
+       /* Don't care if the caller wants a hideously small console */
+       if (wantrows < 10)
+               wantrows = 5000;
+               
+       if (wantcols < 20)
+               wantcols = 5000;
+       
+       /* Now constrain what they get */
+       ri->ri_emuwidth = ri->ri_font->fontwidth * wantcols;
+       ri->ri_emuheight = ri->ri_font->fontheight * wantrows;
+       
+       if (ri->ri_emuwidth > ri->ri_width)
+               ri->ri_emuwidth = ri->ri_width;
+               
+       if (ri->ri_emuheight > ri->ri_height)
+               ri->ri_emuheight = ri->ri_height;
+       
+       /* Reduce width until aligned on a 32-bit boundary */
+       while ((ri->ri_emuwidth*ri->ri_depth & 31) != 0)
+               ri->ri_emuwidth--;
+       
+       ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth;
+       ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight;
+       ri->ri_emustride = ri->ri_emuwidth * ri->ri_depth >> 3;
+       ri->ri_delta = ri->ri_stride - ri->ri_emustride;
+       ri->ri_ccol = 0;
+       ri->ri_crow = 0;
+       ri->ri_pelbytes = ri->ri_depth >> 3;
+       
+       ri->ri_xscale = (ri->ri_font->fontwidth * ri->ri_depth) >> 3;
+       ri->ri_yscale = ri->ri_font->fontheight * ri->ri_stride;
+       ri->ri_fontscale = ri->ri_font->fontheight * ri->ri_font->stride;
+
+#ifdef DEBUG   
+       if (ri->ri_delta & 3)
+               panic("rasops_init: delta isn't aligned on 32-bit boundary!");
+#endif 
+       /* Clear the entire display */
+       if (clear)
+               bzero(ri->ri_bits, ri->ri_stride * ri->ri_height);
+       
+       /* Now centre our window if needs be */ 
+       ri->ri_origbits = ri->ri_bits;
+       
+       if (center) {
+               ri->ri_bits += ((ri->ri_stride - ri->ri_emustride) >> 1) & ~3;
+               ri->ri_bits += ((ri->ri_height - ri->ri_emuheight) >> 1) * 
+                   ri->ri_stride;
+       }
+       
+       /* Fill in defaults for operations set */
+       ri->ri_ops.mapchar = rasops_mapchar;
+       ri->ri_ops.copyrows = rasops_copyrows;
+       ri->ri_ops.copycols = rasops_copycols;
+       ri->ri_ops.cursor = rasops_cursor;
+       
+       if (ri->ri_depth == 1 || ri->ri_forcemono)
+               ri->ri_ops.alloc_attr = rasops_alloc_mattr;
+       else
+               ri->ri_ops.alloc_attr = rasops_alloc_cattr;
+                       
+       switch (ri->ri_depth) {
+#ifdef RASOPS1
+       case 1:
+               rasops1_init(ri);
+               break;
+#endif
+
+#ifdef RASOPS8
+       case 8:
+               rasops8_init(ri);
+               break;
+#endif
+
+#if defined(RASOPS15) || defined(RASOPS16)
+       case 15:
+       case 16:
+               rasops15_init(ri);
+               break;
+#endif
+
+#ifdef RASOPS24
+       case 24:
+               rasops24_init(ri);
+               break;
+#endif
+
+#ifdef RASOPS24
+       case 32:
+               rasops32_init(ri);
+               break;
+#endif
+       default:
+               ri->ri_flg = 0;
+               return (-1);



Home | Main Index | Thread Index | Old Index