1 /* $NetBSD: rasops32.c,v 1.17 2009/03/14 15:36:20 dsl Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.17 2009/03/14 15:36:20 dsl Exp $");
35 #include "opt_rasops.h"
37 #include <sys/param.h>
38 #include <sys/systm.h>
41 #include <dev/wscons/wsdisplayvar.h>
42 #include <dev/wscons/wsconsio.h>
43 #include <dev/rasops/rasops.h>
45 static void rasops32_putchar(void *, int, int, u_int
, long attr
);
48 * Initialize a 'rasops_info' descriptor for this depth.
51 rasops32_init(struct rasops_info
*ri
)
54 if (ri
->ri_rnum
== 0) {
63 ri
->ri_ops
.putchar
= rasops32_putchar
;
67 * Paint a single character.
70 rasops32_putchar(void *cookie
, int row
, int col
, u_int uc
, long attr
)
72 int width
, height
, cnt
, fs
, fb
, clr
[2];
73 struct rasops_info
*ri
;
74 int32_t *dp
, *rp
, *hp
, *hrp
;
77 ri
= (struct rasops_info
*)cookie
;
80 #ifdef RASOPS_CLIPPING
81 /* Catches 'row < 0' case too */
82 if ((unsigned)row
>= (unsigned)ri
->ri_rows
)
85 if ((unsigned)col
>= (unsigned)ri
->ri_cols
)
89 /* check if character fits into font limits */
90 if (uc
< ri
->ri_font
->firstchar
||
91 (uc
- ri
->ri_font
->firstchar
) >= ri
->ri_font
->numchars
)
94 rp
= (int32_t *)(ri
->ri_bits
+ row
*ri
->ri_yscale
+ col
*ri
->ri_xscale
);
96 hrp
= (int32_t *)(ri
->ri_hwbits
+ row
*ri
->ri_yscale
+
99 height
= ri
->ri_font
->fontheight
;
100 width
= ri
->ri_font
->fontwidth
;
102 clr
[0] = ri
->ri_devcmap
[(attr
>> 16) & 0xf];
103 clr
[1] = ri
->ri_devcmap
[(attr
>> 24) & 0xf];
108 DELTA(rp
, ri
->ri_stride
, int32_t *);
111 DELTA(hrp
, ri
->ri_stride
, int32_t *);
114 for (cnt
= width
; cnt
; cnt
--) {
121 uc
-= ri
->ri_font
->firstchar
;
122 fr
= (u_char
*)ri
->ri_font
->data
+ uc
* ri
->ri_fontscale
;
123 fs
= ri
->ri_font
->stride
;
127 fb
= fr
[3] | (fr
[2] << 8) | (fr
[1] << 16) |
130 DELTA(rp
, ri
->ri_stride
, int32_t *);
133 DELTA(hrp
, ri
->ri_stride
, int32_t *);
136 for (cnt
= width
; cnt
; cnt
--) {
137 *dp
++ = clr
[(fb
>> 31) & 1];
139 *hp
++ = clr
[(fb
>> 31) & 1];
146 if ((attr
& 1) != 0) {
147 DELTA(rp
, -(ri
->ri_stride
<< 1), int32_t *);
149 DELTA(hrp
, -(ri
->ri_stride
<< 1), int32_t *);