Home | History | Annotate | Line # | Download | only in rasops
rasops.h revision 1.6
      1 /* 	$NetBSD: rasops.h,v 1.6 1999/05/18 21:51:59 ad Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Andy Doran.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _RASOPS_H_
     40 #define _RASOPS_H_ 1
     41 
     42 /* Avoid dragging in dev/wscons/wsconsio.h */
     43 struct wsdisplay_font;
     44 
     45 struct rasops_info {
     46 	/* These must be filled in by the caller */
     47 	int	ri_depth;	/* depth in bits */
     48 	u_char	*ri_bits;	/* ptr to bits */
     49 	int	ri_width;	/* width (pels) */
     50 	int	ri_height;	/* height (pels) */
     51 	int	ri_stride;	/* stride in bytes */
     52 
     53 	/*
     54 	 * These can optionally be left empty. If you fill ri_font,
     55 	 * but aren't using wsfont, set ri_wsfcookie to -1.
     56 	 */
     57 	struct	wsdisplay_font *ri_font;
     58 	int	ri_wsfcookie;
     59 	void	*ri_priv;	/* driver private data */
     60 	u_char	ri_forcemono;	/* force monochrome operation */
     61 	u_char	ri_swab;	/* swap bytes for 15/16/32 bit depths? */
     62 
     63 	/*
     64 	 * These are optional and will default if zero. Meaningless
     65 	 * on depths other than 15, 16, 24 and 32 bits per pel. On
     66 	 * 24 bit displays, ri_{r,g,b}num must be 8.
     67 	 */
     68 	u_char	ri_rnum;	/* number of bits for red */
     69 	u_char	ri_gnum;	/* number of bits for green */
     70 	u_char	ri_bnum;	/* number of bits for blue */
     71 	u_char	ri_rpos;	/* which bit red starts at */
     72 	u_char	ri_gpos;	/* which bit green starts at */
     73 	u_char	ri_bpos;	/* which bit blue starts at */
     74 
     75 	/* These are filled in by rasops_init() */
     76 	int	ri_emuwidth;	/* width we actually care about */
     77 	int	ri_emuheight;	/* height we actually care about */
     78 	int	ri_emustride;	/* bytes per row we actually care about */
     79 	int	ri_rows;	/* number of rows (characters, not pels) */
     80 	int	ri_cols;	/* number of columns (characters, not pels) */
     81 	int	ri_delta;	/* row delta in bytes */
     82 	int	ri_flg;		/* flags */
     83 	int	ri_crow;	/* cursor row */
     84 	int	ri_ccol;	/* cursor column */
     85 	int	ri_pelbytes;	/* bytes per pel (may be zero) */
     86 	int	ri_fontscale;	/* fontheight * fontstride */
     87 	int	ri_xscale;	/* fontwidth * pelbytes */
     88 	int	ri_yscale;	/* fontheight * stride */
     89 	u_char  *ri_origbits;	/* where screen bits actually start */
     90 	int	ri_xorigin;	/* where ri_bits begins (x) */
     91 	int	ri_yorigin;	/* where ri_bits begins (y) */
     92 
     93 	/* For 15, 16, 24, 32 bits */
     94 	int32_t	ri_devcmap[16]; /* device colormap (WSCOL_*) */
     95 
     96 	/* The emulops you need to use, and the screen caps for wscons */
     97 	struct	wsdisplay_emulops ri_ops;
     98 	int	ri_caps;
     99 
    100 	/* Callbacks so we can share some code */
    101 	void	(*ri_do_cursor) __P((struct rasops_info *));
    102 };
    103 
    104 #define RASOPS_CURSOR		(0x01)	/* cursor is on */
    105 #define RASOPS_INITTED		(0x02)	/* struct is initialized */
    106 #define RASOPS_CURSOR_CLIPPED	(0x04)	/* cursor is clipped */
    107 
    108 #define DELTA(p, d, cast) ((p) = (cast)((caddr_t)(p) + (d)))
    109 
    110 /*
    111  * rasops_init().
    112  *
    113  * Integer parameters are: number of rows we'd like, number of columns we'd
    114  * like, whether we should clear the display and whether we should center
    115  * the output. Remember that what you'd like is always not what you get.
    116  *
    117  * In terms of optimization, fonts that are a multiple of 8 pixels wide
    118  * work the best: this is important, and will cost you if you don't use 'em.
    119  *
    120  * rasops_init() takes care of rasops_setfont(). You only need to use this
    121  * when you want to switch fonts later on. The integer parameters to both
    122  * are the same. Before calling rasops_setfont(), set ri.ri_font. This
    123  * should happen at _splhigh_. If (ri_wsfcookie >= 0), you must call
    124  * wsfont_unlock() on it first.
    125  */
    126 
    127 /* rasops.c */
    128 int	rasops_init __P((struct rasops_info *, int, int, int, int));
    129 int	rasops_setfont __P((struct rasops_info *, int, int, int, int));
    130 void	rasops_unpack_attr __P((long, int *, int *, int *));
    131 
    132 /* These should _not_ be called outside rasops */
    133 void	rasops_eraserows __P((void *, int, int, long));
    134 void	rasops_erasecols __P((void *, int, int, int, long));
    135 void	rasops_copycols __P((void *, int, int, int, int));
    136 
    137 extern u_char	rasops_isgray[16];
    138 extern u_char	rasops_cmap[256*3];
    139 
    140 #endif /* _RASOPS_H_ */
    141