3 #ifdef HAVE_XORG_CONFIG_H
4 #include <xorg-config.h>
11 #include "scrnintstr.h"
12 #include "pixmapstr.h"
15 #include "colormapst.h"
26 #include "mioverlay.h"
31 /* CAUTION: We require that cfb8 and cfb32 were NOT
32 compiled with CFB_NEED_SCREEN_PRIVATE */
34 static BSFuncRec cfb8_32BSFuncRec
= {
37 (BackingStoreSetClipmaskRgnProcPtr
) 0,
38 (BackingStoreGetImagePixmapProcPtr
) 0,
39 (BackingStoreGetSpansPixmapProcPtr
) 0,
43 int cfb8_32GCPrivateIndex
;
44 int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex
; }
45 int cfb8_32ScreenPrivateIndex
;
46 int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex
; }
47 static unsigned long cfb8_32Generation
= 0;
50 cfb8_32AllocatePrivates(ScreenPtr pScreen
)
52 cfb8_32ScreenPtr pScreenPriv
;
54 if(cfb8_32Generation
!= serverGeneration
) {
55 if(((cfb8_32GCPrivateIndex
= AllocateGCPrivateIndex()) < 0) ||
56 ((cfb8_32ScreenPrivateIndex
= AllocateScreenPrivateIndex()) < 0))
58 cfb8_32Generation
= serverGeneration
;
61 if (!(pScreenPriv
= xalloc(sizeof(cfb8_32ScreenRec
))))
64 pScreen
->devPrivates
[cfb8_32ScreenPrivateIndex
].ptr
= (pointer
)pScreenPriv
;
67 /* All cfb will have the same GC and Window private indicies */
68 if(!mfbAllocatePrivates(pScreen
,&cfbWindowPrivateIndex
, &cfbGCPrivateIndex
))
71 /* The cfb indicies are the mfb indicies. Reallocating them resizes them */
72 if(!AllocateWindowPrivate(pScreen
,cfbWindowPrivateIndex
,sizeof(cfbPrivWin
)))
75 if(!AllocateGCPrivate(pScreen
, cfbGCPrivateIndex
, sizeof(cfbPrivGC
)))
78 if(!AllocateGCPrivate(pScreen
, cfb8_32GCPrivateIndex
, sizeof(cfb8_32GCRec
)))
84 static void DestroyColormapNoop(
85 ColormapPtr pColormap
)
90 static void StoreColorsNoop(
91 ColormapPtr pColormap
,
101 pointer pbits
, /* pointer to screen bitmap */
102 int xsize
, int ysize
, /* in pixels */
103 int dpix
, int dpiy
, /* dots per inch */
104 int width
/* pixel width of frame buffer */
106 if (!cfb8_32AllocatePrivates(pScreen
))
108 pScreen
->defColormap
= FakeClientID(0);
109 /* let CreateDefColormap do whatever it wants for pixels */
110 pScreen
->blackPixel
= pScreen
->whitePixel
= (Pixel
) 0;
111 pScreen
->QueryBestSize
= mfbQueryBestSize
;
113 pScreen
->GetImage
= cfb8_32GetImage
;
114 pScreen
->GetSpans
= cfb8_32GetSpans
;
115 pScreen
->CreateWindow
= cfb8_32CreateWindow
;
116 pScreen
->DestroyWindow
= cfb8_32DestroyWindow
;
117 pScreen
->PositionWindow
= cfb8_32PositionWindow
;
118 pScreen
->ChangeWindowAttributes
= cfb8_32ChangeWindowAttributes
;
119 pScreen
->RealizeWindow
= cfb32MapWindow
; /* OK */
120 pScreen
->UnrealizeWindow
= cfb32UnmapWindow
; /* OK */
121 pScreen
->PaintWindowBackground
= cfb8_32PaintWindow
;
122 pScreen
->PaintWindowBorder
= cfb8_32PaintWindow
;
123 pScreen
->CopyWindow
= cfb8_32CopyWindow
;
124 pScreen
->CreatePixmap
= cfb32CreatePixmap
; /* OK */
125 pScreen
->DestroyPixmap
= cfb32DestroyPixmap
; /* OK */
126 pScreen
->RealizeFont
= mfbRealizeFont
;
127 pScreen
->UnrealizeFont
= mfbUnrealizeFont
;
128 pScreen
->CreateGC
= cfb8_32CreateGC
;
129 pScreen
->CreateColormap
= miInitializeColormap
;
130 pScreen
->DestroyColormap
= DestroyColormapNoop
;
131 pScreen
->InstallColormap
= miInstallColormap
;
132 pScreen
->UninstallColormap
= miUninstallColormap
;
133 pScreen
->ListInstalledColormaps
= miListInstalledColormaps
;
134 pScreen
->StoreColors
= StoreColorsNoop
;
135 pScreen
->ResolveColor
= miResolveColor
;
136 pScreen
->BitmapToRegion
= mfbPixmapToRegion
;
138 mfbRegisterCopyPlaneProc (pScreen
, cfb8_32CopyPlane
);
145 } miScreenInitParmsRec
, *miScreenInitParmsPtr
;
148 cfb8_32CreateScreenResources(ScreenPtr pScreen
)
150 miScreenInitParmsPtr pScrInitParms
;
154 /* get the pitch before mi destroys it */
155 pScrInitParms
= (miScreenInitParmsPtr
)pScreen
->devPrivate
;
156 pitch
= pScrInitParms
->width
<< 2;
158 if((retval
= miCreateScreenResources(pScreen
))) {
159 /* fix the screen pixmap */
160 PixmapPtr pPix
= (PixmapPtr
)pScreen
->devPrivate
;
161 pPix
->drawable
.bitsPerPixel
= 32;
162 pPix
->drawable
.depth
= 8;
163 pPix
->devKind
= pitch
;
171 cfb8_32CloseScreen (int i
, ScreenPtr pScreen
)
173 cfb8_32ScreenPtr pScreenPriv
= CFB8_32_GET_SCREEN_PRIVATE(pScreen
);
174 if(pScreenPriv
->visualData
)
175 xfree(pScreenPriv
->visualData
);
177 xfree((pointer
) pScreenPriv
);
178 pScreen
->devPrivates
[cfb8_32ScreenPrivateIndex
].ptr
= NULL
;
180 return(cfb32CloseScreen(i
, pScreen
));
189 cfb8_32FillBoxSolid8(&(WindowTable
[pScreen
->myNum
]->drawable
),
190 nbox
, pbox
, xf86Screens
[pScreen
->myNum
]->colorKey
);
194 cfb8_32InOverlayFunc(WindowPtr pWin
)
196 return (pWin
->drawable
.depth
== 8);
200 cfb8_32FinishScreenInit(
202 pointer pbits
, /* pointer to screen bitmap */
203 int xsize
, int ysize
, /* in pixels */
204 int dpix
, int dpiy
, /* dots per inch */
205 int width
/* pixel width of frame buffer */
212 VisualID defaultVisual
;
215 if (!miInitVisuals (&visuals
, &depths
, &nvisuals
, &ndepths
, &rootdepth
,
216 &defaultVisual
,((unsigned long)1<<(32-1)), 8, -1))
218 if (! miScreenInit(pScreen
, pbits
, xsize
, ysize
, dpix
, dpiy
, width
,
219 rootdepth
, ndepths
, depths
,
220 defaultVisual
, nvisuals
, visuals
))
223 pScreen
->BackingStoreFuncs
= cfb8_32BSFuncRec
;
224 pScreen
->CreateScreenResources
= cfb8_32CreateScreenResources
;
225 pScreen
->CloseScreen
= cfb8_32CloseScreen
;
226 pScreen
->GetScreenPixmap
= cfb32GetScreenPixmap
; /* OK */
227 pScreen
->SetScreenPixmap
= cfb32SetScreenPixmap
; /* OK */
229 if (! miInitOverlay(pScreen
, cfb8_32InOverlayFunc
, cfb8_32TransFunc
))
236 cfb8_32EnableDisableFBAccess (
240 ScreenPtr pScreen
= screenInfo
.screens
[index
];
241 cfb8_32ScreenPtr pScreenPriv
= CFB8_32_GET_SCREEN_PRIVATE(pScreen
);
243 miOverlaySetRootClip(pScreen
, enable
);
245 (*pScreenPriv
->EnableDisableFBAccess
) (index
, enable
);
248 static Atom overlayVisualsAtom
;
251 CARD32 overlay_visual
;
252 CARD32 transparent_type
;
258 cfb8_32SetupVisuals (ScreenPtr pScreen
)
260 cfb8_32ScreenPtr pScreenPriv
= CFB8_32_GET_SCREEN_PRIVATE(pScreen
);
261 char atomString
[] = {"SERVER_OVERLAY_VISUALS"};
262 overlayVisualRec
*overlayVisuals
;
263 VisualID
*visuals
= NULL
;
265 DepthPtr pDepth
= pScreen
->allowedDepths
;
266 int numDepths
= pScreen
->numDepths
;
269 /* find depth 8 visuals */
270 for(i
= 0; i
< numDepths
; i
++, pDepth
++) {
271 if(pDepth
->depth
== 8) {
272 numVisuals
= pDepth
->numVids
;
273 visuals
= pDepth
->vids
;
278 if(!numVisuals
|| !visuals
) {
279 ErrorF("No overlay visuals found!\n");
283 if(!(overlayVisuals
= xalloc(numVisuals
* sizeof(overlayVisualRec
))))
286 for(i
= 0; i
< numVisuals
; i
++) {
287 overlayVisuals
[i
].overlay_visual
= visuals
[i
];
288 overlayVisuals
[i
].transparent_type
= 1; /* transparent pixel */
289 overlayVisuals
[i
].value
= pScreenPriv
->key
;
290 overlayVisuals
[i
].layer
= 1;
293 overlayVisualsAtom
= MakeAtom(atomString
, sizeof(atomString
) - 1, TRUE
);
294 xf86RegisterRootWindowProperty(pScreen
->myNum
, overlayVisualsAtom
,
295 overlayVisualsAtom
, 32, numVisuals
* 4, overlayVisuals
);
296 pScreenPriv
->visualData
= (pointer
)overlayVisuals
;
302 pointer pbits
, /* pointer to screen bitmap */
303 int xsize
, int ysize
, /* in pixels */
304 int dpix
, int dpiy
, /* dots per inch */
305 int w
/* pixel width of frame buffer */
307 cfb8_32ScreenPtr pScreenPriv
;
308 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
310 if (!cfb8_32SetupScreen(pScreen
, pbits
, xsize
, ysize
, dpix
, dpiy
, w
))
313 pScreenPriv
= CFB8_32_GET_SCREEN_PRIVATE(pScreen
);
314 pScreenPriv
->key
= pScrn
->colorKey
;
315 pScreenPriv
->visualData
= NULL
;
318 pScreenPriv
->EnableDisableFBAccess
= pScrn
->EnableDisableFBAccess
;
319 pScrn
->EnableDisableFBAccess
= cfb8_32EnableDisableFBAccess
;
322 if(cfb8_32FinishScreenInit(pScreen
, pbits
, xsize
, ysize
, dpix
, dpiy
, w
))
324 cfb8_32SetupVisuals(pScreen
);