1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright (c) 1987 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
50 #ifdef HAVE_DIX_CONFIG_H
51 #include <dix-config.h>
56 #include <X11/Xproto.h>
58 #include <X11/fonts/fontstruct.h>
59 #include "dixfontstr.h"
61 #include "windowstr.h"
62 #include "scrnintstr.h"
63 #include "pixmapstr.h"
64 #include "regionstr.h"
68 this works for fonts with glyphs <= PPW bits wide.
70 This should be called only with a terminal-emulator font;
71 this means that the FIXED_METRICS flag is set, and that
72 glyphbounds == charbounds.
74 in theory, this goes faster; even if it doesn't, it reduces the
75 flicker caused by writing a string over itself with image text (since
76 the background gets repainted per character instead of per string.)
77 this seems to be important for some converted X10 applications.
79 Image text looks at the bits in the glyph and the fg and bg in the
80 GC. it paints a rectangle, as defined in the protocol dcoument,
81 and the paints the characters.
85 #if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
90 * this macro "knows" that only characters <= 8 bits wide will
91 * fit this case (which is why it is independent of GLYPHPADBYTES)
94 #if (BITMAP_BIT_ORDER == MSBFirst) && (GLYPHPADBYTES != 4)
95 #if GLYPHPADBYTES == 1
102 * Note: for BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER, SCRRIGHT() evaluates its
103 * first argument more than once. Thus the imbedded char++ have to be moved.
106 #if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
108 #define GetBits4 c = (*char1++ << ShiftAmnt) | \
109 SCRRIGHT (*char2++ << ShiftAmnt, xoff2) | \
110 SCRRIGHT (*char3++ << ShiftAmnt, xoff3) | \
111 SCRRIGHT (*char4++ << ShiftAmnt, xoff4);
113 #define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
114 (SCRRIGHT (*char2++ << ShiftAmnt, xoff2) << 32 ) | \
115 (SCRRIGHT (*char3++ << ShiftAmnt, xoff3) << 32 ) | \
116 (SCRRIGHT (*char4++ << ShiftAmnt, xoff4) << 32 ) | \
117 (*char5++ << ShiftAmnt) | \
118 SCRRIGHT (*char6++ << ShiftAmnt, xoff6) | \
119 SCRRIGHT (*char7++ << ShiftAmnt, xoff7) | \
120 SCRRIGHT (*char8++ << ShiftAmnt, xoff8);
122 #else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
124 #define GetBits4 c = (*char1++ << ShiftAmnt) | \
125 SCRRIGHT (*char2 << ShiftAmnt, xoff2) | \
126 SCRRIGHT (*char3 << ShiftAmnt, xoff3) | \
127 SCRRIGHT (*char4 << ShiftAmnt, xoff4); \
128 char2++; char3++; char4++;
129 #else /* PPW == 64 */
130 #define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
131 (SCRRIGHT (*char2 << ShiftAmnt, xoff2) << 32 ) | \
132 (SCRRIGHT (*char3 << ShiftAmnt, xoff3) << 32 ) | \
133 (SCRRIGHT (*char4 << ShiftAmnt, xoff4) << 32 ) | \
134 (*char5++ << ShiftAmnt) | \
135 SCRRIGHT (*char6 << ShiftAmnt, xoff6) | \
136 SCRRIGHT (*char7 << ShiftAmnt, xoff7) | \
137 SCRRIGHT (*char8 << ShiftAmnt, xoff8); \
138 char2++; char3++; char4++; char6++; char7++; char8++;
140 #endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
142 #else /* (BITMAP_BIT_ORDER != MSBFirst) || (GLYPHPADBYTES == 4) */
144 #if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
146 #define GetBits4 c = *char1++ | \
147 SCRRIGHT (*char2++, xoff2) | \
148 SCRRIGHT (*char3++, xoff3) | \
149 SCRRIGHT (*char4++, xoff4);
150 #else /* PPW == 64 */
151 #define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
152 (SCRRIGHT (*char2++, xoff2) << 64 ) | \
153 (SCRRIGHT (*char3++, xoff3) << 64 ) | \
154 (SCRRIGHT (*char4++, xoff4) << 64 ) | \
155 SCRRIGHT (*char5++, xoff5) | \
156 SCRRIGHT (*char6++, xoff6) | \
157 SCRRIGHT (*char7++, xoff7) | \
158 SCRRIGHT (*char8++, xoff8));
160 #else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
162 #define GetBits4 c = *char1++ | \
163 SCRRIGHT (*char2, xoff2) | \
164 SCRRIGHT (*char3, xoff3) | \
165 SCRRIGHT (*char4, xoff4); \
166 char2++; char3++; char4++;
167 #else /* PPW == 64 */
168 #define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
169 (SCRRIGHT (*char2, xoff2) << 64 ) | \
170 (SCRRIGHT (*char3, xoff3) << 64 ) | \
171 (SCRRIGHT (*char4, xoff4) << 64 ) | \
172 SCRRIGHT (*char5, xoff5) | \
173 SCRRIGHT (*char6, xoff6) | \
174 SCRRIGHT (*char7, xoff7) | \
175 SCRRIGHT (*char8, xoff8)); \
176 char2++; char3++; char4++; \
177 char5++; char6++; char7++; char8++;
179 #endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
181 #endif /* BITMAP_BIT_ORDER && GLYPHPADBYTES */
184 #if GLYPHPADBYTES == 1
185 typedef unsigned char *glyphPointer
;
189 #if GLYPHPADBYTES == 2
190 typedef unsigned short *glyphPointer
;
194 #if GLYPHPADBYTES == 4
195 typedef unsigned int *glyphPointer
;
199 #define GetBits1 getleftbits (char1, widthGlyph, c); \
201 char1 = (glyphPointer) (((char *) char1) + glyphBytes);
203 #define GetBits1 c = *char1++;
207 afbTEGlyphBlt (pDrawable
, pGC
, x
, y
, nglyph
, ppci
, pglyphBase
)
208 DrawablePtr pDrawable
;
212 CharInfoPtr
*ppci
; /* array of character info */
213 pointer pglyphBase
; /* start of array of glyphs */
215 FontPtr pfont
= pGC
->font
;
217 PixelType
*pdstBase
; /* pointer to longword with top row
220 int h
; /* height of glyph and char */
221 register int xpos
; /* current x */
222 int ypos
; /* current y */
225 int hTmp
; /* counter for height */
226 register PixelType startmask
, endmask
;
227 int nfirst
; /* used if glyphs spans a longword boundary */
228 BoxRec bbox
; /* for clipping */
233 register PixelType
*dst
;
234 register PixelType c
;
236 register int xoff1
, xoff2
, xoff3
, xoff4
;
237 register glyphPointer char1
, char2
, char3
, char4
;
238 glyphPointer schar1
, schar2
, schar3
, schar4
;
240 register int xoff5
, xoff6
, xoff7
, xoff8
;
241 register glyphPointer char5
, char6
, char7
, char8
;
242 glyphPointer schar5
, schar6
, schar7
, schar8
;
245 unsigned char *rrops
;
247 register PixelType glyphMask
;
248 register PixelType tmpSrc
;
249 register int glyphBytes
;
252 afbGetPixelWidthSizeDepthAndPointer(pDrawable
, widthDst
, sizeDst
, depthDst
,
255 xpos
= x
+ pDrawable
->x
;
256 ypos
= y
+ pDrawable
->y
;
258 widthGlyph
= FONTMAXBOUNDS(pfont
,characterWidth
);
259 h
= FONTASCENT(pfont
) + FONTDESCENT(pfont
);
261 xpos
+= FONTMAXBOUNDS(pfont
,leftSideBearing
);
262 ypos
-= FONTASCENT(pfont
);
264 rrops
= ((afbPrivGCPtr
) pGC
->devPrivates
[afbGCPrivateIndex
].ptr
)->rropOS
;
267 bbox
.x2
= xpos
+ (widthGlyph
* nglyph
);
271 switch (RECT_IN_REGION(pGC
->pScreen
, pGC
->pCompositeClip
, &bbox
)) {
273 /* this is the WRONG thing to do, but it works.
274 calling the non-terminal text is easy, but slow, given
275 what we know about the font.
277 the right thing to do is something like:
278 for each clip rectangle
279 compute at which row the glyph starts to be in it,
280 and at which row the glyph ceases to be in it
281 compute which is the first glyph inside the left
282 edge, and the last one inside the right edge
283 draw a fractional first glyph, using only
284 the rows we know are in
285 draw all the whole glyphs, using the appropriate rows
286 draw any pieces of the last glyph, using the right rows
288 this way, the code would take advantage of knowing that
289 all glyphs are the same height and don't overlap.
293 afbImageGlyphBlt (pDrawable
, pGC
, x
, y
, nglyph
, ppci
, pglyphBase
);
297 pdstBase
= afbScanlineDeltaNoBankSwitch(pdstBase
, ypos
, widthDst
);
298 widthGlyphs
= widthGlyph
* PGSZB
;
301 glyphMask
= mfbGetendtab(widthGlyph
);
302 glyphBytes
= GLYPHWIDTHBYTESPADDED(*ppci
);
305 if (nglyph
>= PGSZB
&& widthGlyphs
<= PPW
) {
306 while (nglyph
>= PGSZB
) {
310 xoff3
= xoff2
+ widthGlyph
;
311 xoff4
= xoff3
+ widthGlyph
;
313 xoff5
= xoff4
+ widthGlyph
;
314 xoff6
= xoff5
+ widthGlyph
;
315 xoff7
= xoff6
+ widthGlyph
;
316 xoff8
= xoff7
+ widthGlyph
;
318 schar1
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
319 schar2
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
320 schar3
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
321 schar4
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
323 schar5
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
324 schar6
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
325 schar7
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
326 schar8
= (glyphPointer
)FONTGLYPHBITS(pglyphBase
,(*ppci
++));
330 saveDst
= afbScanlineOffset(pdstBase
, (xpos
>> PWSH
)); /* switch now */
333 if (xoff1
+ widthGlyphs
<= PPW
) {
334 maskpartialbits (xoff1
, widthGlyphs
, startmask
);
336 for (d
= 0; d
< depthDst
; d
++) {
339 saveDst
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
345 FASTPUTBITS(0, xoff1
, widthGlyphs
, dst
);
347 *(dst
) &= ~startmask
;
349 afbScanlineInc(dst
, widthDst
);
355 FASTPUTBITS(~0, xoff1
, widthGlyphs
, dst
);
359 afbScanlineInc(dst
, widthDst
);
371 # if BITMAP_BIT_ORDER == MSBFirst
372 c
>>= PPW
- widthGlyphs
;
374 FASTPUTBITS(~c
, xoff1
, widthGlyphs
, dst
);
376 *(dst
) = ((*dst
) & ~startmask
) | (~SCRRIGHT(c
, xoff1
) & startmask
);
378 afbScanlineInc(dst
, widthDst
);
390 # if BITMAP_BIT_ORDER == MSBFirst
391 c
>>= PPW
- widthGlyphs
;
393 FASTPUTBITS(c
, xoff1
, widthGlyphs
, dst
);
395 *(dst
) = ((*dst
) & ~startmask
) | (SCRRIGHT(c
, xoff1
) & startmask
);
397 afbScanlineInc(dst
, widthDst
);
402 } /* switch (rrops[d]) */
403 } /* for (d = ... ) */
406 maskPPWbits (xoff1
, widthGlyphs
, startmask
, endmask
);
407 nfirst
= PPW
- xoff1
;
408 for (d
= 0; d
< depthDst
; d
++) {
411 saveDst
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
416 dst
[0] &= ~startmask
;
418 afbScanlineInc(dst
, widthDst
);
425 afbScanlineInc(dst
, widthDst
);
436 dst
[0] = (dst
[0] & ~startmask
) | (~SCRRIGHT(c
,xoff1
) & startmask
);
437 dst
[1] = (dst
[1] & ~endmask
) | (~SCRLEFT(c
,nfirst
) & endmask
);
438 afbScanlineInc(dst
, widthDst
);
449 dst
[0] = (dst
[0] & ~startmask
) | (SCRRIGHT(c
,xoff1
) & startmask
);
450 dst
[1] = (dst
[1] & ~endmask
) | (SCRLEFT(c
,nfirst
) & endmask
);
451 afbScanlineInc(dst
, widthDst
);
458 } /* for (d = ... ) */
467 schar1
= (glyphPointer
) FONTGLYPHBITS(pglyphBase
,(*ppci
++));
469 saveDst
= afbScanlineOffset(pdstBase
, (xpos
>> PWSH
));
471 if (xoff1
+ widthGlyph
<= PPW
) {
472 maskpartialbits (xoff1
, widthGlyph
, startmask
);
474 for (d
= 0; d
< depthDst
; d
++) {
477 saveDst
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
483 (*dst
) &= ~startmask
;
484 afbScanlineInc(dst
, widthDst
);
490 afbScanlineInc(dst
, widthDst
);
497 FASTGETBITS (char1
,0,widthGlyph
,c
);
498 char1
= (glyphPointer
) (((char *) char1
) + glyphBytes
);
501 #if BITMAP_BIT_ORDER == MSBFirst
502 c
>>= PPW
- widthGlyph
;
505 FASTPUTBITS (~c
,xoff1
,widthGlyph
,dst
);
508 (*dst
) = ((*dst
) & ~startmask
) | (~SCRRIGHT(c
, xoff1
) & startmask
);
510 afbScanlineInc(dst
, widthDst
);
517 FASTGETBITS (char1
,0,widthGlyph
,c
);
518 char1
= (glyphPointer
) (((char *) char1
) + glyphBytes
);
521 #if BITMAP_BIT_ORDER == MSBFirst
522 c
>>= PPW
- widthGlyph
;
525 FASTPUTBITS (c
,xoff1
,widthGlyph
,dst
);
528 (*dst
) = ((*dst
) & ~startmask
) | (SCRRIGHT(c
, xoff1
) & startmask
);
530 afbScanlineInc(dst
, widthDst
);
536 } /* for (d = ...) */
538 maskPPWbits (xoff1
, widthGlyph
, startmask
, endmask
);
539 nfirst
= PPW
- xoff1
;
541 for (d
= 0; d
< depthDst
; d
++) {
544 saveDst
+= sizeDst
; /* @@@ NEXT PLANE @@@ */
550 dst
[0] &= ~startmask
;
552 afbScanlineInc(dst
, widthDst
);
559 afbScanlineInc(dst
, widthDst
);
565 dst
[0] = (dst
[0] & ~startmask
) | (~SCRRIGHT(c
,xoff1
) & startmask
);
566 dst
[1] = (dst
[1] & ~endmask
) | (~SCRLEFT(c
,nfirst
) & endmask
);
567 afbScanlineInc(dst
, widthDst
);
573 dst
[0] = (dst
[0] & ~startmask
) | (SCRRIGHT(c
,xoff1
) & startmask
);
574 dst
[1] = (dst
[1] & ~endmask
) | (SCRLEFT(c
,nfirst
) & endmask
);
575 afbScanlineInc(dst
, widthDst
);
581 } /* for (d = ...) */