1
/* $Xorg: sunMultiDepth.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
4
Copyright 1992, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
30
/* $XFree86: xc/programs/Xserver/hw/sun/sunMultiDepth.c,v 1.6 2001/12/14 19:59:43 dawes Exp $ */
35
#include "scrnintstr.h"
36
#include "pixmapstr.h"
39
#include "colormapst.h"
54
return mfbCreateGC (pGC);
56
else if (pGC->depth <= 8)
58
return cfbCreateGC (pGC);
60
else if (pGC->depth <= 16)
62
return cfb16CreateGC (pGC);
64
else if (pGC->depth <= 32)
66
return cfb32CreateGC (pGC);
72
sunCfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
73
DrawablePtr pDrawable; /* drawable from which to get bits */
74
int wMax; /* largest value of all *pwidths */
75
register DDXPointPtr ppt; /* points to start copying from */
76
int *pwidth; /* list of number of bits to copy */
77
int nspans; /* number of scanlines to copy */
78
char *pdstStart; /* where to put the bits */
80
switch (pDrawable->bitsPerPixel) {
82
mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
85
cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
88
cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
91
cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
98
sunCfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
99
DrawablePtr pDrawable;
102
unsigned long planeMask;
105
switch (pDrawable->bitsPerPixel)
108
mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
111
cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
114
cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
117
cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
123
sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
124
register ScreenPtr pScreen;
125
pointer pbits; /* pointer to screen bitmap */
126
int xsize, ysize; /* in pixels */
127
int dpix, dpiy; /* dots per inch */
128
int width; /* pixel width of frame buffer */
129
int bpp; /* bits per pixel of root */
131
extern int cfbWindowPrivateIndex;
132
extern int cfbGCPrivateIndex;
135
sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
136
sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
137
sunRegisterPixmapFormat( /* depth */ 12, /* bits per pixel */ 16);
138
sunRegisterPixmapFormat( /* depth */ 24, /* bits per pixel */ 32);
142
ret = cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
145
ret = cfb16SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
148
ret = cfb32SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
153
pScreen->CreateGC = sunCfbCreateGC;
154
pScreen->GetImage = sunCfbGetImage;
155
pScreen->GetSpans = sunCfbGetSpans;
159
extern BSFuncRec cfbBSFuncRec, cfb16BSFuncRec, cfb32BSFuncRec;
160
extern int cfb16ScreenPrivateIndex, cfb32ScreenPrivateIndex;
161
extern Bool cfbCloseScreen(), cfb16CloseScreen(), cfb32CloseScreen();
164
sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
165
register ScreenPtr pScreen;
166
pointer pbits; /* pointer to screen bitmap */
167
int xsize, ysize; /* in pixels */
168
int dpix, dpiy; /* dots per inch */
169
int width; /* pixel width of frame buffer */
173
pointer oldDevPrivate;
178
VisualID defaultVisual;
181
if (!cfbInitVisuals(&visuals, &depths, &nvisuals, &ndepths,
182
&rootdepth, &defaultVisual, 1 << (bpp - 1), 8))
184
oldDevPrivate = pScreen->devPrivate;
185
if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
186
rootdepth, ndepths, depths,
187
defaultVisual, nvisuals, visuals))
192
pScreen->CloseScreen = cfbCloseScreen;
193
pScreen->BackingStoreFuncs = cfbBSFuncRec;
196
pScreen->CloseScreen = cfb16CloseScreen;
197
pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
199
pScreen->devPrivate = oldDevPrivate;
200
pScreen->BackingStoreFuncs = cfb16BSFuncRec;
203
pScreen->CloseScreen = cfb32CloseScreen;
204
pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr =
206
pScreen->devPrivate = oldDevPrivate;
207
pScreen->BackingStoreFuncs = cfb32BSFuncRec;
215
sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
216
register ScreenPtr pScreen;
217
pointer pbits; /* pointer to screen bitmap */
218
int xsize, ysize; /* in pixels */
219
int dpix, dpiy; /* dots per inch */
220
int width; /* pixel width of frame buffer */
223
if (!sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
226
return sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix,
231
#else /* SINGLEDEPTH */
233
/* stuff for 8-bit only server */
236
sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
237
register ScreenPtr pScreen;
238
pointer pbits; /* pointer to screen bitmap */
239
int xsize, ysize; /* in pixels */
240
int dpix, dpiy; /* dots per inch */
241
int width; /* pixel width of frame buffer */
242
int bpp; /* bits per pixel of root */
244
sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
245
sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
246
return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
251
sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
252
register ScreenPtr pScreen;
253
pointer pbits; /* pointer to screen bitmap */
254
int xsize, ysize; /* in pixels */
255
int dpix, dpiy; /* dots per inch */
256
int width; /* pixel width of frame buffer */
259
return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
264
sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
265
register ScreenPtr pScreen;
266
pointer pbits; /* pointer to screen bitmap */
267
int xsize, ysize; /* in pixels */
268
int dpix, dpiy; /* dots per inch */
269
int width; /* pixel width of frame buffer */
272
sunRegisterPixmapFormat( /* depth */ 1, /* bits per pixel */ 1);
273
sunRegisterPixmapFormat( /* depth */ 8, /* bits per pixel */ 8);
274
return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
277
#endif /* SINGLEDEPTH */