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 | #ifdef RENDER
|
---|
47 | # include "picturestr.h"
|
---|
48 | #endif
|
---|
49 |
|
---|
50 |
|
---|
51 | #define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
|
---|
52 |
|
---|
53 | #define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
|
---|
54 |
|
---|
55 | #define SCREEN_PROLOG(x) pScreen->x = ((VGAarbiterScreenPtr) \
|
---|
56 | dixLookupPrivate(&(pScreen)->devPrivates, VGAarbiterScreenKey))->x
|
---|
57 |
|
---|
58 | #define SCREEN_EPILOG(x,y) pScreen->x = y;
|
---|
59 |
|
---|
60 | #define WRAP_PICT(x,y) if (ps) {pScreenPriv->x = ps->x;\
|
---|
61 | ps->x = y;}
|
---|
62 |
|
---|
63 | #define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
|
---|
64 |
|
---|
65 | #define PICTURE_PROLOGUE(field) ps->field = \
|
---|
66 | ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
---|
67 | VGAarbiterScreenKey))->field
|
---|
68 |
|
---|
69 | #define PICTURE_EPILOGUE(field, wrap) ps->field = wrap
|
---|
70 |
|
---|
71 | #define WRAP_SCREEN_INFO(x,y) do {pScreenPriv->x = pScrn->x; pScrn->x = y;} while(0)
|
---|
72 |
|
---|
73 | #define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
|
---|
74 |
|
---|
75 | #define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
|
---|
76 | (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, \
|
---|
77 | miPointerScreenKey); VGAarbiterScreenPtr pScreenPriv = \
|
---|
78 | ((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
---|
79 | VGAarbiterScreenKey)); PointPriv->spriteFuncs = pScreenPriv->miSprite;
|
---|
80 |
|
---|
81 | #define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
---|
82 | PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs;
|
---|
83 |
|
---|
84 | #define WRAP_SPRITE do { pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
---|
85 | PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs; \
|
---|
86 | } while (0)
|
---|
87 |
|
---|
88 | #define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
|
---|
89 |
|
---|
90 | #define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
|
---|
91 | pGCPriv->wrapFuncs = (x)->funcs; (x)->ops = &VGAarbiterGCOps;\
|
---|
92 | (x)->funcs = &VGAarbiterGCFuncs;
|
---|
93 |
|
---|
94 | #define GC_UNWRAP(x) VGAarbiterGCPtr pGCPriv = \
|
---|
95 | (VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
|
---|
96 | (x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
|
---|
97 |
|
---|
98 | #define GC_SCREEN register ScrnInfoPtr pScrn = \
|
---|
99 | xf86Screens[pGC->pScreen->myNum]
|
---|
100 |
|
---|
101 | #define VGAGet(x)\
|
---|
102 | pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev); \
|
---|
103 | pci_device_vgaarb_lock();
|
---|
104 |
|
---|
105 | #define VGAGet_GC(x)\
|
---|
106 | pci_device_vgaarb_set_target(xf86Screens[pGC->pScreen->myNum]->vgaDev); \
|
---|
107 | pci_device_vgaarb_lock();
|
---|
108 |
|
---|
109 | #define VGAPut(x)\
|
---|
110 | pci_device_vgaarb_unlock();
|
---|
111 |
|
---|
112 | #define VGAPut_GC(x)\
|
---|
113 | pci_device_vgaarb_unlock();
|
---|
114 |
|
---|
115 |
|
---|
116 | typedef struct _VGAarbiterScreen {
|
---|
117 | CreateGCProcPtr CreateGC;
|
---|
118 | CloseScreenProcPtr CloseScreen;
|
---|
119 | ScreenBlockHandlerProcPtr BlockHandler;
|
---|
120 | ScreenWakeupHandlerProcPtr WakeupHandler;
|
---|
121 | GetImageProcPtr GetImage;
|
---|
122 | GetSpansProcPtr GetSpans;
|
---|
123 | SourceValidateProcPtr SourceValidate;
|
---|
124 | CopyWindowProcPtr CopyWindow;
|
---|
125 | ClearToBackgroundProcPtr ClearToBackground;
|
---|
126 | CreatePixmapProcPtr CreatePixmap;
|
---|
127 | SaveScreenProcPtr SaveScreen;
|
---|
128 | /* Colormap */
|
---|
129 | StoreColorsProcPtr StoreColors;
|
---|
130 | /* Cursor */
|
---|
131 | DisplayCursorProcPtr DisplayCursor;
|
---|
132 | RealizeCursorProcPtr RealizeCursor;
|
---|
133 | UnrealizeCursorProcPtr UnrealizeCursor;
|
---|
134 | RecolorCursorProcPtr RecolorCursor;
|
---|
135 | SetCursorPositionProcPtr SetCursorPosition;
|
---|
136 | void (*AdjustFrame)(int,int,int,int);
|
---|
137 | Bool (*SwitchMode)(int, DisplayModePtr,int);
|
---|
138 | Bool (*EnterVT)(int, int);
|
---|
139 | void (*LeaveVT)(int, int);
|
---|
140 | void (*FreeScreen)(int, int);
|
---|
141 | miPointerSpriteFuncPtr miSprite;
|
---|
142 | #ifdef RENDER
|
---|
143 | CompositeProcPtr Composite;
|
---|
144 | GlyphsProcPtr Glyphs;
|
---|
145 | CompositeRectsProcPtr CompositeRects;
|
---|
146 | #endif
|
---|
147 | } VGAarbiterScreenRec, *VGAarbiterScreenPtr;
|
---|
148 |
|
---|
149 | typedef struct _VGAarbiterGC {
|
---|
150 | GCOps *wrapOps;
|
---|
151 | GCFuncs *wrapFuncs;
|
---|
152 | } VGAarbiterGCRec, *VGAarbiterGCPtr;
|
---|
153 |
|
---|
154 | /* Screen funcs */
|
---|
155 | static void VGAarbiterBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask);
|
---|
156 | static void VGAarbiterWakeupHandler(int i, pointer blockData, unsigned long result, pointer pReadmask);
|
---|
157 | static Bool VGAarbiterCloseScreen (int i, ScreenPtr pScreen);
|
---|
158 | static void VGAarbiterGetImage (DrawablePtr pDrawable, int sx, int sy, int w,
|
---|
159 | int h, unsigned int format, unsigned long planemask, char *pdstLine);
|
---|
160 | static void VGAarbiterGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr
|
---|
161 | ppt, int *pwidth, int nspans, char *pdstStart);
|
---|
162 | static void VGAarbiterSourceValidate (DrawablePtr pDrawable, int x, int y,
|
---|
163 | int width, int height);
|
---|
164 | static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
|
---|
165 | RegionPtr prgnSrc);
|
---|
166 | static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w,
|
---|
167 | int h, Bool generateExposures);
|
---|
168 | static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
|
---|
169 | int depth, unsigned int usage_hint);
|
---|
170 | static Bool VGAarbiterCreateGC(GCPtr pGC);
|
---|
171 | static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
|
---|
172 | static void VGAarbiterStoreColors (ColormapPtr pmap, int ndef, xColorItem
|
---|
173 | *pdefs);
|
---|
174 | static void VGAarbiterRecolorCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
175 | CursorPtr pCurs, Bool displayed);
|
---|
176 | static Bool VGAarbiterRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
177 | CursorPtr pCursor);
|
---|
178 | static Bool VGAarbiterUnrealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
179 | CursorPtr pCursor);
|
---|
180 | static Bool VGAarbiterDisplayCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
181 | CursorPtr pCursor);
|
---|
182 | static Bool VGAarbiterSetCursorPosition (DeviceIntPtr pDev, ScreenPtr
|
---|
183 | pScreen, int x, int y, Bool generateEvent);
|
---|
184 | static void VGAarbiterAdjustFrame(int index, int x, int y, int flags);
|
---|
185 | static Bool VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags);
|
---|
186 | static Bool VGAarbiterEnterVT(int index, int flags);
|
---|
187 | static void VGAarbiterLeaveVT(int index, int flags);
|
---|
188 | static void VGAarbiterFreeScreen(int index, int flags);
|
---|
189 |
|
---|
190 | /* GC funcs */
|
---|
191 | static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
|
---|
192 | DrawablePtr pDraw);
|
---|
193 | static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
|
---|
194 | static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
|
---|
195 | static void VGAarbiterDestroyGC(GCPtr pGC);
|
---|
196 | static void VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue,
|
---|
197 | int nrects);
|
---|
198 | static void VGAarbiterDestroyClip(GCPtr pGC);
|
---|
199 | static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
|
---|
200 |
|
---|
201 | /* GC ops */
|
---|
202 | static void VGAarbiterFillSpans( DrawablePtr pDraw, GC *pGC, int nInit,
|
---|
203 | DDXPointPtr pptInit, int *pwidthInit, int fSorted);
|
---|
204 | static void VGAarbiterSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
|
---|
205 | register DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
|
---|
206 | static void VGAarbiterPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
|
---|
207 | int x, int y, int w, int h, int leftPad, int format, char *pImage);
|
---|
208 | static RegionPtr VGAarbiterCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
|
---|
209 | GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty);
|
---|
210 | static RegionPtr VGAarbiterCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
|
---|
211 | GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty,
|
---|
212 | unsigned long bitPlane);
|
---|
213 | static void VGAarbiterPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode,
|
---|
214 | int npt, xPoint *pptInit);
|
---|
215 | static void VGAarbiterPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
|
---|
216 | int npt, DDXPointPtr pptInit);
|
---|
217 | static void VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
|
---|
218 | xSegment *pSeg);
|
---|
219 | static void VGAarbiterPolyRectangle(DrawablePtr pDraw, GCPtr pGC,
|
---|
220 | int nRectsInit, xRectangle *pRectsInit);
|
---|
221 | static void VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
---|
222 | xArc *parcs);
|
---|
223 | static void VGAarbiterFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
|
---|
224 | int mode, int count, DDXPointPtr ptsIn);
|
---|
225 | static void VGAarbiterPolyFillRect( DrawablePtr pDraw, GCPtr pGC,
|
---|
226 | int nrectFill, xRectangle *prectInit);
|
---|
227 | static void VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
---|
228 | xArc *parcs);
|
---|
229 | static int VGAarbiterPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
230 | int count, char *chars);
|
---|
231 | static int VGAarbiterPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
232 | int count, unsigned short *chars);
|
---|
233 | static void VGAarbiterImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
234 | int count, char *chars);
|
---|
235 | static void VGAarbiterImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
---|
236 | int count, unsigned short *chars);
|
---|
237 | static void VGAarbiterImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
---|
238 | int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
|
---|
239 | static void VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
---|
240 | int yInit, unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase);
|
---|
241 | static void VGAarbiterPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr
|
---|
242 | pDraw, int dx, int dy, int xOrg, int yOrg);
|
---|
243 |
|
---|
244 | /* miSpriteFuncs */
|
---|
245 | static Bool VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
---|
246 | pScreen, CursorPtr pCur);
|
---|
247 | static Bool VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
---|
248 | pScreen, CursorPtr pCur);
|
---|
249 | static void VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
250 | CursorPtr pCur, int x, int y);
|
---|
251 | static void VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
---|
252 | int x, int y);
|
---|
253 | static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
|
---|
254 | static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
|
---|
255 |
|
---|
256 |
|
---|
257 | #ifdef RENDER
|
---|
258 | static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
|
---|
259 | PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
|
---|
260 | INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
|
---|
261 | static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
|
---|
262 | PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, GlyphListPtr
|
---|
263 | list, GlyphPtr *glyphs);
|
---|
264 | static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor
|
---|
265 | *color, int nRect, xRectangle *rects);
|
---|
266 | #endif
|
---|