rasops.h revision 1.2 1 /* $NetBSD: rasops.h,v 1.2 1999/04/13 00:40:08 ad Exp $ */
2
3 /*
4 * Copyright (c) 1999 Andy Doran <ad (at) NetBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
29
30 #ifndef _RASOPS_H_
31 #define _RASOPS_H_ 1
32
33 /* Avoid dragging in dev/wscons/wsconsio.h */
34 struct wsdisplay_font;
35
36 struct rasops_info {
37 /* These must be filled in by the caller */
38 int ri_depth; /* depth in bits */
39 u_char *ri_bits; /* ptr to bits */
40 int ri_width; /* width (pels) */
41 int ri_height; /* height (pels) */
42 int ri_stride; /* stride in bytes */
43
44 /* These can optionally be left NULL */
45 struct wsdisplay_font *ri_font;/* font to use */
46 void *ri_priv; /* driver private data */
47 u_char ri_forcemono; /* force monochrome operation */
48 u_char __pad0;
49
50 /*
51 * These are optional and will default if zero. Meaningless
52 * on depths other than 15, 16, 24 and 32 bits per pel. On
53 * 24 bit displays, ri_{r,g,b}num must be 8.
54 */
55 u_char ri_rnum; /* number of bits for red */
56 u_char ri_gnum; /* number of bits for green */
57 u_char ri_bnum; /* number of bits for blue */
58 u_char ri_rpos; /* which bit red starts at */
59 u_char ri_gpos; /* which bit green starts at */
60 u_char ri_bpos; /* which bit blue starts at */
61
62 /* These are filled in by rasops_init() */
63 int ri_emuwidth; /* width we actually care about */
64 int ri_emuheight; /* height we actually care about */
65 int ri_emustride; /* bytes per row we actually care about */
66 int ri_rows; /* number of rows (characters, not pels) */
67 int ri_cols; /* number of columns (characters, not pels) */
68 int ri_delta; /* row delta in bytes */
69 int ri_flg; /* flags */
70 int ri_crow; /* cursor row */
71 int ri_ccol; /* cursor column */
72 int ri_pelbytes; /* bytes per pel */
73 int ri_fontscale; /* fontheight * fontstride */
74 int ri_xscale; /* fontwidth * pelbytes */
75 int ri_yscale; /* fontheight * stride */
76 u_char *ri_origbits; /* where screen bits actually start */
77
78 /* For 15, 16, 24, 32 bits */
79 int32_t ri_devcmap[16]; /* device colormap (WSCOL_*) */
80
81 /* The emulops you need to use */
82 struct wsdisplay_emulops ri_ops;
83
84 /* Callbacks so we can share some code */
85 void (*ri_do_cursor)(struct rasops_info *);
86 };
87
88 #define RASOPS_CURSOR (0x01) /* cursor is on */
89 #define RASOPS_INITTED (0x02) /* struct is initialized */
90 #define RASOPS_CURSOR_CLIPPED (0x04) /* cursor is clipped */
91
92 #define DELTA(p, d, cast) ((p) = (cast)((caddr_t)(p) + (d)))
93
94 /*
95 * rasops_init().
96 *
97 * Integer parameters are: number of rows we'd like, number of columns we'd
98 * like, whether we should clear the display and whether we should center
99 * the output. Remember that what you'd like is always not what you get.
100 *
101 * In terms of optimization, fonts that are a multiple of 8 pixels wide
102 * work the best: this is important, and will cost you if you don't use 'em.
103 */
104
105 /* rasops.c */
106 int rasops_init __P((struct rasops_info *, int, int, int, int));
107 void rasops_unpack_attr __P((long, int *, int *, int *));
108
109 /* This should not be called outside rasops */
110 void rasops_init_devcmap __P((struct rasops_info *));
111
112 extern u_char rasops_isgray[16];
113 extern u_char rasops_cmap[256*3];
114
115 #endif /* _RASOPS_H_ */
116