1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEText.c,v 1.6 1998/12/20 11:57:52 dawes Exp $ */
/********************************************************************
In this file we have GC level replacements for PolyText8/16,
ImageText8/16, ImageGlyphBlt and PolyGlyphBlt for TE (fixed) fonts.
The idea is that everything in this file is device independent.
The mentioned GCOps are merely wrappers for XAAGlyphBltTEColorExpansion
which calculates the boxes containing arbitrarily clipped text
and passes them to the TEGlyphRenderer which will usually be a lower
level XAA function which renders these clipped glyphs using
the basic color expansion functions exported by the chipset driver.
The TEGlyphRenderer itself may optionally be driver supplied to
facilitate work-arounds/optimizations at a higher level than usual.
v1.0 - Mark Vojkovich (mvojkovi@ucsd.edu)
********************************************************************/
#include <X11/misc.h>
#include "xf86.h"
#include "xf86_ansic.h"
#include "xf86_OSproc.h"
#include <X11/X.h>
#include "font.h"
#include "scrnintstr.h"
#include "dixfontstr.h"
#include "xf86str.h"
#include "xaa.h"
#include "xaalocal.h"
#include "gcstruct.h"
#include "pixmapstr.h"
static void XAAGlyphBltTEColorExpansion(ScrnInfoPtr pScrn, int xInit,
int yInit, FontPtr font, int fg, int bg, int rop,
unsigned int planemask, RegionPtr cclip, int nglyph,
unsigned char* gBase, CharInfoPtr *ppci);
/********************************************************************
GC level replacements for PolyText8/16 and ImageText8/16
for TE fonts when using color expansion.
********************************************************************/
int
XAAPolyText8TEColorExpansion(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
int count,
char *chars )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
(unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
/* we have divorced XAAGlyphBltTEColorExpansion from the drawable */
if(n) XAAGlyphBltTEColorExpansion(
infoRec->pScrn, x + pDraw->x, y + pDraw->y,
pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
}
int
XAAPolyText16TEColorExpansion(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
int count,
unsigned short *chars )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
(*pGC->font->get_glyphs)(
pGC->font, (unsigned long)count, (unsigned char *)chars,
(FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
&n, infoRec->CharInfo);
if(n) XAAGlyphBltTEColorExpansion(
infoRec->pScrn, x + pDraw->x, y + pDraw->y,
pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
return (x + (n * FONTMAXBOUNDS(pGC->font, characterWidth)));
}
void
XAAImageText8TEColorExpansion(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
int count,
char *chars )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
if(!REGION_NUM_RECTS(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
(unsigned char *)chars, Linear8Bit, &n, infoRec->CharInfo);
if(n) XAAGlyphBltTEColorExpansion(
infoRec->pScrn, x + pDraw->x, y + pDraw->y,
pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
}
void
XAAImageText16TEColorExpansion(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
int count,
unsigned short *chars )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
if(!REGION_NUM_RECTS(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(
pGC->font, (unsigned long)count, (unsigned char *)chars,
(FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
&n, infoRec->CharInfo);
if(n) XAAGlyphBltTEColorExpansion(
infoRec->pScrn, x + pDraw->x, y + pDraw->y,
pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
pGC->pCompositeClip, n, FONTGLYPHS(pGC->font), infoRec->CharInfo);
}
/********************************************************************
GC level replacements for ImageGlyphBlt and PolyGlyphBlt for
TE fonts when using color expansion.
********************************************************************/
void
XAAImageGlyphBltTEColorExpansion(
DrawablePtr pDrawable,
GCPtr pGC,
int xInit, int yInit,
unsigned int nglyph,
CharInfoPtr *ppci,
pointer pglyphBase )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
if(!REGION_NUM_RECTS(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y,
pGC->font, pGC->fgPixel, pGC->bgPixel, GXcopy, pGC->planemask,
pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
}
void
XAAPolyGlyphBltTEColorExpansion(
DrawablePtr pDrawable,
GCPtr pGC,
int xInit, int yInit,
unsigned int nglyph,
CharInfoPtr *ppci,
pointer pglyphBase )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
if(!REGION_NUM_RECTS(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
infoRec->pScrn, xInit + pDrawable->x, yInit + pDrawable->y,
pGC->font, pGC->fgPixel, -1, pGC->alu, pGC->planemask,
pGC->pCompositeClip, nglyph, (unsigned char*)pglyphBase, ppci);
}
/********************************************************************
XAAGlyphBltTEColorExpansion -
This guy computes the clipped pieces of text and sends it to
the lower-level function which will handle acceleration of
arbitrarily clipped text.
********************************************************************/
static void
XAAGlyphBltTEColorExpansion(
ScrnInfoPtr pScrn,
int xInit, int yInit,
FontPtr font,
int fg, int bg,
int rop,
unsigned int planemask,
RegionPtr cclip,
int nglyph,
unsigned char* gBase,
CharInfoPtr *ppci )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
int skippix, skipglyphs;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge, ytop, ybot;
int nbox = REGION_NUM_RECTS(cclip);
BoxPtr pbox = REGION_RECTS(cclip);
unsigned int **glyphs = NULL;
int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
/* find the size of the box */
Left = xInit;
Right = Left + (glyphWidth * nglyph);
Top = yInit - FONTASCENT(font);
Bottom = yInit + FONTDESCENT(font);
/* get into the first band that may contain part of our string */
while(nbox && (Top >= pbox->y2)) {
pbox++; nbox--;
}
/* stop when the lower edge of the box is beyond our string */
while(nbox && (Bottom > pbox->y1)) {
LeftEdge = max(Left, pbox->x1);
RightEdge = min(Right, pbox->x2);
if(RightEdge > LeftEdge) { /* we have something to draw */
ytop = max(Top, pbox->y1);
ybot = min(Bottom, pbox->y2);
if((skippix = LeftEdge - Left)) {
skipglyphs = skippix/glyphWidth;
skippix %= glyphWidth;
} else skipglyphs = 0;
if(!glyphs) {
int count;
glyphs = (unsigned int**)(infoRec->PreAllocMem);
for(count = 0; count < nglyph; count++)
glyphs[count] = (unsigned int*)
FONTGLYPHBITS(gBase,*ppci++);
/* our new unrolled TE code only writes DWORDS at a time
so it can read up to 6 characters past the last one
we're displaying */
glyphs[count + 0] = glyphs[0];
glyphs[count + 1] = glyphs[0];
glyphs[count + 2] = glyphs[0];
glyphs[count + 3] = glyphs[0];
glyphs[count + 4] = glyphs[0];
glyphs[count + 5] = glyphs[0];
}
/* x, y, w, h, skipleft, skiptop, glyphp, glyphWidth, fg, bg, rop, pm */
(*infoRec->TEGlyphRenderer)( pScrn,
LeftEdge, ytop, RightEdge - LeftEdge, ybot - ytop,
skippix, ytop - Top, glyphs + skipglyphs, glyphWidth,
fg, bg, rop, planemask);
}
nbox--; pbox++;
}
}
|