2
* Copyright Ā© 2004 Eric Anholt
4
* Permission to use, copy, modify, distribute, and sell this software and its
5
* documentation for any purpose is hereby granted without fee, provided that
6
* the above copyright notice appear in all copies and that both that
7
* copyright notice and this permission notice appear in supporting
8
* documentation, and that the name of Eric Anholt not be used in
9
* advertising or publicity pertaining to distribution of the software without
10
* specific, written prior permission. Eric Anholt makes no
11
* representations about the suitability of this software for any purpose. It
12
* is provided "as is" without express or implied warranty.
14
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
* EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
* PERFORMANCE OF THIS SOFTWARE.
22
/* $Header: /cvs/xorg/xserver/xorg/miext/cw/cw_render.c,v 1.14 2005/07/03 07:02:01 daniels Exp $ */
24
#ifdef HAVE_DIX_CONFIG_H
25
#include <dix-config.h>
29
#include "windowstr.h"
34
#define cwPsDecl(pScreen) \
35
PictureScreenPtr ps = GetPictureScreen (pScreen); \
36
cwScreenPtr pCwScreen = getCwScreen (pScreen)
38
#define cwPicturePrivate \
39
cwPicturePtr pPicturePrivate = getCwPicture(pPicture)
41
#define cwSrcPictureDecl \
42
int src_picture_x_off, src_picture_y_off; \
43
PicturePtr pBackingSrcPicture = cwGetBackingPicture(pSrcPicture, \
47
#define cwDstPictureDecl \
48
int dst_picture_x_off, dst_picture_y_off; \
49
PicturePtr pBackingDstPicture = cwGetBackingPicture(pDstPicture, \
53
#define cwMskPictureDecl \
54
int msk_picture_x_off = 0, msk_picture_y_off = 0; \
55
PicturePtr pBackingMskPicture = (!pMskPicture ? 0 : \
56
cwGetBackingPicture(pMskPicture, \
60
#define cwPsUnwrap(elt) { \
61
ps->elt = pCwScreen->elt; \
64
#define cwPsWrap(elt,func) { \
65
pCwScreen->elt = ps->elt; \
70
cwCreatePicturePrivate (PicturePtr pPicture)
72
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
73
PixmapPtr pPixmap = getCwPixmap (pWindow);
75
cwPicturePtr pPicturePrivate;
77
pPicturePrivate = xalloc (sizeof (cwPictureRec));
81
pPicturePrivate->pBackingPicture = CreatePicture (0, &pPixmap->drawable,
85
if (!pPicturePrivate->pBackingPicture)
87
xfree (pPicturePrivate);
92
* Ensure that this serial number does not match the window's
94
pPicturePrivate->serialNumber = pPixmap->drawable.serialNumber;
95
pPicturePrivate->stateChanges = (1 << (CPLastBit + 1)) - 1;
97
setCwPicture(pPicture, pPicturePrivate);
99
return pPicturePrivate;
103
cwDestroyPicturePrivate (PicturePtr pPicture)
109
if (pPicturePrivate->pBackingPicture)
110
FreePicture (pPicturePrivate->pBackingPicture, 0);
111
xfree (pPicturePrivate);
112
setCwPicture(pPicture, NULL);
117
cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off)
123
DrawablePtr pDrawable = pPicture->pDrawable;
124
WindowPtr pWindow = (WindowPtr) pDrawable;
125
PixmapPtr pPixmap = getCwPixmap (pWindow);
127
*x_off = pDrawable->x - pPixmap->screen_x;
128
*y_off = pDrawable->y - pPixmap->screen_y;
130
return pPicturePrivate->pBackingPicture;
140
cwDestroyPicture (PicturePtr pPicture)
142
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
145
cwPsUnwrap(DestroyPicture);
146
cwDestroyPicturePrivate (pPicture);
147
(*ps->DestroyPicture) (pPicture);
148
cwPsWrap(DestroyPicture, cwDestroyPicture);
152
cwChangePicture (PicturePtr pPicture, Mask mask)
154
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
156
cwPicturePtr pPicturePrivate = getCwPicture(pPicture);
158
cwPsUnwrap(ChangePicture);
159
(*ps->ChangePicture) (pPicture, mask);
161
pPicturePrivate->stateChanges |= mask;
162
cwPsWrap(ChangePicture, cwChangePicture);
167
cwValidatePicture (PicturePtr pPicture,
170
DrawablePtr pDrawable = pPicture->pDrawable;
171
ScreenPtr pScreen = pDrawable->pScreen;
175
cwPsUnwrap(ValidatePicture);
178
* Must call ValidatePicture to ensure pPicture->pCompositeClip is valid
180
(*ps->ValidatePicture) (pPicture, mask);
182
if (!cwDrawableIsRedirWindow (pDrawable))
185
cwDestroyPicturePrivate (pPicture);
189
PicturePtr pBackingPicture;
190
DrawablePtr pBackingDrawable;
193
pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
195
if (pPicturePrivate &&
196
pPicturePrivate->pBackingPicture->pDrawable != pBackingDrawable)
198
cwDestroyPicturePrivate (pPicture);
202
if (!pPicturePrivate)
204
pPicturePrivate = cwCreatePicturePrivate (pPicture);
205
if (!pPicturePrivate)
207
cwPsWrap(ValidatePicture, cwValidatePicture);
212
pBackingPicture = pPicturePrivate->pBackingPicture;
215
* Always copy transform and filters because there's no
216
* indication of when they've changed
218
SetPictureTransform(pBackingPicture, pPicture->transform);
220
if (pBackingPicture->filter != pPicture->filter ||
221
pPicture->filter_nparams > 0)
223
char *filter = PictureGetFilterName (pPicture->filter);
225
SetPictureFilter(pBackingPicture,
226
filter, strlen (filter),
227
pPicture->filter_params,
228
pPicture->filter_nparams);
231
pPicturePrivate->stateChanges |= mask;
233
if (pPicturePrivate->serialNumber != pDrawable->serialNumber ||
234
(pPicturePrivate->stateChanges & (CPClipXOrigin|CPClipYOrigin|CPClipMask)))
236
SetPictureClipRegion (pBackingPicture,
237
x_off - pDrawable->x,
238
y_off - pDrawable->y,
239
pPicture->pCompositeClip);
241
pPicturePrivate->serialNumber = pDrawable->serialNumber;
242
pPicturePrivate->stateChanges &= ~(CPClipXOrigin | CPClipYOrigin | CPClipMask);
245
CopyPicture(pPicture, pPicturePrivate->stateChanges, pBackingPicture);
247
ValidatePicture (pBackingPicture);
249
cwPsWrap(ValidatePicture, cwValidatePicture);
253
cwComposite (CARD8 op,
254
PicturePtr pSrcPicture,
255
PicturePtr pMskPicture,
256
PicturePtr pDstPicture,
266
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
272
cwPsUnwrap(Composite);
273
(*ps->Composite) (op, pBackingSrcPicture, pBackingMskPicture, pBackingDstPicture,
274
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
275
xMsk + msk_picture_x_off, yMsk + msk_picture_y_off,
276
xDst + dst_picture_x_off, yDst + dst_picture_y_off,
278
cwPsWrap(Composite, cwComposite);
283
PicturePtr pSrcPicture,
284
PicturePtr pDstPicture,
285
PictFormatPtr maskFormat,
292
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
300
lists->xOff += dst_picture_x_off;
301
lists->yOff += dst_picture_y_off;
303
(*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
304
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
305
nlists, lists, glyphs);
306
cwPsWrap(Glyphs, cwGlyphs);
310
cwCompositeRects (CARD8 op,
311
PicturePtr pDstPicture,
316
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
321
cwPsUnwrap(CompositeRects);
322
for (i = 0; i < nRect; i++)
324
rects[i].x += dst_picture_x_off;
325
rects[i].y += dst_picture_y_off;
327
(*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects);
328
cwPsWrap(CompositeRects, cwCompositeRects);
332
cwTrapezoids (CARD8 op,
333
PicturePtr pSrcPicture,
334
PicturePtr pDstPicture,
335
PictFormatPtr maskFormat,
341
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
347
cwPsUnwrap(Trapezoids);
348
if (dst_picture_x_off || dst_picture_y_off) {
349
for (i = 0; i < ntrap; i++)
351
traps[i].top += dst_picture_y_off << 16;
352
traps[i].bottom += dst_picture_y_off << 16;
353
traps[i].left.p1.x += dst_picture_x_off << 16;
354
traps[i].left.p1.y += dst_picture_y_off << 16;
355
traps[i].left.p2.x += dst_picture_x_off << 16;
356
traps[i].left.p2.y += dst_picture_y_off << 16;
357
traps[i].right.p1.x += dst_picture_x_off << 16;
358
traps[i].right.p1.y += dst_picture_y_off << 16;
359
traps[i].right.p2.x += dst_picture_x_off << 16;
360
traps[i].right.p2.y += dst_picture_y_off << 16;
363
(*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
364
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
366
cwPsWrap(Trapezoids, cwTrapezoids);
370
cwTriangles (CARD8 op,
371
PicturePtr pSrcPicture,
372
PicturePtr pDstPicture,
373
PictFormatPtr maskFormat,
379
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
385
cwPsUnwrap(Triangles);
386
if (dst_picture_x_off || dst_picture_y_off) {
387
for (i = 0; i < ntri; i++)
389
tris[i].p1.x += dst_picture_x_off << 16;
390
tris[i].p1.y += dst_picture_y_off << 16;
391
tris[i].p2.x += dst_picture_x_off << 16;
392
tris[i].p2.y += dst_picture_y_off << 16;
393
tris[i].p3.x += dst_picture_x_off << 16;
394
tris[i].p3.y += dst_picture_y_off << 16;
397
(*ps->Triangles) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
398
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
400
cwPsWrap(Triangles, cwTriangles);
404
cwTriStrip (CARD8 op,
405
PicturePtr pSrcPicture,
406
PicturePtr pDstPicture,
407
PictFormatPtr maskFormat,
413
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
419
cwPsUnwrap(TriStrip);
420
if (dst_picture_x_off || dst_picture_y_off) {
421
for (i = 0; i < npoint; i++)
423
points[i].x += dst_picture_x_off << 16;
424
points[i].y += dst_picture_y_off << 16;
427
(*ps->TriStrip) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
428
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
430
cwPsWrap(TriStrip, cwTriStrip);
435
PicturePtr pSrcPicture,
436
PicturePtr pDstPicture,
437
PictFormatPtr maskFormat,
443
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen;
450
if (dst_picture_x_off || dst_picture_y_off) {
451
for (i = 0; i < npoint; i++)
453
points[i].x += dst_picture_x_off << 16;
454
points[i].y += dst_picture_y_off << 16;
457
(*ps->TriFan) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat,
458
xSrc + src_picture_x_off, ySrc + src_picture_y_off,
460
cwPsWrap(TriFan, cwTriFan);
464
cwInitializeRender (ScreenPtr pScreen)
468
cwPsWrap(DestroyPicture, cwDestroyPicture);
469
cwPsWrap(ChangePicture, cwChangePicture);
470
cwPsWrap(ValidatePicture, cwValidatePicture);
471
cwPsWrap(Composite, cwComposite);
472
cwPsWrap(Glyphs, cwGlyphs);
473
cwPsWrap(CompositeRects, cwCompositeRects);
474
cwPsWrap(Trapezoids, cwTrapezoids);
475
cwPsWrap(Triangles, cwTriangles);
476
cwPsWrap(TriStrip, cwTriStrip);
477
cwPsWrap(TriFan, cwTriFan);
478
/* There is no need to wrap AddTraps as far as we can tell. AddTraps can
479
* only be done on alpha-only pictures, and we won't be getting
480
* alpha-only window pictures, so there's no need to translate.
485
cwFiniRender (ScreenPtr pScreen)
489
cwPsUnwrap(DestroyPicture);
490
cwPsUnwrap(ChangePicture);
491
cwPsUnwrap(ValidatePicture);
492
cwPsUnwrap(Composite);
494
cwPsUnwrap(CompositeRects);
495
cwPsUnwrap(Trapezoids);
496
cwPsUnwrap(Triangles);
497
cwPsUnwrap(TriStrip);