3 Copyright 1990, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
37 #include "scrnintstr.h"
38 #include "pixmapstr.h"
42 #include <X11/extensions/shm.h>
46 /* We use this structure to propogate some information from miScreenInit to
47 * miCreateScreenResources. miScreenInit allocates the structure, fills it
48 * in, and puts it into pScreen->devPrivate. miCreateScreenResources
49 * extracts the info and frees the structure. We could've accomplished the
50 * same thing by adding fields to the screen structure, but they would have
51 * ended up being redundant, and would have exposed this mi implementation
52 * detail to the whole server.
56 pointer pbits
; /* pointer to framebuffer */
57 int width
; /* delta to add to a framebuffer addr to move one row down */
58 } miScreenInitParmsRec
, *miScreenInitParmsPtr
;
60 /* this plugs into pScreen->ModifyPixmapHeader */
62 miModifyPixmapHeader(PixmapPtr pPixmap
, int width
, int height
, int depth
,
63 int bitsPerPixel
, int devKind
, pointer pPixData
)
69 * If all arguments are specified, reinitialize everything (including
72 if ((width
> 0) && (height
> 0) && (depth
> 0) && (bitsPerPixel
> 0) &&
73 (devKind
> 0) && pPixData
) {
74 pPixmap
->drawable
.depth
= depth
;
75 pPixmap
->drawable
.bitsPerPixel
= bitsPerPixel
;
76 pPixmap
->drawable
.id
= 0;
77 pPixmap
->drawable
.x
= 0;
78 pPixmap
->drawable
.y
= 0;
79 pPixmap
->drawable
.width
= width
;
80 pPixmap
->drawable
.height
= height
;
81 pPixmap
->devKind
= devKind
;
83 pPixmap
->devPrivate
.ptr
= pPixData
;
87 * Only modify specified fields, keeping all others intact.
91 pPixmap
->drawable
.width
= width
;
94 pPixmap
->drawable
.height
= height
;
97 pPixmap
->drawable
.depth
= depth
;
100 pPixmap
->drawable
.bitsPerPixel
= bitsPerPixel
;
101 else if ((bitsPerPixel
< 0) && (depth
> 0))
102 pPixmap
->drawable
.bitsPerPixel
= BitsPerPixel(depth
);
105 * CAVEAT: Non-SI DDXen may use devKind and devPrivate fields for
109 pPixmap
->devKind
= devKind
;
110 else if ((devKind
< 0) && ((width
> 0) || (depth
> 0)))
111 pPixmap
->devKind
= PixmapBytePad(pPixmap
->drawable
.width
,
112 pPixmap
->drawable
.depth
);
115 pPixmap
->devPrivate
.ptr
= pPixData
;
117 pPixmap
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
122 miCloseScreen(ScreenPtr pScreen
)
124 return ((*pScreen
->DestroyPixmap
) ((PixmapPtr
) pScreen
->devPrivate
));
127 /* With the introduction of pixmap privates, the "screen pixmap" can no
128 * longer be created in miScreenInit, since all the modules that could
129 * possibly ask for pixmap private space have not been initialized at
130 * that time. pScreen->CreateScreenResources is called after all
131 * possible private-requesting modules have been inited; we create the
132 * screen pixmap here.
135 miCreateScreenResources(ScreenPtr pScreen
)
137 miScreenInitParmsPtr pScrInitParms
;
140 pScrInitParms
= (miScreenInitParmsPtr
) pScreen
->devPrivate
;
142 /* if width is non-zero, pScreen->devPrivate will be a pixmap
143 * else it will just take the value pbits
145 if (pScrInitParms
->width
) {
148 /* create a pixmap with no data, then redirect it to point to
152 (*pScreen
->CreatePixmap
) (pScreen
, 0, 0, pScreen
->rootDepth
, 0);
156 if (!(*pScreen
->ModifyPixmapHeader
) (pPixmap
, pScreen
->width
,
159 BitsPerPixel(pScreen
->rootDepth
),
160 PixmapBytePad(pScrInitParms
->width
,
162 pScrInitParms
->pbits
))
164 value
= (pointer
) pPixmap
;
167 value
= pScrInitParms
->pbits
;
169 free(pScreen
->devPrivate
); /* freeing miScreenInitParmsRec */
170 pScreen
->devPrivate
= value
; /* pPixmap or pbits */
175 miScreenDevPrivateInit(ScreenPtr pScreen
, int width
, pointer pbits
)
177 miScreenInitParmsPtr pScrInitParms
;
179 /* Stash pbits and width in a short-lived miScreenInitParmsRec attached
180 * to the screen, until CreateScreenResources can put them in the
183 pScrInitParms
= malloc(sizeof(miScreenInitParmsRec
));
186 pScrInitParms
->pbits
= pbits
;
187 pScrInitParms
->width
= width
;
188 pScreen
->devPrivate
= (pointer
) pScrInitParms
;
193 miGetScreenPixmap(ScreenPtr pScreen
)
195 return (PixmapPtr
) (pScreen
->devPrivate
);
199 miSetScreenPixmap(PixmapPtr pPix
)
202 pPix
->drawable
.pScreen
->devPrivate
= (pointer
) pPix
;
206 miScreenInit(ScreenPtr pScreen
, pointer pbits
, /* pointer to screen bits */
207 int xsize
, int ysize
, /* in pixels */
208 int dpix
, int dpiy
, /* dots per inch */
209 int width
, /* pixel width of frame buffer */
210 int rootDepth
, /* depth of root window */
211 int numDepths
, /* number of depths supported */
212 DepthRec
* depths
, /* supported depths */
213 VisualID rootVisual
, /* root visual */
214 int numVisuals
, /* number of visuals supported */
215 VisualRec
* visuals
/* supported visuals */
218 pScreen
->width
= xsize
;
219 pScreen
->height
= ysize
;
220 pScreen
->mmWidth
= (xsize
* 254 + dpix
* 5) / (dpix
* 10);
221 pScreen
->mmHeight
= (ysize
* 254 + dpiy
* 5) / (dpiy
* 10);
222 pScreen
->numDepths
= numDepths
;
223 pScreen
->rootDepth
= rootDepth
;
224 pScreen
->allowedDepths
= depths
;
225 pScreen
->rootVisual
= rootVisual
;
227 pScreen
->minInstalledCmaps
= 1;
228 pScreen
->maxInstalledCmaps
= 1;
229 pScreen
->backingStoreSupport
= NotUseful
;
230 pScreen
->saveUnderSupport
= NotUseful
;
231 /* whitePixel, blackPixel */
232 pScreen
->ModifyPixmapHeader
= miModifyPixmapHeader
;
233 pScreen
->CreateScreenResources
= miCreateScreenResources
;
234 pScreen
->GetScreenPixmap
= miGetScreenPixmap
;
235 pScreen
->SetScreenPixmap
= miSetScreenPixmap
;
236 pScreen
->numVisuals
= numVisuals
;
237 pScreen
->visuals
= visuals
;
240 ShmRegisterFbFuncs(pScreen
);
242 pScreen
->CloseScreen
= miCloseScreen
;
244 /* else CloseScreen */
245 /* QueryBestSize, SaveScreen, GetImage, GetSpans */
246 pScreen
->SourceValidate
= (SourceValidateProcPtr
) 0;
247 /* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */
248 /* RealizeWindow, UnrealizeWindow */
249 pScreen
->ValidateTree
= miValidateTree
;
250 pScreen
->PostValidateTree
= (PostValidateTreeProcPtr
) 0;
251 pScreen
->WindowExposures
= miWindowExposures
;
253 pScreen
->ClearToBackground
= miClearToBackground
;
254 pScreen
->ClipNotify
= (ClipNotifyProcPtr
) 0;
255 pScreen
->RestackWindow
= (RestackWindowProcPtr
) 0;
256 /* CreatePixmap, DestroyPixmap */
257 /* RealizeFont, UnrealizeFont */
259 /* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */
260 /* ListInstalledColormaps, StoreColors, ResolveColor */
262 pScreen
->SendGraphicsExpose
= miSendGraphicsExpose
;
263 pScreen
->BlockHandler
= (ScreenBlockHandlerProcPtr
) NoopDDA
;
264 pScreen
->WakeupHandler
= (ScreenWakeupHandlerProcPtr
) NoopDDA
;
265 pScreen
->MarkWindow
= miMarkWindow
;
266 pScreen
->MarkOverlappedWindows
= miMarkOverlappedWindows
;
267 pScreen
->MoveWindow
= miMoveWindow
;
268 pScreen
->ResizeWindow
= miSlideAndSizeWindow
;
269 pScreen
->GetLayerWindow
= miGetLayerWindow
;
270 pScreen
->HandleExposures
= miHandleValidateExposures
;
271 pScreen
->ReparentWindow
= (ReparentWindowProcPtr
) 0;
272 pScreen
->ChangeBorderWidth
= miChangeBorderWidth
;
273 pScreen
->SetShape
= miSetShape
;
274 pScreen
->MarkUnrealizedWindow
= miMarkUnrealizedWindow
;
276 miSetZeroLineBias(pScreen
, DEFAULTZEROLINEBIAS
);
278 return miScreenDevPrivateInit(pScreen
, width
, pbits
);
281 DevPrivateKeyRec miZeroLineScreenKeyRec
;
284 miSetZeroLineBias(ScreenPtr pScreen
, unsigned int bias
)
286 if (!dixRegisterPrivateKey(&miZeroLineScreenKeyRec
, PRIVATE_SCREEN
, 0))
289 dixSetPrivate(&pScreen
->devPrivates
, miZeroLineScreenKey
,
290 (unsigned long *) (unsigned long) bias
);