From ad8ffb96789f90180982b344540870a2d4e2d60b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 31 May 2018 08:12:40 +0800 Subject: init --- 3rdparty/SDL/src/video/photon/SDL_ph_modes.c | 390 +++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 3rdparty/SDL/src/video/photon/SDL_ph_modes.c (limited to '3rdparty/SDL/src/video/photon/SDL_ph_modes.c') diff --git a/3rdparty/SDL/src/video/photon/SDL_ph_modes.c b/3rdparty/SDL/src/video/photon/SDL_ph_modes.c new file mode 100644 index 0000000..8c2bf7e --- /dev/null +++ b/3rdparty/SDL/src/video/photon/SDL_ph_modes.c @@ -0,0 +1,390 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_ph_modes_c.h" + +static PgVideoModeInfo_t mode_info; +static PgVideoModes_t mode_list; + +/* The current list of available video modes */ +SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; +SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; + +static int compare_modes_by_res(const void* mode1, const void* mode2) +{ + PgVideoModeInfo_t mode1_info; + PgVideoModeInfo_t mode2_info; + + if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode1_info) < 0) + { + return 0; + } + + if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0) + { + return 0; + } + + if (mode1_info.width == mode2_info.width) + { + return mode2_info.height - mode1_info.height; + } + else + { + return mode2_info.width - mode1_info.width; + } +} + +SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + int i = 0; + int j = 0; + SDL_Rect Amodelist[PH_MAX_VIDEOMODES]; + + for (i=0; iBitsPerPixel) + { + Amodelist[j].w = mode_info.width; + Amodelist[j].h = mode_info.height; + Amodelist[j].x = 0; + Amodelist[j].y = 0; + j++; + } + } + + /* reorder biggest for smallest, assume width dominates */ + + for(i=0; iflags & SDL_ANYFORMAT) + { + if ((mode = get_mode_any_format(screen->w, screen->h, screen->format->BitsPerPixel)) == 0) + { + SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n"); + return 0; + } + } + else + { + if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0) + { + SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n"); + return 0; + } + if (PgGetVideoModeInfo(mode, &mode_info) < 0) + { + SDL_SetError("ph_EnterFullScreen(): can't get video mode capabilities !\n"); + return 0; + } + if (mode_info.height != screen->h) + { + if ((mode_info.height==480) && (screen->h==400)) + { + videomode_emulatemode=1; + } + } + else + { + videomode_emulatemode=0; + } + } + + /* save old video mode caps */ + PgGetVideoMode(&settings); + old_video_mode=settings.mode; + old_refresh_rate=settings.refresh; + + /* setup new video mode */ + settings.mode = mode; + settings.refresh = 0; + settings.flags = 0; + + refreshrate=SDL_getenv("SDL_PHOTON_FULLSCREEN_REFRESH"); + if (refreshrate!=NULL) + { + if (SDL_sscanf(refreshrate, "%d", &refreshratenum)==1) + { + settings.refresh = refreshratenum; + } + } + + if (PgSetVideoMode(&settings) < 0) + { + SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n"); + return 0; + } + + if (this->screen) + { + if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL) + { +#if !SDL_VIDEO_OPENGL || (_NTO_VERSION < 630) + return 0; /* 6.3.0 */ +#endif + } + } + + if (fmode==0) + { + if (OCImage.direct_context==NULL) + { + OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); + if (!OCImage.direct_context) + { + SDL_SetError("ph_EnterFullScreen(): Can't create direct context !\n"); + ph_LeaveFullScreen(this); + return 0; + } + } + OCImage.oldDC=PdDirectStart(OCImage.direct_context); + } + + currently_fullscreen = 1; + } + PgFlush(); + + return 1; +} + +int ph_LeaveFullScreen(_THIS) +{ + PgDisplaySettings_t oldmode_settings; + + if (currently_fullscreen) + { + if ((this->screen) && ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)) + { +#if !SDL_VIDEO_OPENGL || (_NTO_VERSION < 630) + return 0; +#endif + } + + /* release routines starts here */ + { + if (OCImage.direct_context) + { + PdDirectStop(OCImage.direct_context); + PdReleaseDirectContext(OCImage.direct_context); + OCImage.direct_context=NULL; + } + if (OCImage.oldDC) + { + PhDCSetCurrent(OCImage.oldDC); + OCImage.oldDC=NULL; + } + + currently_fullscreen=0; + + /* Restore old video mode */ + if (old_video_mode != -1) + { + oldmode_settings.mode = (unsigned short) old_video_mode; + oldmode_settings.refresh = (unsigned short) old_refresh_rate; + oldmode_settings.flags = 0; + + if (PgSetVideoMode(&oldmode_settings) < 0) + { + SDL_SetError("Ph_LeaveFullScreen(): PgSetVideoMode() function failed !\n"); + return 0; + } + } + + old_video_mode=-1; + old_refresh_rate=-1; + } + } + return 1; +} -- cgit v1.1-26-g67d0