1 /************************************************************
2 Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
6 Permission to use, copy, modify, and distribute this
7 software and its documentation for any purpose and without
8 fee is hereby granted, provided that the above copyright no-
9 tice appear in all copies and that both that copyright no-
10 tice and this permission notice appear in supporting docu-
11 mentation, and that the names of Sun or X Consortium
12 not be used in advertising or publicity pertaining to
13 distribution of the software without specific prior
14 written permission. Sun and X Consortium make no
15 representations about the suitability of this software for
16 any purpose. It is provided "as is" without any express or
19 SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
21 NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
22 ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
24 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
26 THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 ********************************************************/
29 /* $XConsortium: cfbscrinit.c,v 5.32 94/04/17 20:29:00 dpw Exp $ */
34 #include "scrnintstr.h"
35 #include "pixmapstr.h"
38 #include "colormapst.h"
43 #include "cfbmskbits.h"
47 miBSFuncRec cfbBSFuncRec = {
56 cfbCloseScreen (index, pScreen)
61 DepthPtr depths = pScreen->allowedDepths;
63 for (d = 0; d < pScreen->numDepths; d++)
64 xfree (depths[d].vids);
66 xfree (pScreen->visuals);
67 #ifdef CFB_NEED_SCREEN_PRIVATE
68 xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
70 xfree (pScreen->devPrivate);
76 cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
77 register ScreenPtr pScreen;
78 pointer pbits; /* pointer to screen bitmap */
79 int xsize, ysize; /* in pixels */
80 int dpix, dpiy; /* dots per inch */
81 int width; /* pixel width of frame buffer */
84 extern RegionPtr (*cfbPuntCopyPlane)();
86 if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
88 pScreen->defColormap = FakeClientID(0);
89 /* let CreateDefColormap do whatever it wants for pixels */
90 pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
91 pScreen->QueryBestSize = mfbQueryBestSize;
93 pScreen->GetImage = cfbGetImage;
94 pScreen->GetSpans = cfbGetSpans;
95 pScreen->CreateWindow = cfbCreateWindow;
96 pScreen->DestroyWindow = cfbDestroyWindow;
97 pScreen->PositionWindow = cfbPositionWindow;
98 pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
99 pScreen->RealizeWindow = cfbMapWindow;
100 pScreen->UnrealizeWindow = cfbUnmapWindow;
101 pScreen->PaintWindowBackground = cfbPaintWindow;
102 pScreen->PaintWindowBorder = cfbPaintWindow;
103 pScreen->CopyWindow = cfbCopyWindow;
104 pScreen->CreatePixmap = cfbCreatePixmap;
105 pScreen->DestroyPixmap = cfbDestroyPixmap;
106 pScreen->RealizeFont = mfbRealizeFont;
107 pScreen->UnrealizeFont = mfbUnrealizeFont;
108 pScreen->CreateGC = cfbCreateGC;
109 pScreen->CreateColormap = cfbInitializeColormap;
110 pScreen->DestroyColormap = (void (*)())NoopDDA;
112 pScreen->InstallColormap = cfbInstallColormap;
113 pScreen->UninstallColormap = cfbUninstallColormap;
114 pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
115 pScreen->StoreColors = (void (*)())NoopDDA;
117 pScreen->ResolveColor = cfbResolveColor;
118 pScreen->BitmapToRegion = mfbPixmapToRegion;
120 mfbRegisterCopyPlaneProc (pScreen, cfbCopyPlane);
124 #ifdef CFB_NEED_SCREEN_PRIVATE
126 cfbCreateScreenResources(pScreen)
131 pointer oldDevPrivate = pScreen->devPrivate;
132 pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
133 retval = miCreateScreenResources(pScreen);
134 pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
135 pScreen->devPrivate = oldDevPrivate;
140 cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
141 register ScreenPtr pScreen;
142 pointer pbits; /* pointer to screen bitmap */
143 int xsize, ysize; /* in pixels */
144 int dpix, dpiy; /* dots per inch */
145 int width; /* pixel width of frame buffer */
148 #ifdef CFB_NEED_SCREEN_PRIVATE
149 pointer oldDevPrivate;
156 VisualID defaultVisual;
159 if (!cfbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
160 &defaultVisual,((unsigned long)1<<(PSZ-1)), 8))
162 #ifdef CFB_NEED_SCREEN_PRIVATE
163 oldDevPrivate = pScreen->devPrivate;
165 if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
166 rootdepth, ndepths, depths,
167 defaultVisual, nvisuals, visuals,
170 /* overwrite miCloseScreen with our own */
171 pScreen->CloseScreen = cfbCloseScreen;
172 /* init backing store here so we can overwrite CloseScreen without stepping
173 * on the backing store wrapped version */
174 miInitializeBackingStore (pScreen, &cfbBSFuncRec);
175 #ifdef CFB_NEED_SCREEN_PRIVATE
176 pScreen->CreateScreenResources = cfbCreateScreenResources;
177 pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
178 pScreen->devPrivate = oldDevPrivate;
183 /* dts * (inch/dot) * (25.4 mm / inch) = mm */
185 cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
186 register ScreenPtr pScreen;
187 pointer pbits; /* pointer to screen bitmap */
188 int xsize, ysize; /* in pixels */
189 int dpix, dpiy; /* dots per inch */
190 int width; /* pixel width of frame buffer */
192 if (!cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
194 return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);