comparison src/video/directfb/SDL_DirectFB_video.c @ 2735:204be4fc2726

Final merge of Google Summer of Code 2008 work... Port SDL 1.3 to the Nintendo DS by Darren Alton, mentored by Sam Lantinga
author Sam Lantinga <slouken@libsdl.org>
date Wed, 27 Aug 2008 15:10:03 +0000
parents 91f1706b27be
children 140a7edcf2bd
comparison
equal deleted inserted replaced
2734:dd25eabe441c 2735:204be4fc2726
312 IDirectFBScreen *screen; 312 IDirectFBScreen *screen;
313 313
314 SDL_DFB_CHECKERR(dfb->GetScreen(dfb, devdata->screenid[i], &screen)); 314 SDL_DFB_CHECKERR(dfb->GetScreen(dfb, devdata->screenid[i], &screen));
315 315
316 devdata->aux = i; 316 devdata->aux = i;
317 SDL_DFB_CHECKERR(screen-> 317 SDL_DFB_CHECKERR(screen->EnumDisplayLayers
318 EnumDisplayLayers(screen, &cbLayers, devdata)); 318 (screen, &cbLayers, devdata));
319 #if (DIRECTFB_MAJOR_VERSION >= 1) 319 #if (DIRECTFB_MAJOR_VERSION >= 1)
320 screen->GetSize(screen, &tcw[i], &tch[i]); 320 screen->GetSize(screen, &tcw[i], &tch[i]);
321 #else 321 #else
322 /* FIXME: this is only used to center windows 322 /* FIXME: this is only used to center windows
323 * Should be done otherwise, e.g. get surface from layer 323 * Should be done otherwise, e.g. get surface from layer
336 SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor); 336 SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor);
337 SDL_DFB_DEBUG("Found %d screens\n", devdata->numscreens); 337 SDL_DFB_DEBUG("Found %d screens\n", devdata->numscreens);
338 338
339 for (i = 0; i < devdata->numscreens; i++) { 339 for (i = 0; i < devdata->numscreens; i++) {
340 //SDL_DFB_CHECKERR( dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer) ); 340 //SDL_DFB_CHECKERR( dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer) );
341 SDL_DFB_CHECKERR(dfb-> 341 SDL_DFB_CHECKERR(dfb->GetDisplayLayer
342 GetDisplayLayer(dfb, devdata->gralayer[i], &layer)); 342 (dfb, devdata->gralayer[i], &layer));
343 //SDL_DFB_CHECKERR( dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events) ); 343 //SDL_DFB_CHECKERR( dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events) );
344 344
345 SDL_DFB_CHECKERR(layer-> 345 SDL_DFB_CHECKERR(layer->SetCooperativeLevel
346 SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE)); 346 (layer, DLSCL_ADMINISTRATIVE));
347 layer->EnableCursor(layer, 1); 347 layer->EnableCursor(layer, 1);
348 SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0)); 348 SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0));
349 SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, DLSCL_SHARED)); 349 SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, DLSCL_SHARED));
350 350
351 /* Query layer configuration to determine the current mode and pixelformat */ 351 /* Query layer configuration to determine the current mode and pixelformat */
377 display.driverdata = dispdata; 377 display.driverdata = dispdata;
378 378
379 /* Enumerate the available fullscreen modes */ 379 /* Enumerate the available fullscreen modes */
380 SDL_DFB_CALLOC(dispdata->modelist, DFB_MAX_MODES, 380 SDL_DFB_CALLOC(dispdata->modelist, DFB_MAX_MODES,
381 sizeof(SDL_DisplayMode)); 381 sizeof(SDL_DisplayMode));
382 SDL_DFB_CHECKERR(dfb-> 382 SDL_DFB_CHECKERR(dfb->EnumVideoModes
383 EnumVideoModes(dfb, EnumModesCallback, &display)); 383 (dfb, EnumModesCallback, &display));
384 384
385 SDL_AddVideoDisplay(&display); 385 SDL_AddVideoDisplay(&display);
386 } 386 }
387 387
388 devdata->initialized = 1; 388 devdata->initialized = 1;
431 431
432 for (i = 0; i < devdata->numscreens; i++) { 432 for (i = 0; i < devdata->numscreens; i++) {
433 DFB_DisplayData *dispdata = 433 DFB_DisplayData *dispdata =
434 (DFB_DisplayData *) _this->displays[i].driverdata; 434 (DFB_DisplayData *) _this->displays[i].driverdata;
435 if (dispdata->layer) { 435 if (dispdata->layer) {
436 SDL_DFB_CHECK(dispdata->layer-> 436 SDL_DFB_CHECK(dispdata->
437 SetCooperativeLevel(dispdata->layer, 437 layer->SetCooperativeLevel(dispdata->layer,
438 DLSCL_ADMINISTRATIVE)); 438 DLSCL_ADMINISTRATIVE));
439 SDL_DFB_CHECK(dispdata->layer-> 439 SDL_DFB_CHECK(dispdata->
440 SetCursorOpacity(dispdata->layer, 0x00)); 440 layer->SetCursorOpacity(dispdata->layer, 0x00));
441 SDL_DFB_CHECK(dispdata->layer-> 441 SDL_DFB_CHECK(dispdata->
442 SetCooperativeLevel(dispdata->layer, DLSCL_SHARED)); 442 layer->SetCooperativeLevel(dispdata->layer,
443 DLSCL_SHARED));
443 } 444 }
444 SDL_DFB_RELEASE(dispdata->layer); 445 SDL_DFB_RELEASE(dispdata->layer);
445 446
446 /* Free video mode list */ 447 /* Free video mode list */
447 if (dispdata->modelist) { 448 if (dispdata->modelist) {
576 DFBDisplayLayerConfig config, rconfig; 577 DFBDisplayLayerConfig config, rconfig;
577 DFBDisplayLayerConfigFlags fail = 0; 578 DFBDisplayLayerConfigFlags fail = 0;
578 DFBResult ret; 579 DFBResult ret;
579 DFB_WindowData *win; 580 DFB_WindowData *win;
580 581
581 SDL_DFB_CHECKERR(data->layer-> 582 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
582 SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE)); 583 DLSCL_ADMINISTRATIVE));
583 584
584 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &config)); 585 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &config));
585 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; // | DLCONF_BUFFERMODE; 586 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; // | DLCONF_BUFFERMODE;
586 if (mode->format != SDL_PIXELFORMAT_UNKNOWN) { 587 if (mode->format != SDL_PIXELFORMAT_UNKNOWN) {
587 config.flags |= DLCONF_PIXELFORMAT; 588 config.flags |= DLCONF_PIXELFORMAT;
602 return -1; 603 return -1;
603 } 604 }
604 SDL_DFB_DEBUG("Trace\n"); 605 SDL_DFB_DEBUG("Trace\n");
605 config.flags &= ~fail; 606 config.flags &= ~fail;
606 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); 607 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
607 SDL_DFB_CHECKERR(data->layer-> 608 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
608 SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE)); 609 DLSCL_ADMINISTRATIVE));
609 610
610 /* Double check */ 611 /* Double check */
611 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &rconfig)); 612 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &rconfig));
612 613
613 if ((config.width != rconfig.width) || 614 if ((config.width != rconfig.width) ||
672 window->w, window->h); 673 window->w, window->h);
673 window->driverdata = NULL; 674 window->driverdata = NULL;
674 SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData)); 675 SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
675 windata = (DFB_WindowData *) window->driverdata; 676 windata = (DFB_WindowData *) window->driverdata;
676 677
677 SDL_DFB_CHECKERR(devdata->dfb-> 678 SDL_DFB_CHECKERR(devdata->
678 SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL)); 679 dfb->SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL));
679 SDL_DFB_CHECKERR(dispdata->layer-> 680 SDL_DFB_CHECKERR(dispdata->
680 SetCooperativeLevel(dispdata->layer, 681 layer->SetCooperativeLevel(dispdata->layer,
681 DLSCL_ADMINISTRATIVE)); 682 DLSCL_ADMINISTRATIVE));
682 683
683 /* Fill the window description. */ 684 /* Fill the window description. */
684 if (window->x == SDL_WINDOWPOS_CENTERED) { 685 if (window->x == SDL_WINDOWPOS_CENTERED) {
685 x = (dispdata->cw - window->w) / 2; 686 x = (dispdata->cw - window->w) / 2;
686 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { 687 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
723 desc.pixelformat = dispdata->pixelformat; 724 desc.pixelformat = dispdata->pixelformat;
724 desc.caps = 0; // DWCAPS_DOUBLEBUFFER; 725 desc.caps = 0; // DWCAPS_DOUBLEBUFFER;
725 desc.surface_caps = DSCAPS_DOUBLE | DSCAPS_TRIPLE / DSCAPS_PREMULTIPLIED; 726 desc.surface_caps = DSCAPS_DOUBLE | DSCAPS_TRIPLE / DSCAPS_PREMULTIPLIED;
726 727
727 /* Create the window. */ 728 /* Create the window. */
728 SDL_DFB_CHECKERR(dispdata->layer-> 729 SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
729 CreateWindow(dispdata->layer, &desc, &windata->window)); 730 &windata->window));
730 731
731 windata->window->GetOptions(windata->window, &wopts); 732 windata->window->GetOptions(windata->window, &wopts);
732 #if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0) 733 #if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0)
733 734
734 if (window->flags & SDL_WINDOW_RESIZABLE) 735 if (window->flags & SDL_WINDOW_RESIZABLE)
742 if (window->flags & SDL_WINDOW_FULLSCREEN) 743 if (window->flags & SDL_WINDOW_FULLSCREEN)
743 wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE; 744 wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
744 745
745 windata->window->SetOptions(windata->window, wopts); 746 windata->window->SetOptions(windata->window, wopts);
746 /* Get the window's surface. */ 747 /* Get the window's surface. */
747 SDL_DFB_CHECKERR(windata->window-> 748 SDL_DFB_CHECKERR(windata->
748 GetSurface(windata->window, &windata->surface)); 749 window->GetSurface(windata->window, &windata->surface));
749 windata->window->SetOpacity(windata->window, 0xFF); 750 windata->window->SetOpacity(windata->window, 0xFF);
750 SDL_DFB_CHECKERR(windata->window-> 751 SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
751 CreateEventBuffer(windata->window, 752 &
752 &(windata->eventbuffer))); 753 (windata->
754 eventbuffer)));
753 SDL_DFB_CHECKERR(windata->window-> 755 SDL_DFB_CHECKERR(windata->window->
754 EnableEvents(windata->window, 756 EnableEvents(windata->window,
755 DWET_POSITION | DWET_SIZE | DWET_CLOSE | 757 DWET_POSITION | DWET_SIZE | DWET_CLOSE |
756 DWET_ALL)); 758 DWET_ALL));
757 759
810 812
811 SDL_Unsupported(); 813 SDL_Unsupported();
812 //return -1; 814 //return -1;
813 815
814 } 816 }
817
815 static void 818 static void
816 DirectFB_SetWindowPosition(_THIS, SDL_Window * window) 819 DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
817 { 820 {
818 SDL_DFB_DEVICEDATA(_this); 821 SDL_DFB_DEVICEDATA(_this);
819 SDL_DFB_WINDOWDATA(window); 822 SDL_DFB_WINDOWDATA(window);
884 887
885 windata->window->GetOpacity(windata->window, &windata->opacity); 888 windata->window->GetOpacity(windata->window, &windata->opacity);
886 windata->window->SetOpacity(windata->window, 0); 889 windata->window->SetOpacity(windata->window, 0);
887 890
888 } 891 }
892
889 static void 893 static void
890 DirectFB_RaiseWindow(_THIS, SDL_Window * window) 894 DirectFB_RaiseWindow(_THIS, SDL_Window * window)
891 { 895 {
892 SDL_DFB_DEVICEDATA(_this); 896 SDL_DFB_DEVICEDATA(_this);
893 SDL_DFB_WINDOWDATA(window); 897 SDL_DFB_WINDOWDATA(window);
905 SDL_DFB_DISPLAYDATA(_this, window); 909 SDL_DFB_DISPLAYDATA(_this, window);
906 910
907 SDL_Unsupported(); 911 SDL_Unsupported();
908 912
909 } 913 }
914
910 static void 915 static void
911 DirectFB_MinimizeWindow(_THIS, SDL_Window * window) 916 DirectFB_MinimizeWindow(_THIS, SDL_Window * window)
912 { 917 {
913 SDL_DFB_DEVICEDATA(_this); 918 SDL_DFB_DEVICEDATA(_this);
914 SDL_DFB_WINDOWDATA(window); 919 SDL_DFB_WINDOWDATA(window);
926 SDL_DFB_DISPLAYDATA(_this, window); 931 SDL_DFB_DISPLAYDATA(_this, window);
927 932
928 SDL_Unsupported(); 933 SDL_Unsupported();
929 934
930 } 935 }
936
931 static void 937 static void
932 DirectFB_SetWindowGrab(_THIS, SDL_Window * window) 938 DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
933 { 939 {
934 SDL_DFB_DEVICEDATA(_this); 940 SDL_DFB_DEVICEDATA(_this);
935 SDL_DFB_WINDOWDATA(window); 941 SDL_DFB_WINDOWDATA(window);
1154 devdata->glFinish(); 1160 devdata->glFinish();
1155 else if (devdata->glFlush) 1161 else if (devdata->glFlush)
1156 devdata->glFlush(); 1162 devdata->glFlush();
1157 1163
1158 SDL_DFB_CHECKERR(windata->gl_context->Unlock(windata->gl_context)); 1164 SDL_DFB_CHECKERR(windata->gl_context->Unlock(windata->gl_context));
1159 SDL_DFB_CHECKERR(windata->surface-> 1165 SDL_DFB_CHECKERR(windata->
1160 Flip(windata->surface, &region, DSFLIP_ONSYNC)); 1166 surface->Flip(windata->surface, &region, DSFLIP_ONSYNC));
1161 SDL_DFB_CHECKERR(windata->gl_context->Lock(windata->gl_context)); 1167 SDL_DFB_CHECKERR(windata->gl_context->Lock(windata->gl_context));
1162 1168
1163 return; 1169 return;
1164 error: 1170 error:
1165 return; 1171 return;