Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_photon.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 | 0cbfec87e4f1 |
children | 64ce267332c6 |
comparison
equal
deleted
inserted
replaced
3499:4cf8a1423d57 | 3500:4b594623401b |
---|---|
267 /* Setup all functions which we can handle */ | 267 /* Setup all functions which we can handle */ |
268 device->VideoInit = photon_videoinit; | 268 device->VideoInit = photon_videoinit; |
269 device->VideoQuit = photon_videoquit; | 269 device->VideoQuit = photon_videoquit; |
270 device->GetDisplayModes = photon_getdisplaymodes; | 270 device->GetDisplayModes = photon_getdisplaymodes; |
271 device->SetDisplayMode = photon_setdisplaymode; | 271 device->SetDisplayMode = photon_setdisplaymode; |
272 device->SetDisplayPalette = photon_setdisplaypalette; | |
273 device->GetDisplayPalette = photon_getdisplaypalette; | |
274 device->SetDisplayGammaRamp = photon_setdisplaygammaramp; | |
275 device->GetDisplayGammaRamp = photon_getdisplaygammaramp; | |
276 device->CreateWindow = photon_createwindow; | 272 device->CreateWindow = photon_createwindow; |
277 device->CreateWindowFrom = photon_createwindowfrom; | 273 device->CreateWindowFrom = photon_createwindowfrom; |
278 device->SetWindowTitle = photon_setwindowtitle; | 274 device->SetWindowTitle = photon_setwindowtitle; |
279 device->SetWindowIcon = photon_setwindowicon; | 275 device->SetWindowIcon = photon_setwindowicon; |
280 device->SetWindowPosition = photon_setwindowposition; | 276 device->SetWindowPosition = photon_setwindowposition; |
522 #endif /* SDL_VIDEO_OPENGL_ES */ | 518 #endif /* SDL_VIDEO_OPENGL_ES */ |
523 } | 519 } |
524 } | 520 } |
525 | 521 |
526 void | 522 void |
527 photon_getdisplaymodes(_THIS) | 523 photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display) |
528 { | 524 { |
529 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 525 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
530 SDL_DisplayData *didata = | 526 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
531 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
532 SDL_DisplayMode mode; | 527 SDL_DisplayMode mode; |
533 PgVideoModes_t modes; | 528 PgVideoModes_t modes; |
534 PgVideoModeInfo_t modeinfo; | 529 PgVideoModeInfo_t modeinfo; |
535 int32_t status; | 530 int32_t status; |
536 uint32_t it; | 531 uint32_t it; |
567 mode.w = modeinfo.width; | 562 mode.w = modeinfo.width; |
568 mode.h = modeinfo.height; | 563 mode.h = modeinfo.height; |
569 mode.refresh_rate = modeinfo.refresh_rates[jt]; | 564 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
570 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | 565 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); |
571 mode.driverdata = NULL; | 566 mode.driverdata = NULL; |
572 SDL_AddDisplayMode(_this->current_display, &mode); | 567 SDL_AddDisplayMode(display, &mode); |
573 | 568 |
574 /* If mode is RGBA8888, add the same mode as RGBx888 */ | 569 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
575 if (modeinfo.type == Pg_IMAGE_DIRECT_8888) { | 570 if (modeinfo.type == Pg_IMAGE_DIRECT_8888) { |
576 mode.w = modeinfo.width; | 571 mode.w = modeinfo.width; |
577 mode.h = modeinfo.height; | 572 mode.h = modeinfo.height; |
578 mode.refresh_rate = modeinfo.refresh_rates[jt]; | 573 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
579 mode.format = SDL_PIXELFORMAT_RGB888; | 574 mode.format = SDL_PIXELFORMAT_RGB888; |
580 mode.driverdata = NULL; | 575 mode.driverdata = NULL; |
581 SDL_AddDisplayMode(_this->current_display, &mode); | 576 SDL_AddDisplayMode(display, &mode); |
582 } | 577 } |
583 | 578 |
584 /* If mode is RGBA1555, add the same mode as RGBx555 */ | 579 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
585 if (modeinfo.type == Pg_IMAGE_DIRECT_1555) { | 580 if (modeinfo.type == Pg_IMAGE_DIRECT_1555) { |
586 mode.w = modeinfo.width; | 581 mode.w = modeinfo.width; |
587 mode.h = modeinfo.height; | 582 mode.h = modeinfo.height; |
588 mode.refresh_rate = modeinfo.refresh_rates[jt]; | 583 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
589 mode.format = SDL_PIXELFORMAT_RGB555; | 584 mode.format = SDL_PIXELFORMAT_RGB555; |
590 mode.driverdata = NULL; | 585 mode.driverdata = NULL; |
591 SDL_AddDisplayMode(_this->current_display, &mode); | 586 SDL_AddDisplayMode(display, &mode); |
592 } | 587 } |
593 | 588 |
594 jt++; | 589 jt++; |
595 } else { | 590 } else { |
596 break; | 591 break; |
598 } while (1); | 593 } while (1); |
599 } | 594 } |
600 } | 595 } |
601 | 596 |
602 int | 597 int |
603 photon_setdisplaymode(_THIS, SDL_DisplayMode * mode) | 598 photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) |
604 { | 599 { |
605 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 600 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
606 SDL_DisplayData *didata = | 601 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
607 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
608 PgVideoModes_t modes; | 602 PgVideoModes_t modes; |
609 PgVideoModeInfo_t modeinfo; | 603 PgVideoModeInfo_t modeinfo; |
610 PgDisplaySettings_t modesettings; | 604 PgDisplaySettings_t modesettings; |
611 uint32_t refresh_rate = 0; | 605 uint32_t refresh_rate = 0; |
612 int32_t status; | 606 int32_t status; |
649 /* Clear display mode structure */ | 643 /* Clear display mode structure */ |
650 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | 644 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); |
651 tempmode.refresh_rate = 0x0000FFFF; | 645 tempmode.refresh_rate = 0x0000FFFF; |
652 | 646 |
653 /* Check if window width and height matches one of our modes */ | 647 /* Check if window width and height matches one of our modes */ |
654 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | 648 for (it = 0; it < display->num_display_modes; it++) { |
655 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | 649 if ((display->display_modes[it].w == mode->w) && |
656 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | 650 (display->display_modes[it].h == mode->h) && |
657 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | 651 (display->display_modes[it].format == mode->format)) |
658 { | 652 { |
659 /* Find the lowest refresh rate available */ | 653 /* Find the lowest refresh rate available */ |
660 if (tempmode.refresh_rate > | 654 if (tempmode.refresh_rate > |
661 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 655 display->display_modes[it].refresh_rate) { |
662 tempmode = SDL_CurrentDisplay.display_modes[it]; | 656 tempmode = display->display_modes[it]; |
663 } | 657 } |
664 } | 658 } |
665 } | 659 } |
666 if (tempmode.refresh_rate != 0x0000FFFF) { | 660 if (tempmode.refresh_rate != 0x0000FFFF) { |
667 refresh_rate = tempmode.refresh_rate; | 661 refresh_rate = tempmode.refresh_rate; |
678 /* Clear display mode structure */ | 672 /* Clear display mode structure */ |
679 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | 673 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); |
680 tempmode.refresh_rate = 0x0000FFFF; | 674 tempmode.refresh_rate = 0x0000FFFF; |
681 | 675 |
682 /* Check if window width and height matches one of our modes */ | 676 /* Check if window width and height matches one of our modes */ |
683 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | 677 for (it = 0; it < display->num_display_modes; it++) { |
684 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | 678 if ((display->display_modes[it].w == mode->w) && |
685 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | 679 (display->display_modes[it].h == mode->h) && |
686 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | 680 (display->display_modes[it].format == mode->format)) |
687 { | 681 { |
688 /* Find the lowest refresh rate available */ | 682 /* Find the lowest refresh rate available */ |
689 if (tempmode.refresh_rate > | 683 if (tempmode.refresh_rate > |
690 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 684 display->display_modes[it].refresh_rate) { |
691 tempmode = SDL_CurrentDisplay.display_modes[it]; | 685 tempmode = display->display_modes[it]; |
692 } | 686 } |
693 | 687 |
694 /* Check if requested refresh rate found */ | 688 /* Check if requested refresh rate found */ |
695 if (refresh_rate == | 689 if (refresh_rate == |
696 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 690 display->display_modes[it].refresh_rate) { |
697 tempmode = SDL_CurrentDisplay.display_modes[it]; | 691 tempmode = display->display_modes[it]; |
698 break; | 692 break; |
699 } | 693 } |
700 } | 694 } |
701 } | 695 } |
702 if (tempmode.refresh_rate != 0x0000FFFF) { | 696 if (tempmode.refresh_rate != 0x0000FFFF) { |
777 | 771 |
778 return 0; | 772 return 0; |
779 } | 773 } |
780 | 774 |
781 int | 775 int |
782 photon_setdisplaypalette(_THIS, SDL_Palette * palette) | |
783 { | |
784 SDL_DisplayData *didata = | |
785 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
786 | |
787 /* Setting display palette operation has been failed */ | |
788 return -1; | |
789 } | |
790 | |
791 int | |
792 photon_getdisplaypalette(_THIS, SDL_Palette * palette) | |
793 { | |
794 SDL_DisplayData *didata = | |
795 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
796 | |
797 /* Getting display palette operation has been failed */ | |
798 return -1; | |
799 } | |
800 | |
801 int | |
802 photon_setdisplaygammaramp(_THIS, Uint16 * ramp) | |
803 { | |
804 SDL_DisplayData *didata = | |
805 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
806 | |
807 /* Setting display gamma ramp operation has been failed */ | |
808 return -1; | |
809 } | |
810 | |
811 int | |
812 photon_getdisplaygammaramp(_THIS, Uint16 * ramp) | |
813 { | |
814 /* Getting display gamma ramp operation has been failed */ | |
815 return -1; | |
816 } | |
817 | |
818 int | |
819 photon_createwindow(_THIS, SDL_Window * window) | 776 photon_createwindow(_THIS, SDL_Window * window) |
820 { | 777 { |
821 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 778 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
822 SDL_DisplayData *didata = | 779 SDL_DisplayData *didata = |
823 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 780 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
824 SDL_WindowData *wdata; | 781 SDL_WindowData *wdata; |
825 PhDim_t winsize; | 782 PhDim_t winsize; |
826 PhPoint_t winpos; | 783 PhPoint_t winpos; |
827 PtArg_t winargs[32]; | 784 PtArg_t winargs[32]; |
828 uint32_t winargc = 0; | 785 uint32_t winargc = 0; |
1096 void | 1053 void |
1097 photon_setwindowposition(_THIS, SDL_Window * window) | 1054 photon_setwindowposition(_THIS, SDL_Window * window) |
1098 { | 1055 { |
1099 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1056 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1100 SDL_DisplayData *didata = | 1057 SDL_DisplayData *didata = |
1101 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1058 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1102 PhPoint_t winpos; | 1059 PhPoint_t winpos; |
1103 int32_t status; | 1060 int32_t status; |
1104 | 1061 |
1105 /* Check if upper level requests WM to position window */ | 1062 /* Check if upper level requests WM to position window */ |
1106 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | 1063 if ((window->x == SDL_WINDOWPOS_UNDEFINED) |
1264 void | 1221 void |
1265 photon_destroywindow(_THIS, SDL_Window * window) | 1222 photon_destroywindow(_THIS, SDL_Window * window) |
1266 { | 1223 { |
1267 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1224 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1268 SDL_DisplayData *didata = | 1225 SDL_DisplayData *didata = |
1269 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1226 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1270 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1227 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1271 int32_t status; | 1228 int32_t status; |
1272 | 1229 |
1273 if (wdata != NULL) { | 1230 if (wdata != NULL) { |
1274 status = PtDestroyWidget(wdata->window); | 1231 status = PtDestroyWidget(wdata->window); |
1455 { | 1412 { |
1456 #if defined(SDL_VIDEO_OPENGL_ES) | 1413 #if defined(SDL_VIDEO_OPENGL_ES) |
1457 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1414 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1458 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1415 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1459 SDL_DisplayData *didata = | 1416 SDL_DisplayData *didata = |
1460 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1417 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1461 EGLBoolean status; | 1418 EGLBoolean status; |
1462 int32_t gfstatus; | 1419 int32_t gfstatus; |
1463 EGLint configs; | 1420 EGLint configs; |
1464 uint32_t attr_pos; | 1421 uint32_t attr_pos; |
1465 EGLint attr_value; | 1422 EGLint attr_value; |
1982 { | 1939 { |
1983 #if defined(SDL_VIDEO_OPENGL_ES) | 1940 #if defined(SDL_VIDEO_OPENGL_ES) |
1984 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 1941 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1985 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1942 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1986 SDL_DisplayData *didata = | 1943 SDL_DisplayData *didata = |
1987 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1944 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1988 PhRect_t dst_rect; | 1945 PhRect_t dst_rect; |
1989 PhRect_t src_rect; | 1946 PhRect_t src_rect; |
1990 int32_t status; | 1947 int32_t status; |
1991 | 1948 |
1992 if (phdata->gfinitialized != SDL_TRUE) { | 1949 if (phdata->gfinitialized != SDL_TRUE) { |
2091 { | 2048 { |
2092 #if defined(SDL_VIDEO_OPENGL_ES) | 2049 #if defined(SDL_VIDEO_OPENGL_ES) |
2093 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | 2050 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
2094 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 2051 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
2095 SDL_DisplayData *didata = | 2052 SDL_DisplayData *didata = |
2096 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 2053 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
2097 SDL_bool makecurrent=SDL_FALSE; | 2054 SDL_bool makecurrent=SDL_FALSE; |
2098 int32_t gfstatus; | 2055 int32_t gfstatus; |
2099 | 2056 |
2100 /* Check if context has been initialized */ | 2057 /* Check if context has been initialized */ |
2101 if (wdata->gles_context == EGL_NO_CONTEXT) { | 2058 if (wdata->gles_context == EGL_NO_CONTEXT) { |
2192 { | 2149 { |
2193 uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; | 2150 uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; |
2194 PhEvent_t *event = (PhEvent_t *) eventbuffer; | 2151 PhEvent_t *event = (PhEvent_t *) eventbuffer; |
2195 int32_t status; | 2152 int32_t status; |
2196 uint32_t finish = 0; | 2153 uint32_t finish = 0; |
2197 uint32_t it; | |
2198 SDL_Window *window; | 2154 SDL_Window *window; |
2199 SDL_WindowData *wdata; | 2155 SDL_WindowData *wdata; |
2200 | 2156 |
2201 do { | 2157 do { |
2202 status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); | 2158 status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); |
2209 break; | 2165 break; |
2210 case Ph_EVENT_MSG: | 2166 case Ph_EVENT_MSG: |
2211 { | 2167 { |
2212 /* Find a window, to which this handle destinated */ | 2168 /* Find a window, to which this handle destinated */ |
2213 status = 0; | 2169 status = 0; |
2214 for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) { | 2170 for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) { |
2215 wdata = | 2171 SDL_VideoDisplay *display = SDL_GetVideoDisplay(i); |
2216 (SDL_WindowData *) SDL_CurrentDisplay.windows[it]. | 2172 for (j = 0; j < display->num_windows; ++j) { |
2217 driverdata; | 2173 wdata = (SDL_WindowData *) display->windows[j].driverdata; |
2218 | 2174 |
2219 /* Find the proper window */ | 2175 /* Find the proper window */ |
2220 if (wdata->window != NULL) { | 2176 if (wdata->window != NULL) { |
2221 if (PtWidgetRid(wdata->window) == | 2177 if (PtWidgetRid(wdata->window) == |
2222 event->collector.rid) { | 2178 event->collector.rid) { |
2223 window = | 2179 window = (SDL_Window *) &display->windows[it]; |
2224 (SDL_Window *) & SDL_CurrentDisplay. | 2180 status = 1; |
2225 windows[it]; | 2181 break; |
2226 status = 1; | 2182 } |
2227 break; | 2183 } else { |
2184 continue; | |
2228 } | 2185 } |
2229 } else { | |
2230 continue; | |
2231 } | 2186 } |
2232 } | 2187 } |
2233 if (status == 0) { | 2188 if (status == 0) { |
2234 window = NULL; | 2189 window = NULL; |
2235 wdata = NULL; | 2190 wdata = NULL; |