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