2
/* $XConsortium: ipltegblt.c,v 5.9 94/04/17 20:29:03 dpw 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
******************************************************************/
51
/* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
54
#ifdef HAVE_DIX_CONFIG_H
55
#include <dix-config.h>
60
#include <X11/Xproto.h>
62
#include <X11/fonts/fontstruct.h>
63
#include "dixfontstr.h"
65
#include "windowstr.h"
66
#include "scrnintstr.h"
67
#include "pixmapstr.h"
68
#include "regionstr.h"
70
#define MFB_CONSTS_ONLY
73
#include "iplmskbits.h"
76
this works for fonts with glyphs <= 32 bits wide, on an
77
arbitrarily deep display. Use iplTEGlyphBlt8 for 8 bit displays.
79
This should be called only with a terminal-emulator font;
80
this means that the FIXED_METRICS flag is set, and that
81
glyphbounds == charbounds.
83
in theory, this goes faster; even if it doesn't, it reduces the
84
flicker caused by writing a string over itself with image text (since
85
the background gets repainted per character instead of per string.)
86
this seems to be important for some converted X10 applications.
88
Image text looks at the bits in the glyph and the fg and bg in the
89
GC. it paints a rectangle, as defined in the protocol dcoument,
90
and the paints the characters.
95
iplTEGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
96
DrawablePtr pDrawable;
100
CharInfoPtr *ppci; /* array of character info */
101
pointer pglyphBase; /* start of array of glyphs */
103
FontPtr pfont = pGC->font;
105
INTER_DECLAREG(*pdstBase); /* pointer to group with top row
108
int w; /* width of glyph and char */
109
int h; /* height of glyph and char */
110
register int xpos=x; /* current x%32 */
111
int ypos=y; /* current y%32 */
112
register unsigned char *pglyph;
115
INTER_DECLAREG(*pdst); /* pointer to current group in dst */
116
int hTmp; /* counter for height */
117
BoxRec bbox; /* for clipping */
119
register int wtmp,xtemp,width;
120
INTER_DECLAREGP(bgfill);
121
INTER_DECLAREGP(fgfill);
122
unsigned long *ptemp;
123
INTER_DECLAREGP(tmpDst1);
124
INTER_DECLAREGP(tmpDst2);
125
INTER_DECLAREG(*pdtmp);
128
xpos += pDrawable->x;
129
ypos += pDrawable->y;
131
iplGetGroupWidthAndPointer (pDrawable, widthDst, pdstBase)
133
wtmp = FONTMAXBOUNDS(pfont,characterWidth);
134
h = FONTASCENT(pfont) + FONTDESCENT(pfont);
135
widthGlyph = GLYPHWIDTHBYTESPADDED(*ppci);
137
xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
138
ypos -= FONTASCENT(pfont);
141
bbox.x2 = xpos + (wtmp * nglyph);
145
INTER_PFILL(pGC->fgPixel, fgfill);
146
INTER_PFILL(pGC->bgPixel, bgfill);
148
switch (RECT_IN_REGION(pGC->pScreen, iplGetCompositeClip(pGC), &bbox))
153
/* this is the WRONG thing to do, but it works.
154
calling the non-terminal text is easy, but slow, given
155
what we know about the font.
157
the right thing to do is something like:
158
for each clip rectangle
159
compute at which row the glyph starts to be in it,
160
and at which row the glyph ceases to be in it
161
compute which is the first glyph inside the left
162
edge, and the last one inside the right edge
163
draw a fractional first glyph, using only
164
the rows we know are in
165
draw all the whole glyphs, using the appropriate rows
166
draw any pieces of the last glyph, using the right rows
168
this way, the code would take advantage of knowing that
169
all glyphs are the same height and don't overlap.
174
miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
179
pdtmp = pdstBase + (widthDst * ypos);
183
pglyph = FONTGLYPHBITS(pglyphBase, *ppci++);
195
tmpx = x & INTER_PIM;
196
w = min(width, INTER_PPG - tmpx);
197
/* w = min(w, (PGSZ - xtemp)); */
199
ptemp = (unsigned long *)(pglyph + (xtemp >> MFB_PWSH));
201
INTER_getstipplepixelsb(ptemp,xtemp,w,bgfill,fgfill,tmpDst1);
204
INTER_DECLAREG(*pdsttmp) =
205
pdst + (x >> INTER_PGSH) * INTER_PLANES;
207
INTER_putbits(tmpDst1,tmpx,w,pdsttmp,pGC->planemask);
214
pglyph += widthGlyph;