2
* $XdotOrg: xserver/xorg/fb/fbglyph.c,v 1.5 2005/07/03 07:01:23 daniels Exp $
3
* $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.12tsi Exp $
5
* Copyright Ā© 1998 Keith Packard
7
* Permission to use, copy, modify, distribute, and sell this software and its
8
* documentation for any purpose is hereby granted without fee, provided that
9
* the above copyright notice appear in all copies and that both that
10
* copyright notice and this permission notice appear in supporting
11
* documentation, and that the name of Keith Packard not be used in
12
* advertising or publicity pertaining to distribution of the software without
13
* specific, written prior permission. Keith Packard makes no
14
* representations about the suitability of this software for any purpose. It
15
* is provided "as is" without express or implied warranty.
17
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
* PERFORMANCE OF THIS SOFTWARE.
26
#ifdef HAVE_DIX_CONFIG_H
27
#include <dix-config.h>
31
#include <X11/fonts/fontstruct.h>
32
#include "dixfontstr.h"
34
#define dummyScreen screenInfo.screens[0]
37
fbGlyphIn (RegionPtr pRegion,
44
BoxPtr pExtents = REGION_EXTENTS (dummyScreen, pRegion);
47
* Check extents by hand to avoid 16 bit overflows
49
if (x < (int) pExtents->x1)
51
if ((int) pExtents->x2 < x + width)
53
if (y < (int) pExtents->y1)
55
if ((int) pExtents->y2 < y + height)
61
return RECT_IN_REGION (dummyScreen, pRegion, &box) == rgnIN;
67
#define WRITE1(d,n,fg) ((d)[n] = (CARD8) fg)
68
#define WRITE2(d,n,fg) (*(CARD16 *) &(d[n]) = (CARD16) fg)
69
#define WRITE4(d,n,fg) (*(CARD32 *) &(d[n]) = (CARD32) fg)
70
#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
71
#define WRITE8(d) (*(FbBits *) &(d[0]) = fg)
73
#define WRITE8(d) WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
77
* This is a bit tricky, but it's brief. Write 12 bytes worth
78
* of dest, which is four pixels, at a time. This gives constant
79
* code for each pattern as they're always aligned the same
81
* a b c d a b c d a b c d bytes
82
* A B C A B C A B C A B C pixels
85
* A B C A B C A B C A B C pixels LSB
86
* C A B C A B C A B C A B pixels MSB
110
#if IMAGE_BYTE_ORDER == MSBFirst
120
#define CASE(a,b,c,d) ((a << 3) | (b << 2) | (c << 1) | d)
131
#define CASE(a,b,c,d) (a | (b << 1) | (c << 2) | (d << 3))
135
fbGlyph24 (FbBits *dstBits,
155
dstLine = (CARD8 *) dstBits;
156
dstLine += (x & ~3) * 3;
157
dstStride *= (sizeof (FbBits) / sizeof (CARD8));
167
switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
248
bits = FbStipLeft (bits, n);
252
dstLine += dstStride;
259
fbPolyGlyphBlt (DrawablePtr pDrawable,
267
FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
269
unsigned char *pglyph; /* pointer bits in glyph */
271
int gWidth, gHeight; /* width and height of glyph */
272
FbStride gStride; /* stride of glyph */
274
void (*glyph) (FbBits *,
282
FbStride dstStride = 0;
284
int dstXoff = 0, dstYoff = 0;
287
if (pGC->fillStyle == FillSolid && pPriv->and == 0)
289
fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
291
case 8: glyph = fbGlyph8; break;
292
case 16: glyph = fbGlyph16; break;
294
case 24: glyph = fbGlyph24; break;
296
case 32: glyph = fbGlyph32; break;
306
pglyph = FONTGLYPHBITS(pglyphBase, pci);
307
gWidth = GLYPHWIDTHPIXELS(pci);
308
gHeight = GLYPHHEIGHTPIXELS(pci);
309
if (gWidth && gHeight)
311
gx = x + pci->metrics.leftSideBearing;
312
gy = y - pci->metrics.ascent;
314
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
315
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
317
(*glyph) (dst + (gy + dstYoff) * dstStride,
328
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
329
fbPushImage (pDrawable,
341
x += pci->metrics.characterWidth;
347
fbImageGlyphBlt (DrawablePtr pDrawable,
352
CharInfoPtr *ppciInit,
355
FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
358
unsigned char *pglyph; /* pointer bits in glyph */
359
int gWidth, gHeight; /* width and height of glyph */
360
FbStride gStride; /* stride of glyph */
365
void (*glyph) (FbBits *,
373
FbStride dstStride = 0;
375
int dstXoff = 0, dstYoff = 0;
380
fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
382
case 8: glyph = fbGlyph8; break;
383
case 16: glyph = fbGlyph16; break;
385
case 24: glyph = fbGlyph24; break;
387
case 32: glyph = fbGlyph32; break;
395
if (TERMINALFONT (pGC->font)
405
int xBack, widthBack;
406
int yBack, heightBack;
412
widthBack += (*ppci++)->metrics.characterWidth;
418
widthBack = -widthBack;
420
yBack = y - FONTASCENT(pGC->font);
421
heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
422
fbSolidBoxClipped (pDrawable,
423
fbGetCompositeClip(pGC),
428
fbAnd(GXcopy,pPriv->bg,pPriv->pm),
429
fbXor(GXcopy,pPriv->bg,pPriv->pm));
437
pglyph = FONTGLYPHBITS(pglyphBase, pci);
438
gWidth = GLYPHWIDTHPIXELS(pci);
439
gHeight = GLYPHHEIGHTPIXELS(pci);
440
if (gWidth && gHeight)
442
gx = x + pci->metrics.leftSideBearing;
443
gy = y - pci->metrics.ascent;
445
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
446
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
448
(*glyph) (dst + (gy + dstYoff) * dstStride,
459
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
460
fbPutXYImage (pDrawable,
461
fbGetCompositeClip(pGC),
477
x += pci->metrics.characterWidth;