comparison src/video/dga/SDL_dgavideo.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
42 #include "../x11/SDL_x11dyn.h" 42 #include "../x11/SDL_x11dyn.h"
43 43
44 /*#define DGA_DEBUG*/ 44 /*#define DGA_DEBUG*/
45 45
46 /* Heheh we're using X11 event code */ 46 /* Heheh we're using X11 event code */
47 extern void X11_SaveScreenSaver (Display * display, int *saved_timeout, 47 extern void X11_SaveScreenSaver(Display * display, int *saved_timeout,
48 BOOL * dpms); 48 BOOL * dpms);
49 extern void X11_DisableScreenSaver (Display * display); 49 extern void X11_DisableScreenSaver(Display * display);
50 extern void X11_RestoreScreenSaver (Display * display, int saved_timeout, 50 extern void X11_RestoreScreenSaver(Display * display, int saved_timeout,
51 BOOL dpms); 51 BOOL dpms);
52 52
53 /* Initialization/Query functions */ 53 /* Initialization/Query functions */
54 static int DGA_VideoInit (_THIS, SDL_PixelFormat * vformat); 54 static int DGA_VideoInit(_THIS, SDL_PixelFormat * vformat);
55 static SDL_Rect **DGA_ListModes (_THIS, SDL_PixelFormat * format, 55 static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat * format,
56 Uint32 flags); 56 Uint32 flags);
57 static SDL_Surface *DGA_SetVideoMode (_THIS, SDL_Surface * current, int width, 57 static SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface * current, int width,
58 int height, int bpp, Uint32 flags); 58 int height, int bpp, Uint32 flags);
59 static int DGA_SetColors (_THIS, int firstcolor, int ncolors, 59 static int DGA_SetColors(_THIS, int firstcolor, int ncolors,
60 SDL_Color * colors); 60 SDL_Color * colors);
61 static int DGA_SetGammaRamp (_THIS, Uint16 * ramp); 61 static int DGA_SetGammaRamp(_THIS, Uint16 * ramp);
62 static void DGA_VideoQuit (_THIS); 62 static void DGA_VideoQuit(_THIS);
63 63
64 /* Hardware surface functions */ 64 /* Hardware surface functions */
65 static int DGA_InitHWSurfaces (_THIS, SDL_Surface * screen, Uint8 * base, 65 static int DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base,
66 int size); 66 int size);
67 static void DGA_FreeHWSurfaces (_THIS); 67 static void DGA_FreeHWSurfaces(_THIS);
68 static int DGA_AllocHWSurface (_THIS, SDL_Surface * surface); 68 static int DGA_AllocHWSurface(_THIS, SDL_Surface * surface);
69 static int DGA_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, 69 static int DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect,
70 Uint32 color); 70 Uint32 color);
71 static int DGA_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); 71 static int DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
72 static int DGA_LockHWSurface (_THIS, SDL_Surface * surface); 72 static int DGA_LockHWSurface(_THIS, SDL_Surface * surface);
73 static void DGA_UnlockHWSurface (_THIS, SDL_Surface * surface); 73 static void DGA_UnlockHWSurface(_THIS, SDL_Surface * surface);
74 static void DGA_FreeHWSurface (_THIS, SDL_Surface * surface); 74 static void DGA_FreeHWSurface(_THIS, SDL_Surface * surface);
75 static int DGA_FlipHWSurface (_THIS, SDL_Surface * surface); 75 static int DGA_FlipHWSurface(_THIS, SDL_Surface * surface);
76 76
77 /* DGA driver bootstrap functions */ 77 /* DGA driver bootstrap functions */
78 78
79 static int 79 static int
80 DGA_Available (void) 80 DGA_Available(void)
81 { 81 {
82 const char *display = NULL; 82 const char *display = NULL;
83 Display *dpy = NULL; 83 Display *dpy = NULL;
84 int available = 0; 84 int available = 0;
85 85
86 /* The driver is available is available if the display is local 86 /* The driver is available is available if the display is local
87 and the DGA 2.0+ extension is available, and we can map mem. 87 and the DGA 2.0+ extension is available, and we can map mem.
88 */ 88 */
89 if (SDL_X11_LoadSymbols ()) { 89 if (SDL_X11_LoadSymbols()) {
90 if ((SDL_strncmp (XDisplayName (display), ":", 1) == 0) || 90 if ((SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
91 (SDL_strncmp (XDisplayName (display), "unix:", 5) == 0)) { 91 (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0)) {
92 dpy = XOpenDisplay (display); 92 dpy = XOpenDisplay(display);
93 if (dpy) { 93 if (dpy) {
94 int events, errors, major, minor; 94 int events, errors, major, minor;
95 95
96 if (SDL_NAME (XDGAQueryExtension) 96 if (SDL_NAME(XDGAQueryExtension)
97 (dpy, &events, &errors) 97 (dpy, &events, &errors)
98 && SDL_NAME (XDGAQueryVersion) (dpy, &major, &minor)) { 98 && SDL_NAME(XDGAQueryVersion) (dpy, &major, &minor)) {
99 int screen; 99 int screen;
100 100
101 screen = DefaultScreen (dpy); 101 screen = DefaultScreen(dpy);
102 if ((major >= 2) && 102 if ((major >= 2) &&
103 SDL_NAME (XDGAOpenFramebuffer) (dpy, screen)) { 103 SDL_NAME(XDGAOpenFramebuffer) (dpy, screen)) {
104 available = 1; 104 available = 1;
105 SDL_NAME (XDGACloseFramebuffer) (dpy, screen); 105 SDL_NAME(XDGACloseFramebuffer) (dpy, screen);
106 } 106 }
107 } 107 }
108 XCloseDisplay (dpy); 108 XCloseDisplay(dpy);
109 } 109 }
110 } 110 }
111 SDL_X11_UnloadSymbols (); 111 SDL_X11_UnloadSymbols();
112 } 112 }
113 return (available); 113 return (available);
114 } 114 }
115 115
116 static void 116 static void
117 DGA_DeleteDevice (SDL_VideoDevice * device) 117 DGA_DeleteDevice(SDL_VideoDevice * device)
118 { 118 {
119 if (device != NULL) { 119 if (device != NULL) {
120 SDL_free (device->hidden); 120 SDL_free(device->hidden);
121 SDL_free (device); 121 SDL_free(device);
122 SDL_X11_UnloadSymbols (); 122 SDL_X11_UnloadSymbols();
123 } 123 }
124 } 124 }
125 125
126 static SDL_VideoDevice * 126 static SDL_VideoDevice *
127 DGA_CreateDevice (int devindex) 127 DGA_CreateDevice(int devindex)
128 { 128 {
129 SDL_VideoDevice *device = NULL; 129 SDL_VideoDevice *device = NULL;
130 130
131 /* Initialize all variables that we clean on shutdown */ 131 /* Initialize all variables that we clean on shutdown */
132 if (SDL_X11_LoadSymbols ()) { 132 if (SDL_X11_LoadSymbols()) {
133 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); 133 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
134 if (device) { 134 if (device) {
135 SDL_memset (device, 0, (sizeof *device)); 135 SDL_memset(device, 0, (sizeof *device));
136 device->hidden = (struct SDL_PrivateVideoData *) 136 device->hidden = (struct SDL_PrivateVideoData *)
137 SDL_malloc ((sizeof *device->hidden)); 137 SDL_malloc((sizeof *device->hidden));
138 } 138 }
139 if ((device == NULL) || (device->hidden == NULL)) { 139 if ((device == NULL) || (device->hidden == NULL)) {
140 SDL_OutOfMemory (); 140 SDL_OutOfMemory();
141 if (device) { 141 if (device) {
142 SDL_free (device); 142 SDL_free(device);
143 } 143 }
144 SDL_X11_UnloadSymbols (); 144 SDL_X11_UnloadSymbols();
145 return (0); 145 return (0);
146 } 146 }
147 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); 147 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
148 148
149 /* Set the function pointers */ 149 /* Set the function pointers */
150 device->VideoInit = DGA_VideoInit; 150 device->VideoInit = DGA_VideoInit;
151 device->ListModes = DGA_ListModes; 151 device->ListModes = DGA_ListModes;
152 device->SetVideoMode = DGA_SetVideoMode; 152 device->SetVideoMode = DGA_SetVideoMode;
182 "dga", "XFree86 DGA 2.0", 182 "dga", "XFree86 DGA 2.0",
183 DGA_Available, DGA_CreateDevice 183 DGA_Available, DGA_CreateDevice
184 }; 184 };
185 185
186 static int 186 static int
187 DGA_AddMode (_THIS, int bpp, int w, int h) 187 DGA_AddMode(_THIS, int bpp, int w, int h)
188 { 188 {
189 SDL_Rect *mode; 189 SDL_Rect *mode;
190 int index; 190 int index;
191 int next_mode; 191 int next_mode;
192 192
201 return (0); 201 return (0);
202 } 202 }
203 } 203 }
204 204
205 /* Set up the new video mode rectangle */ 205 /* Set up the new video mode rectangle */
206 mode = (SDL_Rect *) SDL_malloc (sizeof *mode); 206 mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
207 if (mode == NULL) { 207 if (mode == NULL) {
208 SDL_OutOfMemory (); 208 SDL_OutOfMemory();
209 return (-1); 209 return (-1);
210 } 210 }
211 mode->x = 0; 211 mode->x = 0;
212 mode->y = 0; 212 mode->y = 0;
213 mode->w = w; 213 mode->w = w;
214 mode->h = h; 214 mode->h = h;
215 215
216 /* Allocate the new list of modes, and fill in the new mode */ 216 /* Allocate the new list of modes, and fill in the new mode */
217 next_mode = SDL_nummodes[index]; 217 next_mode = SDL_nummodes[index];
218 SDL_modelist[index] = (SDL_Rect **) 218 SDL_modelist[index] = (SDL_Rect **)
219 SDL_realloc (SDL_modelist[index], 219 SDL_realloc(SDL_modelist[index],
220 (1 + next_mode + 1) * sizeof (SDL_Rect *)); 220 (1 + next_mode + 1) * sizeof(SDL_Rect *));
221 if (SDL_modelist[index] == NULL) { 221 if (SDL_modelist[index] == NULL) {
222 SDL_OutOfMemory (); 222 SDL_OutOfMemory();
223 SDL_nummodes[index] = 0; 223 SDL_nummodes[index] = 0;
224 SDL_free (mode); 224 SDL_free(mode);
225 return (-1); 225 return (-1);
226 } 226 }
227 SDL_modelist[index][next_mode] = mode; 227 SDL_modelist[index][next_mode] = mode;
228 SDL_modelist[index][next_mode + 1] = NULL; 228 SDL_modelist[index][next_mode + 1] = NULL;
229 SDL_nummodes[index]++; 229 SDL_nummodes[index]++;
231 return (0); 231 return (0);
232 } 232 }
233 233
234 /* This whole function is a hack. :) */ 234 /* This whole function is a hack. :) */
235 static Uint32 235 static Uint32
236 get_video_size (_THIS) 236 get_video_size(_THIS)
237 { 237 {
238 /* This is a non-exported function from libXxf86dga.a */ 238 /* This is a non-exported function from libXxf86dga.a */
239 extern unsigned char *SDL_NAME (XDGAGetMappedMemory) (int screen); 239 extern unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen);
240 FILE *proc; 240 FILE *proc;
241 unsigned long mem; 241 unsigned long mem;
242 unsigned start, stop; 242 unsigned start, stop;
243 char line[BUFSIZ]; 243 char line[BUFSIZ];
244 Uint32 size; 244 Uint32 size;
245 245
246 mem = (unsigned long) SDL_NAME (XDGAGetMappedMemory) (DGA_Screen); 246 mem = (unsigned long) SDL_NAME(XDGAGetMappedMemory) (DGA_Screen);
247 size = 0; 247 size = 0;
248 proc = fopen ("/proc/self/maps", "r"); 248 proc = fopen("/proc/self/maps", "r");
249 if (proc) { 249 if (proc) {
250 while (fgets (line, sizeof (line) - 1, proc)) { 250 while (fgets(line, sizeof(line) - 1, proc)) {
251 SDL_sscanf (line, "%x-%x", &start, &stop); 251 SDL_sscanf(line, "%x-%x", &start, &stop);
252 if (start == mem) { 252 if (start == mem) {
253 size = (Uint32) ((stop - start) / 1024); 253 size = (Uint32) ((stop - start) / 1024);
254 break; 254 break;
255 } 255 }
256 } 256 }
257 fclose (proc); 257 fclose(proc);
258 } 258 }
259 return (size); 259 return (size);
260 } 260 }
261 261
262 #ifdef DGA_DEBUG 262 #ifdef DGA_DEBUG
263 static void 263 static void
264 PrintMode (SDL_NAME (XDGAMode) * mode) 264 PrintMode(SDL_NAME(XDGAMode) * mode)
265 { 265 {
266 printf ("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n", 266 printf("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n",
267 mode->name, 267 mode->name,
268 mode->viewportWidth, mode->viewportHeight, 268 mode->viewportWidth, mode->viewportHeight,
269 mode->depth == 24 ? mode->bitsPerPixel : mode->depth, 269 mode->depth == 24 ? mode->bitsPerPixel : mode->depth,
270 mode->verticalRefresh, mode->bytesPerScanline, mode->num); 270 mode->verticalRefresh, mode->bytesPerScanline, mode->num);
271 printf ("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n", 271 printf("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n",
272 mode->redMask, mode->greenMask, mode->blueMask, 272 mode->redMask, mode->greenMask, mode->blueMask,
273 mode->visualClass, 273 mode->visualClass,
274 mode->visualClass == TrueColor ? "truecolor" : 274 mode->visualClass == TrueColor ? "truecolor" :
275 mode->visualClass == DirectColor ? "directcolor" : 275 mode->visualClass == DirectColor ? "directcolor" :
276 mode->visualClass == PseudoColor ? "pseudocolor" : "unknown"); 276 mode->visualClass == PseudoColor ? "pseudocolor" : "unknown");
277 printf ("\tFlags: "); 277 printf("\tFlags: ");
278 if (mode->flags & XDGAConcurrentAccess) 278 if (mode->flags & XDGAConcurrentAccess)
279 printf (" XDGAConcurrentAccess"); 279 printf(" XDGAConcurrentAccess");
280 if (mode->flags & XDGASolidFillRect) 280 if (mode->flags & XDGASolidFillRect)
281 printf (" XDGASolidFillRect"); 281 printf(" XDGASolidFillRect");
282 if (mode->flags & XDGABlitRect) 282 if (mode->flags & XDGABlitRect)
283 printf (" XDGABlitRect"); 283 printf(" XDGABlitRect");
284 if (mode->flags & XDGABlitTransRect) 284 if (mode->flags & XDGABlitTransRect)
285 printf (" XDGABlitTransRect"); 285 printf(" XDGABlitTransRect");
286 if (mode->flags & XDGAPixmap) 286 if (mode->flags & XDGAPixmap)
287 printf (" XDGAPixmap"); 287 printf(" XDGAPixmap");
288 if (mode->flags & XDGAInterlaced) 288 if (mode->flags & XDGAInterlaced)
289 printf (" XDGAInterlaced"); 289 printf(" XDGAInterlaced");
290 if (mode->flags & XDGADoublescan) 290 if (mode->flags & XDGADoublescan)
291 printf (" XDGADoublescan"); 291 printf(" XDGADoublescan");
292 if (mode->viewportFlags & XDGAFlipRetrace) 292 if (mode->viewportFlags & XDGAFlipRetrace)
293 printf (" XDGAFlipRetrace"); 293 printf(" XDGAFlipRetrace");
294 if (mode->viewportFlags & XDGAFlipImmediate) 294 if (mode->viewportFlags & XDGAFlipImmediate)
295 printf (" XDGAFlipImmediate"); 295 printf(" XDGAFlipImmediate");
296 printf ("\n"); 296 printf("\n");
297 } 297 }
298 #endif /* DGA_DEBUG */ 298 #endif /* DGA_DEBUG */
299 299
300 static int 300 static int
301 cmpmodes (const void *va, const void *vb) 301 cmpmodes(const void *va, const void *vb)
302 { 302 {
303 const SDL_NAME (XDGAMode) * a = (const SDL_NAME (XDGAMode) *) va; 303 const SDL_NAME(XDGAMode) * a = (const SDL_NAME(XDGAMode) *) va;
304 const SDL_NAME (XDGAMode) * b = (const SDL_NAME (XDGAMode) *) vb; 304 const SDL_NAME(XDGAMode) * b = (const SDL_NAME(XDGAMode) *) vb;
305 305
306 if ((a->viewportWidth == b->viewportWidth) && 306 if ((a->viewportWidth == b->viewportWidth) &&
307 (b->viewportHeight == a->viewportHeight)) { 307 (b->viewportHeight == a->viewportHeight)) {
308 /* Prefer 32 bpp over 24 bpp, 16 bpp over 15 bpp */ 308 /* Prefer 32 bpp over 24 bpp, 16 bpp over 15 bpp */
309 int a_bpp = a->depth == 24 ? a->bitsPerPixel : a->depth; 309 int a_bpp = a->depth == 24 ? a->bitsPerPixel : a->depth;
323 } else { 323 } else {
324 return b->viewportWidth - a->viewportWidth; 324 return b->viewportWidth - a->viewportWidth;
325 } 325 }
326 } 326 }
327 static void 327 static void
328 UpdateHWInfo (_THIS, SDL_NAME (XDGAMode) * mode) 328 UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) * mode)
329 { 329 {
330 this->info.wm_available = 0; 330 this->info.wm_available = 0;
331 this->info.hw_available = 1; 331 this->info.hw_available = 1;
332 if (mode->flags & XDGABlitRect) { 332 if (mode->flags & XDGABlitRect) {
333 this->info.blit_hw = 1; 333 this->info.blit_hw = 1;
342 if (mode->flags & XDGASolidFillRect) { 342 if (mode->flags & XDGASolidFillRect) {
343 this->info.blit_fill = 1; 343 this->info.blit_fill = 1;
344 } else { 344 } else {
345 this->info.blit_fill = 0; 345 this->info.blit_fill = 0;
346 } 346 }
347 this->info.video_mem = get_video_size (this); 347 this->info.video_mem = get_video_size(this);
348 } 348 }
349 349
350 static int 350 static int
351 DGA_VideoInit (_THIS, SDL_PixelFormat * vformat) 351 DGA_VideoInit(_THIS, SDL_PixelFormat * vformat)
352 { 352 {
353 const char *display; 353 const char *display;
354 int event_base, error_base; 354 int event_base, error_base;
355 int major_version, minor_version; 355 int major_version, minor_version;
356 Visual *visual; 356 Visual *visual;
357 SDL_NAME (XDGAMode) * modes; 357 SDL_NAME(XDGAMode) * modes;
358 int i, num_modes; 358 int i, num_modes;
359 359
360 /* Open the X11 display */ 360 /* Open the X11 display */
361 display = NULL; /* Get it from DISPLAY environment variable */ 361 display = NULL; /* Get it from DISPLAY environment variable */
362 362
363 DGA_Display = XOpenDisplay (display); 363 DGA_Display = XOpenDisplay(display);
364 if (DGA_Display == NULL) { 364 if (DGA_Display == NULL) {
365 SDL_SetError ("Couldn't open X11 display"); 365 SDL_SetError("Couldn't open X11 display");
366 return (-1); 366 return (-1);
367 } 367 }
368 368
369 /* Check for the DGA extension */ 369 /* Check for the DGA extension */
370 if (!SDL_NAME (XDGAQueryExtension) (DGA_Display, &event_base, &error_base) 370 if (!SDL_NAME(XDGAQueryExtension) (DGA_Display, &event_base, &error_base)
371 || !SDL_NAME (XDGAQueryVersion) (DGA_Display, &major_version, 371 || !SDL_NAME(XDGAQueryVersion) (DGA_Display, &major_version,
372 &minor_version)) { 372 &minor_version)) {
373 SDL_SetError ("DGA extension not available"); 373 SDL_SetError("DGA extension not available");
374 XCloseDisplay (DGA_Display); 374 XCloseDisplay(DGA_Display);
375 return (-1); 375 return (-1);
376 } 376 }
377 if (major_version < 2) { 377 if (major_version < 2) {
378 SDL_SetError ("DGA driver requires DGA 2.0 or newer"); 378 SDL_SetError("DGA driver requires DGA 2.0 or newer");
379 XCloseDisplay (DGA_Display); 379 XCloseDisplay(DGA_Display);
380 return (-1); 380 return (-1);
381 } 381 }
382 DGA_event_base = event_base; 382 DGA_event_base = event_base;
383 383
384 /* Determine the current screen size */ 384 /* Determine the current screen size */
385 this->info.current_w = DisplayWidth (DGA_Display, DGA_Screen); 385 this->info.current_w = DisplayWidth(DGA_Display, DGA_Screen);
386 this->info.current_h = DisplayHeight (DGA_Display, DGA_Screen); 386 this->info.current_h = DisplayHeight(DGA_Display, DGA_Screen);
387 387
388 /* Determine the current screen depth */ 388 /* Determine the current screen depth */
389 visual = DefaultVisual (DGA_Display, DGA_Screen); 389 visual = DefaultVisual(DGA_Display, DGA_Screen);
390 { 390 {
391 XPixmapFormatValues *pix_format; 391 XPixmapFormatValues *pix_format;
392 int i, num_formats; 392 int i, num_formats;
393 393
394 vformat->BitsPerPixel = DefaultDepth (DGA_Display, DGA_Screen); 394 vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen);
395 pix_format = XListPixmapFormats (DGA_Display, &num_formats); 395 pix_format = XListPixmapFormats(DGA_Display, &num_formats);
396 if (pix_format == NULL) { 396 if (pix_format == NULL) {
397 SDL_SetError ("Couldn't determine screen formats"); 397 SDL_SetError("Couldn't determine screen formats");
398 XCloseDisplay (DGA_Display); 398 XCloseDisplay(DGA_Display);
399 return (-1); 399 return (-1);
400 } 400 }
401 for (i = 0; i < num_formats; ++i) { 401 for (i = 0; i < num_formats; ++i) {
402 if (vformat->BitsPerPixel == pix_format[i].depth) 402 if (vformat->BitsPerPixel == pix_format[i].depth)
403 break; 403 break;
404 } 404 }
405 if (i != num_formats) 405 if (i != num_formats)
406 vformat->BitsPerPixel = pix_format[i].bits_per_pixel; 406 vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
407 XFree ((char *) pix_format); 407 XFree((char *) pix_format);
408 } 408 }
409 if (vformat->BitsPerPixel > 8) { 409 if (vformat->BitsPerPixel > 8) {
410 vformat->Rmask = visual->red_mask; 410 vformat->Rmask = visual->red_mask;
411 vformat->Gmask = visual->green_mask; 411 vformat->Gmask = visual->green_mask;
412 vformat->Bmask = visual->blue_mask; 412 vformat->Bmask = visual->blue_mask;
413 } 413 }
414 414
415 /* Open access to the framebuffer */ 415 /* Open access to the framebuffer */
416 if (!SDL_NAME (XDGAOpenFramebuffer) (DGA_Display, DGA_Screen)) { 416 if (!SDL_NAME(XDGAOpenFramebuffer) (DGA_Display, DGA_Screen)) {
417 SDL_SetError ("Unable to map the video memory"); 417 SDL_SetError("Unable to map the video memory");
418 XCloseDisplay (DGA_Display); 418 XCloseDisplay(DGA_Display);
419 return (-1); 419 return (-1);
420 } 420 }
421 421
422 /* Save DPMS and screensaver settings */ 422 /* Save DPMS and screensaver settings */
423 X11_SaveScreenSaver (DGA_Display, &screensaver_timeout, &dpms_enabled); 423 X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled);
424 X11_DisableScreenSaver (DGA_Display); 424 X11_DisableScreenSaver(DGA_Display);
425 425
426 /* Query for the list of available video modes */ 426 /* Query for the list of available video modes */
427 modes = SDL_NAME (XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); 427 modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes);
428 SDL_qsort (modes, num_modes, sizeof *modes, cmpmodes); 428 SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
429 for (i = 0; i < num_modes; ++i) { 429 for (i = 0; i < num_modes; ++i) {
430 if (((modes[i].visualClass == PseudoColor) || 430 if (((modes[i].visualClass == PseudoColor) ||
431 (modes[i].visualClass == DirectColor) || 431 (modes[i].visualClass == DirectColor) ||
432 (modes[i].visualClass == TrueColor)) && 432 (modes[i].visualClass == TrueColor)) &&
433 !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) { 433 !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) {
434 #ifdef DGA_DEBUG 434 #ifdef DGA_DEBUG
435 PrintMode (&modes[i]); 435 PrintMode(&modes[i]);
436 #endif 436 #endif
437 DGA_AddMode (this, modes[i].bitsPerPixel, 437 DGA_AddMode(this, modes[i].bitsPerPixel,
438 modes[i].viewportWidth, modes[i].viewportHeight); 438 modes[i].viewportWidth, modes[i].viewportHeight);
439 } 439 }
440 } 440 }
441 UpdateHWInfo (this, modes); 441 UpdateHWInfo(this, modes);
442 XFree (modes); 442 XFree(modes);
443 443
444 /* Create the hardware surface lock mutex */ 444 /* Create the hardware surface lock mutex */
445 hw_lock = SDL_CreateMutex (); 445 hw_lock = SDL_CreateMutex();
446 if (hw_lock == NULL) { 446 if (hw_lock == NULL) {
447 SDL_SetError ("Unable to create lock mutex"); 447 SDL_SetError("Unable to create lock mutex");
448 DGA_VideoQuit (this); 448 DGA_VideoQuit(this);
449 return (-1); 449 return (-1);
450 } 450 }
451 #ifdef LOCK_DGA_DISPLAY 451 #ifdef LOCK_DGA_DISPLAY
452 /* Create the event lock so we're thread-safe.. :-/ */ 452 /* Create the event lock so we're thread-safe.. :-/ */
453 event_lock = SDL_CreateMutex (); 453 event_lock = SDL_CreateMutex();
454 #endif /* LOCK_DGA_DISPLAY */ 454 #endif /* LOCK_DGA_DISPLAY */
455 455
456 /* We're done! */ 456 /* We're done! */
457 return (0); 457 return (0);
458 } 458 }
459 459
460 SDL_Rect ** 460 SDL_Rect **
461 DGA_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) 461 DGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
462 { 462 {
463 return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); 463 return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
464 } 464 }
465 465
466 /* Various screen update functions available */ 466 /* Various screen update functions available */
467 static void DGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); 467 static void DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
468 468
469 SDL_Surface * 469 SDL_Surface *
470 DGA_SetVideoMode (_THIS, SDL_Surface * current, 470 DGA_SetVideoMode(_THIS, SDL_Surface * current,
471 int width, int height, int bpp, Uint32 flags) 471 int width, int height, int bpp, Uint32 flags)
472 { 472 {
473 SDL_NAME (XDGAMode) * modes; 473 SDL_NAME(XDGAMode) * modes;
474 int i, num_modes; 474 int i, num_modes;
475 SDL_NAME (XDGADevice) * mode; 475 SDL_NAME(XDGADevice) * mode;
476 int screen_len; 476 int screen_len;
477 Uint8 *surfaces_mem; 477 Uint8 *surfaces_mem;
478 int surfaces_len; 478 int surfaces_len;
479 479
480 /* Free any previous colormap */ 480 /* Free any previous colormap */
481 if (DGA_colormap) { 481 if (DGA_colormap) {
482 XFreeColormap (DGA_Display, DGA_colormap); 482 XFreeColormap(DGA_Display, DGA_colormap);
483 DGA_colormap = 0; 483 DGA_colormap = 0;
484 } 484 }
485 485
486 /* Search for a matching video mode */ 486 /* Search for a matching video mode */
487 modes = SDL_NAME (XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); 487 modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes);
488 SDL_qsort (modes, num_modes, sizeof *modes, cmpmodes); 488 SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
489 for (i = 0; i < num_modes; ++i) { 489 for (i = 0; i < num_modes; ++i) {
490 int depth; 490 int depth;
491 491
492 depth = modes[i].depth; 492 depth = modes[i].depth;
493 if (depth == 24) { /* Distinguish between 24 and 32 bpp */ 493 if (depth == 24) { /* Distinguish between 24 and 32 bpp */
502 !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) { 502 !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) {
503 break; 503 break;
504 } 504 }
505 } 505 }
506 if (i == num_modes) { 506 if (i == num_modes) {
507 SDL_SetError ("No matching video mode found"); 507 SDL_SetError("No matching video mode found");
508 return (NULL); 508 return (NULL);
509 } 509 }
510 #ifdef DGA_DEBUG 510 #ifdef DGA_DEBUG
511 PrintMode (&modes[i]); 511 PrintMode(&modes[i]);
512 #endif 512 #endif
513 513
514 /* Set the video mode */ 514 /* Set the video mode */
515 mode = SDL_NAME (XDGASetMode) (DGA_Display, DGA_Screen, modes[i].num); 515 mode = SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, modes[i].num);
516 XFree (modes); 516 XFree(modes);
517 if (mode == NULL) { 517 if (mode == NULL) {
518 SDL_SetError ("Unable to switch to requested mode"); 518 SDL_SetError("Unable to switch to requested mode");
519 return (NULL); 519 return (NULL);
520 } 520 }
521 DGA_visualClass = mode->mode.visualClass; 521 DGA_visualClass = mode->mode.visualClass;
522 memory_base = (Uint8 *) mode->data; 522 memory_base = (Uint8 *) mode->data;
523 memory_pitch = mode->mode.bytesPerScanline; 523 memory_pitch = mode->mode.bytesPerScanline;
526 current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE); 526 current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
527 current->w = mode->mode.viewportWidth; 527 current->w = mode->mode.viewportWidth;
528 current->h = mode->mode.viewportHeight; 528 current->h = mode->mode.viewportHeight;
529 current->pitch = memory_pitch; 529 current->pitch = memory_pitch;
530 current->pixels = memory_base; 530 current->pixels = memory_base;
531 if (!SDL_ReallocFormat (current, mode->mode.bitsPerPixel, 531 if (!SDL_ReallocFormat(current, mode->mode.bitsPerPixel,
532 mode->mode.redMask, 532 mode->mode.redMask,
533 mode->mode.greenMask, mode->mode.blueMask, 0)) { 533 mode->mode.greenMask, mode->mode.blueMask, 0)) {
534 return (NULL); 534 return (NULL);
535 } 535 }
536 screen_len = current->h * current->pitch; 536 screen_len = current->h * current->pitch;
537 537
538 /* Create a colormap if necessary */ 538 /* Create a colormap if necessary */
539 if ((DGA_visualClass == PseudoColor) || (DGA_visualClass == DirectColor)) { 539 if ((DGA_visualClass == PseudoColor) || (DGA_visualClass == DirectColor)) {
540 DGA_colormap = 540 DGA_colormap =
541 SDL_NAME (XDGACreateColormap) (DGA_Display, DGA_Screen, mode, 541 SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode,
542 AllocAll); 542 AllocAll);
543 if (DGA_visualClass == PseudoColor) { 543 if (DGA_visualClass == PseudoColor) {
544 current->flags |= SDL_HWPALETTE; 544 current->flags |= SDL_HWPALETTE;
545 } else { 545 } else {
546 /* Initialize the colormap to the identity mapping */ 546 /* Initialize the colormap to the identity mapping */
547 SDL_GetGammaRamp (0, 0, 0); 547 SDL_GetGammaRamp(0, 0, 0);
548 this->screen = current; 548 this->screen = current;
549 DGA_SetGammaRamp (this, this->gamma); 549 DGA_SetGammaRamp(this, this->gamma);
550 this->screen = NULL; 550 this->screen = NULL;
551 } 551 }
552 } else { 552 } else {
553 DGA_colormap = 553 DGA_colormap =
554 SDL_NAME (XDGACreateColormap) (DGA_Display, DGA_Screen, mode, 554 SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode,
555 AllocNone); 555 AllocNone);
556 } 556 }
557 SDL_NAME (XDGAInstallColormap) (DGA_Display, DGA_Screen, DGA_colormap); 557 SDL_NAME(XDGAInstallColormap) (DGA_Display, DGA_Screen, DGA_colormap);
558 558
559 /* Update the hardware capabilities */ 559 /* Update the hardware capabilities */
560 UpdateHWInfo (this, &mode->mode); 560 UpdateHWInfo(this, &mode->mode);
561 561
562 /* Set up the information for hardware surfaces */ 562 /* Set up the information for hardware surfaces */
563 surfaces_mem = (Uint8 *) current->pixels + screen_len; 563 surfaces_mem = (Uint8 *) current->pixels + screen_len;
564 surfaces_len = (mode->mode.imageHeight * current->pitch - screen_len); 564 surfaces_len = (mode->mode.imageHeight * current->pitch - screen_len);
565 565
566 /* Update for double-buffering, if we can */ 566 /* Update for double-buffering, if we can */
567 SDL_NAME (XDGASetViewport) (DGA_Display, DGA_Screen, 0, 0, 567 SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen, 0, 0,
568 XDGAFlipRetrace); 568 XDGAFlipRetrace);
569 if (flags & SDL_DOUBLEBUF) { 569 if (flags & SDL_DOUBLEBUF) {
570 if (mode->mode.imageHeight >= (current->h * 2)) { 570 if (mode->mode.imageHeight >= (current->h * 2)) {
571 current->flags |= SDL_DOUBLEBUF; 571 current->flags |= SDL_DOUBLEBUF;
572 flip_page = 0; 572 flip_page = 0;
573 flip_yoffset[0] = 0; 573 flip_yoffset[0] = 0;
578 surfaces_len -= screen_len; 578 surfaces_len -= screen_len;
579 } 579 }
580 } 580 }
581 581
582 /* Allocate memory tracking for hardware surfaces */ 582 /* Allocate memory tracking for hardware surfaces */
583 DGA_FreeHWSurfaces (this); 583 DGA_FreeHWSurfaces(this);
584 if (surfaces_len < 0) { 584 if (surfaces_len < 0) {
585 surfaces_len = 0; 585 surfaces_len = 0;
586 } 586 }
587 DGA_InitHWSurfaces (this, current, surfaces_mem, surfaces_len); 587 DGA_InitHWSurfaces(this, current, surfaces_mem, surfaces_len);
588 588
589 /* Expose the back buffer as surface memory */ 589 /* Expose the back buffer as surface memory */
590 if (current->flags & SDL_DOUBLEBUF) { 590 if (current->flags & SDL_DOUBLEBUF) {
591 this->screen = current; 591 this->screen = current;
592 DGA_FlipHWSurface (this, current); 592 DGA_FlipHWSurface(this, current);
593 this->screen = NULL; 593 this->screen = NULL;
594 } 594 }
595 595
596 /* Set the update rectangle function */ 596 /* Set the update rectangle function */
597 this->UpdateRects = DGA_DirectUpdate; 597 this->UpdateRects = DGA_DirectUpdate;
600 { 600 {
601 long input_mask; 601 long input_mask;
602 input_mask = (KeyPressMask | KeyReleaseMask); 602 input_mask = (KeyPressMask | KeyReleaseMask);
603 input_mask |= (ButtonPressMask | ButtonReleaseMask); 603 input_mask |= (ButtonPressMask | ButtonReleaseMask);
604 input_mask |= PointerMotionMask; 604 input_mask |= PointerMotionMask;
605 SDL_NAME (XDGASelectInput) (DGA_Display, DGA_Screen, input_mask); 605 SDL_NAME(XDGASelectInput) (DGA_Display, DGA_Screen, input_mask);
606 } 606 }
607 607
608 /* We're done */ 608 /* We're done */
609 return (current); 609 return (current);
610 } 610 }
611 611
612 #ifdef DGA_DEBUG 612 #ifdef DGA_DEBUG
613 static void 613 static void
614 DGA_DumpHWSurfaces (_THIS) 614 DGA_DumpHWSurfaces(_THIS)
615 { 615 {
616 vidmem_bucket *bucket; 616 vidmem_bucket *bucket;
617 617
618 printf ("Memory left: %d (%d total)\n", surfaces_memleft, 618 printf("Memory left: %d (%d total)\n", surfaces_memleft,
619 surfaces_memtotal); 619 surfaces_memtotal);
620 printf ("\n"); 620 printf("\n");
621 printf (" Base Size\n"); 621 printf(" Base Size\n");
622 for (bucket = &surfaces; bucket; bucket = bucket->next) { 622 for (bucket = &surfaces; bucket; bucket = bucket->next) {
623 printf ("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, 623 printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size,
624 bucket->used ? "used" : "free"); 624 bucket->used ? "used" : "free");
625 if (bucket->prev) { 625 if (bucket->prev) {
626 if (bucket->base != bucket->prev->base + bucket->prev->size) { 626 if (bucket->base != bucket->prev->base + bucket->prev->size) {
627 printf ("Warning, corrupt bucket list! (prev)\n"); 627 printf("Warning, corrupt bucket list! (prev)\n");
628 } 628 }
629 } else { 629 } else {
630 if (bucket != &surfaces) { 630 if (bucket != &surfaces) {
631 printf ("Warning, corrupt bucket list! (!prev)\n"); 631 printf("Warning, corrupt bucket list! (!prev)\n");
632 } 632 }
633 } 633 }
634 if (bucket->next) { 634 if (bucket->next) {
635 if (bucket->next->base != bucket->base + bucket->size) { 635 if (bucket->next->base != bucket->base + bucket->size) {
636 printf ("Warning, corrupt bucket list! (next)\n"); 636 printf("Warning, corrupt bucket list! (next)\n");
637 } 637 }
638 } 638 }
639 } 639 }
640 printf ("\n"); 640 printf("\n");
641 } 641 }
642 #endif 642 #endif
643 643
644 static int 644 static int
645 DGA_InitHWSurfaces (_THIS, SDL_Surface * screen, Uint8 * base, int size) 645 DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base, int size)
646 { 646 {
647 vidmem_bucket *bucket; 647 vidmem_bucket *bucket;
648 648
649 surfaces_memtotal = size; 649 surfaces_memtotal = size;
650 surfaces_memleft = size; 650 surfaces_memleft = size;
651 651
652 if (surfaces_memleft > 0) { 652 if (surfaces_memleft > 0) {
653 bucket = (vidmem_bucket *) SDL_malloc (sizeof (*bucket)); 653 bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket));
654 if (bucket == NULL) { 654 if (bucket == NULL) {
655 SDL_OutOfMemory (); 655 SDL_OutOfMemory();
656 return (-1); 656 return (-1);
657 } 657 }
658 bucket->prev = &surfaces; 658 bucket->prev = &surfaces;
659 bucket->used = 0; 659 bucket->used = 0;
660 bucket->dirty = 0; 660 bucket->dirty = 0;
673 surfaces.next = bucket; 673 surfaces.next = bucket;
674 screen->hwdata = (struct private_hwdata *) &surfaces; 674 screen->hwdata = (struct private_hwdata *) &surfaces;
675 return (0); 675 return (0);
676 } 676 }
677 static void 677 static void
678 DGA_FreeHWSurfaces (_THIS) 678 DGA_FreeHWSurfaces(_THIS)
679 { 679 {
680 vidmem_bucket *bucket, *freeable; 680 vidmem_bucket *bucket, *freeable;
681 681
682 bucket = surfaces.next; 682 bucket = surfaces.next;
683 while (bucket) { 683 while (bucket) {
684 freeable = bucket; 684 freeable = bucket;
685 bucket = bucket->next; 685 bucket = bucket->next;
686 SDL_free (freeable); 686 SDL_free(freeable);
687 } 687 }
688 surfaces.next = NULL; 688 surfaces.next = NULL;
689 } 689 }
690 690
691 static __inline__ void 691 static __inline__ void
692 DGA_AddBusySurface (SDL_Surface * surface) 692 DGA_AddBusySurface(SDL_Surface * surface)
693 { 693 {
694 ((vidmem_bucket *) surface->hwdata)->dirty = 1; 694 ((vidmem_bucket *) surface->hwdata)->dirty = 1;
695 } 695 }
696 696
697 static __inline__ int 697 static __inline__ int
698 DGA_IsSurfaceBusy (SDL_Surface * surface) 698 DGA_IsSurfaceBusy(SDL_Surface * surface)
699 { 699 {
700 return ((vidmem_bucket *) surface->hwdata)->dirty; 700 return ((vidmem_bucket *) surface->hwdata)->dirty;
701 } 701 }
702 702
703 static __inline__ void 703 static __inline__ void
704 DGA_WaitBusySurfaces (_THIS) 704 DGA_WaitBusySurfaces(_THIS)
705 { 705 {
706 vidmem_bucket *bucket; 706 vidmem_bucket *bucket;
707 707
708 /* Wait for graphic operations to complete */ 708 /* Wait for graphic operations to complete */
709 SDL_NAME (XDGASync) (DGA_Display, DGA_Screen); 709 SDL_NAME(XDGASync) (DGA_Display, DGA_Screen);
710 710
711 /* Clear all surface dirty bits */ 711 /* Clear all surface dirty bits */
712 for (bucket = &surfaces; bucket; bucket = bucket->next) { 712 for (bucket = &surfaces; bucket; bucket = bucket->next) {
713 bucket->dirty = 0; 713 bucket->dirty = 0;
714 } 714 }
715 } 715 }
716 716
717 static int 717 static int
718 DGA_AllocHWSurface (_THIS, SDL_Surface * surface) 718 DGA_AllocHWSurface(_THIS, SDL_Surface * surface)
719 { 719 {
720 vidmem_bucket *bucket; 720 vidmem_bucket *bucket;
721 int size; 721 int size;
722 int extra; 722 int extra;
723 int retval = 0; 723 int retval = 0;
725 /* Temporarily, we only allow surfaces the same width as display. 725 /* Temporarily, we only allow surfaces the same width as display.
726 Some blitters require the pitch between two hardware surfaces 726 Some blitters require the pitch between two hardware surfaces
727 to be the same. Others have interesting alignment restrictions. 727 to be the same. Others have interesting alignment restrictions.
728 */ 728 */
729 if (surface->pitch > SDL_VideoSurface->pitch) { 729 if (surface->pitch > SDL_VideoSurface->pitch) {
730 SDL_SetError ("Surface requested wider than screen"); 730 SDL_SetError("Surface requested wider than screen");
731 return (-1); 731 return (-1);
732 } 732 }
733 surface->pitch = SDL_VideoSurface->pitch; 733 surface->pitch = SDL_VideoSurface->pitch;
734 size = surface->h * surface->pitch; 734 size = surface->h * surface->pitch;
735 #ifdef DGA_DEBUG 735 #ifdef DGA_DEBUG
736 fprintf (stderr, "Allocating bucket of %d bytes\n", size); 736 fprintf(stderr, "Allocating bucket of %d bytes\n", size);
737 #endif 737 #endif
738 LOCK_DISPLAY (); 738 LOCK_DISPLAY();
739 739
740 /* Quick check for available mem */ 740 /* Quick check for available mem */
741 if (size > surfaces_memleft) { 741 if (size > surfaces_memleft) {
742 SDL_SetError ("Not enough video memory"); 742 SDL_SetError("Not enough video memory");
743 retval = -1; 743 retval = -1;
744 goto done; 744 goto done;
745 } 745 }
746 746
747 /* Search for an empty bucket big enough */ 747 /* Search for an empty bucket big enough */
749 if (!bucket->used && (size <= bucket->size)) { 749 if (!bucket->used && (size <= bucket->size)) {
750 break; 750 break;
751 } 751 }
752 } 752 }
753 if (bucket == NULL) { 753 if (bucket == NULL) {
754 SDL_SetError ("Video memory too fragmented"); 754 SDL_SetError("Video memory too fragmented");
755 retval = -1; 755 retval = -1;
756 goto done; 756 goto done;
757 } 757 }
758 758
759 /* Create a new bucket for left-over memory */ 759 /* Create a new bucket for left-over memory */
760 extra = (bucket->size - size); 760 extra = (bucket->size - size);
761 if (extra) { 761 if (extra) {
762 vidmem_bucket *newbucket; 762 vidmem_bucket *newbucket;
763 763
764 #ifdef DGA_DEBUG 764 #ifdef DGA_DEBUG
765 fprintf (stderr, "Adding new free bucket of %d bytes\n", extra); 765 fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
766 #endif 766 #endif
767 newbucket = (vidmem_bucket *) SDL_malloc (sizeof (*newbucket)); 767 newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket));
768 if (newbucket == NULL) { 768 if (newbucket == NULL) {
769 SDL_OutOfMemory (); 769 SDL_OutOfMemory();
770 retval = -1; 770 retval = -1;
771 goto done; 771 goto done;
772 } 772 }
773 newbucket->prev = bucket; 773 newbucket->prev = bucket;
774 newbucket->used = 0; 774 newbucket->used = 0;
784 /* Set the current bucket values and return it! */ 784 /* Set the current bucket values and return it! */
785 bucket->used = 1; 785 bucket->used = 1;
786 bucket->size = size; 786 bucket->size = size;
787 bucket->dirty = 0; 787 bucket->dirty = 0;
788 #ifdef DGA_DEBUG 788 #ifdef DGA_DEBUG
789 fprintf (stderr, "Allocated %d bytes at %p\n", bucket->size, 789 fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
790 bucket->base);
791 #endif 790 #endif
792 surfaces_memleft -= size; 791 surfaces_memleft -= size;
793 surface->flags |= SDL_HWSURFACE; 792 surface->flags |= SDL_HWSURFACE;
794 surface->pixels = bucket->base; 793 surface->pixels = bucket->base;
795 surface->hwdata = (struct private_hwdata *) bucket; 794 surface->hwdata = (struct private_hwdata *) bucket;
796 done: 795 done:
797 UNLOCK_DISPLAY (); 796 UNLOCK_DISPLAY();
798 return (retval); 797 return (retval);
799 } 798 }
800 static void 799 static void
801 DGA_FreeHWSurface (_THIS, SDL_Surface * surface) 800 DGA_FreeHWSurface(_THIS, SDL_Surface * surface)
802 { 801 {
803 vidmem_bucket *bucket, *freeable; 802 vidmem_bucket *bucket, *freeable;
804 803
805 /* Wait for any pending operations involving this surface */ 804 /* Wait for any pending operations involving this surface */
806 if (DGA_IsSurfaceBusy (surface)) { 805 if (DGA_IsSurfaceBusy(surface)) {
807 LOCK_DISPLAY (); 806 LOCK_DISPLAY();
808 DGA_WaitBusySurfaces (this); 807 DGA_WaitBusySurfaces(this);
809 UNLOCK_DISPLAY (); 808 UNLOCK_DISPLAY();
810 } 809 }
811 810
812 /* Look for the bucket in the current list */ 811 /* Look for the bucket in the current list */
813 for (bucket = &surfaces; bucket; bucket = bucket->next) { 812 for (bucket = &surfaces; bucket; bucket = bucket->next) {
814 if (bucket == (vidmem_bucket *) surface->hwdata) { 813 if (bucket == (vidmem_bucket *) surface->hwdata) {
816 } 815 }
817 } 816 }
818 if (bucket && bucket->used) { 817 if (bucket && bucket->used) {
819 /* Add the memory back to the total */ 818 /* Add the memory back to the total */
820 #ifdef DGA_DEBUG 819 #ifdef DGA_DEBUG
821 printf ("Freeing bucket of %d bytes\n", bucket->size); 820 printf("Freeing bucket of %d bytes\n", bucket->size);
822 #endif 821 #endif
823 surfaces_memleft += bucket->size; 822 surfaces_memleft += bucket->size;
824 823
825 /* Can we merge the space with surrounding buckets? */ 824 /* Can we merge the space with surrounding buckets? */
826 bucket->used = 0; 825 bucket->used = 0;
827 if (bucket->next && !bucket->next->used) { 826 if (bucket->next && !bucket->next->used) {
828 #ifdef DGA_DEBUG 827 #ifdef DGA_DEBUG
829 printf ("Merging with next bucket, for %d total bytes\n", 828 printf("Merging with next bucket, for %d total bytes\n",
830 bucket->size + bucket->next->size); 829 bucket->size + bucket->next->size);
831 #endif 830 #endif
832 freeable = bucket->next; 831 freeable = bucket->next;
833 bucket->size += bucket->next->size; 832 bucket->size += bucket->next->size;
834 bucket->next = bucket->next->next; 833 bucket->next = bucket->next->next;
835 if (bucket->next) { 834 if (bucket->next) {
836 bucket->next->prev = bucket; 835 bucket->next->prev = bucket;
837 } 836 }
838 SDL_free (freeable); 837 SDL_free(freeable);
839 } 838 }
840 if (bucket->prev && !bucket->prev->used) { 839 if (bucket->prev && !bucket->prev->used) {
841 #ifdef DGA_DEBUG 840 #ifdef DGA_DEBUG
842 printf ("Merging with previous bucket, for %d total bytes\n", 841 printf("Merging with previous bucket, for %d total bytes\n",
843 bucket->prev->size + bucket->size); 842 bucket->prev->size + bucket->size);
844 #endif 843 #endif
845 freeable = bucket; 844 freeable = bucket;
846 bucket->prev->size += bucket->size; 845 bucket->prev->size += bucket->size;
847 bucket->prev->next = bucket->next; 846 bucket->prev->next = bucket->next;
848 if (bucket->next) { 847 if (bucket->next) {
849 bucket->next->prev = bucket->prev; 848 bucket->next->prev = bucket->prev;
850 } 849 }
851 SDL_free (freeable); 850 SDL_free(freeable);
852 } 851 }
853 } 852 }
854 surface->pixels = NULL; 853 surface->pixels = NULL;
855 surface->hwdata = NULL; 854 surface->hwdata = NULL;
856 } 855 }
857 856
858 static __inline__ void 857 static __inline__ void
859 DGA_dst_to_xy (_THIS, SDL_Surface * dst, int *x, int *y) 858 DGA_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y)
860 { 859 {
861 *x = (long) ((Uint8 *) dst->pixels - memory_base) % memory_pitch; 860 *x = (long) ((Uint8 *) dst->pixels - memory_base) % memory_pitch;
862 *y = (long) ((Uint8 *) dst->pixels - memory_base) / memory_pitch; 861 *y = (long) ((Uint8 *) dst->pixels - memory_base) / memory_pitch;
863 } 862 }
864 863
865 static int 864 static int
866 DGA_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) 865 DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
867 { 866 {
868 int x, y; 867 int x, y;
869 unsigned int w, h; 868 unsigned int w, h;
870 869
871 /* Don't fill the visible part of the screen, wait until flipped */ 870 /* Don't fill the visible part of the screen, wait until flipped */
872 LOCK_DISPLAY (); 871 LOCK_DISPLAY();
873 if (was_flipped && (dst == this->screen)) { 872 if (was_flipped && (dst == this->screen)) {
874 while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) 873 while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
875 /* Keep waiting for the hardware ... */ ; 874 /* Keep waiting for the hardware ... */ ;
876 was_flipped = 0; 875 was_flipped = 0;
877 } 876 }
878 DGA_dst_to_xy (this, dst, &x, &y); 877 DGA_dst_to_xy(this, dst, &x, &y);
879 x += rect->x; 878 x += rect->x;
880 y += rect->y; 879 y += rect->y;
881 w = rect->w; 880 w = rect->w;
882 h = rect->h; 881 h = rect->h;
883 #if 0 882 #if 0
884 printf ("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x, 883 printf("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x,
885 y); 884 y);
886 #endif 885 #endif
887 SDL_NAME (XDGAFillRectangle) (DGA_Display, DGA_Screen, x, y, w, h, color); 886 SDL_NAME(XDGAFillRectangle) (DGA_Display, DGA_Screen, x, y, w, h, color);
888 if (!(this->screen->flags & SDL_DOUBLEBUF)) { 887 if (!(this->screen->flags & SDL_DOUBLEBUF)) {
889 XFlush (DGA_Display); 888 XFlush(DGA_Display);
890 } 889 }
891 DGA_AddBusySurface (dst); 890 DGA_AddBusySurface(dst);
892 UNLOCK_DISPLAY (); 891 UNLOCK_DISPLAY();
893 return (0); 892 return (0);
894 } 893 }
895 894
896 static int 895 static int
897 HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, 896 HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
898 SDL_Surface * dst, SDL_Rect * dstrect) 897 SDL_Surface * dst, SDL_Rect * dstrect)
899 { 898 {
900 SDL_VideoDevice *this; 899 SDL_VideoDevice *this;
901 int srcx, srcy; 900 int srcx, srcy;
902 int dstx, dsty; 901 int dstx, dsty;
903 unsigned int w, h; 902 unsigned int w, h;
904 903
905 this = current_video; 904 this = current_video;
906 /* Don't blit to the visible part of the screen, wait until flipped */ 905 /* Don't blit to the visible part of the screen, wait until flipped */
907 LOCK_DISPLAY (); 906 LOCK_DISPLAY();
908 if (was_flipped && (dst == this->screen)) { 907 if (was_flipped && (dst == this->screen)) {
909 while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) 908 while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
910 /* Keep waiting for the hardware ... */ ; 909 /* Keep waiting for the hardware ... */ ;
911 was_flipped = 0; 910 was_flipped = 0;
912 } 911 }
913 DGA_dst_to_xy (this, src, &srcx, &srcy); 912 DGA_dst_to_xy(this, src, &srcx, &srcy);
914 srcx += srcrect->x; 913 srcx += srcrect->x;
915 srcy += srcrect->y; 914 srcy += srcrect->y;
916 DGA_dst_to_xy (this, dst, &dstx, &dsty); 915 DGA_dst_to_xy(this, dst, &dstx, &dsty);
917 dstx += dstrect->x; 916 dstx += dstrect->x;
918 dsty += dstrect->y; 917 dsty += dstrect->y;
919 w = srcrect->w; 918 w = srcrect->w;
920 h = srcrect->h; 919 h = srcrect->h;
921 #if 0 920 #if 0
922 printf ("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx, 921 printf("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx,
923 dsty); 922 dsty);
924 #endif 923 #endif
925 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { 924 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
926 SDL_NAME (XDGACopyTransparentArea) (DGA_Display, DGA_Screen, 925 SDL_NAME(XDGACopyTransparentArea) (DGA_Display, DGA_Screen,
927 srcx, srcy, w, h, dstx, dsty, 926 srcx, srcy, w, h, dstx, dsty,
928 src->format->colorkey); 927 src->format->colorkey);
929 } else { 928 } else {
930 SDL_NAME (XDGACopyArea) (DGA_Display, DGA_Screen, 929 SDL_NAME(XDGACopyArea) (DGA_Display, DGA_Screen,
931 srcx, srcy, w, h, dstx, dsty); 930 srcx, srcy, w, h, dstx, dsty);
932 } 931 }
933 if (!(this->screen->flags & SDL_DOUBLEBUF)) { 932 if (!(this->screen->flags & SDL_DOUBLEBUF)) {
934 XFlush (DGA_Display); 933 XFlush(DGA_Display);
935 } 934 }
936 DGA_AddBusySurface (src); 935 DGA_AddBusySurface(src);
937 DGA_AddBusySurface (dst); 936 DGA_AddBusySurface(dst);
938 UNLOCK_DISPLAY (); 937 UNLOCK_DISPLAY();
939 return (0); 938 return (0);
940 } 939 }
941 940
942 static int 941 static int
943 DGA_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) 942 DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
944 { 943 {
945 int accelerated; 944 int accelerated;
946 945
947 /* Set initial acceleration on */ 946 /* Set initial acceleration on */
948 src->flags |= SDL_HWACCEL; 947 src->flags |= SDL_HWACCEL;
966 } 965 }
967 return (accelerated); 966 return (accelerated);
968 } 967 }
969 968
970 static __inline__ void 969 static __inline__ void
971 DGA_WaitFlip (_THIS) 970 DGA_WaitFlip(_THIS)
972 { 971 {
973 if (was_flipped) { 972 if (was_flipped) {
974 while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) 973 while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
975 /* Keep waiting for the hardware ... */ ; 974 /* Keep waiting for the hardware ... */ ;
976 was_flipped = 0; 975 was_flipped = 0;
977 } 976 }
978 } 977 }
979 978
980 static int 979 static int
981 DGA_LockHWSurface (_THIS, SDL_Surface * surface) 980 DGA_LockHWSurface(_THIS, SDL_Surface * surface)
982 { 981 {
983 if (surface == this->screen) { 982 if (surface == this->screen) {
984 SDL_mutexP (hw_lock); 983 SDL_mutexP(hw_lock);
985 LOCK_DISPLAY (); 984 LOCK_DISPLAY();
986 if (DGA_IsSurfaceBusy (surface)) { 985 if (DGA_IsSurfaceBusy(surface)) {
987 DGA_WaitBusySurfaces (this); 986 DGA_WaitBusySurfaces(this);
988 } 987 }
989 DGA_WaitFlip (this); 988 DGA_WaitFlip(this);
990 UNLOCK_DISPLAY (); 989 UNLOCK_DISPLAY();
991 } else { 990 } else {
992 if (DGA_IsSurfaceBusy (surface)) { 991 if (DGA_IsSurfaceBusy(surface)) {
993 LOCK_DISPLAY (); 992 LOCK_DISPLAY();
994 DGA_WaitBusySurfaces (this); 993 DGA_WaitBusySurfaces(this);
995 UNLOCK_DISPLAY (); 994 UNLOCK_DISPLAY();
996 } 995 }
997 } 996 }
998 return (0); 997 return (0);
999 } 998 }
1000 static void 999 static void
1001 DGA_UnlockHWSurface (_THIS, SDL_Surface * surface) 1000 DGA_UnlockHWSurface(_THIS, SDL_Surface * surface)
1002 { 1001 {
1003 if (surface == this->screen) { 1002 if (surface == this->screen) {
1004 SDL_mutexV (hw_lock); 1003 SDL_mutexV(hw_lock);
1005 } 1004 }
1006 } 1005 }
1007 1006
1008 static int 1007 static int
1009 DGA_FlipHWSurface (_THIS, SDL_Surface * surface) 1008 DGA_FlipHWSurface(_THIS, SDL_Surface * surface)
1010 { 1009 {
1011 /* Wait for vertical retrace and then flip display */ 1010 /* Wait for vertical retrace and then flip display */
1012 LOCK_DISPLAY (); 1011 LOCK_DISPLAY();
1013 if (DGA_IsSurfaceBusy (this->screen)) { 1012 if (DGA_IsSurfaceBusy(this->screen)) {
1014 DGA_WaitBusySurfaces (this); 1013 DGA_WaitBusySurfaces(this);
1015 } 1014 }
1016 DGA_WaitFlip (this); 1015 DGA_WaitFlip(this);
1017 SDL_NAME (XDGASetViewport) (DGA_Display, DGA_Screen, 1016 SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen,
1018 0, flip_yoffset[flip_page], XDGAFlipRetrace); 1017 0, flip_yoffset[flip_page], XDGAFlipRetrace);
1019 XFlush (DGA_Display); 1018 XFlush(DGA_Display);
1020 UNLOCK_DISPLAY (); 1019 UNLOCK_DISPLAY();
1021 was_flipped = 1; 1020 was_flipped = 1;
1022 flip_page = !flip_page; 1021 flip_page = !flip_page;
1023 1022
1024 surface->pixels = flip_address[flip_page]; 1023 surface->pixels = flip_address[flip_page];
1025 return (0); 1024 return (0);
1026 } 1025 }
1027 1026
1028 static void 1027 static void
1029 DGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) 1028 DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
1030 { 1029 {
1031 /* The application is already updating the visible video memory */ 1030 /* The application is already updating the visible video memory */
1032 return; 1031 return;
1033 } 1032 }
1034 1033
1035 static int 1034 static int
1036 DGA_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) 1035 DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
1037 { 1036 {
1038 int i; 1037 int i;
1039 XColor *xcmap; 1038 XColor *xcmap;
1040 1039
1041 /* This happens on initialization */ 1040 /* This happens on initialization */
1042 if (!DGA_colormap) { 1041 if (!DGA_colormap) {
1043 return (0); 1042 return (0);
1044 } 1043 }
1045 xcmap = SDL_stack_alloc (XColor, ncolors); 1044 xcmap = SDL_stack_alloc(XColor, ncolors);
1046 for (i = 0; i < ncolors; ++i) { 1045 for (i = 0; i < ncolors; ++i) {
1047 xcmap[i].pixel = firstcolor + i; 1046 xcmap[i].pixel = firstcolor + i;
1048 xcmap[i].red = (colors[i].r << 8) | colors[i].r; 1047 xcmap[i].red = (colors[i].r << 8) | colors[i].r;
1049 xcmap[i].green = (colors[i].g << 8) | colors[i].g; 1048 xcmap[i].green = (colors[i].g << 8) | colors[i].g;
1050 xcmap[i].blue = (colors[i].b << 8) | colors[i].b; 1049 xcmap[i].blue = (colors[i].b << 8) | colors[i].b;
1051 xcmap[i].flags = (DoRed | DoGreen | DoBlue); 1050 xcmap[i].flags = (DoRed | DoGreen | DoBlue);
1052 } 1051 }
1053 LOCK_DISPLAY (); 1052 LOCK_DISPLAY();
1054 XStoreColors (DGA_Display, DGA_colormap, xcmap, ncolors); 1053 XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
1055 XSync (DGA_Display, False); 1054 XSync(DGA_Display, False);
1056 UNLOCK_DISPLAY (); 1055 UNLOCK_DISPLAY();
1057 SDL_stack_free (xcmap); 1056 SDL_stack_free(xcmap);
1058 1057
1059 /* That was easy. :) */ 1058 /* That was easy. :) */
1060 return (1); 1059 return (1);
1061 } 1060 }
1062 1061
1063 int 1062 int
1064 DGA_SetGammaRamp (_THIS, Uint16 * ramp) 1063 DGA_SetGammaRamp(_THIS, Uint16 * ramp)
1065 { 1064 {
1066 int i, ncolors; 1065 int i, ncolors;
1067 XColor xcmap[256]; 1066 XColor xcmap[256];
1068 1067
1069 /* See if actually setting the gamma is supported */ 1068 /* See if actually setting the gamma is supported */
1070 if (DGA_visualClass != DirectColor) { 1069 if (DGA_visualClass != DirectColor) {
1071 SDL_SetError ("Gamma correction not supported on this visual"); 1070 SDL_SetError("Gamma correction not supported on this visual");
1072 return (-1); 1071 return (-1);
1073 } 1072 }
1074 1073
1075 /* Calculate the appropriate palette for the given gamma ramp */ 1074 /* Calculate the appropriate palette for the given gamma ramp */
1076 if (this->screen->format->BitsPerPixel <= 16) { 1075 if (this->screen->format->BitsPerPixel <= 16) {
1078 } else { 1077 } else {
1079 ncolors = 256; 1078 ncolors = 256;
1080 } 1079 }
1081 for (i = 0; i < ncolors; ++i) { 1080 for (i = 0; i < ncolors; ++i) {
1082 Uint8 c = (256 * i / ncolors); 1081 Uint8 c = (256 * i / ncolors);
1083 xcmap[i].pixel = SDL_MapRGB (this->screen->format, c, c, c); 1082 xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
1084 xcmap[i].red = ramp[0 * 256 + c]; 1083 xcmap[i].red = ramp[0 * 256 + c];
1085 xcmap[i].green = ramp[1 * 256 + c]; 1084 xcmap[i].green = ramp[1 * 256 + c];
1086 xcmap[i].blue = ramp[2 * 256 + c]; 1085 xcmap[i].blue = ramp[2 * 256 + c];
1087 xcmap[i].flags = (DoRed | DoGreen | DoBlue); 1086 xcmap[i].flags = (DoRed | DoGreen | DoBlue);
1088 } 1087 }
1089 LOCK_DISPLAY (); 1088 LOCK_DISPLAY();
1090 XStoreColors (DGA_Display, DGA_colormap, xcmap, ncolors); 1089 XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
1091 XSync (DGA_Display, False); 1090 XSync(DGA_Display, False);
1092 UNLOCK_DISPLAY (); 1091 UNLOCK_DISPLAY();
1093 return (0); 1092 return (0);
1094 } 1093 }
1095 1094
1096 void 1095 void
1097 DGA_VideoQuit (_THIS) 1096 DGA_VideoQuit(_THIS)
1098 { 1097 {
1099 int i, j; 1098 int i, j;
1100 1099
1101 if (DGA_Display) { 1100 if (DGA_Display) {
1102 /* Free colormap, if necessary */ 1101 /* Free colormap, if necessary */
1103 if (DGA_colormap) { 1102 if (DGA_colormap) {
1104 XFreeColormap (DGA_Display, DGA_colormap); 1103 XFreeColormap(DGA_Display, DGA_colormap);
1105 DGA_colormap = 0; 1104 DGA_colormap = 0;
1106 } 1105 }
1107 1106
1108 /* Unmap memory and reset video mode */ 1107 /* Unmap memory and reset video mode */
1109 SDL_NAME (XDGACloseFramebuffer) (DGA_Display, DGA_Screen); 1108 SDL_NAME(XDGACloseFramebuffer) (DGA_Display, DGA_Screen);
1110 if (this->screen) { 1109 if (this->screen) {
1111 /* Tell SDL not to free the pixels */ 1110 /* Tell SDL not to free the pixels */
1112 DGA_FreeHWSurface (this, this->screen); 1111 DGA_FreeHWSurface(this, this->screen);
1113 } 1112 }
1114 SDL_NAME (XDGASetMode) (DGA_Display, DGA_Screen, 0); 1113 SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, 0);
1115 1114
1116 /* Clear the lock mutex */ 1115 /* Clear the lock mutex */
1117 if (hw_lock != NULL) { 1116 if (hw_lock != NULL) {
1118 SDL_DestroyMutex (hw_lock); 1117 SDL_DestroyMutex(hw_lock);
1119 hw_lock = NULL; 1118 hw_lock = NULL;
1120 } 1119 }
1121 #ifdef LOCK_DGA_DISPLAY 1120 #ifdef LOCK_DGA_DISPLAY
1122 if (event_lock != NULL) { 1121 if (event_lock != NULL) {
1123 SDL_DestroyMutex (event_lock); 1122 SDL_DestroyMutex(event_lock);
1124 event_lock = NULL; 1123 event_lock = NULL;
1125 } 1124 }
1126 #endif /* LOCK_DGA_DISPLAY */ 1125 #endif /* LOCK_DGA_DISPLAY */
1127 1126
1128 /* Clean up defined video modes */ 1127 /* Clean up defined video modes */
1129 for (i = 0; i < NUM_MODELISTS; ++i) { 1128 for (i = 0; i < NUM_MODELISTS; ++i) {
1130 if (SDL_modelist[i] != NULL) { 1129 if (SDL_modelist[i] != NULL) {
1131 for (j = 0; SDL_modelist[i][j]; ++j) { 1130 for (j = 0; SDL_modelist[i][j]; ++j) {
1132 SDL_free (SDL_modelist[i][j]); 1131 SDL_free(SDL_modelist[i][j]);
1133 } 1132 }
1134 SDL_free (SDL_modelist[i]); 1133 SDL_free(SDL_modelist[i]);
1135 SDL_modelist[i] = NULL; 1134 SDL_modelist[i] = NULL;
1136 } 1135 }
1137 } 1136 }
1138 1137
1139 /* Clean up the memory bucket list */ 1138 /* Clean up the memory bucket list */
1140 DGA_FreeHWSurfaces (this); 1139 DGA_FreeHWSurfaces(this);
1141 1140
1142 /* Restore DPMS and screensaver settings */ 1141 /* Restore DPMS and screensaver settings */
1143 X11_RestoreScreenSaver (DGA_Display, screensaver_timeout, 1142 X11_RestoreScreenSaver(DGA_Display, screensaver_timeout,
1144 dpms_enabled); 1143 dpms_enabled);
1145 1144
1146 /* Close up the display */ 1145 /* Close up the display */
1147 XCloseDisplay (DGA_Display); 1146 XCloseDisplay(DGA_Display);
1148 } 1147 }
1149 } 1148 }
1150 1149
1151 /* vi: set ts=4 sw=4 expandtab: */ 1150 /* vi: set ts=4 sw=4 expandtab: */