1
/* $XFree86: xc/programs/Xserver/cfb/cfbscrinit.c,v 1.19 2001/01/17 22:36:36 dawes Exp $ */
2
/************************************************************
3
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
7
Permission to use, copy, modify, and distribute this
8
software and its documentation for any purpose and without
9
fee is hereby granted, provided that the above copyright no-
10
tice appear in all copies and that both that copyright no-
11
tice and this permission notice appear in supporting docu-
12
mentation, and that the names of Sun or The Open Group
13
not be used in advertising or publicity pertaining to
14
distribution of the software without specific prior
15
written permission. Sun and The Open Group make no
16
representations about the suitability of this software for
17
any purpose. It is provided "as is" without any express or
20
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
21
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
22
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
23
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
25
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
27
THE USE OR PERFORMANCE OF THIS SOFTWARE.
29
********************************************************/
30
/* $Xorg: cfbscrinit.c,v 1.3 2000/08/17 19:48:15 cpqbld Exp $ */
32
#ifdef HAVE_DIX_CONFIG_H
33
#include <dix-config.h>
39
#include "scrnintstr.h"
40
#include "pixmapstr.h"
43
#include "colormapst.h"
48
#include "cfbmskbits.h"
51
BSFuncRec cfbBSFuncRec = {
54
(BackingStoreSetClipmaskRgnProcPtr) 0,
55
(BackingStoreGetImagePixmapProcPtr) 0,
56
(BackingStoreGetSpansPixmapProcPtr) 0,
60
cfbCloseScreen (index, pScreen)
65
DepthPtr depths = pScreen->allowedDepths;
67
for (d = 0; d < pScreen->numDepths; d++)
68
xfree (depths[d].vids);
70
xfree (pScreen->visuals);
71
#ifdef CFB_NEED_SCREEN_PRIVATE
72
xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
74
xfree (pScreen->devPrivate);
79
static void DestroyColormapNoop(
80
ColormapPtr pColormap)
85
static void StoreColorsNoop(
86
ColormapPtr pColormap,
94
cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
95
register ScreenPtr pScreen;
96
pointer pbits; /* pointer to screen bitmap */
97
int xsize, ysize; /* in pixels */
98
int dpix, dpiy; /* dots per inch */
99
int width; /* pixel width of frame buffer */
101
if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
103
pScreen->defColormap = FakeClientID(0);
104
/* let CreateDefColormap do whatever it wants for pixels */
105
pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
106
pScreen->QueryBestSize = mfbQueryBestSizeWeak();
108
pScreen->GetImage = cfbGetImage;
109
pScreen->GetSpans = cfbGetSpans;
110
pScreen->CreateWindow = cfbCreateWindow;
111
pScreen->DestroyWindow = cfbDestroyWindow;
112
pScreen->PositionWindow = cfbPositionWindow;
113
pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
114
pScreen->RealizeWindow = cfbMapWindow;
115
pScreen->UnrealizeWindow = cfbUnmapWindow;
116
pScreen->PaintWindowBackground = cfbPaintWindow;
117
pScreen->PaintWindowBorder = cfbPaintWindow;
118
pScreen->CopyWindow = cfbCopyWindow;
119
pScreen->CreatePixmap = cfbCreatePixmap;
120
pScreen->DestroyPixmap = cfbDestroyPixmap;
121
pScreen->RealizeFont = mfbRealizeFontWeak();
122
pScreen->UnrealizeFont = mfbUnrealizeFontWeak();
123
pScreen->CreateGC = cfbCreateGC;
124
pScreen->CreateColormap = cfbInitializeColormap;
125
pScreen->DestroyColormap = DestroyColormapNoop;
126
pScreen->InstallColormap = cfbInstallColormap;
127
pScreen->UninstallColormap = cfbUninstallColormap;
128
pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
129
pScreen->StoreColors = StoreColorsNoop;
130
pScreen->ResolveColor = cfbResolveColor;
131
pScreen->BitmapToRegion = mfbPixmapToRegionWeak();
133
mfbRegisterCopyPlaneProc (pScreen, cfbCopyPlane);
137
#ifdef CFB_NEED_SCREEN_PRIVATE
139
cfbCreateScreenResources(pScreen)
144
pointer oldDevPrivate = pScreen->devPrivate;
145
pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
146
retval = miCreateScreenResources(pScreen);
147
pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
148
pScreen->devPrivate = oldDevPrivate;
154
cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
155
register ScreenPtr pScreen;
156
pointer pbits; /* pointer to screen bitmap */
157
int xsize, ysize; /* in pixels */
158
int dpix, dpiy; /* dots per inch */
159
int width; /* pixel width of frame buffer */
161
#ifdef CFB_NEED_SCREEN_PRIVATE
162
pointer oldDevPrivate;
169
VisualID defaultVisual;
172
if (!cfbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
173
&defaultVisual,((unsigned long)1<<(PSZ-1)), 8))
175
#ifdef CFB_NEED_SCREEN_PRIVATE
176
oldDevPrivate = pScreen->devPrivate;
178
if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
179
rootdepth, ndepths, depths,
180
defaultVisual, nvisuals, visuals))
182
/* overwrite miCloseScreen with our own */
183
pScreen->CloseScreen = cfbCloseScreen;
184
#ifdef CFB_NEED_SCREEN_PRIVATE
185
pScreen->CreateScreenResources = cfbCreateScreenResources;
186
pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
187
pScreen->devPrivate = oldDevPrivate;
189
pScreen->BackingStoreFuncs = cfbBSFuncRec;
190
pScreen->GetScreenPixmap = cfbGetScreenPixmap;
191
pScreen->SetScreenPixmap = cfbSetScreenPixmap;
195
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
197
cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
198
register ScreenPtr pScreen;
199
pointer pbits; /* pointer to screen bitmap */
200
int xsize, ysize; /* in pixels */
201
int dpix, dpiy; /* dots per inch */
202
int width; /* pixel width of frame buffer */
204
if (!cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
206
return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
210
cfbGetScreenPixmap(pScreen)
213
#ifdef CFB_NEED_SCREEN_PRIVATE
214
return (PixmapPtr)pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
216
return (PixmapPtr)pScreen->devPrivate;
221
cfbSetScreenPixmap(pPix)
224
#ifdef CFB_NEED_SCREEN_PRIVATE
226
pPix->drawable.pScreen->devPrivates[cfbScreenPrivateIndex].ptr =
230
pPix->drawable.pScreen->devPrivate = (pointer)pPix;