]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IOGraphics/IOCursorBlits.h
9f31b4f77b48045a3cebb4c721bf9cb94646c24d
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #define RBMASK 0xF0F0 /* Short, or 16 bit format */
24 #define GAMASK 0x0F0F /* Short, or 16 bit format */
25 #define AMASK 0x000F /* Short, or 16 bit format */
28 #define short34to35WithGamma(x) \
29 ( (((x) & 0xf000) >> 1) \
30 | (((x) & 0x0f00) >> 2) \
31 | (((x) & 0x00f0) >> 3) \
32 | (((x) & 0x8000) >> 5) \
33 | (((x) & 0x0800) >> 6) \
34 | (((x) & 0x0080) >> 7) )
36 #define short35to34WithGamma(x) \
38 | (((x) & 0x001e) << 3) \
39 | (((x) & 0x03c0) << 2) \
40 | (((x) & 0x7800) << 1) )
42 #define short34to35WithGamma(x) \
43 ( (_bm34To35SampleTable[((x) & 0x00F0) >> 4]) \
44 | (_bm34To35SampleTable[((x) & 0x0F00) >> 8] << 5) \
45 | (_bm34To35SampleTable[(x) >> 12] << 10) )
47 #define short35to34WithGamma(x) \
49 | (_bm35To34SampleTable[x & 0x001F] << 4) \
50 | (_bm35To34SampleTable[(x & 0x03E0) >> 5] << 8) \
51 | (_bm35To34SampleTable[(x & 0x7C00) >> 10] << 12) )
54 void IOFramebuffer::StdFBDisplayCursor555(
57 volatile unsigned short *vramPtr
,
58 unsigned int cursStart
,
65 volatile unsigned short *cursPtr
;
66 volatile unsigned short *savePtr
;
67 unsigned short s
, d
, f
;
68 unsigned char *_bm34To35SampleTable
;
69 unsigned char *_bm35To34SampleTable
;
71 savePtr
= (volatile unsigned short *) inst
->cursorSave
;
72 cursPtr
= (volatile unsigned short *) inst
->cursorImages
[ shmem
->frame
];
75 _bm34To35SampleTable
= inst
->colorConvert
.t
._bm34To35SampleTable
;
76 _bm35To34SampleTable
= inst
->colorConvert
.t
._bm35To34SampleTable
;
78 for (i
= height
; --i
>= 0; ) {
79 for (j
= width
; --j
>= 0; ) {
80 d
= *savePtr
++ = *vramPtr
;
81 if ( (s
= *cursPtr
++) == 0 )
82 { /* Transparent black area. Leave dst as is. */
86 if ( (f
= (~s
) & (unsigned int)AMASK
) == 0 )
87 { /* Opaque cursor pixel. Mark it. */
88 *vramPtr
++ = short34to35WithGamma(s
);
92 { /* Transparent non black cursor pixel. xor it. */
93 *vramPtr
++ = d
^ short34to35WithGamma(s
);
96 /* Alpha is not 0 or 1.0. Sover the cursor. */
97 d
= short35to34WithGamma(d
);
98 d
= s
+ (((((d
& RBMASK
)>>4)*f
+ GAMASK
) & RBMASK
)
99 | ((((d
& GAMASK
)*f
+GAMASK
)>>4) & GAMASK
));
100 *vramPtr
++ = short34to35WithGamma(d
);
102 cursPtr
+= cursRow
; /* starting point of next cursor line */
103 vramPtr
+= vramRow
; /* starting point of next screen line */
107 void IOFramebuffer::StdFBDisplayCursor444(
108 IOFramebuffer
* inst
,
110 volatile unsigned short *vramPtr
,
111 unsigned int cursStart
,
112 unsigned int vramRow
,
113 unsigned int cursRow
,
118 volatile unsigned short *savePtr
; /* saved screen data pointer */
119 volatile unsigned short *cursPtr
;
120 unsigned short s
, d
, f
;
122 savePtr
= (volatile unsigned short *) inst
->cursorSave
;
123 cursPtr
= (volatile unsigned short *) inst
->cursorImages
[ shmem
->frame
];
124 cursPtr
+= cursStart
;
126 for (i
= height
; --i
>= 0; ) {
127 for (j
= width
; --j
>= 0; ) {
128 d
= *savePtr
++ = *vramPtr
;
129 if ( (s
= *cursPtr
++) == 0 )
130 { /* Transparent black area. Leave dst as is. */
134 if ( (f
= (~s
) & (unsigned int)AMASK
) == 0 )
135 { /* Opaque cursor pixel. Mark it. */
140 { /* Transparent non black cursor pixel. xor it. */
144 /* Alpha is not 0 or 1.0. Sover the cursor. */
145 *vramPtr
++ = s
+ (((((d
& RBMASK
)>>4)*f
+ GAMASK
) & RBMASK
)
146 | ((((d
& GAMASK
)*f
+GAMASK
)>>4) & GAMASK
));
148 cursPtr
+= cursRow
; /* starting point of next cursor line */
149 vramPtr
+= vramRow
; /* starting point of next screen line */
153 static inline unsigned int MUL32(unsigned int a
, unsigned int b
)
157 v
= ((a
& 0xff00ff00) >> 8) * b
;
158 v
+= ((v
& 0xff00ff00) >> 8) + 0x00010001;
159 w
= (a
& 0x00ff00ff) * b
;
160 w
+= ((w
& 0xff00ff00) >> 8) + 0x00010001;
162 return (v
& 0xff00ff00) | ((w
>> 8) & 0x00ff00ff);
165 static inline unsigned char map32to256( unsigned char *directToLogical
, unsigned int s
)
167 unsigned char logicalValue
;
169 if ((s
^ (s
>>8)) & 0x00ffff00) {
170 logicalValue
= directToLogical
[(s
>>24) + 0] +
171 directToLogical
[((s
>>16)&0xff) + 256] +
172 directToLogical
[((s
>>8)&0xff) + 512];
174 logicalValue
= directToLogical
[(s
>>24) + 768];
176 // final conversion to actual palette
177 return( directToLogical
[ logicalValue
+ 1024 ]);
180 void IOFramebuffer::StdFBDisplayCursor8P(
181 IOFramebuffer
* inst
,
183 volatile unsigned char *vramPtr
,
184 unsigned int cursStart
,
185 unsigned int vramRow
,
186 unsigned int cursRow
,
191 volatile unsigned char *savePtr
; /* saved screen data pointer */
192 volatile unsigned char *cursPtr
;
193 unsigned char dst
, src
, alpha
, white
;
194 unsigned int rgb32val
;
195 volatile unsigned char *maskPtr
; /* cursor mask pointer */
196 unsigned int *_bm256To38SampleTable
197 = inst
->colorConvert
.t
._bm256To38SampleTable
;
198 unsigned char *_bm38To256SampleTable
199 = inst
->colorConvert
.t
._bm38To256SampleTable
;
201 savePtr
= (volatile unsigned char *) inst
->cursorSave
;
202 cursPtr
= (volatile unsigned char *) inst
->cursorImages
[ shmem
->frame
];
203 maskPtr
= (volatile unsigned char *) inst
->cursorMasks
[ shmem
->frame
];
204 cursPtr
+= cursStart
;
205 maskPtr
+= cursStart
;
208 for (i
= height
; --i
>= 0; ) {
209 for (j
= width
; --j
>= 0; savePtr
++,maskPtr
++,cursPtr
++,vramPtr
++) {
210 dst
= *savePtr
= *vramPtr
;
212 if ((alpha
= *maskPtr
)) {
213 if ((alpha
= ~alpha
)) {
214 rgb32val
= _bm256To38SampleTable
[dst
];
215 rgb32val
= (_bm256To38SampleTable
[src
] & ~0xff) +
216 MUL32(rgb32val
, alpha
);
217 *vramPtr
= map32to256(_bm38To256SampleTable
, rgb32val
);
220 } else if (src
== white
)
221 *vramPtr
= map32to256(_bm38To256SampleTable
,
222 _bm256To38SampleTable
[dst
] ^ 0xffffffff);
224 cursPtr
+= cursRow
; /* starting point of next cursor line */
226 vramPtr
+= vramRow
; /* starting point of next screen line */
231 void IOFramebuffer::StdFBDisplayCursor8G(
232 IOFramebuffer
* inst
,
234 volatile unsigned char *vramPtr
,
235 unsigned int cursStart
,
236 unsigned int vramRow
,
237 unsigned int cursRow
,
242 volatile unsigned char *savePtr
; /* saved screen data pointer */
243 unsigned short s
, d
, a
;
244 volatile unsigned char *cursPtr
;
245 volatile unsigned char *maskPtr
; /* cursor mask pointer */
247 savePtr
= (volatile unsigned char *) inst
->cursorSave
;
248 cursPtr
= (volatile unsigned char *) inst
->cursorImages
[ shmem
->frame
];
249 maskPtr
= (volatile unsigned char *) inst
->cursorMasks
[ shmem
->frame
];
250 cursPtr
+= cursStart
;
251 maskPtr
+= cursStart
;
253 for (i
= height
; --i
>= 0; ) {
254 for (j
= width
; --j
>= 0; ) {
256 d
= *savePtr
++ = *vramPtr
;
260 t
= d
* (255 - *maskPtr
++);
261 *vramPtr
= s
+ ((t
+ (t
>> 8) + 1) >> 8);
266 cursPtr
+= cursRow
; /* starting point of next cursor line */
268 vramPtr
+= vramRow
; /* starting point of next screen line */
272 void IOFramebuffer::StdFBDisplayCursor32Axxx(
273 IOFramebuffer
* inst
,
275 volatile unsigned int *vramPtr
,
276 unsigned int cursStart
,
277 unsigned int vramRow
,
278 unsigned int cursRow
,
283 volatile unsigned int *savePtr
; /* saved screen data pointer */
284 unsigned int s
, d
, f
;
285 volatile unsigned int *cursPtr
;
287 savePtr
= (volatile unsigned int *) inst
->cursorSave
;
288 cursPtr
= (volatile unsigned int *) inst
->cursorImages
[ shmem
->frame
];
289 cursPtr
+= cursStart
;
291 /* Pixel format is Axxx */
292 for (i
= height
; --i
>= 0; ) {
293 for (j
= width
; --j
>= 0; ) {
294 d
= *savePtr
++ = *vramPtr
;
298 if (f
== 0xff) // Opaque pixel
300 else { // SOVER the cursor pixel
301 s
<<= 8; d
<<= 8; /* Now pixels are xxxA */
303 d
= s
+(((((d
&0xFF00FF00)>>8)*f
+0x00FF00FF)&0xFF00FF00)
304 | ((((d
& 0x00FF00FF)*f
+0x00FF00FF)>>8) &
306 *vramPtr
++ = (d
>>8) | 0xff000000;
309 // Transparent non black cursor pixel. xor it.
312 } else // Transparent cursor pixel
315 cursPtr
+= cursRow
; /* starting point of next cursor line */
316 vramPtr
+= vramRow
; /* starting point of next screen line */
320 void IOFramebuffer::StdFBDisplayCursor32xxxA(
321 IOFramebuffer
* inst
,
323 volatile unsigned int *vramPtr
,
324 unsigned int cursStart
,
325 unsigned int vramRow
,
326 unsigned int cursRow
,
331 volatile unsigned int *savePtr
; /* saved screen data pointer */
332 unsigned int s
, d
, f
;
333 volatile unsigned int *cursPtr
;
335 savePtr
= (volatile unsigned int *) inst
->cursorSave
;
336 cursPtr
= (volatile unsigned int *) inst
->cursorImages
[ shmem
->frame
];
337 cursPtr
+= cursStart
;
339 /* Pixel format is xxxA */
340 for (i
= height
; --i
>= 0; ) {
341 for (j
= width
; --j
>= 0; ) {
342 d
= *savePtr
++ = *vramPtr
;
344 f
= s
& (unsigned int)0xFF;
346 if (f
== 0xff) // Opaque pixel
348 else { // SOVER the cursor pixel
350 d
= s
+(((((d
&0xFF00FF00)>>8)*f
+0x00FF00FF)&0xFF00FF00)
351 | ((((d
& 0x00FF00FF)*f
+0x00FF00FF)>>8) &
356 // Transparent non black cursor pixel. xor it.
359 } else // Transparent cursor pixel
362 cursPtr
+= cursRow
; /* starting point of next cursor line */
363 vramPtr
+= vramRow
; /* starting point of next screen line */
367 void IOFramebuffer::StdFBRemoveCursor16(
368 IOFramebuffer
* inst
,
370 volatile unsigned short *vramPtr
,
371 unsigned int vramRow
,
376 volatile unsigned short *savePtr
;
378 savePtr
= (volatile unsigned short *) inst
->cursorSave
;
380 for (i
= height
; --i
>= 0; ) {
381 for (j
= width
; --j
>= 0; )
382 *vramPtr
++ = *savePtr
++;
387 void IOFramebuffer::StdFBRemoveCursor8(
388 IOFramebuffer
* inst
,
390 volatile unsigned char *vramPtr
,
391 unsigned int vramRow
,
396 volatile unsigned char *savePtr
;
398 savePtr
= (volatile unsigned char *) inst
->cursorSave
;
400 for (i
= height
; --i
>= 0; ) {
401 for (j
= width
; --j
>= 0; )
402 *vramPtr
++ = *savePtr
++;
407 void IOFramebuffer::StdFBRemoveCursor32(
408 IOFramebuffer
* inst
,
410 volatile unsigned int *vramPtr
,
411 unsigned int vramRow
,
416 volatile unsigned int *savePtr
;
418 savePtr
= (volatile unsigned int *) inst
->cursorSave
;
420 for (i
= height
; --i
>= 0; ) {
421 for (j
= width
; --j
>= 0; )
422 *vramPtr
++ = *savePtr
++;