3 * Copyright © 2000 SuSE, Inc.
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
9 * documentation, and that the name of SuSE not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. SuSE makes no representations about the
12 * suitability of this software for any purpose. It is provided "as is"
13 * without express or implied warranty.
15 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Author: Keith Packard, SuSE, Inc.
25 #ifdef HAVE_DIX_CONFIG_H
26 #include <dix-config.h>
29 #include "scrnintstr.h"
31 #include "pixmapstr.h"
32 #include "windowstr.h"
34 #include "picturestr.h"
38 miRealizeGlyph (ScreenPtr pScreen
,
45 miUnrealizeGlyph (ScreenPtr pScreen
,
51 miGlyphExtents (int nlist
,
63 extents
->x1
= MAXSHORT
;
64 extents
->x2
= MINSHORT
;
65 extents
->y1
= MAXSHORT
;
66 extents
->y2
= MINSHORT
;
76 x1
= x
- glyph
->info
.x
;
79 y1
= y
- glyph
->info
.y
;
82 x2
= x1
+ glyph
->info
.width
;
85 y2
= y1
+ glyph
->info
.height
;
96 x
+= glyph
->info
.xOff
;
97 y
+= glyph
->info
.yOff
;
102 #define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
108 PictFormatPtr maskFormat
,
115 PixmapPtr pPixmap
= 0;
117 PixmapPtr pMaskPixmap
= 0;
119 ScreenPtr pScreen
= pDst
->pDrawable
->pScreen
;
120 int width
= 0, height
= 0;
122 int xDst
= list
->xOff
, yDst
= list
->yOff
;
127 CARD32 component_alpha
;
134 miGlyphExtents (nlist
, list
, glyphs
, &extents
);
136 if (extents
.x2
<= extents
.x1
|| extents
.y2
<= extents
.y1
)
138 width
= extents
.x2
- extents
.x1
;
139 height
= extents
.y2
- extents
.y1
;
140 pMaskPixmap
= (*pScreen
->CreatePixmap
) (pScreen
, width
, height
, maskFormat
->depth
);
143 component_alpha
= NeedsComponent(maskFormat
->format
);
144 pMask
= CreatePicture (0, &pMaskPixmap
->drawable
,
145 maskFormat
, CPComponentAlpha
, &component_alpha
,
146 serverClient
, &error
);
149 (*pScreen
->DestroyPixmap
) (pMaskPixmap
);
152 pGC
= GetScratchGC (pMaskPixmap
->drawable
.depth
, pScreen
);
153 ValidateGC (&pMaskPixmap
->drawable
, pGC
);
157 rect
.height
= height
;
158 (*pGC
->ops
->PolyFillRect
) (&pMaskPixmap
->drawable
, pGC
, 1, &rect
);
180 pPixmap
= GetScratchPixmapHeader (pScreen
, glyph
->info
.width
, glyph
->info
.height
,
183 0, (pointer
) (glyph
+ 1));
186 component_alpha
= NeedsComponent(list
->format
->format
);
187 pPicture
= CreatePicture (0, &pPixmap
->drawable
, list
->format
,
188 CPComponentAlpha
, &component_alpha
,
189 serverClient
, &error
);
192 FreeScratchPixmapHeader (pPixmap
);
196 (*pScreen
->ModifyPixmapHeader
) (pPixmap
,
197 glyph
->info
.width
, glyph
->info
.height
,
198 0, 0, -1, (pointer
) (glyph
+ 1));
199 pPixmap
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
202 CompositePicture (PictOpAdd
,
215 CompositePicture (op
,
219 xSrc
+ (x
- glyph
->info
.x
) - xDst
,
220 ySrc
+ (y
- glyph
->info
.y
) - yDst
,
227 x
+= glyph
->info
.xOff
;
228 y
+= glyph
->info
.yOff
;
233 FreeScratchPixmapHeader (pPixmap
);
234 FreePicture ((pointer
) pPicture
, 0);
243 CompositePicture (op
,
252 FreePicture ((pointer
) pMask
, (XID
) 0);
253 (*pScreen
->DestroyPixmap
) (pMaskPixmap
);