comparison src/video/directfb/SDL_DirectFB_modes.c @ 3500:4b594623401b

Work in progress on multi-display support: * Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one. * The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 05:57:15 +0000
parents 490f3e4fe753
children 58c1b9ec7074
comparison
equal deleted inserted replaced
3499:4cf8a1423d57 3500:4b594623401b
195 } 195 }
196 return DFENUM_OK; 196 return DFENUM_OK;
197 } 197 }
198 198
199 static void 199 static void
200 CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode) 200 CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, SDL_DisplayMode * mode)
201 { 201 {
202 SDL_DFB_DEVICEDATA(_this); 202 SDL_DFB_DEVICEDATA(_this);
203 DFBDisplayLayerConfig config; 203 DFBDisplayLayerConfig config;
204 DFBDisplayLayerConfigFlags failed; 204 DFBDisplayLayerConfigFlags failed;
205 int ret; 205 int ret;
217 failed = 0; 217 failed = 0;
218 data->layer->TestConfiguration(data->layer, &config, &failed); 218 data->layer->TestConfiguration(data->layer, &config, &failed);
219 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, 219 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
220 DLSCL_SHARED)); 220 DLSCL_SHARED));
221 if (failed == 0) 221 if (failed == 0)
222 SDL_AddDisplayMode(_this->current_display, mode); 222 SDL_AddDisplayMode(display, mode);
223 else 223 else
224 SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w, 224 SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
225 mode->h, failed); 225 mode->h, failed);
226 226
227 return; 227 return;
354 SDL_DFB_RELEASE(layer); 354 SDL_DFB_RELEASE(layer);
355 return; 355 return;
356 } 356 }
357 357
358 void 358 void
359 DirectFB_GetDisplayModes(_THIS) 359 DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
360 { 360 {
361 SDL_DFB_DEVICEDATA(_this); 361 SDL_DFB_DEVICEDATA(_this);
362 DFB_DisplayData *dispdata = 362 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
363 (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
364 SDL_DisplayMode mode; 363 SDL_DisplayMode mode;
365 struct modes_callback_t data; 364 struct modes_callback_t data;
366 int i; 365 int i;
367 int ret; 366 int ret;
368 367
374 373
375 for (i = 0; i < data.nummodes; ++i) { 374 for (i = 0; i < data.nummodes; ++i) {
376 mode = data.modelist[i]; 375 mode = data.modelist[i];
377 376
378 mode.format = SDL_PIXELFORMAT_ARGB8888; 377 mode.format = SDL_PIXELFORMAT_ARGB8888;
379 CheckSetDisplayMode(_this, dispdata, &mode); 378 CheckSetDisplayMode(_this, display, dispdata, &mode);
380 mode.format = SDL_PIXELFORMAT_RGB888; 379 mode.format = SDL_PIXELFORMAT_RGB888;
381 CheckSetDisplayMode(_this, dispdata, &mode); 380 CheckSetDisplayMode(_this, display, dispdata, &mode);
382 mode.format = SDL_PIXELFORMAT_RGB24; 381 mode.format = SDL_PIXELFORMAT_RGB24;
383 CheckSetDisplayMode(_this, dispdata, &mode); 382 CheckSetDisplayMode(_this, display, dispdata, &mode);
384 mode.format = SDL_PIXELFORMAT_RGB565; 383 mode.format = SDL_PIXELFORMAT_RGB565;
385 CheckSetDisplayMode(_this, dispdata, &mode); 384 CheckSetDisplayMode(_this, display, dispdata, &mode);
386 mode.format = SDL_PIXELFORMAT_INDEX8; 385 mode.format = SDL_PIXELFORMAT_INDEX8;
387 CheckSetDisplayMode(_this, dispdata, &mode); 386 CheckSetDisplayMode(_this, display, dispdata, &mode);
388 } 387 }
388
389 SDL_DFB_FREE(data.modelist); 389 SDL_DFB_FREE(data.modelist);
390 return; 390 return;
391 error:
392 SDL_DFB_FREE(data.modelist);
393 return;
394 } 391 }
395 392
396 int 393 int
397 DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode) 394 DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
398 { 395 {
399 /* 396 /*
400 * FIXME: video mode switch is currently broken for 1.2.0 397 * FIXME: video mode switch is currently broken for 1.2.0
401 * 398 *
402 */ 399 */
403 400
404 SDL_DFB_DEVICEDATA(_this); 401 SDL_DFB_DEVICEDATA(_this);
405 DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata; 402 DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
406 DFBDisplayLayerConfig config, rconfig; 403 DFBDisplayLayerConfig config, rconfig;
407 DFBDisplayLayerConfigFlags fail = 0; 404 DFBDisplayLayerConfigFlags fail = 0;
408 DFBResult ret; 405 DFBResult ret;
409 406
410 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, 407 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
457 } 454 }
458 455
459 data->pixelformat = rconfig.pixelformat; 456 data->pixelformat = rconfig.pixelformat;
460 data->cw = config.width; 457 data->cw = config.width;
461 data->ch = config.height; 458 data->ch = config.height;
462 SDL_CurrentDisplay.current_mode = *mode; 459 display->current_mode = *mode;
463 460
464 return 0; 461 return 0;
465 error: 462 error:
466 return -1; 463 return -1;
467 } 464 }
472 //DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata; 469 //DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata;
473 SDL_DisplayMode tmode; 470 SDL_DisplayMode tmode;
474 DFBResult ret; 471 DFBResult ret;
475 int i; 472 int i;
476 473
477 SDL_SelectVideoDisplay(0); 474 for (i = 0; i < _this->num_displays; ++i) {
478 475 SDL_VideoDisplay *display = &_this->displays[i];
479 SDL_GetDesktopDisplayMode(&tmode); 476 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
480 tmode.format = SDL_PIXELFORMAT_UNKNOWN; 477
481 DirectFB_SetDisplayMode(_this, &tmode); 478 SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
482 479 tmode.format = SDL_PIXELFORMAT_UNKNOWN;
483 SDL_GetDesktopDisplayMode(&tmode); 480 DirectFB_SetDisplayMode(_this, display, &tmode);
484 DirectFB_SetDisplayMode(_this, &tmode); 481
485 482 SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
486 for (i = 0; i < SDL_GetNumVideoDisplays(); i++) { 483 DirectFB_SetDisplayMode(_this, display, &tmode);
487 DFB_DisplayData *dispdata =
488 (DFB_DisplayData *) _this->displays[i].driverdata;
489 484
490 if (dispdata->layer) { 485 if (dispdata->layer) {
491 SDL_DFB_CHECK(dispdata-> 486 SDL_DFB_CHECK(dispdata->
492 layer->SetCooperativeLevel(dispdata->layer, 487 layer->SetCooperativeLevel(dispdata->layer,
493 DLSCL_ADMINISTRATIVE)); 488 DLSCL_ADMINISTRATIVE));