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