1 /* 2 * Copyright 2004 Eric Anholt 3 * 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. 13 * 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. 21 */ 22 23 #ifdef HAVE_DIX_CONFIG_H 24 #include <dix-config.h> 25 #endif 26 27 #include "gcstruct.h" 28 #include "picturestr.h" 29 #include "privates.h" 30 31 /* 32 * One of these structures is allocated per GC that gets used with a window with 33 * backing pixmap. 34 */ 35 36 typedef struct { 37 GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures 38 * set FALSE and the clientClip set to 39 * clip output to the valid regions of the 40 * backing pixmap. */ 41 unsigned long serialNumber; /* clientClip computed time */ 42 unsigned long stateChanges; /* changes in parent gc since last copy */ 43 GCOps *wrapOps; /* wrapped ops */ 44 GCFuncs *wrapFuncs; /* wrapped funcs */ 45 } cwGCRec, *cwGCPtr; 46 47 extern _X_EXPORT DevPrivateKeyRec cwGCKeyRec; 48 #define cwGCKey (&cwGCKeyRec) 49 50 #define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey)) 51 #define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p) 52 53 /* 54 * One of these structures is allocated per Picture that gets used with a 55 * window with a backing pixmap 56 */ 57 58 typedef struct { 59 PicturePtr pBackingPicture; 60 unsigned long serialNumber; 61 unsigned long stateChanges; 62 } cwPictureRec, *cwPicturePtr; 63 64 extern _X_EXPORT DevPrivateKeyRec cwPictureKeyRec; 65 #define cwPictureKey (&cwPictureKeyRec) 66 67 #define getCwPicture(pPicture) (pPicture->pDrawable ? \ 68 (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0) 69 #define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p) 70 71 extern _X_EXPORT DevPrivateKeyRec cwWindowKeyRec; 72 #define cwWindowKey (&cwWindowKeyRec) 73 74 #define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey) 75 #define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) 76 #define setCwPixmap(pWindow,pPixmap) \ 77 dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap) 78 79 #define cwDrawableIsRedirWindow(pDraw) \ 80 ((pDraw)->type == DRAWABLE_WINDOW && \ 81 getCwPixmap((WindowPtr) (pDraw)) != NULL) 82 83 typedef struct { 84 /* 85 * screen func wrappers 86 */ 87 CloseScreenProcPtr CloseScreen; 88 GetImageProcPtr GetImage; 89 GetSpansProcPtr GetSpans; 90 CreateGCProcPtr CreateGC; 91 92 CopyWindowProcPtr CopyWindow; 93 94 GetWindowPixmapProcPtr GetWindowPixmap; 95 SetWindowPixmapProcPtr SetWindowPixmap; 96 97 DestroyPictureProcPtr DestroyPicture; 98 ChangePictureClipProcPtr ChangePictureClip; 99 DestroyPictureClipProcPtr DestroyPictureClip; 100 101 ChangePictureProcPtr ChangePicture; 102 ValidatePictureProcPtr ValidatePicture; 103 104 CompositeProcPtr Composite; 105 CompositeRectsProcPtr CompositeRects; 106 107 TrapezoidsProcPtr Trapezoids; 108 TrianglesProcPtr Triangles; 109 TriStripProcPtr TriStrip; 110 TriFanProcPtr TriFan; 111 112 RasterizeTrapezoidProcPtr RasterizeTrapezoid; 113 } cwScreenRec, *cwScreenPtr; 114 115 extern _X_EXPORT DevPrivateKeyRec cwScreenKeyRec; 116 #define cwScreenKey (&cwScreenKeyRec) 117 118 #define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey)) 119 #define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p) 120 121 #define CW_OFFSET_XYPOINTS(ppt, npt) do { \ 122 DDXPointPtr _ppt = (DDXPointPtr)(ppt); \ 123 int _i; \ 124 for (_i = 0; _i < npt; _i++) { \ 125 _ppt[_i].x += dst_off_x; \ 126 _ppt[_i].y += dst_off_y; \ 127 } \ 128 } while (0) 129 130 #define CW_OFFSET_RECTS(prect, nrect) do { \ 131 int _i; \ 132 for (_i = 0; _i < nrect; _i++) { \ 133 (prect)[_i].x += dst_off_x; \ 134 (prect)[_i].y += dst_off_y; \ 135 } \ 136 } while (0) 137 138 #define CW_OFFSET_ARCS(parc, narc) do { \ 139 int _i; \ 140 for (_i = 0; _i < narc; _i++) { \ 141 (parc)[_i].x += dst_off_x; \ 142 (parc)[_i].y += dst_off_y; \ 143 } \ 144 } while (0) 145 146 #define CW_OFFSET_XY_DST(x, y) do { \ 147 (x) = (x) + dst_off_x; \ 148 (y) = (y) + dst_off_y; \ 149 } while (0) 150 151 #define CW_OFFSET_XY_SRC(x, y) do { \ 152 (x) = (x) + src_off_x; \ 153 (y) = (y) + src_off_y; \ 154 } while (0) 155 156 /* cw.c */ 157 extern _X_EXPORT DrawablePtr 158 cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off); 159 160 /* cw_render.c */ 161 162 extern _X_EXPORT void 163 cwInitializeRender (ScreenPtr pScreen); 164 165 extern _X_EXPORT void 166 cwFiniRender (ScreenPtr pScreen); 167 168 /* cw.c */ 169 170 extern _X_EXPORT void 171 miInitializeCompositeWrapper(ScreenPtr pScreen); 172