1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
/* $TOG: InitOutput.c /main/20 1998/02/10 13:23:56 kaleb $ */
/*
Copyright 1993, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/programs/Xserver/hw/xwin/InitOutput.c,v 1.5 2001/04/18 17:14:06 dawes Exp $ */
#include "win.h"
int g_nNumScreens;
winScreenInfo g_winScreens[MAXSCREENS];
int g_nLastScreen = -1;
ColormapPtr g_cmInstalledMaps[MAXSCREENS];
int g_fdMessageQueue = -1;
int g_winScreenPrivateIndex = -1;
unsigned long g_winGeneration = 0;
static PixmapFormatRec g_PixmapFormats[] = {
{ 1, 1, BITMAP_SCANLINE_PAD },
{ 4, 8, BITMAP_SCANLINE_PAD },
{ 8, 8, BITMAP_SCANLINE_PAD },
{ 15, 16, BITMAP_SCANLINE_PAD },
{ 16, 16, BITMAP_SCANLINE_PAD },
{ 24, 32, BITMAP_SCANLINE_PAD },
{ 32, 32, BITMAP_SCANLINE_PAD }
};
const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
void
winInitializeDefaultScreens (void)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].dwScreen = i;
g_winScreens[i].dwWidth = WIN_DEFAULT_WIDTH;
g_winScreens[i].dwHeight = WIN_DEFAULT_HEIGHT;
g_winScreens[i].dwDepth = WIN_DEFAULT_DEPTH;
g_winScreens[i].pixelBlack = WIN_DEFAULT_BLACKPIXEL;
g_winScreens[i].pixelWhite = WIN_DEFAULT_WHITEPIXEL;
g_winScreens[i].dwLineBias = WIN_DEFAULT_LINEBIAS;
g_winScreens[i].pfb = NULL;
}
g_nNumScreens = 1;
}
DWORD
winBitsPerPixel (DWORD dwDepth)
{
if (dwDepth == 1) return 1;
else if (dwDepth <= 8) return 8;
else if (dwDepth <= 16) return 16;
else return 32;
}
/* See Porting Layer Definition - p. 57 */
void
ddxGiveUp()
{
#if CYGDEBUG
ErrorF ("ddxGiveUp ()\n");
#endif
/* Close our handle to our message queue */
if (g_fdMessageQueue != WIN_FD_INVALID)
{
/* Close /dev/windows */
close (g_fdMessageQueue);
/* Set the file handle to invalid */
g_fdMessageQueue = WIN_FD_INVALID;
}
/* Tell Windows that we want to end the app */
PostQuitMessage (0);
}
/* See Porting Layer Definition - p. 57 */
void
AbortDDX (void)
{
#if CYGDEBUG
ErrorF ("AbortDDX ()\n");
#endif
ddxGiveUp ();
}
void
OsVendorInit (void)
{
#if CYGDEBUG
ErrorF ("OsVendorInit ()\n");
#endif
}
/* See Porting Layer Definition - p. 57 */
void
ddxUseMsg (void)
{
ErrorF ("-screen n WxHxD\n"\
"\tSet screen n's width, height, and bit depth\n");
ErrorF ("-linebias n\n"\
"\tAdjust thin line pixelization\n");
ErrorF ("-blackpixel n\n"\
"\tPixel value for black\n");
ErrorF ("-whitepixel n\n"\
"\tPixel value for white\n");
ErrorF ("-engine n\n"\
"\tOverride the server's detected engine type:\n"\
"\t\tGDI blitter\t\t1\n"\
"\t\tDirectDraw blitter\t2\n"\
"\t\tDirectDraw4 blitter\t4\n");
ErrorF ("-fullscreen\n"
"\tRun the specified server engine in fullscreen mode\n");
}
/* See Porting Layer Definition - p. 57 */
int
ddxProcessArgument (int argc, char *argv[], int i)
{
static Bool fFirstTime = TRUE;
/* Run some initialization procedures the first time through */
if (fFirstTime)
{
winInitializeDefaultScreens ();
fFirstTime = FALSE;
}
/*
Look for the '-screen n WxHxD' arugment
*/
if (strcmp (argv[i], "-screen") == 0)
{
int nScreenNum;
/* Display the usage message if the argument is malformed */
if (i + 2 >= argc)
{
UseMsg ();
return 0;
}
nScreenNum = atoi (argv[i+1]);
if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
{
ErrorF ("Invalid screen number %d\n", nScreenNum);
UseMsg ();
return 0;
}
if (3 != sscanf (argv[i+2], "%dx%dx%d",
(int*)&g_winScreens[nScreenNum].dwWidth,
(int*)&g_winScreens[nScreenNum].dwHeight,
(int*)&g_winScreens[nScreenNum].dwDepth))
{
ErrorF ("Invalid screen configuration %s\n", argv[i+2]);
UseMsg ();
return 0;
}
if (nScreenNum >= g_nNumScreens)
g_nNumScreens = nScreenNum + 1;
g_nLastScreen = nScreenNum;
return 3;
}
/*
Look for the '-blackpixel n' argument
*/
if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
{
Pixel pix;
/* Display the usage message if the argument is malformed */
if (++i >= argc)
{
UseMsg ();
return 0;
}
pix = atoi (argv[i]);
if (-1 == g_nLastScreen)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].pixelBlack = pix;
}
}
else
{
g_winScreens[g_nLastScreen].pixelBlack = pix;
}
return 2;
}
/*
Look for the '-whitepixel n' argument
*/
if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */
{
Pixel pix;
/* Display the usage message if the argument is malformed */
if (++i >= argc)
{
UseMsg ();
return 0;
}
pix = atoi (argv[i]);
if (-1 == g_nLastScreen)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].pixelWhite = pix;
}
}
else
{
g_winScreens[g_nLastScreen].pixelWhite = pix;
}
return 2;
}
/*
Look for the '-linebias n' argument
*/
if (strcmp (argv[i], "-linebias") == 0)
{
unsigned int uiLinebias;
/* Display the usage message if the argument is malformed */
if (++i >= argc)
{
UseMsg ();
return 0;
}
uiLinebias = atoi (argv[i]);
if (-1 == g_nLastScreen)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].dwLineBias = uiLinebias;
}
}
else
{
g_winScreens[g_nLastScreen].dwLineBias = uiLinebias;
}
return 2;
}
/*
Look for the '-engine n' argument
*/
if (strcmp (argv[i], "-engine") == 0)
{
DWORD dwEngine = 0;
CARD8 c8OnBits = 0;
/* Display the usage message if the argument is malformed */
if (++i >= argc)
{
UseMsg ();
return 0;
}
/* Grab the argument */
dwEngine = atoi (argv[i]);
/* Count the one bits in the engine argument */
c8OnBits = winCountBits (dwEngine);
/* Argument should only have a single bit on */
if (c8OnBits != 1)
{
UseMsg ();
return 0;
}
/* Is this parameter attached to a screen or global? */
if (-1 == g_nLastScreen)
{
int i;
/* Parameter is for all screens */
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].dwEnginePreferred = dwEngine;
}
}
else
{
/* Parameter is for a single screen */
g_winScreens[g_nLastScreen].dwEnginePreferred = dwEngine;
}
/* Indicate that we have processed the argument */
return 2;
}
/* Look for the '-fullscreen' argument */
if (strcmp(argv[i], "-fullscreen") == 0)
{
/* Is this parameter attached to a screen or is it global? */
if (-1 == g_nLastScreen)
{
int i;
/* Parameter is for all screens */
for (i = 0; i < MAXSCREENS; i++)
{
g_winScreens[i].fFullScreen = TRUE;
}
}
else
{
/* Parameter is for a single screen */
g_winScreens[g_nLastScreen].fFullScreen = TRUE;
}
/* Indicate that we have processed this argument */
return 1;
}
return 0;
}
#ifdef DDXTIME /* from ServerOSDefines */
CARD32
GetTimeInMillis (void)
{
return GetTickCount ();
}
#endif /* DDXTIME */
/* See Porting Layer Definition - p. 20 */
/* We use ddxProcessArgument, so we don't need to touch argc and argv */
void
InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
{
int i;
/* Setup global screen info parameters */
screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
screenInfo->numPixmapFormats = NUMFORMATS;
/* Describe how we want common pixmap formats padded */
for (i = 0; i < NUMFORMATS; i++)
{
screenInfo->formats[i] = g_PixmapFormats[i];
}
/* Initialize each screen */
for (i = 0; i < g_nNumScreens; i++)
{
if (-1 == AddScreen (winScreenInit, argc, argv))
{
FatalError ("Couldn't add screen %d", i);
}
}
}
|