| 1 |
/* |
| 2 |
|
| 3 |
Copyright 1993, 1998 The Open Group |
| 4 |
|
| 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 |
| 9 |
documentation. |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included |
| 12 |
in all copies or substantial portions of the Software. |
| 13 |
|
| 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. |
| 21 |
|
| 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 |
| 25 |
from The Open Group. |
| 26 |
|
| 27 |
*/ |
| 28 |
|
| 29 |
#ifdef HAVE_DIX_CONFIG_H |
| 30 |
#include <dix-config.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
#if defined(WIN32) |
| 34 |
#include <X11/Xwinsock.h> |
| 35 |
#endif |
| 36 |
#include <stdio.h> |
| 37 |
#include <X11/X.h> |
| 38 |
#include <X11/Xproto.h> |
| 39 |
#include <X11/Xos.h> |
| 40 |
|
| 41 |
#include "dix/screenint_priv.h" |
| 42 |
|
| 43 |
#include "scrnintstr.h" |
| 44 |
#include "servermd.h" |
| 45 |
#define PSZ 8 |
| 46 |
#include "fb.h" |
| 47 |
#include "colormapst.h" |
| 48 |
#include "gcstruct.h" |
| 49 |
#include "input.h" |
| 50 |
#include "mipointer.h" |
| 51 |
#include "micmap.h" |
| 52 |
#include <sys/types.h> |
| 53 |
#ifdef HAVE_MMAP |
| 54 |
#include <sys/mman.h> |
| 55 |
#ifndef MAP_FILE |
| 56 |
#define MAP_FILE 0 |
| 57 |
#endif |
| 58 |
#endif /* HAVE_MMAP */ |
| 59 |
#include <sys/stat.h> |
| 60 |
#include <errno.h> |
| 61 |
#ifndef WIN32 |
| 62 |
#include <sys/param.h> |
| 63 |
#endif |
| 64 |
#include <X11/XWDFile.h> |
| 65 |
#ifdef MITSHM |
| 66 |
#include <sys/ipc.h> |
| 67 |
#include <sys/shm.h> |
| 68 |
#endif /* MITSHM */ |
| 69 |
#include "dix.h" |
| 70 |
#include "miline.h" |
| 71 |
#include "glx_extinit.h" |
| 72 |
#include "randrstr.h" |
| 73 |
|
| 74 |
#define VFB_DEFAULT_WIDTH 1280 |
| 75 |
#define VFB_DEFAULT_HEIGHT 1024 |
| 76 |
#define VFB_DEFAULT_DEPTH 24 |
| 77 |
#define VFB_DEFAULT_WHITEPIXEL 1 |
| 78 |
#define VFB_DEFAULT_BLACKPIXEL 0 |
| 79 |
#define VFB_DEFAULT_LINEBIAS 0 |
| 80 |
#define XWD_WINDOW_NAME_LEN 60 |
| 81 |
|
| 82 |
typedef struct { |
| 83 |
int width; |
| 84 |
int paddedBytesWidth; |
| 85 |
int paddedWidth; |
| 86 |
int height; |
| 87 |
int depth; |
| 88 |
int bitsPerPixel; |
| 89 |
int sizeInBytes; |
| 90 |
int ncolors; |
| 91 |
char *pfbMemory; |
| 92 |
XWDColor *pXWDCmap; |
| 93 |
XWDFileHeader *pXWDHeader; |
| 94 |
Pixel blackPixel; |
| 95 |
Pixel whitePixel; |
| 96 |
unsigned int lineBias; |
| 97 |
CloseScreenProcPtr closeScreen; |
| 98 |
|
| 99 |
#ifdef HAVE_MMAP |
| 100 |
int mmap_fd; |
| 101 |
char mmap_file[MAXPATHLEN]; |
| 102 |
#endif |
| 103 |
|
| 104 |
#ifdef MITSHM |
| 105 |
int shmid; |
| 106 |
#endif |
| 107 |
} vfbScreenInfo, *vfbScreenInfoPtr; |
| 108 |
|
| 109 |
static int vfbNumScreens; |
| 110 |
static vfbScreenInfo *vfbScreens; |
| 111 |
|
| 112 |
static vfbScreenInfo defaultScreenInfo = { |
| 113 |
.width = VFB_DEFAULT_WIDTH, |
| 114 |
.height = VFB_DEFAULT_HEIGHT, |
| 115 |
.depth = VFB_DEFAULT_DEPTH, |
| 116 |
.blackPixel = VFB_DEFAULT_BLACKPIXEL, |
| 117 |
.whitePixel = VFB_DEFAULT_WHITEPIXEL, |
| 118 |
.lineBias = VFB_DEFAULT_LINEBIAS, |
| 119 |
}; |
| 120 |
|
| 121 |
static Bool vfbPixmapDepths[33]; |
| 122 |
|
| 123 |
#ifdef HAVE_MMAP |
| 124 |
static char *pfbdir = NULL; |
| 125 |
#endif |
| 126 |
typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType; |
| 127 |
static fbMemType fbmemtype = NORMAL_MEMORY_FB; |
| 128 |
static char needswap = 0; |
| 129 |
static Bool Render = TRUE; |
| 130 |
|
| 131 |
#define swapcopy16(_dst, _src) \ |
| 132 |
if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \ |
| 133 |
else _dst = _src; |
| 134 |
|
| 135 |
#define swapcopy32(_dst, _src) \ |
| 136 |
if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \ |
| 137 |
else _dst = _src; |
| 138 |
|
| 139 |
static void |
| 140 |
vfbInitializePixmapDepths(void) |
| 141 |
{ |
| 142 |
int i; |
| 143 |
|
| 144 |
vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ |
| 145 |
for (i = 2; i <= 32; i++) |
| 146 |
vfbPixmapDepths[i] = FALSE; |
| 147 |
} |
| 148 |
|
| 149 |
static int |
| 150 |
vfbBitsPerPixel(int depth) |
| 151 |
{ |
| 152 |
if (depth == 1) |
| 153 |
return 1; |
| 154 |
else if (depth <= 8) |
| 155 |
return 8; |
| 156 |
else if (depth <= 16) |
| 157 |
return 16; |
| 158 |
else |
| 159 |
return 32; |
| 160 |
} |
| 161 |
|
| 162 |
static void |
| 163 |
freeScreenInfo(vfbScreenInfoPtr pvfb) |
| 164 |
{ |
| 165 |
switch (fbmemtype) { |
| 166 |
#ifdef HAVE_MMAP |
| 167 |
case MMAPPED_FILE_FB: |
| 168 |
if (-1 == unlink(pvfb->mmap_file)) { |
| 169 |
perror("unlink"); |
| 170 |
ErrorF("unlink %s failed, %s", |
| 171 |
pvfb->mmap_file, strerror(errno)); |
| 172 |
} |
| 173 |
break; |
| 174 |
#else /* HAVE_MMAP */ |
| 175 |
case MMAPPED_FILE_FB: |
| 176 |
break; |
| 177 |
#endif /* HAVE_MMAP */ |
| 178 |
|
| 179 |
#ifdef MITSHM |
| 180 |
case SHARED_MEMORY_FB: |
| 181 |
if (-1 == shmdt((char *) pvfb->pXWDHeader)) { |
| 182 |
perror("shmdt"); |
| 183 |
ErrorF("shmdt failed, %s", strerror(errno)); |
| 184 |
} |
| 185 |
break; |
| 186 |
#else /* MITSHM */ |
| 187 |
case SHARED_MEMORY_FB: |
| 188 |
break; |
| 189 |
#endif /* MITSHM */ |
| 190 |
|
| 191 |
case NORMAL_MEMORY_FB: |
| 192 |
free(pvfb->pXWDHeader); |
| 193 |
break; |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
void |
| 198 |
ddxGiveUp(enum ExitCode error) |
| 199 |
{ |
| 200 |
int i; |
| 201 |
|
| 202 |
/* clean up the framebuffers */ |
| 203 |
for (i = 0; i < vfbNumScreens; i++) { |
| 204 |
freeScreenInfo(&vfbScreens[i]); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
#ifdef __APPLE__ |
| 209 |
void |
| 210 |
DarwinHandleGUI(int argc, char *argv[]) |
| 211 |
{ |
| 212 |
} |
| 213 |
#endif |
| 214 |
|
| 215 |
void |
| 216 |
OsVendorInit(void) |
| 217 |
{ |
| 218 |
} |
| 219 |
|
| 220 |
void |
| 221 |
OsVendorFatalError(const char *f, va_list args) |
| 222 |
{ |
| 223 |
} |
| 224 |
|
| 225 |
#if defined(DDXBEFORERESET) |
| 226 |
void |
| 227 |
ddxBeforeReset(void) |
| 228 |
{ |
| 229 |
return; |
| 230 |
} |
| 231 |
#endif |
| 232 |
|
| 233 |
#if INPUTTHREAD |
| 234 |
/** This function is called in Xserver/os/inputthread.c when starting |
| 235 |
the input thread. */ |
| 236 |
void |
| 237 |
ddxInputThreadInit(void) |
| 238 |
{ |
| 239 |
} |
| 240 |
#endif |
| 241 |
|
| 242 |
void |
| 243 |
ddxUseMsg(void) |
| 244 |
{ |
| 245 |
ErrorF("-screen scrn WxHxD set screen's width, height, depth\n"); |
| 246 |
ErrorF("-pixdepths list-of-int support given pixmap depths\n"); |
| 247 |
ErrorF("+/-render turn on/off RENDER extension support" |
| 248 |
"(default on)\n"); |
| 249 |
ErrorF("-linebias n adjust thin line pixelization\n"); |
| 250 |
ErrorF("-blackpixel n pixel value for black\n"); |
| 251 |
ErrorF("-whitepixel n pixel value for white\n"); |
| 252 |
|
| 253 |
#ifdef HAVE_MMAP |
| 254 |
ErrorF |
| 255 |
("-fbdir directory put framebuffers in mmap'ed files in directory\n"); |
| 256 |
#endif |
| 257 |
|
| 258 |
#ifdef MITSHM |
| 259 |
ErrorF("-shmem put framebuffers in shared memory\n"); |
| 260 |
#endif |
| 261 |
} |
| 262 |
|
| 263 |
int |
| 264 |
ddxProcessArgument(int argc, char *argv[], int i) |
| 265 |
{ |
| 266 |
static Bool firstTime = TRUE; |
| 267 |
static int lastScreen = -1; |
| 268 |
vfbScreenInfo *currentScreen; |
| 269 |
|
| 270 |
if (firstTime) { |
| 271 |
vfbInitializePixmapDepths(); |
| 272 |
firstTime = FALSE; |
| 273 |
} |
| 274 |
|
| 275 |
if (lastScreen == -1) |
| 276 |
currentScreen = &defaultScreenInfo; |
| 277 |
else |
| 278 |
currentScreen = &vfbScreens[lastScreen]; |
| 279 |
|
| 280 |
if (strcmp(argv[i], "-screen") == 0) { /* -screen n WxHxD */ |
| 281 |
int screenNum; |
| 282 |
|
| 283 |
CHECK_FOR_REQUIRED_ARGUMENTS(2); |
| 284 |
screenNum = atoi(argv[i + 1]); |
| 285 |
/* The protocol only has a CARD8 for number of screens in the |
| 286 |
connection setup block, so don't allow more than that. */ |
| 287 |
if ((screenNum < 0) || (screenNum >= 255)) { |
| 288 |
ErrorF("Invalid screen number %d\n", screenNum); |
| 289 |
UseMsg(); |
| 290 |
FatalError("Invalid screen number %d passed to -screen\n", |
| 291 |
screenNum); |
| 292 |
} |
| 293 |
|
| 294 |
if (vfbNumScreens <= screenNum) { |
| 295 |
vfbScreens = |
| 296 |
reallocarray(vfbScreens, screenNum + 1, sizeof(*vfbScreens)); |
| 297 |
if (!vfbScreens) |
| 298 |
FatalError("Not enough memory for screen %d\n", screenNum); |
| 299 |
for (; vfbNumScreens <= screenNum; ++vfbNumScreens) |
| 300 |
vfbScreens[vfbNumScreens] = defaultScreenInfo; |
| 301 |
} |
| 302 |
|
| 303 |
if (3 != sscanf(argv[i + 2], "%dx%dx%d", |
| 304 |
&vfbScreens[screenNum].width, |
| 305 |
&vfbScreens[screenNum].height, |
| 306 |
&vfbScreens[screenNum].depth)) { |
| 307 |
ErrorF("Invalid screen configuration %s\n", argv[i + 2]); |
| 308 |
UseMsg(); |
| 309 |
FatalError("Invalid screen configuration %s for -screen %d\n", |
| 310 |
argv[i + 2], screenNum); |
| 311 |
} |
| 312 |
|
| 313 |
lastScreen = screenNum; |
| 314 |
return 3; |
| 315 |
} |
| 316 |
|
| 317 |
if (strcmp(argv[i], "-pixdepths") == 0) { /* -pixdepths list-of-depth */ |
| 318 |
int depth, ret = 1; |
| 319 |
|
| 320 |
CHECK_FOR_REQUIRED_ARGUMENTS(1); |
| 321 |
while ((++i < argc) && (depth = atoi(argv[i])) != 0) { |
| 322 |
if (depth < 0 || depth > 32) { |
| 323 |
ErrorF("Invalid pixmap depth %d\n", depth); |
| 324 |
UseMsg(); |
| 325 |
FatalError("Invalid pixmap depth %d passed to -pixdepths\n", |
| 326 |
depth); |
| 327 |
} |
| 328 |
vfbPixmapDepths[depth] = TRUE; |
| 329 |
ret++; |
| 330 |
} |
| 331 |
return ret; |
| 332 |
} |
| 333 |
|
| 334 |
if (strcmp(argv[i], "+render") == 0) { /* +render */ |
| 335 |
Render = TRUE; |
| 336 |
return 1; |
| 337 |
} |
| 338 |
|
| 339 |
if (strcmp(argv[i], "-render") == 0) { /* -render */ |
| 340 |
Render = FALSE; |
| 341 |
#ifdef COMPOSITE |
| 342 |
noCompositeExtension = TRUE; |
| 343 |
#endif |
| 344 |
return 1; |
| 345 |
} |
| 346 |
|
| 347 |
if (strcmp(argv[i], "-blackpixel") == 0) { /* -blackpixel n */ |
| 348 |
CHECK_FOR_REQUIRED_ARGUMENTS(1); |
| 349 |
currentScreen->blackPixel = atoi(argv[++i]); |
| 350 |
return 2; |
| 351 |
} |
| 352 |
|
| 353 |
if (strcmp(argv[i], "-whitepixel") == 0) { /* -whitepixel n */ |
| 354 |
CHECK_FOR_REQUIRED_ARGUMENTS(1); |
| 355 |
currentScreen->whitePixel = atoi(argv[++i]); |
| 356 |
return 2; |
| 357 |
} |
| 358 |
|
| 359 |
if (strcmp(argv[i], "-linebias") == 0) { /* -linebias n */ |
| 360 |
CHECK_FOR_REQUIRED_ARGUMENTS(1); |
| 361 |
currentScreen->lineBias = atoi(argv[++i]); |
| 362 |
return 2; |
| 363 |
} |
| 364 |
|
| 365 |
#ifdef HAVE_MMAP |
| 366 |
if (strcmp(argv[i], "-fbdir") == 0) { /* -fbdir directory */ |
| 367 |
CHECK_FOR_REQUIRED_ARGUMENTS(1); |
| 368 |
pfbdir = argv[++i]; |
| 369 |
fbmemtype = MMAPPED_FILE_FB; |
| 370 |
return 2; |
| 371 |
} |
| 372 |
#endif /* HAVE_MMAP */ |
| 373 |
|
| 374 |
#ifdef MITSHM |
| 375 |
if (strcmp(argv[i], "-shmem") == 0) { /* -shmem */ |
| 376 |
fbmemtype = SHARED_MEMORY_FB; |
| 377 |
return 1; |
| 378 |
} |
| 379 |
#endif |
| 380 |
|
| 381 |
return 0; |
| 382 |
} |
| 383 |
|
| 384 |
static void |
| 385 |
vfbInstallColormap(ColormapPtr pmap) |
| 386 |
{ |
| 387 |
ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen); |
| 388 |
|
| 389 |
if (pmap != oldpmap) { |
| 390 |
int entries; |
| 391 |
XWDFileHeader *pXWDHeader; |
| 392 |
VisualPtr pVisual; |
| 393 |
Pixel *ppix; |
| 394 |
xrgb *prgb; |
| 395 |
xColorItem *defs; |
| 396 |
int i; |
| 397 |
|
| 398 |
miInstallColormap(pmap); |
| 399 |
|
| 400 |
entries = pmap->pVisual->ColormapEntries; |
| 401 |
pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader; |
| 402 |
pVisual = pmap->pVisual; |
| 403 |
|
| 404 |
swapcopy32(pXWDHeader->visual_class, pVisual->class); |
| 405 |
swapcopy32(pXWDHeader->red_mask, pVisual->redMask); |
| 406 |
swapcopy32(pXWDHeader->green_mask, pVisual->greenMask); |
| 407 |
swapcopy32(pXWDHeader->blue_mask, pVisual->blueMask); |
| 408 |
swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); |
| 409 |
swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); |
| 410 |
|
| 411 |
ppix = xallocarray(entries, sizeof(Pixel)); |
| 412 |
prgb = xallocarray(entries, sizeof(xrgb)); |
| 413 |
defs = xallocarray(entries, sizeof(xColorItem)); |
| 414 |
|
| 415 |
for (i = 0; i < entries; i++) |
| 416 |
ppix[i] = i; |
| 417 |
/* XXX truecolor */ |
| 418 |
QueryColors(pmap, entries, ppix, prgb, serverClient); |
| 419 |
|
| 420 |
for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ |
| 421 |
defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ |
| 422 |
defs[i].red = prgb[i].red; |
| 423 |
defs[i].green = prgb[i].green; |
| 424 |
defs[i].blue = prgb[i].blue; |
| 425 |
defs[i].flags = DoRed | DoGreen | DoBlue; |
| 426 |
} |
| 427 |
(*pmap->pScreen->StoreColors) (pmap, entries, defs); |
| 428 |
|
| 429 |
free(ppix); |
| 430 |
free(prgb); |
| 431 |
free(defs); |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
static void |
| 436 |
vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs) |
| 437 |
{ |
| 438 |
XWDColor *pXWDCmap; |
| 439 |
int i; |
| 440 |
|
| 441 |
if (pmap != GetInstalledmiColormap(pmap->pScreen)) { |
| 442 |
return; |
| 443 |
} |
| 444 |
|
| 445 |
pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; |
| 446 |
|
| 447 |
if ((pmap->pVisual->class | DynamicClass) == DirectColor) { |
| 448 |
return; |
| 449 |
} |
| 450 |
|
| 451 |
for (i = 0; i < ndef; i++) { |
| 452 |
if (pdefs[i].flags & DoRed) { |
| 453 |
swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red); |
| 454 |
} |
| 455 |
if (pdefs[i].flags & DoGreen) { |
| 456 |
swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green); |
| 457 |
} |
| 458 |
if (pdefs[i].flags & DoBlue) { |
| 459 |
swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue); |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
#ifdef HAVE_MMAP |
| 465 |
|
| 466 |
/* this flushes any changes to the screens out to the mmapped file */ |
| 467 |
static void |
| 468 |
vfbBlockHandler(void *blockData, void *timeout) |
| 469 |
{ |
| 470 |
int i; |
| 471 |
|
| 472 |
for (i = 0; i < vfbNumScreens; i++) { |
| 473 |
#ifdef MS_ASYNC |
| 474 |
if (-1 == msync((caddr_t) vfbScreens[i].pXWDHeader, |
| 475 |
(size_t) vfbScreens[i].sizeInBytes, MS_ASYNC)) |
| 476 |
#else |
| 477 |
/* silly NetBSD and who else? */ |
| 478 |
if (-1 == msync((caddr_t) vfbScreens[i].pXWDHeader, |
| 479 |
(size_t) vfbScreens[i].sizeInBytes)) |
| 480 |
#endif |
| 481 |
{ |
| 482 |
perror("msync"); |
| 483 |
ErrorF("msync failed, %s", strerror(errno)); |
| 484 |
} |
| 485 |
} |
| 486 |
} |
| 487 |
|
| 488 |
static void |
| 489 |
vfbWakeupHandler(void *blockData, int result) |
| 490 |
{ |
| 491 |
} |
| 492 |
|
| 493 |
static void |
| 494 |
vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) |
| 495 |
{ |
| 496 |
#define DUMMY_BUFFER_SIZE 65536 |
| 497 |
char dummyBuffer[DUMMY_BUFFER_SIZE]; |
| 498 |
int currentFileSize, writeThisTime; |
| 499 |
|
| 500 |
snprintf(pvfb->mmap_file, sizeof(pvfb->mmap_file), "%s/Xvfb_screen%d", |
| 501 |
pfbdir, (int) (pvfb - vfbScreens)); |
| 502 |
if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT | O_RDWR, 0666))) { |
| 503 |
perror("open"); |
| 504 |
ErrorF("open %s failed, %s", pvfb->mmap_file, strerror(errno)); |
| 505 |
return; |
| 506 |
} |
| 507 |
|
| 508 |
/* Extend the file to be the proper size */ |
| 509 |
|
| 510 |
memset(dummyBuffer, 0, DUMMY_BUFFER_SIZE); |
| 511 |
for (currentFileSize = 0; |
| 512 |
currentFileSize < pvfb->sizeInBytes; |
| 513 |
currentFileSize += writeThisTime) { |
| 514 |
writeThisTime = min(DUMMY_BUFFER_SIZE, |
| 515 |
pvfb->sizeInBytes - currentFileSize); |
| 516 |
if (-1 == write(pvfb->mmap_fd, dummyBuffer, writeThisTime)) { |
| 517 |
perror("write"); |
| 518 |
ErrorF("write %s failed, %s", pvfb->mmap_file, strerror(errno)); |
| 519 |
return; |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
/* try to mmap the file */ |
| 524 |
|
| 525 |
pvfb->pXWDHeader = (XWDFileHeader *) mmap((caddr_t) NULL, pvfb->sizeInBytes, |
| 526 |
PROT_READ | PROT_WRITE, |
| 527 |
MAP_FILE | MAP_SHARED, |
| 528 |
pvfb->mmap_fd, 0); |
| 529 |
if (-1 == (long) pvfb->pXWDHeader) { |
| 530 |
perror("mmap"); |
| 531 |
ErrorF("mmap %s failed, %s", pvfb->mmap_file, strerror(errno)); |
| 532 |
pvfb->pXWDHeader = NULL; |
| 533 |
return; |
| 534 |
} |
| 535 |
|
| 536 |
if (!RegisterBlockAndWakeupHandlers(vfbBlockHandler, vfbWakeupHandler, |
| 537 |
NULL)) { |
| 538 |
pvfb->pXWDHeader = NULL; |
| 539 |
} |
| 540 |
} |
| 541 |
#endif /* HAVE_MMAP */ |
| 542 |
|
| 543 |
#ifdef MITSHM |
| 544 |
static void |
| 545 |
vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb) |
| 546 |
{ |
| 547 |
/* create the shared memory segment */ |
| 548 |
|
| 549 |
pvfb->shmid = shmget(IPC_PRIVATE, pvfb->sizeInBytes, IPC_CREAT | 0777); |
| 550 |
if (pvfb->shmid < 0) { |
| 551 |
perror("shmget"); |
| 552 |
ErrorF("shmget %d bytes failed, %s", pvfb->sizeInBytes, |
| 553 |
strerror(errno)); |
| 554 |
return; |
| 555 |
} |
| 556 |
|
| 557 |
/* try to attach it */ |
| 558 |
|
| 559 |
pvfb->pXWDHeader = (XWDFileHeader *) shmat(pvfb->shmid, 0, 0); |
| 560 |
if (-1 == (long) pvfb->pXWDHeader) { |
| 561 |
perror("shmat"); |
| 562 |
ErrorF("shmat failed, %s", strerror(errno)); |
| 563 |
pvfb->pXWDHeader = NULL; |
| 564 |
return; |
| 565 |
} |
| 566 |
|
| 567 |
ErrorF("screen %d shmid %d\n", (int) (pvfb - vfbScreens), pvfb->shmid); |
| 568 |
} |
| 569 |
#endif /* MITSHM */ |
| 570 |
|
| 571 |
static char * |
| 572 |
vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) |
| 573 |
{ |
| 574 |
if (pvfb->pfbMemory) |
| 575 |
return pvfb->pfbMemory; /* already done */ |
| 576 |
|
| 577 |
pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; |
| 578 |
|
| 579 |
/* Calculate how many entries in colormap. This is rather bogus, because |
| 580 |
* the visuals haven't even been set up yet, but we need to know because we |
| 581 |
* have to allocate space in the file for the colormap. The number 10 |
| 582 |
* below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. |
| 583 |
*/ |
| 584 |
|
| 585 |
if (pvfb->depth <= 10) { /* single index colormaps */ |
| 586 |
pvfb->ncolors = 1 << pvfb->depth; |
| 587 |
} |
| 588 |
else { /* decomposed colormaps */ |
| 589 |
int nplanes_per_color_component = pvfb->depth / 3; |
| 590 |
|
| 591 |
if (pvfb->depth % 3) |
| 592 |
nplanes_per_color_component++; |
| 593 |
pvfb->ncolors = 1 << nplanes_per_color_component; |
| 594 |
} |
| 595 |
|
| 596 |
/* add extra bytes for XWDFileHeader, window name, and colormap */ |
| 597 |
|
| 598 |
pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + |
| 599 |
pvfb->ncolors * SIZEOF(XWDColor); |
| 600 |
|
| 601 |
pvfb->pXWDHeader = NULL; |
| 602 |
switch (fbmemtype) { |
| 603 |
#ifdef HAVE_MMAP |
| 604 |
case MMAPPED_FILE_FB: |
| 605 |
vfbAllocateMmappedFramebuffer(pvfb); |
| 606 |
break; |
| 607 |
#else |
| 608 |
case MMAPPED_FILE_FB: |
| 609 |
break; |
| 610 |
#endif |
| 611 |
|
| 612 |
#ifdef MITSHM |
| 613 |
case SHARED_MEMORY_FB: |
| 614 |
vfbAllocateSharedMemoryFramebuffer(pvfb); |
| 615 |
break; |
| 616 |
#else |
| 617 |
case SHARED_MEMORY_FB: |
| 618 |
break; |
| 619 |
#endif |
| 620 |
|
| 621 |
case NORMAL_MEMORY_FB: |
| 622 |
pvfb->pXWDHeader = (XWDFileHeader *) malloc(pvfb->sizeInBytes); |
| 623 |
break; |
| 624 |
} |
| 625 |
|
| 626 |
if (pvfb->pXWDHeader) { |
| 627 |
pvfb->pXWDCmap = (XWDColor *) ((char *) pvfb->pXWDHeader |
| 628 |
+ SIZEOF(XWDheader) + |
| 629 |
XWD_WINDOW_NAME_LEN); |
| 630 |
pvfb->pfbMemory = (char *) (pvfb->pXWDCmap + pvfb->ncolors); |
| 631 |
|
| 632 |
return pvfb->pfbMemory; |
| 633 |
} |
| 634 |
|
| 635 |
return NULL; |
| 636 |
} |
| 637 |
|
| 638 |
static void |
| 639 |
vfbWriteXWDFileHeader(ScreenPtr pScreen) |
| 640 |
{ |
| 641 |
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; |
| 642 |
XWDFileHeader *pXWDHeader = pvfb->pXWDHeader; |
| 643 |
char hostname[XWD_WINDOW_NAME_LEN]; |
| 644 |
unsigned long swaptest = 1; |
| 645 |
int i; |
| 646 |
|
| 647 |
needswap = *(char *) &swaptest; |
| 648 |
|
| 649 |
pXWDHeader->header_size = |
| 650 |
(char *) pvfb->pXWDCmap - (char *) pvfb->pXWDHeader; |
| 651 |
pXWDHeader->file_version = XWD_FILE_VERSION; |
| 652 |
|
| 653 |
pXWDHeader->pixmap_format = ZPixmap; |
| 654 |
pXWDHeader->pixmap_depth = pvfb->depth; |
| 655 |
pXWDHeader->pixmap_height = pXWDHeader->window_height = pvfb->height; |
| 656 |
pXWDHeader->xoffset = 0; |
| 657 |
pXWDHeader->byte_order = IMAGE_BYTE_ORDER; |
| 658 |
pXWDHeader->bitmap_bit_order = BITMAP_BIT_ORDER; |
| 659 |
#ifndef INTERNAL_VS_EXTERNAL_PADDING |
| 660 |
pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->width; |
| 661 |
pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT; |
| 662 |
pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD; |
| 663 |
#else |
| 664 |
pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->paddedWidth; |
| 665 |
pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT_PROTO; |
| 666 |
pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD_PROTO; |
| 667 |
#endif |
| 668 |
pXWDHeader->bits_per_pixel = pvfb->bitsPerPixel; |
| 669 |
pXWDHeader->bytes_per_line = pvfb->paddedBytesWidth; |
| 670 |
pXWDHeader->ncolors = pvfb->ncolors; |
| 671 |
|
| 672 |
/* visual related fields are written when colormap is installed */ |
| 673 |
|
| 674 |
pXWDHeader->window_x = pXWDHeader->window_y = 0; |
| 675 |
pXWDHeader->window_bdrwidth = 0; |
| 676 |
|
| 677 |
/* write xwd "window" name: Xvfb hostname:server.screen */ |
| 678 |
|
| 679 |
if (-1 == gethostname(hostname, sizeof(hostname))) |
| 680 |
hostname[0] = 0; |
| 681 |
else |
| 682 |
hostname[XWD_WINDOW_NAME_LEN - 1] = 0; |
| 683 |
sprintf((char *) (pXWDHeader + 1), "Xvfb %s:%s.%d", hostname, display, |
| 684 |
pScreen->myNum); |
| 685 |
|
| 686 |
/* write colormap pixel slot values */ |
| 687 |
|
| 688 |
for (i = 0; i < pvfb->ncolors; i++) { |
| 689 |
pvfb->pXWDCmap[i].pixel = i; |
| 690 |
} |
| 691 |
|
| 692 |
/* byte swap to most significant byte first */ |
| 693 |
|
| 694 |
if (needswap) { |
| 695 |
SwapLongs((CARD32 *) pXWDHeader, SIZEOF(XWDheader) / 4); |
| 696 |
for (i = 0; i < pvfb->ncolors; i++) { |
| 697 |
swapl(&pvfb->pXWDCmap[i].pixel); |
| 698 |
} |
| 699 |
} |
| 700 |
} |
| 701 |
|
| 702 |
static Bool |
| 703 |
vfbCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y) |
| 704 |
{ |
| 705 |
return FALSE; |
| 706 |
} |
| 707 |
|
| 708 |
static void |
| 709 |
vfbCrossScreen(ScreenPtr pScreen, Bool entering) |
| 710 |
{ |
| 711 |
} |
| 712 |
|
| 713 |
static miPointerScreenFuncRec vfbPointerCursorFuncs = { |
| 714 |
vfbCursorOffScreen, |
| 715 |
vfbCrossScreen, |
| 716 |
miPointerWarpCursor |
| 717 |
}; |
| 718 |
|
| 719 |
static Bool |
| 720 |
vfbCloseScreen(ScreenPtr pScreen) |
| 721 |
{ |
| 722 |
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; |
| 723 |
|
| 724 |
pScreen->CloseScreen = pvfb->closeScreen; |
| 725 |
|
| 726 |
/* |
| 727 |
* fb overwrites miCloseScreen, so do this here |
| 728 |
*/ |
| 729 |
if (pScreen->devPrivate) |
| 730 |
(*pScreen->DestroyPixmap) (pScreen->devPrivate); |
| 731 |
pScreen->devPrivate = NULL; |
| 732 |
|
| 733 |
return pScreen->CloseScreen(pScreen); |
| 734 |
} |
| 735 |
|
| 736 |
static Bool |
| 737 |
vfbRROutputValidateMode(ScreenPtr pScreen, |
| 738 |
RROutputPtr output, |
| 739 |
RRModePtr mode) |
| 740 |
{ |
| 741 |
rrScrPriv(pScreen); |
| 742 |
|
| 743 |
if (pScrPriv->minWidth <= mode->mode.width && |
| 744 |
pScrPriv->maxWidth >= mode->mode.width && |
| 745 |
pScrPriv->minHeight <= mode->mode.height && |
| 746 |
pScrPriv->maxHeight >= mode->mode.height) |
| 747 |
return TRUE; |
| 748 |
else |
| 749 |
return FALSE; |
| 750 |
} |
| 751 |
|
| 752 |
static Bool |
| 753 |
vfbRRScreenSetSize(ScreenPtr pScreen, |
| 754 |
CARD16 width, |
| 755 |
CARD16 height, |
| 756 |
CARD32 mmWidth, |
| 757 |
CARD32 mmHeight) |
| 758 |
{ |
| 759 |
rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); |
| 760 |
|
| 761 |
// Prevent screen updates while we change things around |
| 762 |
SetRootClip(pScreen, ROOT_CLIP_NONE); |
| 763 |
|
| 764 |
pScreen->width = width; |
| 765 |
pScreen->height = height; |
| 766 |
pScreen->mmWidth = mmWidth; |
| 767 |
pScreen->mmHeight = mmHeight; |
| 768 |
|
| 769 |
// Restore the ability to update screen, now with new dimensions |
| 770 |
SetRootClip(pScreen, ROOT_CLIP_FULL); |
| 771 |
|
| 772 |
RRScreenSizeNotify (pScreen); |
| 773 |
RRTellChanged(pScreen); |
| 774 |
|
| 775 |
return RROutputSetPhysicalSize(pScrPriv->outputs[pScreen->myNum], mmWidth, mmHeight); |
| 776 |
} |
| 777 |
|
| 778 |
static Bool |
| 779 |
vfbRRCrtcSet(ScreenPtr pScreen, |
| 780 |
RRCrtcPtr crtc, |
| 781 |
RRModePtr mode, |
| 782 |
int x, |
| 783 |
int y, |
| 784 |
Rotation rotation, |
| 785 |
int numOutput, |
| 786 |
RROutputPtr *outputs) |
| 787 |
{ |
| 788 |
return RRCrtcNotify(crtc, mode, x, y, rotation, NULL, numOutput, outputs); |
| 789 |
} |
| 790 |
|
| 791 |
static Bool |
| 792 |
vfbRRGetInfo(ScreenPtr pScreen, Rotation *rotations) |
| 793 |
{ |
| 794 |
/* Don't support rotations */ |
| 795 |
*rotations = RR_Rotate_0; |
| 796 |
|
| 797 |
return TRUE; |
| 798 |
} |
| 799 |
|
| 800 |
static Bool |
| 801 |
vfbRandRInit(ScreenPtr pScreen) |
| 802 |
{ |
| 803 |
rrScrPrivPtr pScrPriv; |
| 804 |
#if RANDR_12_INTERFACE |
| 805 |
RRModePtr mode; |
| 806 |
RRCrtcPtr crtc; |
| 807 |
RROutputPtr output; |
| 808 |
xRRModeInfo modeInfo; |
| 809 |
char name[64]; |
| 810 |
#endif |
| 811 |
int mmWidth, mmHeight; |
| 812 |
|
| 813 |
if (!RRScreenInit (pScreen)) |
| 814 |
return FALSE; |
| 815 |
pScrPriv = rrGetScrPriv(pScreen); |
| 816 |
pScrPriv->rrGetInfo = vfbRRGetInfo; |
| 817 |
#if RANDR_12_INTERFACE |
| 818 |
pScrPriv->rrCrtcSet = vfbRRCrtcSet; |
| 819 |
pScrPriv->rrScreenSetSize = vfbRRScreenSetSize; |
| 820 |
pScrPriv->rrOutputSetProperty = NULL; |
| 821 |
#if RANDR_13_INTERFACE |
| 822 |
pScrPriv->rrOutputGetProperty = NULL; |
| 823 |
#endif |
| 824 |
pScrPriv->rrOutputValidateMode = vfbRROutputValidateMode; |
| 825 |
pScrPriv->rrModeDestroy = NULL; |
| 826 |
|
| 827 |
mmWidth = pScreen->width * 25.4 / monitorResolution; |
| 828 |
mmHeight = pScreen->height * 25.4 / monitorResolution; |
| 829 |
|
| 830 |
RRScreenSetSizeRange (pScreen, |
| 831 |
1, 1, |
| 832 |
pScreen->width, pScreen->height); |
| 833 |
|
| 834 |
sprintf (name, "%dx%d", pScreen->width, pScreen->height); |
| 835 |
memset (&modeInfo, '\0', sizeof (modeInfo)); |
| 836 |
modeInfo.width = pScreen->width; |
| 837 |
modeInfo.height = pScreen->height; |
| 838 |
modeInfo.nameLength = strlen (name); |
| 839 |
|
| 840 |
mode = RRModeGet (&modeInfo, name); |
| 841 |
if (!mode) |
| 842 |
return FALSE; |
| 843 |
|
| 844 |
crtc = RRCrtcCreate (pScreen, NULL); |
| 845 |
if (!crtc) |
| 846 |
return FALSE; |
| 847 |
|
| 848 |
/* This is to avoid xrandr to complain about the gamma missing */ |
| 849 |
RRCrtcGammaSetSize (crtc, 256); |
| 850 |
|
| 851 |
output = RROutputCreate (pScreen, "screen", 6, NULL); |
| 852 |
if (!output) |
| 853 |
return FALSE; |
| 854 |
if (!RROutputSetClones (output, NULL, 0)) |
| 855 |
return FALSE; |
| 856 |
if (!RROutputSetModes (output, &mode, 1, 0)) |
| 857 |
return FALSE; |
| 858 |
if (!RROutputSetCrtcs (output, &crtc, 1)) |
| 859 |
return FALSE; |
| 860 |
if (!RROutputSetConnection (output, RR_Connected)) |
| 861 |
return FALSE; |
| 862 |
if (!RROutputSetPhysicalSize (output, mmWidth, mmHeight)) |
| 863 |
return FALSE; |
| 864 |
RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &output); |
| 865 |
#endif |
| 866 |
return TRUE; |
| 867 |
} |
| 868 |
|
| 869 |
static Bool |
| 870 |
vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) |
| 871 |
{ |
| 872 |
vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; |
| 873 |
int dpix = monitorResolution, dpiy = monitorResolution; |
| 874 |
int ret; |
| 875 |
char *pbits; |
| 876 |
|
| 877 |
if (dpix == 0) |
| 878 |
dpix = 100; |
| 879 |
|
| 880 |
if (dpiy == 0) |
| 881 |
dpiy = 100; |
| 882 |
|
| 883 |
pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth); |
| 884 |
pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth); |
| 885 |
if (pvfb->bitsPerPixel >= 8) |
| 886 |
pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8); |
| 887 |
else |
| 888 |
pvfb->paddedWidth = pvfb->paddedBytesWidth * 8; |
| 889 |
pbits = vfbAllocateFramebufferMemory(pvfb); |
| 890 |
if (!pbits) |
| 891 |
return FALSE; |
| 892 |
|
| 893 |
switch (pvfb->depth) { |
| 894 |
case 8: |
| 895 |
miSetVisualTypesAndMasks(8, |
| 896 |
((1 << StaticGray) | |
| 897 |
(1 << GrayScale) | |
| 898 |
(1 << StaticColor) | |
| 899 |
(1 << PseudoColor) | |
| 900 |
(1 << TrueColor) | |
| 901 |
(1 << DirectColor)), 8, PseudoColor, 0, 0, 0); |
| 902 |
break; |
| 903 |
case 15: |
| 904 |
miSetVisualTypesAndMasks(15, |
| 905 |
((1 << TrueColor) | |
| 906 |
(1 << DirectColor)), |
| 907 |
8, TrueColor, 0x7c00, 0x03e0, 0x001f); |
| 908 |
break; |
| 909 |
case 16: |
| 910 |
miSetVisualTypesAndMasks(16, |
| 911 |
((1 << TrueColor) | |
| 912 |
(1 << DirectColor)), |
| 913 |
8, TrueColor, 0xf800, 0x07e0, 0x001f); |
| 914 |
break; |
| 915 |
case 24: |
| 916 |
miSetVisualTypesAndMasks(24, |
| 917 |
((1 << TrueColor) | |
| 918 |
(1 << DirectColor)), |
| 919 |
8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); |
| 920 |
break; |
| 921 |
case 30: |
| 922 |
miSetVisualTypesAndMasks(30, |
| 923 |
((1 << TrueColor) | |
| 924 |
(1 << DirectColor)), |
| 925 |
10, TrueColor, 0x3ff00000, 0x000ffc00, |
| 926 |
0x000003ff); |
| 927 |
break; |
| 928 |
default: |
| 929 |
return FALSE; |
| 930 |
} |
| 931 |
|
| 932 |
miSetPixmapDepths(); |
| 933 |
|
| 934 |
ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, |
| 935 |
dpix, dpiy, pvfb->paddedWidth, pvfb->bitsPerPixel); |
| 936 |
if (ret && Render) |
| 937 |
fbPictureInit(pScreen, 0, 0); |
| 938 |
|
| 939 |
if (!ret) |
| 940 |
return FALSE; |
| 941 |
|
| 942 |
if (!vfbRandRInit(pScreen)) |
| 943 |
return FALSE; |
| 944 |
|
| 945 |
pScreen->InstallColormap = vfbInstallColormap; |
| 946 |
pScreen->StoreColors = vfbStoreColors; |
| 947 |
|
| 948 |
miDCInitialize(pScreen, &vfbPointerCursorFuncs); |
| 949 |
|
| 950 |
vfbWriteXWDFileHeader(pScreen); |
| 951 |
|
| 952 |
pScreen->blackPixel = pvfb->blackPixel; |
| 953 |
pScreen->whitePixel = pvfb->whitePixel; |
| 954 |
|
| 955 |
ret = fbCreateDefColormap(pScreen); |
| 956 |
|
| 957 |
miSetZeroLineBias(pScreen, pvfb->lineBias); |
| 958 |
|
| 959 |
pvfb->closeScreen = pScreen->CloseScreen; |
| 960 |
pScreen->CloseScreen = vfbCloseScreen; |
| 961 |
|
| 962 |
return ret; |
| 963 |
|
| 964 |
} /* end vfbScreenInit */ |
| 965 |
|
| 966 |
void |
| 967 |
InitOutput(ScreenInfo * screen_info, int argc, char **argv) |
| 968 |
{ |
| 969 |
int i; |
| 970 |
int NumFormats = 0; |
| 971 |
|
| 972 |
if (!monitorResolution) |
| 973 |
monitorResolution = 96; |
| 974 |
|
| 975 |
/* initialize pixmap formats */ |
| 976 |
|
| 977 |
/* must have a pixmap depth to match every screen depth */ |
| 978 |
for (i = 0; i < vfbNumScreens; i++) { |
| 979 |
vfbPixmapDepths[vfbScreens[i].depth] = TRUE; |
| 980 |
} |
| 981 |
|
| 982 |
/* RENDER needs a good set of pixmaps. */ |
| 983 |
if (Render) { |
| 984 |
vfbPixmapDepths[1] = TRUE; |
| 985 |
vfbPixmapDepths[4] = TRUE; |
| 986 |
vfbPixmapDepths[8] = TRUE; |
| 987 |
#if 0 |
| 988 |
vfbPixmapDepths[12] = TRUE; |
| 989 |
#endif |
| 990 |
/* vfbPixmapDepths[15] = TRUE; */ |
| 991 |
vfbPixmapDepths[16] = TRUE; |
| 992 |
vfbPixmapDepths[24] = TRUE; |
| 993 |
#if 0 |
| 994 |
vfbPixmapDepths[30] = TRUE; |
| 995 |
#endif |
| 996 |
vfbPixmapDepths[32] = TRUE; |
| 997 |
} |
| 998 |
|
| 999 |
xorgGlxCreateVendor(); |
| 1000 |
|
| 1001 |
for (i = 1; i <= 32; i++) { |
| 1002 |
if (vfbPixmapDepths[i]) { |
| 1003 |
if (NumFormats >= MAXFORMATS) |
| 1004 |
FatalError("MAXFORMATS is too small for this server\n"); |
| 1005 |
screen_info->formats[NumFormats].depth = i; |
| 1006 |
screen_info->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); |
| 1007 |
screen_info->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; |
| 1008 |
NumFormats++; |
| 1009 |
} |
| 1010 |
} |
| 1011 |
|
| 1012 |
screen_info->imageByteOrder = IMAGE_BYTE_ORDER; |
| 1013 |
screen_info->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; |
| 1014 |
screen_info->bitmapScanlinePad = BITMAP_SCANLINE_PAD; |
| 1015 |
screen_info->bitmapBitOrder = BITMAP_BIT_ORDER; |
| 1016 |
screen_info->numPixmapFormats = NumFormats; |
| 1017 |
|
| 1018 |
/* initialize screens */ |
| 1019 |
|
| 1020 |
if (vfbNumScreens < 1) { |
| 1021 |
vfbScreens = &defaultScreenInfo; |
| 1022 |
vfbNumScreens = 1; |
| 1023 |
} |
| 1024 |
for (i = 0; i < vfbNumScreens; i++) { |
| 1025 |
if (-1 == AddScreen(vfbScreenInit, argc, argv)) { |
| 1026 |
FatalError("Couldn't add screen %d", i); |
| 1027 |
} |
| 1028 |
} |
| 1029 |
|
| 1030 |
} /* end InitOutput */ |