rasops.h revision 1.1 1 /* $NetBSD: rasops.h,v 1.1 1999/04/13 00:17: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 <ad (at) NetBSD.org>.
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 #ifndef _RASOPS_H_
39 #define _RASOPS_H_ 1
40
41 /* Avoid dragging in dev/wscons/wsconsio.h */
42 struct wsdisplay_font;
43
44 struct rasops_info {
45 /* These must be filled in by the caller */
46 int ri_depth; /* depth in bits */
47 u_char *ri_bits; /* ptr to bits */
48 int ri_width; /* width (pels) */
49 int ri_height; /* height (pels) */
50 int ri_stride; /* stride in bytes */
51
52 /* These can optionally be left NULL */
53 struct wsdisplay_font *ri_font;/* font to use */
54 void *ri_priv; /* driver private data */
55 u_char ri_forcemono; /* force monochrome operation */
56 u_char __pad0;
57
58 /*
59 * These are optional and will default if zero. Meaningless
60 * on depths other than 15, 16, 24 and 32 bits per pel. On
61 * 24 bit displays, ri_{r,g,b}num must be 8.
62 */
63 u_char ri_rnum; /* number of bits for red */
64 u_char ri_gnum; /* number of bits for green */
65 u_char ri_bnum; /* number of bits for blue */
66 u_char ri_rpos; /* which bit red starts at */
67 u_char ri_gpos; /* which bit green starts at */
68 u_char ri_bpos; /* which bit blue starts at */
69
70 /* These are filled in by rasops_init() */
71 int ri_emuwidth; /* width we actually care about */
72 int ri_emuheight; /* height we actually care about */
73 int ri_emustride; /* bytes per row we actually care about */
74 int ri_rows; /* number of rows (characters, not pels) */
75 int ri_cols; /* number of columns (characters, not pels) */
76 int ri_delta; /* row delta in bytes */
77 int ri_flg; /* flags */
78 int ri_crow; /* cursor row */
79 int ri_ccol; /* cursor column */
80 int ri_pelbytes; /* bytes per pel */
81 int ri_fontscale; /* fontheight * fontstride */
82 int ri_xscale; /* fontwidth * pelbytes */
83 int ri_yscale; /* fontheight * stride */
84 u_char *ri_origbits; /* where screen bits actually start */
85
86 /* For 15, 16, 24, 32 bits */
87 int32_t ri_devcmap[16]; /* device colormap (WSCOL_*) */
88
89 /* The emulops you need to use */
90 struct wsdisplay_emulops ri_ops;
91
92 /* Callbacks so we can share some code */
93 void (*ri_do_cursor)(struct rasops_info *);
94 };
95
96 #define RASOPS_CURSOR (0x01) /* cursor is on */
97 #define RASOPS_INITTED (0x02) /* struct is initialized */
98 #define RASOPS_CURSOR_CLIPPED (0x04) /* cursor is clipped */
99
100 #define DELTA(p, d, cast) ((p) = (cast)((caddr_t)(p) + (d)))
101
102 /*
103 * rasops_init().
104 *
105 * Integer parameters are: number of rows we'd like, number of columns we'd
106 * like, whether we should clear the display and whether we should center
107 * the output. Remember that what you'd like is always not what you get.
108 *
109 * In terms of optimization, fonts that are a multiple of 8 pixels wide
110 * work the best: this is important, and will cost you if you don't use 'em.
111 */
112
113 /* rasops.c */
114 int rasops_init __P((struct rasops_info *, int, int, int, int));
115 void rasops_unpack_attr __P((long, int *, int *, int *));
116
117 /* This should not be called outside rasops */
118 void rasops_init_devcmap __P((struct rasops_info *));
119
120 extern u_char rasops_isgray[16];
121 extern u_char rasops_cmap[256*3];
122
123 #endif /* _RASOPS_H_ */
124