1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
49 #ifdef HAVE_DIX_CONFIG_H
50 #include <dix-config.h>
55 #include <X11/Xproto.h>
57 #include <X11/fonts/fontstruct.h>
58 #include "dixfontstr.h"
60 #include "windowstr.h"
61 #include "scrnintstr.h"
67 machine-independent glyph blt.
68 assumes that glyph bits in snf are written in bytes,
69 have same bit order as the server's bitmap format,
70 and are byte padded. this corresponds to the snf distributed
71 with the sample server.
74 in the scratch GC set alu = GXcopy, fg = 1, bg = 0
75 allocate a bitmap big enough to hold the largest glyph in the font
76 validate the scratch gc with the bitmap
78 carefully put the bits of the glyph in a buffer,
79 padded to the server pixmap scanline padding rules
80 fake a call to PutImage from the buffer into the bitmap
81 use the bitmap in a call to PushPixels
85 miPolyGlyphBlt(pDrawable
, pGC
, x
, y
, nglyph
, ppci
, pglyphBase
)
86 DrawablePtr pDrawable
;
90 CharInfoPtr
*ppci
; /* array of character info */
91 pointer pglyphBase
; /* start of array of glyphs */
95 int nbyLine
; /* bytes per line of padded pixmap */
100 unsigned char *pbits
; /* buffer for PutImage */
101 unsigned char *pb
; /* temp pointer into buffer */
102 CharInfoPtr pci
; /* currect char info */
103 unsigned char *pglyph
; /* pointer bits in glyph */
104 int gWidth
, gHeight
; /* width and height of glyph */
105 int nbyGlyphWidth
; /* bytes per scanline of glyph */
106 int nbyPadGlyph
; /* server padded line of glyph */
110 if (pGC
->miTranslate
)
117 width
= FONTMAXBOUNDS(pfont
,rightSideBearing
) -
118 FONTMINBOUNDS(pfont
,leftSideBearing
);
119 height
= FONTMAXBOUNDS(pfont
,ascent
) +
120 FONTMAXBOUNDS(pfont
,descent
);
122 pPixmap
= (*pDrawable
->pScreen
->CreatePixmap
)(pDrawable
->pScreen
,
127 pGCtmp
= GetScratchGC(1, pDrawable
->pScreen
);
130 (*pDrawable
->pScreen
->DestroyPixmap
)(pPixmap
);
138 DoChangeGC(pGCtmp
, GCFunction
|GCForeground
|GCBackground
, gcvals
, 0);
140 nbyLine
= BitmapBytePad(width
);
141 pbits
= (unsigned char *)ALLOCATE_LOCAL(height
*nbyLine
);
144 (*pDrawable
->pScreen
->DestroyPixmap
)(pPixmap
);
145 FreeScratchGC(pGCtmp
);
151 pglyph
= FONTGLYPHBITS(pglyphBase
, pci
);
152 gWidth
= GLYPHWIDTHPIXELS(pci
);
153 gHeight
= GLYPHHEIGHTPIXELS(pci
);
154 if (gWidth
&& gHeight
)
156 nbyGlyphWidth
= GLYPHWIDTHBYTESPADDED(pci
);
157 nbyPadGlyph
= BitmapBytePad(gWidth
);
159 if (nbyGlyphWidth
== nbyPadGlyph
160 #if GLYPHPADBYTES != 4
161 && (((int) pglyph
) & 3) == 0
169 for (i
=0, pb
= pbits
; i
<gHeight
; i
++, pb
= pbits
+(i
*nbyPadGlyph
))
170 for (j
= 0; j
< nbyGlyphWidth
; j
++)
175 if ((pGCtmp
->serialNumber
) != (pPixmap
->drawable
.serialNumber
))
176 ValidateGC((DrawablePtr
)pPixmap
, pGCtmp
);
177 (*pGCtmp
->ops
->PutImage
)((DrawablePtr
)pPixmap
, pGCtmp
,
178 pPixmap
->drawable
.depth
,
179 0, 0, gWidth
, gHeight
,
180 0, XYBitmap
, (char *)pb
);
182 if ((pGC
->serialNumber
) != (pDrawable
->serialNumber
))
183 ValidateGC(pDrawable
, pGC
);
184 (*pGC
->ops
->PushPixels
)(pGC
, pPixmap
, pDrawable
,
186 x
+ pci
->metrics
.leftSideBearing
,
187 y
- pci
->metrics
.ascent
);
189 x
+= pci
->metrics
.characterWidth
;
191 (*pDrawable
->pScreen
->DestroyPixmap
)(pPixmap
);
192 DEALLOCATE_LOCAL(pbits
);
193 FreeScratchGC(pGCtmp
);
198 miImageGlyphBlt(pDrawable
, pGC
, x
, y
, nglyph
, ppci
, pglyphBase
)
199 DrawablePtr pDrawable
;
203 CharInfoPtr
*ppci
; /* array of character info */
204 pointer pglyphBase
; /* start of array of glyphs */
206 ExtentInfoRec info
; /* used by QueryGlyphExtents() */
212 QueryGlyphExtents(pGC
->font
, ppci
, (unsigned long)nglyph
, &info
);
214 if (info
.overallWidth
>= 0)
217 backrect
.width
= info
.overallWidth
;
221 backrect
.x
= x
+ info
.overallWidth
;
222 backrect
.width
= -info
.overallWidth
;
224 backrect
.y
= y
- FONTASCENT(pGC
->font
);
225 backrect
.height
= FONTASCENT(pGC
->font
) + FONTDESCENT(pGC
->font
);
228 oldFG
= pGC
->fgPixel
;
229 oldFS
= pGC
->fillStyle
;
231 /* fill in the background */
233 gcvals
[1] = pGC
->bgPixel
;
234 gcvals
[2] = FillSolid
;
235 DoChangeGC(pGC
, GCFunction
|GCForeground
|GCFillStyle
, gcvals
, 0);
236 ValidateGC(pDrawable
, pGC
);
237 (*pGC
->ops
->PolyFillRect
)(pDrawable
, pGC
, 1, &backrect
);
239 /* put down the glyphs */
241 DoChangeGC(pGC
, GCForeground
, gcvals
, 0);
242 ValidateGC(pDrawable
, pGC
);
243 (*pGC
->ops
->PolyGlyphBlt
)(pDrawable
, pGC
, x
, y
, nglyph
, ppci
,
246 /* put all the toys away when done playing */
250 DoChangeGC(pGC
, GCFunction
|GCForeground
|GCFillStyle
, gcvals
, 0);
251 ValidateGC(pDrawable
, pGC
);