1 | /*
|
---|
2 | * Copyright (c) 2009 Tiago Vignatti
|
---|
3 | *
|
---|
4 | * Permission is hereby granted, free of charge, to any person
|
---|
5 | * obtaining a copy of this software and associated documentation
|
---|
6 | * files (the "Software"), to deal in the Software without
|
---|
7 | * restriction, including without limitation the rights to use,
|
---|
8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
9 | * copies of the Software, and to permit persons to whom the
|
---|
10 | * Software is furnished to do so, subject to the following
|
---|
11 | * conditions:
|
---|
12 | *
|
---|
13 | * The above copyright notice and this permission notice shall be
|
---|
14 | * included in all copies or substantial portions of the Software.
|
---|
15 | *
|
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
23 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifdef HAVE_XORG_CONFIG_H
|
---|
28 | #include <xorg-config.h>
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #include "misc.h"
|
---|
32 | #include "xf86.h"
|
---|
33 | #include "xf86_OSproc.h"
|
---|
34 | #include <X11/X.h>
|
---|
35 | #include "colormapst.h"
|
---|
36 | #include "scrnintstr.h"
|
---|
37 | #include "screenint.h"
|
---|
38 | #include "gcstruct.h"
|
---|
39 | #include "pixmapstr.h"
|
---|
40 | #include "pixmap.h"
|
---|
41 | #include "windowstr.h"
|
---|
42 | #include "window.h"
|
---|
43 | #include "xf86str.h"
|
---|
44 | #include "mipointer.h"
|
---|
45 | #include "mipointrst.h"
|
---|
46 | # include "picturestr.h"
|
---|
47 |
|
---|
48 |
|
---|
49 | #define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
|
---|
50 |
|
---|
51 | #define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
|
---|
52 |
|
---|
53 | #define SCREEN_PROLOG(x) pScreen->x = ((VGAarbiterScreenPtr) \
|
---|
54 | dixLookupPrivate(&(pScreen)->devPrivates, VGAarbiterScreenKey))->x
|
---|
55 |
|
---|
56 | #define SCREEN_EPILOG(x,y) pScreen->x = y;
|
---|
57 |
|
---|
58 | #define WRAP_PICT(x,y) if (ps) {pScreenPriv->x = ps->x;\
|
---|
59 | ps->x = y;}
|
---|
60 |
|
---|
61 | #define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
|
---|
62 |
|
---|
63 | #define PICTURE_PROLOGUE(field) ps->field = \
|
---|
64 | ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
---|
65 | VGAarbiterScreenKey))->field
|
---|
66 |
|
---|
67 | #define PICTURE_EPILOGUE(field, wrap) ps->field = wrap
|
---|
68 |
|
---|
69 | #define WRAP_SCREEN_INFO(x,y) do {pScreenPriv->x = pScrn->x; pScrn->x = y;} while(0)
|
---|
70 |
|
---|
71 | #define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
|
---|
72 |
|
---|
73 | #define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
|
---|
74 | (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, \
|
---|
75 | miPointerScreenKey); VGAarbiterScreenPtr pScreenPriv = \
|
---|
76 | ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
---|
77 | VGAarbiterScreenKey)); PointPriv->spriteFuncs = pScreenPriv->miSprite;
|
---|
78 |
|
---|
79 | #define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
---|
80 | PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs;
|
---|
81 |
|
---|
82 | #define WRAP_SPRITE do { pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
---|
83 | PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs; \
|
---|
84 | } while (0)
|
---|
85 |
|
---|
86 | #define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
|
---|
87 |
|
---|
88 | #define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
|
---|
89 | pGCPriv->wrapFuncs = (x)->funcs; (x)->ops = &VGAarbiterGCOps;\
|
---|
90 | (x)->funcs = &VGAarbiterGCFuncs;
|
---|
91 |
|
---|
92 | #define GC_UNWRAP(x) VGAarbiterGCPtr pGCPriv = \
|
---|
93 | (VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
|
---|
94 | (x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
|
---|
95 |
|
---|
96 | #define GC_SCREEN register ScrnInfoPtr pScrn = \
|
---|
97 | xf86Screens[pGC->pScreen->myNum]
|
---|
98 |
|
---|
99 | #define VGAGet(x)\
|
---|
100 | pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev); \
|
---|
101 | pci_device_vgaarb_lock();
|
---|
102 |
|
---|
103 | #define VGAGet_GC(x)\
|
---|
104 | pci_device_vgaarb_set_target(xf86Screens[pGC->pScreen->myNum]->vgaDev); \
|
---|
105 | pci_device_vgaarb_lock();
|
---|
106 |
|
---|
107 | #define VGAPut(x)\
|
---|
108 | pci_device_vgaarb_unlock();
|
---|
109 |
|
---|
110 | #define VGAPut_GC(x)\
|
---|
111 | pci_device_vgaarb_unlock();
|
---|
112 |
|
---|
113 |
|
---|
114 | typedef struct _VGAarbiterScreen {
|
---|
115 | CreateGCProcPtr CreateGC;
|
---|
116 | CloseScreenProcPtr CloseScreen;
|
---|
117 | ScreenBlockHandlerProcPtr BlockHandler;
|
---|
118 | ScreenWakeupHandlerProcPtr WakeupHandler;
|
---|
119 | GetImageProcPtr GetImage;
|
---|
120 | GetSpansProcPtr GetSpans;
|
---|
121 | SourceValidateProcPtr SourceValidate;
|
---|
122 | CopyWindowProcPtr CopyWindow;
|
---|
123 | ClearToBackgroundProcPtr ClearToBackground;
|
---|
124 | CreatePixmapProcPtr CreatePixmap;
|
---|
125 | SaveScreenProcPtr SaveScreen;
|
---|
126 | /* Colormap */
|
---|
127 | StoreColorsProcPtr StoreColors;
|
---|
128 | /* Cursor */
|
---|
129 | DisplayCursorProcPtr DisplayCursor;
|
---|
130 | RealizeCursorProcPtr RealizeCursor;
|
---|
131 | UnrealizeCursorProcPtr UnrealizeCursor;
|
---|
132 | RecolorCursorProcPtr RecolorCursor;
|
---|
133 | SetCursorPositionProcPtr SetCursorPosition;
|
---|
134 | void (*AdjustFrame)(int,int,int,int);
|
---|
135 | Bool (*SwitchMode)(int, DisplayModePtr,int);
|
---|
136 | Bool (*EnterVT)(int, int);
|
---|
137 | void (*LeaveVT)(int, int);
|
---|
138 | void (*FreeScreen)(int, int);
|
---|
139 | miPointerSpriteFuncPtr miSprite;
|
---|
140 | CompositeProcPtr Composite;
|
---|
141 | GlyphsProcPtr Glyphs;
|
---|
142 | CompositeRectsProcPtr CompositeRects;
|
---|
143 | } VGAarbiterScreenRec, *VGAarbiterScreenPtr;
|
---|
144 |
|
---|
145 | typedef struct _VGAarbiterGC {
|
---|
146 | GCOps *wrapOps;
|
---|
147 | GCFuncs *wrapFuncs;
|
---|
148 | } VGAarbiterGCRec, *VGAarbiterGCPtr;
|
---|
149 |
|
---|
150 | /* Screen funcs */
|
---|
151 | static void VGAarbiterBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask);
|
---|
152 | static void VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask);
|
---|
153 | static Bool VGAarbiterCloseScreen (int i, ScreenPtr pScreen);
|
---|
154 | static void VGAarbiterGetImage (DrawablePtr pDrawable, int sx, int sy, int w,
|
---|
155 | int h, unsigned int format, unsigned long planemask, char *pdstLine);
|
---|
156 | static void VGAarbiterGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr
|
---|
157 | ppt, int *pwidth, int nspans, char *pdstStart);
|
---|
158 | static void VGAarbiterSourceValidate (DrawablePtr pDrawable, int x, int y,
|
---|
159 | int width, int height);
|
---|
160 | static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
|
---|
161 | RegionPtr prgnSrc);
|
---|
162 | static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w,
|
---|
163 | int h, Bool generateExposures);
|
---|
164 | static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
|
---|
165 | int depth, unsigned int usage_hint);
|
---|
166 | static Bool VGAarbiterCreateGC(GCPtr pGC);
|
---|
167 | static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
|
---|
168 | static void VGAarbiterStoreColors (ColormapPtr pmap, int ndef, xColorItem
|
---|
169 | *pdefs);
|
---|
170 | static void VGAarbiterRecolorCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
171 | CursorPtr pCurs, Bool displayed);
|
---|
172 | static Bool VGAarbiterRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
173 | CursorPtr pCursor);
|
---|
174 | static Bool VGAarbiterUnrealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
175 | CursorPtr pCursor);
|
---|
176 | static Bool VGAarbiterDisplayCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
177 | CursorPtr pCursor);
|
---|
178 | static Bool VGAarbiterSetCursorPosition (DeviceIntPtr pDev, ScreenPtr
|
---|
179 | pScreen, int x, int y, Bool generateEvent);
|
---|
180 | static void VGAarbiterAdjustFrame(int index, int x, int y, int flags);
|
---|
181 | static Bool VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags);
|
---|
182 | static Bool VGAarbiterEnterVT(int index, int flags);
|
---|
183 | static void VGAarbiterLeaveVT(int index, int flags);
|
---|
184 | static void VGAarbiterFreeScreen(int index, int flags);
|
---|
185 |
|
---|
186 | /* GC funcs */
|
---|
187 | static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
|
---|
188 | DrawablePtr pDraw);
|
---|
189 | static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
|
---|
190 | static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
|
---|
191 | static void VGAarbiterDestroyGC(GCPtr pGC);
|
---|
192 | static void VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue,
|
---|
193 | int nrects);
|
---|
194 | static void VGAarbiterDestroyClip(GCPtr pGC);
|
---|
195 | static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
|
---|
196 |
|
---|
197 | /* GC ops */
|
---|
198 | static void VGAarbiterFillSpans( DrawablePtr pDraw, GC *pGC, int nInit,
|
---|
199 | DDXPointPtr pptInit, int *pwidthInit, int fSorted);
|
---|
200 | static void VGAarbiterSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
|
---|
201 | register DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
|
---|
202 | static void VGAarbiterPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
|
---|
203 | int x, int y, int w, int h, int leftPad, int format, char *pImage);
|
---|
204 | static RegionPtr VGAarbiterCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
|
---|
205 | GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty);
|
---|
206 | static RegionPtr VGAarbiterCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
|
---|
207 | GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty,
|
---|
208 | unsigned long bitPlane);
|
---|
209 | static void VGAarbiterPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode,
|
---|
210 | int npt, xPoint *pptInit);
|
---|
211 | static void VGAarbiterPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
|
---|
212 | int npt, DDXPointPtr pptInit);
|
---|
213 | static void VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
|
---|
214 | xSegment *pSeg);
|
---|
215 | static void VGAarbiterPolyRectangle(DrawablePtr pDraw, GCPtr pGC,
|
---|
216 | int nRectsInit, xRectangle *pRectsInit);
|
---|
217 | static void VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
---|
218 | xArc *parcs);
|
---|
219 | static void VGAarbiterFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
|
---|
220 | int mode, int count, DDXPointPtr ptsIn);
|
---|
221 | static void VGAarbiterPolyFillRect( DrawablePtr pDraw, GCPtr pGC,
|
---|
222 | int nrectFill, xRectangle *prectInit);
|
---|
223 | static void VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
---|
224 | xArc *parcs);
|
---|
225 | static int VGAarbiterPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
226 | int count, char *chars);
|
---|
227 | static int VGAarbiterPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
228 | int count, unsigned short *chars);
|
---|
229 | static void VGAarbiterImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
230 | int count, char *chars);
|
---|
231 | static void VGAarbiterImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
232 | int count, unsigned short *chars);
|
---|
233 | static void VGAarbiterImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
---|
234 | int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
|
---|
235 | static void VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
---|
236 | int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
|
---|
237 | static void VGAarbiterPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr
|
---|
238 | pDraw, int dx, int dy, int xOrg, int yOrg);
|
---|
239 |
|
---|
240 | /* miSpriteFuncs */
|
---|
241 | static Bool VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
---|
242 | pScreen, CursorPtr pCur);
|
---|
243 | static Bool VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
---|
244 | pScreen, CursorPtr pCur);
|
---|
245 | static void VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
246 | CursorPtr pCur, int x, int y);
|
---|
247 | static void VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
248 | int x, int y);
|
---|
249 | static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
|
---|
250 | static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
|
---|
251 |
|
---|
252 |
|
---|
253 | static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
|
---|
254 | PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
|
---|
255 | INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
|
---|
256 | static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
|
---|
257 | PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, GlyphListPtr
|
---|
258 | list, GlyphPtr *glyphs);
|
---|
259 | static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor
|
---|
260 | *color, int nRect, xRectangle *rects);
|
---|