1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * All Rights Reserved.
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining
7*4882a593Smuzhiyun * a copy of this software and associated documentation files (the
8*4882a593Smuzhiyun * "Software"), to deal in the Software without restriction, including
9*4882a593Smuzhiyun * without limitation on the rights to use, copy, modify, merge,
10*4882a593Smuzhiyun * publish, distribute, sublicense, and/or sell copies of the Software,
11*4882a593Smuzhiyun * and to permit persons to whom the Software is furnished to do so,
12*4882a593Smuzhiyun * subject to the following conditions:
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the
15*4882a593Smuzhiyun * next paragraph) shall be included in all copies or substantial
16*4882a593Smuzhiyun * portions of the Software.
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21*4882a593Smuzhiyun * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
22*4882a593Smuzhiyun * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23*4882a593Smuzhiyun * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24*4882a593Smuzhiyun * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25*4882a593Smuzhiyun * SOFTWARE.
26*4882a593Smuzhiyun */
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun * Authors:
30*4882a593Smuzhiyun * Kevin E. Martin <kem@redhat.com>
31*4882a593Smuzhiyun *
32*4882a593Smuzhiyun */
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun /** \file
35*4882a593Smuzhiyun * Provide support for the RENDER extension (version 0.8).
36*4882a593Smuzhiyun */
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun #ifdef HAVE_DMX_CONFIG_H
39*4882a593Smuzhiyun #include <dmx-config.h>
40*4882a593Smuzhiyun #endif
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun #include "dmx.h"
43*4882a593Smuzhiyun #include "dmxsync.h"
44*4882a593Smuzhiyun #include "dmxpict.h"
45*4882a593Smuzhiyun #include "dmxwindow.h"
46*4882a593Smuzhiyun #include "dmxpixmap.h"
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun #include "fb.h"
49*4882a593Smuzhiyun #include "pixmapstr.h"
50*4882a593Smuzhiyun #include "dixstruct.h"
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun #include <X11/extensions/render.h>
53*4882a593Smuzhiyun #include <X11/extensions/renderproto.h>
54*4882a593Smuzhiyun #include <X11/extensions/Xfixes.h>
55*4882a593Smuzhiyun #include "picture.h"
56*4882a593Smuzhiyun #include "picturestr.h"
57*4882a593Smuzhiyun #include "mipict.h"
58*4882a593Smuzhiyun #include "fbpict.h"
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun extern int (*ProcRenderVector[RenderNumberRequests]) (ClientPtr);
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun static int (*dmxSaveRenderVector[RenderNumberRequests]) (ClientPtr);
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun static int dmxProcRenderCreateGlyphSet(ClientPtr client);
65*4882a593Smuzhiyun static int dmxProcRenderFreeGlyphSet(ClientPtr client);
66*4882a593Smuzhiyun static int dmxProcRenderAddGlyphs(ClientPtr client);
67*4882a593Smuzhiyun static int dmxProcRenderFreeGlyphs(ClientPtr client);
68*4882a593Smuzhiyun static int dmxProcRenderCompositeGlyphs(ClientPtr client);
69*4882a593Smuzhiyun static int dmxProcRenderSetPictureTransform(ClientPtr client);
70*4882a593Smuzhiyun static int dmxProcRenderSetPictureFilter(ClientPtr client);
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun #if 0
73*4882a593Smuzhiyun /* FIXME: Not (yet) supported */
74*4882a593Smuzhiyun static int dmxProcRenderCreateCursor(ClientPtr client);
75*4882a593Smuzhiyun static int dmxProcRenderCreateAnimCursor(ClientPtr client);
76*4882a593Smuzhiyun #endif
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun /** Catch errors that might occur when allocating Glyph Sets. Errors
79*4882a593Smuzhiyun * are saved in dmxGlyphLastError for later handling. */
80*4882a593Smuzhiyun static int dmxGlyphLastError;
81*4882a593Smuzhiyun static int
dmxGlyphErrorHandler(Display * dpy,XErrorEvent * ev)82*4882a593Smuzhiyun dmxGlyphErrorHandler(Display * dpy, XErrorEvent * ev)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun dmxGlyphLastError = ev->error_code;
85*4882a593Smuzhiyun return 0;
86*4882a593Smuzhiyun }
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun /** Initialize the Proc Vector for the RENDER extension. The functions
89*4882a593Smuzhiyun * here cannot be handled by the mi layer RENDER hooks either because
90*4882a593Smuzhiyun * the required information is no longer available when it reaches the
91*4882a593Smuzhiyun * mi layer or no mi layer hooks exist. This function is called from
92*4882a593Smuzhiyun * InitOutput() since it should be initialized only once per server
93*4882a593Smuzhiyun * generation. */
94*4882a593Smuzhiyun void
dmxInitRender(void)95*4882a593Smuzhiyun dmxInitRender(void)
96*4882a593Smuzhiyun {
97*4882a593Smuzhiyun int i;
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun for (i = 0; i < RenderNumberRequests; i++)
100*4882a593Smuzhiyun dmxSaveRenderVector[i] = ProcRenderVector[i];
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun ProcRenderVector[X_RenderCreateGlyphSet]
103*4882a593Smuzhiyun = dmxProcRenderCreateGlyphSet;
104*4882a593Smuzhiyun ProcRenderVector[X_RenderFreeGlyphSet]
105*4882a593Smuzhiyun = dmxProcRenderFreeGlyphSet;
106*4882a593Smuzhiyun ProcRenderVector[X_RenderAddGlyphs]
107*4882a593Smuzhiyun = dmxProcRenderAddGlyphs;
108*4882a593Smuzhiyun ProcRenderVector[X_RenderFreeGlyphs]
109*4882a593Smuzhiyun = dmxProcRenderFreeGlyphs;
110*4882a593Smuzhiyun ProcRenderVector[X_RenderCompositeGlyphs8]
111*4882a593Smuzhiyun = dmxProcRenderCompositeGlyphs;
112*4882a593Smuzhiyun ProcRenderVector[X_RenderCompositeGlyphs16]
113*4882a593Smuzhiyun = dmxProcRenderCompositeGlyphs;
114*4882a593Smuzhiyun ProcRenderVector[X_RenderCompositeGlyphs32]
115*4882a593Smuzhiyun = dmxProcRenderCompositeGlyphs;
116*4882a593Smuzhiyun ProcRenderVector[X_RenderSetPictureTransform]
117*4882a593Smuzhiyun = dmxProcRenderSetPictureTransform;
118*4882a593Smuzhiyun ProcRenderVector[X_RenderSetPictureFilter]
119*4882a593Smuzhiyun = dmxProcRenderSetPictureFilter;
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun /** Reset the Proc Vector for the RENDER extension back to the original
123*4882a593Smuzhiyun * functions. This function is called from dmxCloseScreen() during the
124*4882a593Smuzhiyun * server reset (only for screen #0). */
125*4882a593Smuzhiyun void
dmxResetRender(void)126*4882a593Smuzhiyun dmxResetRender(void)
127*4882a593Smuzhiyun {
128*4882a593Smuzhiyun int i;
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun for (i = 0; i < RenderNumberRequests; i++)
131*4882a593Smuzhiyun ProcRenderVector[i] = dmxSaveRenderVector[i];
132*4882a593Smuzhiyun }
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun /** Initialize the RENDER extension, allocate the picture privates and
135*4882a593Smuzhiyun * wrap mi function hooks. If the shadow frame buffer is used, then
136*4882a593Smuzhiyun * call the appropriate fb initialization function. */
137*4882a593Smuzhiyun Bool
dmxPictureInit(ScreenPtr pScreen,PictFormatPtr formats,int nformats)138*4882a593Smuzhiyun dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
141*4882a593Smuzhiyun PictureScreenPtr ps;
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun if (!miPictureInit(pScreen, formats, nformats))
144*4882a593Smuzhiyun return FALSE;
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun if (!dixRegisterPrivateKey
147*4882a593Smuzhiyun (&dmxPictPrivateKeyRec, PRIVATE_PICTURE, sizeof(dmxPictPrivRec)))
148*4882a593Smuzhiyun return FALSE;
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun ps = GetPictureScreen(pScreen);
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps);
153*4882a593Smuzhiyun DMX_WRAP(DestroyPicture, dmxDestroyPicture, dmxScreen, ps);
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun DMX_WRAP(ChangePictureClip, dmxChangePictureClip, dmxScreen, ps);
156*4882a593Smuzhiyun DMX_WRAP(DestroyPictureClip, dmxDestroyPictureClip, dmxScreen, ps);
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun DMX_WRAP(ChangePicture, dmxChangePicture, dmxScreen, ps);
159*4882a593Smuzhiyun DMX_WRAP(ValidatePicture, dmxValidatePicture, dmxScreen, ps);
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun DMX_WRAP(Composite, dmxComposite, dmxScreen, ps);
162*4882a593Smuzhiyun DMX_WRAP(Glyphs, dmxGlyphs, dmxScreen, ps);
163*4882a593Smuzhiyun DMX_WRAP(CompositeRects, dmxCompositeRects, dmxScreen, ps);
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun DMX_WRAP(Trapezoids, dmxTrapezoids, dmxScreen, ps);
166*4882a593Smuzhiyun DMX_WRAP(Triangles, dmxTriangles, dmxScreen, ps);
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun return TRUE;
169*4882a593Smuzhiyun }
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun /** Find the appropriate format on the requested screen given the
172*4882a593Smuzhiyun * internal format requested. The list of formats is searched
173*4882a593Smuzhiyun * sequentially as the XRenderFindFormat() function does not always
174*4882a593Smuzhiyun * find the appropriate format when a specific format is requested. */
175*4882a593Smuzhiyun static XRenderPictFormat *
dmxFindFormat(DMXScreenInfo * dmxScreen,PictFormatPtr pFmt)176*4882a593Smuzhiyun dmxFindFormat(DMXScreenInfo * dmxScreen, PictFormatPtr pFmt)
177*4882a593Smuzhiyun {
178*4882a593Smuzhiyun XRenderPictFormat *pFormat = NULL;
179*4882a593Smuzhiyun int i = 0;
180*4882a593Smuzhiyun
181*4882a593Smuzhiyun if (!pFmt || !dmxScreen->beDisplay)
182*4882a593Smuzhiyun return pFormat;
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun while (1) {
185*4882a593Smuzhiyun pFormat = XRenderFindFormat(dmxScreen->beDisplay, 0, 0, i++);
186*4882a593Smuzhiyun if (!pFormat)
187*4882a593Smuzhiyun break;
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun if (pFormat->type != pFmt->type)
190*4882a593Smuzhiyun continue;
191*4882a593Smuzhiyun if (pFormat->depth != pFmt->depth)
192*4882a593Smuzhiyun continue;
193*4882a593Smuzhiyun if (pFormat->direct.red != pFmt->direct.red)
194*4882a593Smuzhiyun continue;
195*4882a593Smuzhiyun if (pFormat->direct.redMask != pFmt->direct.redMask)
196*4882a593Smuzhiyun continue;
197*4882a593Smuzhiyun if (pFormat->direct.green != pFmt->direct.green)
198*4882a593Smuzhiyun continue;
199*4882a593Smuzhiyun if (pFormat->direct.greenMask != pFmt->direct.greenMask)
200*4882a593Smuzhiyun continue;
201*4882a593Smuzhiyun if (pFormat->direct.blue != pFmt->direct.blue)
202*4882a593Smuzhiyun continue;
203*4882a593Smuzhiyun if (pFormat->direct.blueMask != pFmt->direct.blueMask)
204*4882a593Smuzhiyun continue;
205*4882a593Smuzhiyun if (pFormat->direct.alpha != pFmt->direct.alpha)
206*4882a593Smuzhiyun continue;
207*4882a593Smuzhiyun if (pFormat->direct.alphaMask != pFmt->direct.alphaMask)
208*4882a593Smuzhiyun continue;
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun /* We have a match! */
211*4882a593Smuzhiyun break;
212*4882a593Smuzhiyun }
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun return pFormat;
215*4882a593Smuzhiyun }
216*4882a593Smuzhiyun
217*4882a593Smuzhiyun /** Free \a glyphSet on back-end screen number \a idx. */
218*4882a593Smuzhiyun Bool
dmxBEFreeGlyphSet(ScreenPtr pScreen,GlyphSetPtr glyphSet)219*4882a593Smuzhiyun dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet)
220*4882a593Smuzhiyun {
221*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
222*4882a593Smuzhiyun int idx = pScreen->myNum;
223*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[idx];
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun if (glyphPriv->glyphSets[idx]) {
226*4882a593Smuzhiyun XRenderFreeGlyphSet(dmxScreen->beDisplay, glyphPriv->glyphSets[idx]);
227*4882a593Smuzhiyun glyphPriv->glyphSets[idx] = (GlyphSet) 0;
228*4882a593Smuzhiyun return TRUE;
229*4882a593Smuzhiyun }
230*4882a593Smuzhiyun
231*4882a593Smuzhiyun return FALSE;
232*4882a593Smuzhiyun }
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun /** Create \a glyphSet on the backend screen number \a idx. */
235*4882a593Smuzhiyun int
dmxBECreateGlyphSet(int idx,GlyphSetPtr glyphSet)236*4882a593Smuzhiyun dmxBECreateGlyphSet(int idx, GlyphSetPtr glyphSet)
237*4882a593Smuzhiyun {
238*4882a593Smuzhiyun XRenderPictFormat *pFormat;
239*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[idx];
240*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
241*4882a593Smuzhiyun PictFormatPtr pFmt = glyphSet->format;
242*4882a593Smuzhiyun int (*oldErrorHandler) (Display *, XErrorEvent *);
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun pFormat = dmxFindFormat(dmxScreen, pFmt);
245*4882a593Smuzhiyun if (!pFormat) {
246*4882a593Smuzhiyun return BadMatch;
247*4882a593Smuzhiyun }
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun dmxGlyphLastError = 0;
250*4882a593Smuzhiyun oldErrorHandler = XSetErrorHandler(dmxGlyphErrorHandler);
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun /* Catch when this fails */
253*4882a593Smuzhiyun glyphPriv->glyphSets[idx]
254*4882a593Smuzhiyun = XRenderCreateGlyphSet(dmxScreen->beDisplay, pFormat);
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun XSetErrorHandler(oldErrorHandler);
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun if (dmxGlyphLastError) {
259*4882a593Smuzhiyun return dmxGlyphLastError;
260*4882a593Smuzhiyun }
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun return Success;
263*4882a593Smuzhiyun }
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun /** Create a Glyph Set on each screen. Save the glyphset ID from each
266*4882a593Smuzhiyun * screen in the Glyph Set's private structure. Fail if the format
267*4882a593Smuzhiyun * requested is not available or if the Glyph Set cannot be created on
268*4882a593Smuzhiyun * the screen. */
269*4882a593Smuzhiyun static int
dmxProcRenderCreateGlyphSet(ClientPtr client)270*4882a593Smuzhiyun dmxProcRenderCreateGlyphSet(ClientPtr client)
271*4882a593Smuzhiyun {
272*4882a593Smuzhiyun int ret;
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun REQUEST(xRenderCreateGlyphSetReq);
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun ret = dmxSaveRenderVector[stuff->renderReqType] (client);
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun if (ret == Success) {
279*4882a593Smuzhiyun GlyphSetPtr glyphSet;
280*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv;
281*4882a593Smuzhiyun int i;
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun /* Look up glyphSet that was just created ???? */
284*4882a593Smuzhiyun /* Store glyphsets from backends in glyphSet->devPrivate ????? */
285*4882a593Smuzhiyun /* Make sure we handle all errors here!! */
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
288*4882a593Smuzhiyun stuff->gsid, GlyphSetType,
289*4882a593Smuzhiyun client, DixDestroyAccess);
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun glyphPriv = malloc(sizeof(dmxGlyphPrivRec));
292*4882a593Smuzhiyun if (!glyphPriv)
293*4882a593Smuzhiyun return BadAlloc;
294*4882a593Smuzhiyun glyphPriv->glyphSets = NULL;
295*4882a593Smuzhiyun MAXSCREENSALLOC_RETURN(glyphPriv->glyphSets, BadAlloc);
296*4882a593Smuzhiyun DMX_SET_GLYPH_PRIV(glyphSet, glyphPriv);
297*4882a593Smuzhiyun
298*4882a593Smuzhiyun for (i = 0; i < dmxNumScreens; i++) {
299*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[i];
300*4882a593Smuzhiyun int beret;
301*4882a593Smuzhiyun
302*4882a593Smuzhiyun if (!dmxScreen->beDisplay) {
303*4882a593Smuzhiyun glyphPriv->glyphSets[i] = 0;
304*4882a593Smuzhiyun continue;
305*4882a593Smuzhiyun }
306*4882a593Smuzhiyun
307*4882a593Smuzhiyun if ((beret = dmxBECreateGlyphSet(i, glyphSet)) != Success) {
308*4882a593Smuzhiyun int j;
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun /* Free the glyph sets we've allocated thus far */
311*4882a593Smuzhiyun for (j = 0; j < i; j++)
312*4882a593Smuzhiyun dmxBEFreeGlyphSet(screenInfo.screens[j], glyphSet);
313*4882a593Smuzhiyun
314*4882a593Smuzhiyun /* Free the resource created by render */
315*4882a593Smuzhiyun FreeResource(stuff->gsid, RT_NONE);
316*4882a593Smuzhiyun
317*4882a593Smuzhiyun return beret;
318*4882a593Smuzhiyun }
319*4882a593Smuzhiyun }
320*4882a593Smuzhiyun }
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun return ret;
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun /** Free the previously allocated Glyph Sets for each screen. */
326*4882a593Smuzhiyun static int
dmxProcRenderFreeGlyphSet(ClientPtr client)327*4882a593Smuzhiyun dmxProcRenderFreeGlyphSet(ClientPtr client)
328*4882a593Smuzhiyun {
329*4882a593Smuzhiyun GlyphSetPtr glyphSet;
330*4882a593Smuzhiyun
331*4882a593Smuzhiyun REQUEST(xRenderFreeGlyphSetReq);
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
334*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
335*4882a593Smuzhiyun stuff->glyphset, GlyphSetType,
336*4882a593Smuzhiyun client, DixDestroyAccess);
337*4882a593Smuzhiyun
338*4882a593Smuzhiyun if (glyphSet && glyphSet->refcnt == 1) {
339*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
340*4882a593Smuzhiyun int i;
341*4882a593Smuzhiyun
342*4882a593Smuzhiyun for (i = 0; i < dmxNumScreens; i++) {
343*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[i];
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun if (dmxScreen->beDisplay) {
346*4882a593Smuzhiyun if (dmxBEFreeGlyphSet(screenInfo.screens[i], glyphSet))
347*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
348*4882a593Smuzhiyun }
349*4882a593Smuzhiyun }
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun MAXSCREENSFREE(glyphPriv->glyphSets);
352*4882a593Smuzhiyun free(glyphPriv);
353*4882a593Smuzhiyun DMX_SET_GLYPH_PRIV(glyphSet, NULL);
354*4882a593Smuzhiyun }
355*4882a593Smuzhiyun
356*4882a593Smuzhiyun return dmxSaveRenderVector[stuff->renderReqType] (client);
357*4882a593Smuzhiyun }
358*4882a593Smuzhiyun
359*4882a593Smuzhiyun /** Add glyphs to the Glyph Set on each screen. */
360*4882a593Smuzhiyun static int
dmxProcRenderAddGlyphs(ClientPtr client)361*4882a593Smuzhiyun dmxProcRenderAddGlyphs(ClientPtr client)
362*4882a593Smuzhiyun {
363*4882a593Smuzhiyun int ret;
364*4882a593Smuzhiyun
365*4882a593Smuzhiyun REQUEST(xRenderAddGlyphsReq);
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun ret = dmxSaveRenderVector[stuff->renderReqType] (client);
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun if (ret == Success) {
370*4882a593Smuzhiyun GlyphSetPtr glyphSet;
371*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv;
372*4882a593Smuzhiyun int i;
373*4882a593Smuzhiyun int nglyphs;
374*4882a593Smuzhiyun CARD32 *gids;
375*4882a593Smuzhiyun Glyph *gidsCopy;
376*4882a593Smuzhiyun xGlyphInfo *gi;
377*4882a593Smuzhiyun CARD8 *bits;
378*4882a593Smuzhiyun int nbytes;
379*4882a593Smuzhiyun
380*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
381*4882a593Smuzhiyun stuff->glyphset, GlyphSetType,
382*4882a593Smuzhiyun client, DixReadAccess);
383*4882a593Smuzhiyun glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
384*4882a593Smuzhiyun
385*4882a593Smuzhiyun nglyphs = stuff->nglyphs;
386*4882a593Smuzhiyun gids = (CARD32 *) (stuff + 1);
387*4882a593Smuzhiyun gi = (xGlyphInfo *) (gids + nglyphs);
388*4882a593Smuzhiyun bits = (CARD8 *) (gi + nglyphs);
389*4882a593Smuzhiyun nbytes = ((stuff->length << 2) -
390*4882a593Smuzhiyun sizeof(xRenderAddGlyphsReq) -
391*4882a593Smuzhiyun (sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs);
392*4882a593Smuzhiyun
393*4882a593Smuzhiyun gidsCopy = xallocarray(nglyphs, sizeof(*gidsCopy));
394*4882a593Smuzhiyun for (i = 0; i < nglyphs; i++)
395*4882a593Smuzhiyun gidsCopy[i] = gids[i];
396*4882a593Smuzhiyun
397*4882a593Smuzhiyun /* FIXME: Will this ever fail? */
398*4882a593Smuzhiyun for (i = 0; i < dmxNumScreens; i++) {
399*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[i];
400*4882a593Smuzhiyun
401*4882a593Smuzhiyun if (dmxScreen->beDisplay) {
402*4882a593Smuzhiyun XRenderAddGlyphs(dmxScreen->beDisplay,
403*4882a593Smuzhiyun glyphPriv->glyphSets[i],
404*4882a593Smuzhiyun gidsCopy,
405*4882a593Smuzhiyun (XGlyphInfo *) gi,
406*4882a593Smuzhiyun nglyphs, (char *) bits, nbytes);
407*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
408*4882a593Smuzhiyun }
409*4882a593Smuzhiyun }
410*4882a593Smuzhiyun free(gidsCopy);
411*4882a593Smuzhiyun }
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun return ret;
414*4882a593Smuzhiyun }
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun /** Free glyphs from the Glyph Set for each screen. */
417*4882a593Smuzhiyun static int
dmxProcRenderFreeGlyphs(ClientPtr client)418*4882a593Smuzhiyun dmxProcRenderFreeGlyphs(ClientPtr client)
419*4882a593Smuzhiyun {
420*4882a593Smuzhiyun GlyphSetPtr glyphSet;
421*4882a593Smuzhiyun
422*4882a593Smuzhiyun REQUEST(xRenderFreeGlyphsReq);
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
425*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
426*4882a593Smuzhiyun stuff->glyphset, GlyphSetType,
427*4882a593Smuzhiyun client, DixWriteAccess);
428*4882a593Smuzhiyun
429*4882a593Smuzhiyun if (glyphSet) {
430*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
431*4882a593Smuzhiyun int i;
432*4882a593Smuzhiyun int nglyphs;
433*4882a593Smuzhiyun Glyph *gids;
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun nglyphs = ((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq)) >> 2;
436*4882a593Smuzhiyun if (nglyphs) {
437*4882a593Smuzhiyun gids = xallocarray(nglyphs, sizeof(*gids));
438*4882a593Smuzhiyun for (i = 0; i < nglyphs; i++)
439*4882a593Smuzhiyun gids[i] = ((CARD32 *) (stuff + 1))[i];
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun for (i = 0; i < dmxNumScreens; i++) {
442*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[i];
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun if (dmxScreen->beDisplay) {
445*4882a593Smuzhiyun XRenderFreeGlyphs(dmxScreen->beDisplay,
446*4882a593Smuzhiyun glyphPriv->glyphSets[i], gids, nglyphs);
447*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
448*4882a593Smuzhiyun }
449*4882a593Smuzhiyun }
450*4882a593Smuzhiyun free(gids);
451*4882a593Smuzhiyun }
452*4882a593Smuzhiyun }
453*4882a593Smuzhiyun
454*4882a593Smuzhiyun return dmxSaveRenderVector[stuff->renderReqType] (client);
455*4882a593Smuzhiyun }
456*4882a593Smuzhiyun
457*4882a593Smuzhiyun /** Composite glyphs on each screen into the requested picture. If
458*4882a593Smuzhiyun * either the src or dest picture has not been allocated due to lazy
459*4882a593Smuzhiyun * window creation, this request will gracefully return. */
460*4882a593Smuzhiyun static int
dmxProcRenderCompositeGlyphs(ClientPtr client)461*4882a593Smuzhiyun dmxProcRenderCompositeGlyphs(ClientPtr client)
462*4882a593Smuzhiyun {
463*4882a593Smuzhiyun int ret;
464*4882a593Smuzhiyun
465*4882a593Smuzhiyun REQUEST(xRenderCompositeGlyphsReq);
466*4882a593Smuzhiyun
467*4882a593Smuzhiyun ret = dmxSaveRenderVector[stuff->renderReqType] (client);
468*4882a593Smuzhiyun
469*4882a593Smuzhiyun /* For the following to work with PanoramiX, it assumes that Render
470*4882a593Smuzhiyun * wraps the ProcRenderVector after dmxRenderInit has been called.
471*4882a593Smuzhiyun */
472*4882a593Smuzhiyun if (ret == Success) {
473*4882a593Smuzhiyun PicturePtr pSrc;
474*4882a593Smuzhiyun dmxPictPrivPtr pSrcPriv;
475*4882a593Smuzhiyun PicturePtr pDst;
476*4882a593Smuzhiyun dmxPictPrivPtr pDstPriv;
477*4882a593Smuzhiyun PictFormatPtr pFmt;
478*4882a593Smuzhiyun XRenderPictFormat *pFormat;
479*4882a593Smuzhiyun int size;
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun int scrnNum;
482*4882a593Smuzhiyun DMXScreenInfo *dmxScreen;
483*4882a593Smuzhiyun
484*4882a593Smuzhiyun CARD8 *buffer;
485*4882a593Smuzhiyun CARD8 *end;
486*4882a593Smuzhiyun int space;
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun int nglyph;
489*4882a593Smuzhiyun char *glyphs;
490*4882a593Smuzhiyun char *curGlyph;
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun xGlyphElt *elt;
493*4882a593Smuzhiyun int nelt;
494*4882a593Smuzhiyun XGlyphElt8 *elts;
495*4882a593Smuzhiyun XGlyphElt8 *curElt;
496*4882a593Smuzhiyun
497*4882a593Smuzhiyun GlyphSetPtr glyphSet;
498*4882a593Smuzhiyun dmxGlyphPrivPtr glyphPriv;
499*4882a593Smuzhiyun
500*4882a593Smuzhiyun dixLookupResourceByType((void **) &pSrc,
501*4882a593Smuzhiyun stuff->src, PictureType, client, DixReadAccess);
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
504*4882a593Smuzhiyun if (!pSrcPriv->pict)
505*4882a593Smuzhiyun return ret;
506*4882a593Smuzhiyun
507*4882a593Smuzhiyun dixLookupResourceByType((void **) &pDst,
508*4882a593Smuzhiyun stuff->dst, PictureType,
509*4882a593Smuzhiyun client, DixWriteAccess);
510*4882a593Smuzhiyun
511*4882a593Smuzhiyun pDstPriv = DMX_GET_PICT_PRIV(pDst);
512*4882a593Smuzhiyun if (!pDstPriv->pict)
513*4882a593Smuzhiyun return ret;
514*4882a593Smuzhiyun
515*4882a593Smuzhiyun scrnNum = pDst->pDrawable->pScreen->myNum;
516*4882a593Smuzhiyun dmxScreen = &dmxScreens[scrnNum];
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun /* Note: If the back-end display has been detached, then it
519*4882a593Smuzhiyun * should not be possible to reach here since the pSrcPriv->pict
520*4882a593Smuzhiyun * and pDstPriv->pict will have already been set to 0.
521*4882a593Smuzhiyun */
522*4882a593Smuzhiyun if (!dmxScreen->beDisplay)
523*4882a593Smuzhiyun return ret;
524*4882a593Smuzhiyun
525*4882a593Smuzhiyun if (stuff->maskFormat)
526*4882a593Smuzhiyun dixLookupResourceByType((void **) &pFmt,
527*4882a593Smuzhiyun stuff->maskFormat, PictFormatType,
528*4882a593Smuzhiyun client, DixReadAccess);
529*4882a593Smuzhiyun else
530*4882a593Smuzhiyun pFmt = NULL;
531*4882a593Smuzhiyun
532*4882a593Smuzhiyun pFormat = dmxFindFormat(dmxScreen, pFmt);
533*4882a593Smuzhiyun
534*4882a593Smuzhiyun switch (stuff->renderReqType) {
535*4882a593Smuzhiyun case X_RenderCompositeGlyphs8:
536*4882a593Smuzhiyun size = sizeof(CARD8);
537*4882a593Smuzhiyun break;
538*4882a593Smuzhiyun case X_RenderCompositeGlyphs16:
539*4882a593Smuzhiyun size = sizeof(CARD16);
540*4882a593Smuzhiyun break;
541*4882a593Smuzhiyun case X_RenderCompositeGlyphs32:
542*4882a593Smuzhiyun size = sizeof(CARD32);
543*4882a593Smuzhiyun break;
544*4882a593Smuzhiyun default:
545*4882a593Smuzhiyun return BadPictOp; /* Can't happen */
546*4882a593Smuzhiyun }
547*4882a593Smuzhiyun
548*4882a593Smuzhiyun buffer = (CARD8 *) (stuff + 1);
549*4882a593Smuzhiyun end = (CARD8 *) stuff + (stuff->length << 2);
550*4882a593Smuzhiyun nelt = 0;
551*4882a593Smuzhiyun nglyph = 0;
552*4882a593Smuzhiyun while (buffer + sizeof(xGlyphElt) < end) {
553*4882a593Smuzhiyun elt = (xGlyphElt *) buffer;
554*4882a593Smuzhiyun buffer += sizeof(xGlyphElt);
555*4882a593Smuzhiyun
556*4882a593Smuzhiyun if (elt->len == 0xff) {
557*4882a593Smuzhiyun buffer += 4;
558*4882a593Smuzhiyun }
559*4882a593Smuzhiyun else {
560*4882a593Smuzhiyun nelt++;
561*4882a593Smuzhiyun nglyph += elt->len;
562*4882a593Smuzhiyun space = size * elt->len;
563*4882a593Smuzhiyun if (space & 3)
564*4882a593Smuzhiyun space += 4 - (space & 3);
565*4882a593Smuzhiyun buffer += space;
566*4882a593Smuzhiyun }
567*4882a593Smuzhiyun }
568*4882a593Smuzhiyun
569*4882a593Smuzhiyun /* The following only works for Render version > 0.2 */
570*4882a593Smuzhiyun
571*4882a593Smuzhiyun /* All of the XGlyphElt* structure sizes are identical */
572*4882a593Smuzhiyun elts = xallocarray(nelt, sizeof(XGlyphElt8));
573*4882a593Smuzhiyun if (!elts)
574*4882a593Smuzhiyun return BadAlloc;
575*4882a593Smuzhiyun
576*4882a593Smuzhiyun glyphs = xallocarray(nglyph, size);
577*4882a593Smuzhiyun if (!glyphs) {
578*4882a593Smuzhiyun free(elts);
579*4882a593Smuzhiyun return BadAlloc;
580*4882a593Smuzhiyun }
581*4882a593Smuzhiyun
582*4882a593Smuzhiyun buffer = (CARD8 *) (stuff + 1);
583*4882a593Smuzhiyun end = (CARD8 *) stuff + (stuff->length << 2);
584*4882a593Smuzhiyun curGlyph = glyphs;
585*4882a593Smuzhiyun curElt = elts;
586*4882a593Smuzhiyun
587*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
588*4882a593Smuzhiyun stuff->glyphset, GlyphSetType,
589*4882a593Smuzhiyun client, DixReadAccess);
590*4882a593Smuzhiyun glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
591*4882a593Smuzhiyun
592*4882a593Smuzhiyun while (buffer + sizeof(xGlyphElt) < end) {
593*4882a593Smuzhiyun elt = (xGlyphElt *) buffer;
594*4882a593Smuzhiyun buffer += sizeof(xGlyphElt);
595*4882a593Smuzhiyun
596*4882a593Smuzhiyun if (elt->len == 0xff) {
597*4882a593Smuzhiyun dixLookupResourceByType((void **) &glyphSet,
598*4882a593Smuzhiyun *((CARD32 *) buffer),
599*4882a593Smuzhiyun GlyphSetType, client, DixReadAccess);
600*4882a593Smuzhiyun glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
601*4882a593Smuzhiyun buffer += 4;
602*4882a593Smuzhiyun }
603*4882a593Smuzhiyun else {
604*4882a593Smuzhiyun curElt->glyphset = glyphPriv->glyphSets[scrnNum];
605*4882a593Smuzhiyun curElt->xOff = elt->deltax;
606*4882a593Smuzhiyun curElt->yOff = elt->deltay;
607*4882a593Smuzhiyun curElt->nchars = elt->len;
608*4882a593Smuzhiyun curElt->chars = curGlyph;
609*4882a593Smuzhiyun
610*4882a593Smuzhiyun memcpy(curGlyph, buffer, size * elt->len);
611*4882a593Smuzhiyun curGlyph += size * elt->len;
612*4882a593Smuzhiyun
613*4882a593Smuzhiyun curElt++;
614*4882a593Smuzhiyun
615*4882a593Smuzhiyun space = size * elt->len;
616*4882a593Smuzhiyun if (space & 3)
617*4882a593Smuzhiyun space += 4 - (space & 3);
618*4882a593Smuzhiyun buffer += space;
619*4882a593Smuzhiyun }
620*4882a593Smuzhiyun }
621*4882a593Smuzhiyun
622*4882a593Smuzhiyun switch (stuff->renderReqType) {
623*4882a593Smuzhiyun case X_RenderCompositeGlyphs8:
624*4882a593Smuzhiyun XRenderCompositeText8(dmxScreen->beDisplay, stuff->op,
625*4882a593Smuzhiyun pSrcPriv->pict, pDstPriv->pict,
626*4882a593Smuzhiyun pFormat,
627*4882a593Smuzhiyun stuff->xSrc, stuff->ySrc, 0, 0, elts, nelt);
628*4882a593Smuzhiyun break;
629*4882a593Smuzhiyun case X_RenderCompositeGlyphs16:
630*4882a593Smuzhiyun XRenderCompositeText16(dmxScreen->beDisplay, stuff->op,
631*4882a593Smuzhiyun pSrcPriv->pict, pDstPriv->pict,
632*4882a593Smuzhiyun pFormat,
633*4882a593Smuzhiyun stuff->xSrc, stuff->ySrc,
634*4882a593Smuzhiyun 0, 0, (XGlyphElt16 *) elts, nelt);
635*4882a593Smuzhiyun break;
636*4882a593Smuzhiyun case X_RenderCompositeGlyphs32:
637*4882a593Smuzhiyun XRenderCompositeText32(dmxScreen->beDisplay, stuff->op,
638*4882a593Smuzhiyun pSrcPriv->pict, pDstPriv->pict,
639*4882a593Smuzhiyun pFormat,
640*4882a593Smuzhiyun stuff->xSrc, stuff->ySrc,
641*4882a593Smuzhiyun 0, 0, (XGlyphElt32 *) elts, nelt);
642*4882a593Smuzhiyun break;
643*4882a593Smuzhiyun }
644*4882a593Smuzhiyun
645*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
646*4882a593Smuzhiyun
647*4882a593Smuzhiyun free(elts);
648*4882a593Smuzhiyun free(glyphs);
649*4882a593Smuzhiyun }
650*4882a593Smuzhiyun
651*4882a593Smuzhiyun return ret;
652*4882a593Smuzhiyun }
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun /** Set the picture transform on each screen. */
655*4882a593Smuzhiyun static int
dmxProcRenderSetPictureTransform(ClientPtr client)656*4882a593Smuzhiyun dmxProcRenderSetPictureTransform(ClientPtr client)
657*4882a593Smuzhiyun {
658*4882a593Smuzhiyun DMXScreenInfo *dmxScreen;
659*4882a593Smuzhiyun PicturePtr pPicture;
660*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv;
661*4882a593Smuzhiyun XTransform xform;
662*4882a593Smuzhiyun
663*4882a593Smuzhiyun REQUEST(xRenderSetPictureTransformReq);
664*4882a593Smuzhiyun
665*4882a593Smuzhiyun REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
666*4882a593Smuzhiyun VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess);
667*4882a593Smuzhiyun
668*4882a593Smuzhiyun /* For the following to work with PanoramiX, it assumes that Render
669*4882a593Smuzhiyun * wraps the ProcRenderVector after dmxRenderInit has been called.
670*4882a593Smuzhiyun */
671*4882a593Smuzhiyun dmxScreen = &dmxScreens[pPicture->pDrawable->pScreen->myNum];
672*4882a593Smuzhiyun pPictPriv = DMX_GET_PICT_PRIV(pPicture);
673*4882a593Smuzhiyun
674*4882a593Smuzhiyun if (pPictPriv->pict) {
675*4882a593Smuzhiyun xform.matrix[0][0] = stuff->transform.matrix11;
676*4882a593Smuzhiyun xform.matrix[0][1] = stuff->transform.matrix12;
677*4882a593Smuzhiyun xform.matrix[0][2] = stuff->transform.matrix13;
678*4882a593Smuzhiyun xform.matrix[1][0] = stuff->transform.matrix21;
679*4882a593Smuzhiyun xform.matrix[1][1] = stuff->transform.matrix22;
680*4882a593Smuzhiyun xform.matrix[1][2] = stuff->transform.matrix23;
681*4882a593Smuzhiyun xform.matrix[2][0] = stuff->transform.matrix31;
682*4882a593Smuzhiyun xform.matrix[2][1] = stuff->transform.matrix32;
683*4882a593Smuzhiyun xform.matrix[2][2] = stuff->transform.matrix33;
684*4882a593Smuzhiyun
685*4882a593Smuzhiyun XRenderSetPictureTransform(dmxScreen->beDisplay,
686*4882a593Smuzhiyun pPictPriv->pict, &xform);
687*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
688*4882a593Smuzhiyun }
689*4882a593Smuzhiyun
690*4882a593Smuzhiyun return dmxSaveRenderVector[stuff->renderReqType] (client);
691*4882a593Smuzhiyun }
692*4882a593Smuzhiyun
693*4882a593Smuzhiyun /** Set the picture filter on each screen. */
694*4882a593Smuzhiyun static int
dmxProcRenderSetPictureFilter(ClientPtr client)695*4882a593Smuzhiyun dmxProcRenderSetPictureFilter(ClientPtr client)
696*4882a593Smuzhiyun {
697*4882a593Smuzhiyun DMXScreenInfo *dmxScreen;
698*4882a593Smuzhiyun PicturePtr pPicture;
699*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv;
700*4882a593Smuzhiyun char *filter;
701*4882a593Smuzhiyun XFixed *params;
702*4882a593Smuzhiyun int nparams;
703*4882a593Smuzhiyun
704*4882a593Smuzhiyun REQUEST(xRenderSetPictureFilterReq);
705*4882a593Smuzhiyun
706*4882a593Smuzhiyun REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
707*4882a593Smuzhiyun VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess);
708*4882a593Smuzhiyun
709*4882a593Smuzhiyun /* For the following to work with PanoramiX, it assumes that Render
710*4882a593Smuzhiyun * wraps the ProcRenderVector after dmxRenderInit has been called.
711*4882a593Smuzhiyun */
712*4882a593Smuzhiyun dmxScreen = &dmxScreens[pPicture->pDrawable->pScreen->myNum];
713*4882a593Smuzhiyun pPictPriv = DMX_GET_PICT_PRIV(pPicture);
714*4882a593Smuzhiyun
715*4882a593Smuzhiyun if (pPictPriv->pict) {
716*4882a593Smuzhiyun filter = (char *) (stuff + 1);
717*4882a593Smuzhiyun params = (XFixed *) (filter + ((stuff->nbytes + 3) & ~3));
718*4882a593Smuzhiyun nparams = ((XFixed *) stuff + client->req_len) - params;
719*4882a593Smuzhiyun if (nparams < 0)
720*4882a593Smuzhiyun return BadLength;
721*4882a593Smuzhiyun
722*4882a593Smuzhiyun XRenderSetPictureFilter(dmxScreen->beDisplay,
723*4882a593Smuzhiyun pPictPriv->pict, filter, params, nparams);
724*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
725*4882a593Smuzhiyun }
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun return dmxSaveRenderVector[stuff->renderReqType] (client);
728*4882a593Smuzhiyun }
729*4882a593Smuzhiyun
730*4882a593Smuzhiyun /** Create a picture on the appropriate screen. This is the actual
731*4882a593Smuzhiyun * function that creates the picture. However, if the associated
732*4882a593Smuzhiyun * window has not yet been created due to lazy window creation, then
733*4882a593Smuzhiyun * delay the picture creation until the window is mapped. */
734*4882a593Smuzhiyun static Picture
dmxDoCreatePicture(PicturePtr pPicture)735*4882a593Smuzhiyun dmxDoCreatePicture(PicturePtr pPicture)
736*4882a593Smuzhiyun {
737*4882a593Smuzhiyun DrawablePtr pDraw = pPicture->pDrawable;
738*4882a593Smuzhiyun ScreenPtr pScreen = pDraw->pScreen;
739*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
740*4882a593Smuzhiyun XRenderPictFormat *pFormat;
741*4882a593Smuzhiyun Drawable draw;
742*4882a593Smuzhiyun
743*4882a593Smuzhiyun if (pPicture->pDrawable->type == DRAWABLE_WINDOW) {
744*4882a593Smuzhiyun dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV((WindowPtr) (pDraw));
745*4882a593Smuzhiyun
746*4882a593Smuzhiyun if (!(draw = pWinPriv->window)) {
747*4882a593Smuzhiyun /* Window has not been created yet due to the window
748*4882a593Smuzhiyun * optimization. Delay picture creation until window is
749*4882a593Smuzhiyun * mapped.
750*4882a593Smuzhiyun */
751*4882a593Smuzhiyun pWinPriv->hasPict = TRUE;
752*4882a593Smuzhiyun return 0;
753*4882a593Smuzhiyun }
754*4882a593Smuzhiyun }
755*4882a593Smuzhiyun else {
756*4882a593Smuzhiyun dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV((PixmapPtr) (pDraw));
757*4882a593Smuzhiyun
758*4882a593Smuzhiyun if (!(draw = pPixPriv->pixmap)) {
759*4882a593Smuzhiyun /* FIXME: Zero width/height pixmap?? */
760*4882a593Smuzhiyun return 0;
761*4882a593Smuzhiyun }
762*4882a593Smuzhiyun }
763*4882a593Smuzhiyun
764*4882a593Smuzhiyun /* This should not be reached if the back-end display has been
765*4882a593Smuzhiyun * detached because the pWinPriv->window or the pPixPriv->pixmap
766*4882a593Smuzhiyun * will be NULL; however, we add it here for completeness
767*4882a593Smuzhiyun */
768*4882a593Smuzhiyun if (!dmxScreen->beDisplay)
769*4882a593Smuzhiyun return 0;
770*4882a593Smuzhiyun
771*4882a593Smuzhiyun pFormat = dmxFindFormat(dmxScreen, pPicture->pFormat);
772*4882a593Smuzhiyun
773*4882a593Smuzhiyun return XRenderCreatePicture(dmxScreen->beDisplay, draw, pFormat, 0, 0);
774*4882a593Smuzhiyun }
775*4882a593Smuzhiyun
776*4882a593Smuzhiyun /** Create a list of pictures. This function is called by
777*4882a593Smuzhiyun * dmxCreateAndRealizeWindow() during the lazy window creation
778*4882a593Smuzhiyun * realization process. It creates the entire list of pictures that
779*4882a593Smuzhiyun * are associated with the given window. */
780*4882a593Smuzhiyun void
dmxCreatePictureList(WindowPtr pWindow)781*4882a593Smuzhiyun dmxCreatePictureList(WindowPtr pWindow)
782*4882a593Smuzhiyun {
783*4882a593Smuzhiyun PicturePtr pPicture = GetPictureWindow(pWindow);
784*4882a593Smuzhiyun
785*4882a593Smuzhiyun while (pPicture) {
786*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
787*4882a593Smuzhiyun
788*4882a593Smuzhiyun /* Create the picture for this window */
789*4882a593Smuzhiyun pPictPriv->pict = dmxDoCreatePicture(pPicture);
790*4882a593Smuzhiyun
791*4882a593Smuzhiyun /* ValidatePicture takes care of the state changes */
792*4882a593Smuzhiyun
793*4882a593Smuzhiyun pPicture = pPicture->pNext;
794*4882a593Smuzhiyun }
795*4882a593Smuzhiyun }
796*4882a593Smuzhiyun
797*4882a593Smuzhiyun /** Create \a pPicture on the backend. */
798*4882a593Smuzhiyun int
dmxBECreatePicture(PicturePtr pPicture)799*4882a593Smuzhiyun dmxBECreatePicture(PicturePtr pPicture)
800*4882a593Smuzhiyun {
801*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
802*4882a593Smuzhiyun
803*4882a593Smuzhiyun /* Create picutre on BE */
804*4882a593Smuzhiyun pPictPriv->pict = dmxDoCreatePicture(pPicture);
805*4882a593Smuzhiyun
806*4882a593Smuzhiyun /* Flush changes to the backend server */
807*4882a593Smuzhiyun dmxValidatePicture(pPicture, (1 << (CPLastBit + 1)) - 1);
808*4882a593Smuzhiyun
809*4882a593Smuzhiyun return Success;
810*4882a593Smuzhiyun }
811*4882a593Smuzhiyun
812*4882a593Smuzhiyun /** Create a picture. This function handles the CreatePicture
813*4882a593Smuzhiyun * unwrapping/wrapping and calls dmxDoCreatePicture to actually create
814*4882a593Smuzhiyun * the picture on the appropriate screen. */
815*4882a593Smuzhiyun int
dmxCreatePicture(PicturePtr pPicture)816*4882a593Smuzhiyun dmxCreatePicture(PicturePtr pPicture)
817*4882a593Smuzhiyun {
818*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
819*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
820*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
821*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
822*4882a593Smuzhiyun int ret = Success;
823*4882a593Smuzhiyun
824*4882a593Smuzhiyun DMX_UNWRAP(CreatePicture, dmxScreen, ps);
825*4882a593Smuzhiyun #if 1
826*4882a593Smuzhiyun if (ps->CreatePicture)
827*4882a593Smuzhiyun ret = ps->CreatePicture(pPicture);
828*4882a593Smuzhiyun #endif
829*4882a593Smuzhiyun
830*4882a593Smuzhiyun /* Create picture on back-end server */
831*4882a593Smuzhiyun pPictPriv->pict = dmxDoCreatePicture(pPicture);
832*4882a593Smuzhiyun pPictPriv->savedMask = 0;
833*4882a593Smuzhiyun
834*4882a593Smuzhiyun DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps);
835*4882a593Smuzhiyun
836*4882a593Smuzhiyun return ret;
837*4882a593Smuzhiyun }
838*4882a593Smuzhiyun
839*4882a593Smuzhiyun /** Destroy \a pPicture on the back-end server. */
840*4882a593Smuzhiyun Bool
dmxBEFreePicture(PicturePtr pPicture)841*4882a593Smuzhiyun dmxBEFreePicture(PicturePtr pPicture)
842*4882a593Smuzhiyun {
843*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
844*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
845*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
846*4882a593Smuzhiyun
847*4882a593Smuzhiyun if (pPictPriv->pict) {
848*4882a593Smuzhiyun XRenderFreePicture(dmxScreen->beDisplay, pPictPriv->pict);
849*4882a593Smuzhiyun pPictPriv->pict = (Picture) 0;
850*4882a593Smuzhiyun return TRUE;
851*4882a593Smuzhiyun }
852*4882a593Smuzhiyun
853*4882a593Smuzhiyun return FALSE;
854*4882a593Smuzhiyun }
855*4882a593Smuzhiyun
856*4882a593Smuzhiyun /** Destroy a list of pictures that are associated with the window that
857*4882a593Smuzhiyun * is being destroyed. This function is called by #dmxDestroyWindow().
858*4882a593Smuzhiyun * */
859*4882a593Smuzhiyun Bool
dmxDestroyPictureList(WindowPtr pWindow)860*4882a593Smuzhiyun dmxDestroyPictureList(WindowPtr pWindow)
861*4882a593Smuzhiyun {
862*4882a593Smuzhiyun PicturePtr pPicture = GetPictureWindow(pWindow);
863*4882a593Smuzhiyun Bool ret = FALSE;
864*4882a593Smuzhiyun
865*4882a593Smuzhiyun while (pPicture) {
866*4882a593Smuzhiyun ret |= dmxBEFreePicture(pPicture);
867*4882a593Smuzhiyun pPicture = pPicture->pNext;
868*4882a593Smuzhiyun }
869*4882a593Smuzhiyun
870*4882a593Smuzhiyun return ret;
871*4882a593Smuzhiyun }
872*4882a593Smuzhiyun
873*4882a593Smuzhiyun /** Destroy a picture. This function calls the wrapped function that
874*4882a593Smuzhiyun * frees the resources in the DMX server associated with this
875*4882a593Smuzhiyun * picture. */
876*4882a593Smuzhiyun void
dmxDestroyPicture(PicturePtr pPicture)877*4882a593Smuzhiyun dmxDestroyPicture(PicturePtr pPicture)
878*4882a593Smuzhiyun {
879*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
880*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
881*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
882*4882a593Smuzhiyun
883*4882a593Smuzhiyun DMX_UNWRAP(DestroyPicture, dmxScreen, ps);
884*4882a593Smuzhiyun
885*4882a593Smuzhiyun /* Destroy picture on back-end server */
886*4882a593Smuzhiyun if (dmxBEFreePicture(pPicture))
887*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
888*4882a593Smuzhiyun
889*4882a593Smuzhiyun #if 1
890*4882a593Smuzhiyun if (ps->DestroyPicture)
891*4882a593Smuzhiyun ps->DestroyPicture(pPicture);
892*4882a593Smuzhiyun #endif
893*4882a593Smuzhiyun DMX_WRAP(DestroyPicture, dmxDestroyPicture, dmxScreen, ps);
894*4882a593Smuzhiyun }
895*4882a593Smuzhiyun
896*4882a593Smuzhiyun /** Change the picture's list of clip rectangles. */
897*4882a593Smuzhiyun int
dmxChangePictureClip(PicturePtr pPicture,int clipType,void * value,int n)898*4882a593Smuzhiyun dmxChangePictureClip(PicturePtr pPicture, int clipType, void *value, int n)
899*4882a593Smuzhiyun {
900*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
901*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
902*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
903*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
904*4882a593Smuzhiyun
905*4882a593Smuzhiyun DMX_UNWRAP(ChangePictureClip, dmxScreen, ps);
906*4882a593Smuzhiyun #if 1
907*4882a593Smuzhiyun if (ps->ChangePictureClip)
908*4882a593Smuzhiyun ps->ChangePictureClip(pPicture, clipType, value, n);
909*4882a593Smuzhiyun #endif
910*4882a593Smuzhiyun
911*4882a593Smuzhiyun /* Change picture clip rects on back-end server */
912*4882a593Smuzhiyun if (pPictPriv->pict) {
913*4882a593Smuzhiyun /* The clip has already been changed into a region by the mi
914*4882a593Smuzhiyun * routine called above.
915*4882a593Smuzhiyun */
916*4882a593Smuzhiyun if (clipType == CT_NONE) {
917*4882a593Smuzhiyun /* Disable clipping, show all */
918*4882a593Smuzhiyun XFixesSetPictureClipRegion(dmxScreen->beDisplay,
919*4882a593Smuzhiyun pPictPriv->pict, 0, 0, None);
920*4882a593Smuzhiyun }
921*4882a593Smuzhiyun else if (pPicture->clientClip) {
922*4882a593Smuzhiyun RegionPtr pClip = pPicture->clientClip;
923*4882a593Smuzhiyun BoxPtr pBox = RegionRects(pClip);
924*4882a593Smuzhiyun int nBox = RegionNumRects(pClip);
925*4882a593Smuzhiyun XRectangle *pRects;
926*4882a593Smuzhiyun XRectangle *pRect;
927*4882a593Smuzhiyun int nRects;
928*4882a593Smuzhiyun
929*4882a593Smuzhiyun nRects = nBox;
930*4882a593Smuzhiyun pRects = pRect = xallocarray(nRects, sizeof(*pRect));
931*4882a593Smuzhiyun
932*4882a593Smuzhiyun while (nBox--) {
933*4882a593Smuzhiyun pRect->x = pBox->x1;
934*4882a593Smuzhiyun pRect->y = pBox->y1;
935*4882a593Smuzhiyun pRect->width = pBox->x2 - pBox->x1;
936*4882a593Smuzhiyun pRect->height = pBox->y2 - pBox->y1;
937*4882a593Smuzhiyun pBox++;
938*4882a593Smuzhiyun pRect++;
939*4882a593Smuzhiyun }
940*4882a593Smuzhiyun
941*4882a593Smuzhiyun XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
942*4882a593Smuzhiyun pPictPriv->pict,
943*4882a593Smuzhiyun 0, 0, pRects, nRects);
944*4882a593Smuzhiyun free(pRects);
945*4882a593Smuzhiyun }
946*4882a593Smuzhiyun else {
947*4882a593Smuzhiyun XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
948*4882a593Smuzhiyun pPictPriv->pict, 0, 0, NULL, 0);
949*4882a593Smuzhiyun }
950*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
951*4882a593Smuzhiyun }
952*4882a593Smuzhiyun else {
953*4882a593Smuzhiyun /* FIXME: Handle saving clip region when offscreen */
954*4882a593Smuzhiyun }
955*4882a593Smuzhiyun
956*4882a593Smuzhiyun DMX_WRAP(ChangePictureClip, dmxChangePictureClip, dmxScreen, ps);
957*4882a593Smuzhiyun
958*4882a593Smuzhiyun return Success;
959*4882a593Smuzhiyun }
960*4882a593Smuzhiyun
961*4882a593Smuzhiyun /** Destroy the picture's list of clip rectangles. */
962*4882a593Smuzhiyun void
dmxDestroyPictureClip(PicturePtr pPicture)963*4882a593Smuzhiyun dmxDestroyPictureClip(PicturePtr pPicture)
964*4882a593Smuzhiyun {
965*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
966*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
967*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
968*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
969*4882a593Smuzhiyun
970*4882a593Smuzhiyun DMX_UNWRAP(DestroyPictureClip, dmxScreen, ps);
971*4882a593Smuzhiyun #if 1
972*4882a593Smuzhiyun if (ps->DestroyPictureClip)
973*4882a593Smuzhiyun ps->DestroyPictureClip(pPicture);
974*4882a593Smuzhiyun #endif
975*4882a593Smuzhiyun
976*4882a593Smuzhiyun /* Destroy picture clip rects on back-end server */
977*4882a593Smuzhiyun if (pPictPriv->pict) {
978*4882a593Smuzhiyun XRenderSetPictureClipRectangles(dmxScreen->beDisplay,
979*4882a593Smuzhiyun pPictPriv->pict, 0, 0, NULL, 0);
980*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
981*4882a593Smuzhiyun }
982*4882a593Smuzhiyun else {
983*4882a593Smuzhiyun /* FIXME: Handle destroying clip region when offscreen */
984*4882a593Smuzhiyun }
985*4882a593Smuzhiyun
986*4882a593Smuzhiyun DMX_WRAP(DestroyPictureClip, dmxDestroyPictureClip, dmxScreen, ps);
987*4882a593Smuzhiyun }
988*4882a593Smuzhiyun
989*4882a593Smuzhiyun /** Change the attributes of the pictures. If the picture has not yet
990*4882a593Smuzhiyun * been created due to lazy window creation, save the mask so that it
991*4882a593Smuzhiyun * can be used to appropriately initialize the picture's attributes
992*4882a593Smuzhiyun * when it is created later. */
993*4882a593Smuzhiyun void
dmxChangePicture(PicturePtr pPicture,Mask mask)994*4882a593Smuzhiyun dmxChangePicture(PicturePtr pPicture, Mask mask)
995*4882a593Smuzhiyun {
996*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
997*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
998*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
999*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
1000*4882a593Smuzhiyun
1001*4882a593Smuzhiyun DMX_UNWRAP(ChangePicture, dmxScreen, ps);
1002*4882a593Smuzhiyun #if 1
1003*4882a593Smuzhiyun if (ps->ChangePicture)
1004*4882a593Smuzhiyun ps->ChangePicture(pPicture, mask);
1005*4882a593Smuzhiyun #endif
1006*4882a593Smuzhiyun
1007*4882a593Smuzhiyun /* Picture attribute changes are handled in ValidatePicture */
1008*4882a593Smuzhiyun pPictPriv->savedMask |= mask;
1009*4882a593Smuzhiyun
1010*4882a593Smuzhiyun DMX_WRAP(ChangePicture, dmxChangePicture, dmxScreen, ps);
1011*4882a593Smuzhiyun }
1012*4882a593Smuzhiyun
1013*4882a593Smuzhiyun /** Validate the picture's attributes before rendering to it. Update
1014*4882a593Smuzhiyun * any picture attributes that have been changed by one of the higher
1015*4882a593Smuzhiyun * layers. */
1016*4882a593Smuzhiyun void
dmxValidatePicture(PicturePtr pPicture,Mask mask)1017*4882a593Smuzhiyun dmxValidatePicture(PicturePtr pPicture, Mask mask)
1018*4882a593Smuzhiyun {
1019*4882a593Smuzhiyun ScreenPtr pScreen = pPicture->pDrawable->pScreen;
1020*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
1021*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
1022*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pPicture);
1023*4882a593Smuzhiyun
1024*4882a593Smuzhiyun DMX_UNWRAP(ValidatePicture, dmxScreen, ps);
1025*4882a593Smuzhiyun
1026*4882a593Smuzhiyun /* Change picture attributes on back-end server */
1027*4882a593Smuzhiyun if (pPictPriv->pict) {
1028*4882a593Smuzhiyun XRenderPictureAttributes attribs;
1029*4882a593Smuzhiyun
1030*4882a593Smuzhiyun if (mask & CPRepeat) {
1031*4882a593Smuzhiyun attribs.repeat = pPicture->repeatType;
1032*4882a593Smuzhiyun }
1033*4882a593Smuzhiyun if (mask & CPAlphaMap) {
1034*4882a593Smuzhiyun if (pPicture->alphaMap) {
1035*4882a593Smuzhiyun dmxPictPrivPtr pAlphaPriv;
1036*4882a593Smuzhiyun
1037*4882a593Smuzhiyun pAlphaPriv = DMX_GET_PICT_PRIV(pPicture->alphaMap);
1038*4882a593Smuzhiyun if (pAlphaPriv->pict) {
1039*4882a593Smuzhiyun attribs.alpha_map = pAlphaPriv->pict;
1040*4882a593Smuzhiyun }
1041*4882a593Smuzhiyun else {
1042*4882a593Smuzhiyun /* FIXME: alpha picture drawable has not been created?? */
1043*4882a593Smuzhiyun return; /* or should this be: attribs.alpha_map = None; */
1044*4882a593Smuzhiyun }
1045*4882a593Smuzhiyun }
1046*4882a593Smuzhiyun else {
1047*4882a593Smuzhiyun attribs.alpha_map = None;
1048*4882a593Smuzhiyun }
1049*4882a593Smuzhiyun }
1050*4882a593Smuzhiyun if (mask & CPAlphaXOrigin)
1051*4882a593Smuzhiyun attribs.alpha_x_origin = pPicture->alphaOrigin.x;
1052*4882a593Smuzhiyun if (mask & CPAlphaYOrigin)
1053*4882a593Smuzhiyun attribs.alpha_y_origin = pPicture->alphaOrigin.y;
1054*4882a593Smuzhiyun if (mask & CPClipXOrigin)
1055*4882a593Smuzhiyun attribs.clip_x_origin = pPicture->clipOrigin.x;
1056*4882a593Smuzhiyun if (mask & CPClipYOrigin)
1057*4882a593Smuzhiyun attribs.clip_y_origin = pPicture->clipOrigin.y;
1058*4882a593Smuzhiyun if (mask & CPClipMask)
1059*4882a593Smuzhiyun mask &= ~CPClipMask; /* Handled in ChangePictureClip */
1060*4882a593Smuzhiyun if (mask & CPGraphicsExposure)
1061*4882a593Smuzhiyun attribs.graphics_exposures = pPicture->graphicsExposures;
1062*4882a593Smuzhiyun if (mask & CPSubwindowMode)
1063*4882a593Smuzhiyun attribs.subwindow_mode = pPicture->subWindowMode;
1064*4882a593Smuzhiyun if (mask & CPPolyEdge)
1065*4882a593Smuzhiyun attribs.poly_edge = pPicture->polyEdge;
1066*4882a593Smuzhiyun if (mask & CPPolyMode)
1067*4882a593Smuzhiyun attribs.poly_mode = pPicture->polyMode;
1068*4882a593Smuzhiyun if (mask & CPComponentAlpha)
1069*4882a593Smuzhiyun attribs.component_alpha = pPicture->componentAlpha;
1070*4882a593Smuzhiyun
1071*4882a593Smuzhiyun XRenderChangePicture(dmxScreen->beDisplay, pPictPriv->pict,
1072*4882a593Smuzhiyun mask, &attribs);
1073*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
1074*4882a593Smuzhiyun }
1075*4882a593Smuzhiyun else {
1076*4882a593Smuzhiyun pPictPriv->savedMask |= mask;
1077*4882a593Smuzhiyun }
1078*4882a593Smuzhiyun
1079*4882a593Smuzhiyun #if 1
1080*4882a593Smuzhiyun if (ps->ValidatePicture)
1081*4882a593Smuzhiyun ps->ValidatePicture(pPicture, mask);
1082*4882a593Smuzhiyun #endif
1083*4882a593Smuzhiyun
1084*4882a593Smuzhiyun DMX_WRAP(ValidatePicture, dmxValidatePicture, dmxScreen, ps);
1085*4882a593Smuzhiyun }
1086*4882a593Smuzhiyun
1087*4882a593Smuzhiyun /** Composite a picture on the appropriate screen by combining the
1088*4882a593Smuzhiyun * specified rectangle of the transformed src and mask operands with
1089*4882a593Smuzhiyun * the specified rectangle of the dst using op as the compositing
1090*4882a593Smuzhiyun * operator. For a complete description see the protocol document of
1091*4882a593Smuzhiyun * the RENDER library. */
1092*4882a593Smuzhiyun void
dmxComposite(CARD8 op,PicturePtr pSrc,PicturePtr pMask,PicturePtr pDst,INT16 xSrc,INT16 ySrc,INT16 xMask,INT16 yMask,INT16 xDst,INT16 yDst,CARD16 width,CARD16 height)1093*4882a593Smuzhiyun dmxComposite(CARD8 op,
1094*4882a593Smuzhiyun PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
1095*4882a593Smuzhiyun INT16 xSrc, INT16 ySrc,
1096*4882a593Smuzhiyun INT16 xMask, INT16 yMask,
1097*4882a593Smuzhiyun INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
1098*4882a593Smuzhiyun {
1099*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
1100*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
1101*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
1102*4882a593Smuzhiyun dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
1103*4882a593Smuzhiyun dmxPictPrivPtr pMaskPriv = NULL;
1104*4882a593Smuzhiyun dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
1105*4882a593Smuzhiyun
1106*4882a593Smuzhiyun if (pMask)
1107*4882a593Smuzhiyun pMaskPriv = DMX_GET_PICT_PRIV(pMask);
1108*4882a593Smuzhiyun
1109*4882a593Smuzhiyun DMX_UNWRAP(Composite, dmxScreen, ps);
1110*4882a593Smuzhiyun #if 0
1111*4882a593Smuzhiyun if (ps->Composite)
1112*4882a593Smuzhiyun ps->Composite(op, pSrc, pMask, pDst,
1113*4882a593Smuzhiyun xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
1114*4882a593Smuzhiyun #endif
1115*4882a593Smuzhiyun
1116*4882a593Smuzhiyun /* Composite on back-end server */
1117*4882a593Smuzhiyun if (pSrcPriv->pict && pDstPriv->pict &&
1118*4882a593Smuzhiyun ((pMaskPriv && pMaskPriv->pict) || !pMaskPriv)) {
1119*4882a593Smuzhiyun XRenderComposite(dmxScreen->beDisplay,
1120*4882a593Smuzhiyun op,
1121*4882a593Smuzhiyun pSrcPriv->pict,
1122*4882a593Smuzhiyun pMaskPriv ? pMaskPriv->pict : None,
1123*4882a593Smuzhiyun pDstPriv->pict,
1124*4882a593Smuzhiyun xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
1125*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
1126*4882a593Smuzhiyun }
1127*4882a593Smuzhiyun
1128*4882a593Smuzhiyun DMX_WRAP(Composite, dmxComposite, dmxScreen, ps);
1129*4882a593Smuzhiyun }
1130*4882a593Smuzhiyun
1131*4882a593Smuzhiyun /** Null function to catch when/if RENDER calls lower level mi hooks.
1132*4882a593Smuzhiyun * Compositing glyphs is handled by dmxProcRenderCompositeGlyphs().
1133*4882a593Smuzhiyun * This function should never be called. */
1134*4882a593Smuzhiyun void
dmxGlyphs(CARD8 op,PicturePtr pSrc,PicturePtr pDst,PictFormatPtr maskFormat,INT16 xSrc,INT16 ySrc,int nlists,GlyphListPtr lists,GlyphPtr * glyphs)1135*4882a593Smuzhiyun dmxGlyphs(CARD8 op,
1136*4882a593Smuzhiyun PicturePtr pSrc, PicturePtr pDst,
1137*4882a593Smuzhiyun PictFormatPtr maskFormat,
1138*4882a593Smuzhiyun INT16 xSrc, INT16 ySrc,
1139*4882a593Smuzhiyun int nlists, GlyphListPtr lists, GlyphPtr * glyphs)
1140*4882a593Smuzhiyun {
1141*4882a593Smuzhiyun /* This won't work, so we need to wrap ProcRenderCompositeGlyphs */
1142*4882a593Smuzhiyun }
1143*4882a593Smuzhiyun
1144*4882a593Smuzhiyun /** Fill a rectangle on the appropriate screen by combining the color
1145*4882a593Smuzhiyun * with the dest picture in the area specified by the list of
1146*4882a593Smuzhiyun * rectangles. For a complete description see the protocol document of
1147*4882a593Smuzhiyun * the RENDER library. */
1148*4882a593Smuzhiyun void
dmxCompositeRects(CARD8 op,PicturePtr pDst,xRenderColor * color,int nRect,xRectangle * rects)1149*4882a593Smuzhiyun dmxCompositeRects(CARD8 op,
1150*4882a593Smuzhiyun PicturePtr pDst,
1151*4882a593Smuzhiyun xRenderColor * color, int nRect, xRectangle *rects)
1152*4882a593Smuzhiyun {
1153*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
1154*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
1155*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
1156*4882a593Smuzhiyun dmxPictPrivPtr pPictPriv = DMX_GET_PICT_PRIV(pDst);
1157*4882a593Smuzhiyun
1158*4882a593Smuzhiyun DMX_UNWRAP(CompositeRects, dmxScreen, ps);
1159*4882a593Smuzhiyun #if 0
1160*4882a593Smuzhiyun if (ps->CompositeRects)
1161*4882a593Smuzhiyun ps->CompositeRects(op, pDst, color, nRect, rects);
1162*4882a593Smuzhiyun #endif
1163*4882a593Smuzhiyun
1164*4882a593Smuzhiyun /* CompositeRects on back-end server */
1165*4882a593Smuzhiyun if (pPictPriv->pict) {
1166*4882a593Smuzhiyun XRenderFillRectangles(dmxScreen->beDisplay,
1167*4882a593Smuzhiyun op,
1168*4882a593Smuzhiyun pPictPriv->pict,
1169*4882a593Smuzhiyun (XRenderColor *) color,
1170*4882a593Smuzhiyun (XRectangle *) rects, nRect);
1171*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
1172*4882a593Smuzhiyun }
1173*4882a593Smuzhiyun
1174*4882a593Smuzhiyun DMX_WRAP(CompositeRects, dmxCompositeRects, dmxScreen, ps);
1175*4882a593Smuzhiyun }
1176*4882a593Smuzhiyun
1177*4882a593Smuzhiyun /** Indexed color visuals are not yet supported. */
1178*4882a593Smuzhiyun Bool
dmxInitIndexed(ScreenPtr pScreen,PictFormatPtr pFormat)1179*4882a593Smuzhiyun dmxInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
1180*4882a593Smuzhiyun {
1181*4882a593Smuzhiyun return TRUE;
1182*4882a593Smuzhiyun }
1183*4882a593Smuzhiyun
1184*4882a593Smuzhiyun /** Indexed color visuals are not yet supported. */
1185*4882a593Smuzhiyun void
dmxCloseIndexed(ScreenPtr pScreen,PictFormatPtr pFormat)1186*4882a593Smuzhiyun dmxCloseIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
1187*4882a593Smuzhiyun {
1188*4882a593Smuzhiyun }
1189*4882a593Smuzhiyun
1190*4882a593Smuzhiyun /** Indexed color visuals are not yet supported. */
1191*4882a593Smuzhiyun void
dmxUpdateIndexed(ScreenPtr pScreen,PictFormatPtr pFormat,int ndef,xColorItem * pdef)1192*4882a593Smuzhiyun dmxUpdateIndexed(ScreenPtr pScreen, PictFormatPtr pFormat,
1193*4882a593Smuzhiyun int ndef, xColorItem * pdef)
1194*4882a593Smuzhiyun {
1195*4882a593Smuzhiyun }
1196*4882a593Smuzhiyun
1197*4882a593Smuzhiyun /** Composite a list of trapezoids on the appropriate screen. For a
1198*4882a593Smuzhiyun * complete description see the protocol document of the RENDER
1199*4882a593Smuzhiyun * library. */
1200*4882a593Smuzhiyun void
dmxTrapezoids(CARD8 op,PicturePtr pSrc,PicturePtr pDst,PictFormatPtr maskFormat,INT16 xSrc,INT16 ySrc,int ntrap,xTrapezoid * traps)1201*4882a593Smuzhiyun dmxTrapezoids(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
1202*4882a593Smuzhiyun PictFormatPtr maskFormat,
1203*4882a593Smuzhiyun INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps)
1204*4882a593Smuzhiyun {
1205*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
1206*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
1207*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
1208*4882a593Smuzhiyun dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
1209*4882a593Smuzhiyun dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
1210*4882a593Smuzhiyun
1211*4882a593Smuzhiyun DMX_UNWRAP(Trapezoids, dmxScreen, ps);
1212*4882a593Smuzhiyun #if 0
1213*4882a593Smuzhiyun if (ps->Trapezoids)
1214*4882a593Smuzhiyun ps->Trapezoids(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntrap, *traps);
1215*4882a593Smuzhiyun #endif
1216*4882a593Smuzhiyun
1217*4882a593Smuzhiyun /* Draw trapezoids on back-end server */
1218*4882a593Smuzhiyun if (pDstPriv->pict) {
1219*4882a593Smuzhiyun XRenderPictFormat *pFormat;
1220*4882a593Smuzhiyun
1221*4882a593Smuzhiyun pFormat = dmxFindFormat(dmxScreen, maskFormat);
1222*4882a593Smuzhiyun if (!pFormat) {
1223*4882a593Smuzhiyun /* FIXME: Error! */
1224*4882a593Smuzhiyun }
1225*4882a593Smuzhiyun
1226*4882a593Smuzhiyun XRenderCompositeTrapezoids(dmxScreen->beDisplay,
1227*4882a593Smuzhiyun op,
1228*4882a593Smuzhiyun pSrcPriv->pict,
1229*4882a593Smuzhiyun pDstPriv->pict,
1230*4882a593Smuzhiyun pFormat,
1231*4882a593Smuzhiyun xSrc, ySrc, (XTrapezoid *) traps, ntrap);
1232*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
1233*4882a593Smuzhiyun }
1234*4882a593Smuzhiyun
1235*4882a593Smuzhiyun DMX_WRAP(Trapezoids, dmxTrapezoids, dmxScreen, ps);
1236*4882a593Smuzhiyun }
1237*4882a593Smuzhiyun
1238*4882a593Smuzhiyun /** Composite a list of triangles on the appropriate screen. For a
1239*4882a593Smuzhiyun * complete description see the protocol document of the RENDER
1240*4882a593Smuzhiyun * library. */
1241*4882a593Smuzhiyun void
dmxTriangles(CARD8 op,PicturePtr pSrc,PicturePtr pDst,PictFormatPtr maskFormat,INT16 xSrc,INT16 ySrc,int ntri,xTriangle * tris)1242*4882a593Smuzhiyun dmxTriangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
1243*4882a593Smuzhiyun PictFormatPtr maskFormat,
1244*4882a593Smuzhiyun INT16 xSrc, INT16 ySrc, int ntri, xTriangle * tris)
1245*4882a593Smuzhiyun {
1246*4882a593Smuzhiyun ScreenPtr pScreen = pDst->pDrawable->pScreen;
1247*4882a593Smuzhiyun DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
1248*4882a593Smuzhiyun PictureScreenPtr ps = GetPictureScreen(pScreen);
1249*4882a593Smuzhiyun dmxPictPrivPtr pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
1250*4882a593Smuzhiyun dmxPictPrivPtr pDstPriv = DMX_GET_PICT_PRIV(pDst);
1251*4882a593Smuzhiyun
1252*4882a593Smuzhiyun DMX_UNWRAP(Triangles, dmxScreen, ps);
1253*4882a593Smuzhiyun #if 0
1254*4882a593Smuzhiyun if (ps->Triangles)
1255*4882a593Smuzhiyun ps->Triangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, *tris);
1256*4882a593Smuzhiyun #endif
1257*4882a593Smuzhiyun
1258*4882a593Smuzhiyun /* Draw trapezoids on back-end server */
1259*4882a593Smuzhiyun if (pDstPriv->pict) {
1260*4882a593Smuzhiyun XRenderPictFormat *pFormat;
1261*4882a593Smuzhiyun
1262*4882a593Smuzhiyun pFormat = dmxFindFormat(dmxScreen, maskFormat);
1263*4882a593Smuzhiyun if (!pFormat) {
1264*4882a593Smuzhiyun /* FIXME: Error! */
1265*4882a593Smuzhiyun }
1266*4882a593Smuzhiyun
1267*4882a593Smuzhiyun XRenderCompositeTriangles(dmxScreen->beDisplay,
1268*4882a593Smuzhiyun op,
1269*4882a593Smuzhiyun pSrcPriv->pict,
1270*4882a593Smuzhiyun pDstPriv->pict,
1271*4882a593Smuzhiyun pFormat,
1272*4882a593Smuzhiyun xSrc, ySrc, (XTriangle *) tris, ntri);
1273*4882a593Smuzhiyun dmxSync(dmxScreen, FALSE);
1274*4882a593Smuzhiyun }
1275*4882a593Smuzhiyun
1276*4882a593Smuzhiyun DMX_WRAP(Triangles, dmxTriangles, dmxScreen, ps);
1277*4882a593Smuzhiyun }
1278