1 /* $XConsortium: cfbtegblt.c,v 5.9 94/04/17 20:29:03 dpw Exp $ */
2 /* $XFree86: xc/programs/Xserver/cfb/cfbtegblt.c,v 3.0 1996/06/29 09:05:52 dawes Exp $ */
3 /***********************************************************
5 Copyright (c) 1987 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of Digital not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49 ******************************************************************/
54 #include "fontstruct.h"
55 #include "dixfontstr.h"
57 #include "windowstr.h"
58 #include "scrnintstr.h"
59 #include "pixmapstr.h"
60 #include "regionstr.h"
61 #include "cfbmskbits.h"
63 #define MFB_CONSTS_ONLY
67 this works for fonts with glyphs <= 32 bits wide, on an
68 arbitrarily deep display. Use cfbTEGlyphBlt8 for 8 bit displays.
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.
86 cfbTEGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
87 DrawablePtr pDrawable;
91 CharInfoPtr *ppci; /* array of character info */
92 pointer pglyphBase; /* start of array of glyphs */
94 FontPtr pfont = pGC->font;
96 unsigned long *pdstBase; /* pointer to longword with top row
99 int w; /* width of glyph and char */
100 int h; /* height of glyph and char */
101 register int xpos=x; /* current x%32 */
102 int ypos=y; /* current y%32 */
103 register unsigned char *pglyph;
106 register unsigned long *pdst;/* pointer to current longword in dst */
107 int hTmp; /* counter for height */
108 BoxRec bbox; /* for clipping */
110 register int wtmp,xtemp,width;
111 unsigned long bgfill,fgfill,*ptemp,tmpDst1,tmpDst2,*pdtmp;
117 xpos += pDrawable->x;
118 ypos += pDrawable->y;
120 cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase)
122 wtmp = FONTMAXBOUNDS(pfont,characterWidth);
123 h = FONTASCENT(pfont) + FONTDESCENT(pfont);
124 widthGlyph = GLYPHWIDTHBYTESPADDED(*ppci);
126 xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
127 ypos -= FONTASCENT(pfont);
130 bbox.x2 = xpos + (wtmp * nglyph);
134 fgfill = PFILL(pGC->fgPixel);
135 bgfill = PFILL(pGC->bgPixel);
137 switch (RECT_IN_REGION(pGC->pScreen, cfbGetCompositeClip(pGC), &bbox))
142 /* this is the WRONG thing to do, but it works.
143 calling the non-terminal text is easy, but slow, given
144 what we know about the font.
146 the right thing to do is something like:
147 for each clip rectangle
148 compute at which row the glyph starts to be in it,
149 and at which row the glyph ceases to be in it
150 compute which is the first glyph inside the left
151 edge, and the last one inside the right edge
152 draw a fractional first glyph, using only
153 the rows we know are in
154 draw all the whole glyphs, using the appropriate rows
155 draw any pieces of the last glyph, using the right rows
157 this way, the code would take advantage of knowing that
158 all glyphs are the same height and don't overlap.
162 miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
166 pdtmp = pdstBase + (widthDst * ypos);
170 pglyph = FONTGLYPHBITS(pglyphBase, *ppci++);
187 w = min(width, PPW - tmpx);
188 w = min(w, (PGSZ - xtemp));
192 ptemp = (unsigned long *)(pglyph + ((xtemp *3)>> 2));
194 ptemp = (unsigned long *)(pglyph + (xtemp >> MFB_PWSH));
197 getstipplepixels24(ptemp,xtemp,0,&bgfill,&tmpDst1, xtemp);
198 getstipplepixels24(ptemp,xtemp,1,&fgfill,&tmpDst2, xtemp);
200 getstipplepixels(ptemp,xtemp,w,0,&bgfill,&tmpDst1);
201 getstipplepixels(ptemp,xtemp,w,1,&fgfill,&tmpDst2);
205 unsigned long tmpDst = tmpDst1 | tmpDst2;
207 unsigned long *pdsttmp = pdst + ((x*3) >> 2);
208 putbits24(tmpDst,tmpx,w,pdsttmp,pGC->planemask,x);
210 unsigned long *pdsttmp = pdst + (x >> PWSH);
211 putbits(tmpDst,tmpx,w,pdsttmp,pGC->planemask);
218 pglyph += widthGlyph;