First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xgl / xglsolid.c
blob8657a9a165d3ebef396980ea74409a3419e3724a
1 /*
2 * Copyright © 2004 David Reveman
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * David Reveman not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * David Reveman makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
15 * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: David Reveman <davidr@novell.com>
26 #include "xgl.h"
27 #include "gcstruct.h"
28 #include <X11/fonts/fontstruct.h>
29 #include "dixfontstr.h"
31 Bool
32 xglSolid (DrawablePtr pDrawable,
33 glitz_operator_t op,
34 glitz_surface_t *solid,
35 xglGeometryPtr pGeometry,
36 int x,
37 int y,
38 int width,
39 int height,
40 BoxPtr pBox,
41 int nBox)
43 glitz_surface_t *surface;
44 int xOff, yOff;
46 if (nBox < 1)
47 return TRUE;
49 if (!xglPrepareTarget (pDrawable))
50 return FALSE;
52 XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
54 if (pGeometry)
56 glitz_surface_set_clip_region (surface, xOff, yOff,
57 (glitz_box_t *) pBox, nBox);
59 else
61 pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen, 4 * nBox);
62 GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
65 GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
67 if (!GEOMETRY_ENABLE (pGeometry, surface))
68 return FALSE;
70 glitz_composite (op,
71 solid, NULL, surface,
72 0, 0,
73 0, 0,
74 x + xOff,
75 y + yOff,
76 width, height);
78 glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
80 if (glitz_surface_get_status (surface))
81 return FALSE;
83 return TRUE;
86 Bool
87 xglSolidGlyph (DrawablePtr pDrawable,
88 GCPtr pGC,
89 int x,
90 int y,
91 unsigned int nGlyph,
92 CharInfoPtr *ppci,
93 pointer pglyphBase)
95 xglGeometryRec geometry;
96 int xBack, widthBack;
97 int yBack, heightBack;
99 XGL_GC_PRIV (pGC);
101 x += pDrawable->x;
102 y += pDrawable->y;
104 GEOMETRY_INIT (pDrawable->pScreen, &geometry,
105 GLITZ_GEOMETRY_TYPE_BITMAP,
106 GEOMETRY_USAGE_SYSMEM, 0);
108 GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
109 &geometry,
110 nGlyph,
111 ppci,
112 pglyphBase);
114 GEOMETRY_TRANSLATE (&geometry, x, y);
116 widthBack = 0;
117 while (nGlyph--)
118 widthBack += (*ppci++)->metrics.characterWidth;
120 xBack = x;
121 if (widthBack < 0)
123 xBack += widthBack;
124 widthBack = -widthBack;
126 yBack = y - FONTASCENT (pGC->font);
127 heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font);
129 if (xglSolid (pDrawable,
130 pGCPriv->op,
131 pGCPriv->bg,
132 NULL,
133 xBack,
134 yBack,
135 widthBack,
136 heightBack,
137 REGION_RECTS (pGC->pCompositeClip),
138 REGION_NUM_RECTS (pGC->pCompositeClip)))
140 if (xglSolid (pDrawable,
141 pGCPriv->op,
142 pGCPriv->fg,
143 &geometry,
144 xBack,
145 yBack,
146 widthBack,
147 heightBack,
148 REGION_RECTS (pGC->pCompositeClip),
149 REGION_NUM_RECTS (pGC->pCompositeClip)))
151 GEOMETRY_UNINIT (&geometry);
152 xglAddCurrentBitDamage (pDrawable);
153 return TRUE;
157 GEOMETRY_UNINIT (&geometry);
158 return FALSE;