int graphics_init (void) { if (currprefs.x11_use_mitshm && ! shmavail) { write_log ("MIT-SHM extension not supported by X server.\n"); } if (currprefs.color_mode > 5) write_log ("Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; x11_init_ok = 0; need_dither = 0; screen_is_picasso = 0; dgamode = 0; init_dispinfo (&ami_dinfo); init_dispinfo (&pic_dinfo); write_log ("Using %d bit visual, %d bits per pixel\n", bitdepth, bit_unit); fixup_prefs_dimensions (&currprefs); gfxvidinfo.width = currprefs.gfx_width_win; gfxvidinfo.height = currprefs.gfx_height_win; current_width = currprefs.gfx_width_win; current_height = currprefs.gfx_height_win; cmap = XCreateColormap (display, rootwin, vis, AllocNone); cmap2 = XCreateColormap (display, rootwin, vis, AllocNone); if (visualInfo.VI_CLASS == GrayScale || visualInfo.VI_CLASS == PseudoColor) { XAllocColorCells (display, cmap, 0, 0, 0, pixel_return, 1 << bitdepth); XAllocColorCells (display, cmap2, 0, 0, 0, pixel_return, 1 << bitdepth); } if (bitdepth < 8 || (bitdepth == 8 && currprefs.color_mode == 3)) { gfxvidinfo.pixbytes = 2; currprefs.x11_use_low_bandwidth = 0; need_dither = 1; } else { gfxvidinfo.pixbytes = bit_unit >> 3; } if (! init_colors ()) return 0; blankCursor = XCreatePixmapCursor (display, XCreatePixmap (display, rootwin, 1, 1, 1), XCreatePixmap (display, rootwin, 1, 1, 1), &black, &white, 0, 0); xhairCursor = XCreateFontCursor (display, XC_crosshair); graphics_subinit (); grabbed = 0; return x11_init_ok = 1; }
Error DXVisualizeMemory(int which, int procid) { int nprocs = 0; int i, start, end; nprocs = DXProcessors(0); if (which == 0) { /* delete all windows cleanly */ cleanup_memory_visual(d_small); cleanup_memory_visual(d_large); for (i=0; i<nprocs; i++) cleanup_memory_visual(d_local[i]); return OK; } if (which & 1) { /* small arena */ /* if already active, just update again and return */ if (d_small) d_small->refresh = 1; else { d_small = (struct dispinfo *)DXAllocateZero(sizeof(struct dispinfo)); if (!d_small) return ERROR; if (DXGetMemorySize(&d_small->arena_size, NULL, NULL) && DXGetMemoryBase(&d_small->arena_base, NULL, NULL)) { d_small->which = MEMORY_SMALL; d_small->alloc_unit = 16; strcpy(d_small->title, "DX Small Arena Memory"); init_dispinfo(d_small); if (! init_memory_visual(d_small)) return ERROR; d_small->active = 1; } } } if (which & 2) { /* large arena */ /* if already active, just update again and return */ if (d_large) d_large->refresh = 1; else { d_large = (struct dispinfo *)DXAllocateZero(sizeof(struct dispinfo)); if (!d_large) return ERROR; if (DXGetMemorySize(NULL, &d_large->arena_size, NULL) && DXGetMemoryBase(NULL, &d_large->arena_base, NULL)) { d_large->which = MEMORY_LARGE; #if ibmpvs d_large->alloc_unit = 1024; #else d_large->alloc_unit = 16; #endif strcpy(d_large->title, "DX Large Arena Memory"); init_dispinfo(d_large); if (! init_memory_visual(d_large)) return ERROR; /* if blocks smaller than this are in the large arena, * they are overflow blocks. */ d_large->smallsize = 1024; d_large->active = 1; } } } if (which & 4) { /* local memory */ ulong local_size; if (!DXGetMemorySize(NULL, NULL, &local_size) || local_size == 0) { DXSetError(ERROR_DATA_INVALID, "local memory not supported"); return ERROR; } nprocs = DXProcessors(0); if (procid >= 0 && procid < nprocs) goto done; /* -1 means all, N means just that specific processor */ if (procid < 0) { start = 0; end = nprocs; } else { start = procid; end = procid + 1; } for (i=start; i < end; i++) { /* if already active, just update again and return */ if (d_local[i]) { d_local[i]->refresh = 1; continue; } d_local[i] = (struct dispinfo *)DXAllocateZero(sizeof(struct dispinfo)); if (!d_local[i]) return ERROR; if (!DXGetMemorySize(NULL, NULL, &d_local[i]->arena_size) || d_local[i]->arena_size == 0) continue; if (!DXGetMemoryBase(NULL, NULL, &d_local[i]->arena_base)) continue; d_local[i]->which = MEMORY_LOCAL; d_local[i]->nproc = i; d_local[i]->alloc_unit = 16; sprintf(d_local[i]->title, "DX Local Arena Memory, Processor %d", i); init_dispinfo(d_local[i]); if (! init_memory_visual(d_local[i])) return ERROR; d_local[i]->active = 1; } } done: if (d_small && d_small->refresh) report_memory(d_small); if (d_large && d_large->refresh) report_memory(d_large); for (i=0; i<nprocs; i++) if (d_local[i] && d_local[i]->refresh) report_memory(d_local[i]); #if !defined(intelnt) signal(SIGALRM, _dxf_sigcatch); alarm(NSECONDS); #endif return OK; }