From 8a6e57cba1c89f922e27bb72201cfda55681f6dc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 15 Aug 2013 18:53:55 +0200 Subject: BACKENDS: Remove OpenGL and OpenGL SDL backend. This breaks our Tizen port. --- backends/platform/sdl/sdl.cpp | 214 +----------------------------------------- backends/platform/sdl/sdl.h | 17 ---- 2 files changed, 2 insertions(+), 229 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 7ab367d4a4..16fe88e990 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -47,10 +47,6 @@ #include "backends/mutex/sdl/sdl-mutex.h" #include "backends/timer/sdl/sdl-timer.h" #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#ifdef USE_OPENGL -#include "backends/graphics/openglsdl/openglsdl-graphics.h" -#include "graphics/cursorman.h" -#endif #include "icons/scummvm.xpm" @@ -64,12 +60,6 @@ OSystem_SDL::OSystem_SDL() : -#ifdef USE_OPENGL - _graphicsModes(0), - _graphicsMode(0), - _sdlModesCount(0), - _glModesCount(0), -#endif _inited(false), _initedSDL(false), _logger(0), @@ -110,10 +100,6 @@ OSystem_SDL::~OSystem_SDL() { delete _mutexManager; _mutexManager = 0; -#ifdef USE_OPENGL - delete[] _graphicsModes; -#endif - delete _logger; _logger = 0; @@ -143,11 +129,6 @@ void OSystem_SDL::init() { if (_taskbarManager == 0) _taskbarManager = new Common::TaskbarManager(); #endif - -#ifdef USE_OPENGL - // Setup a list with both SDL and OpenGL graphics modes - setupGraphicsModes(); -#endif } void OSystem_SDL::initBackend() { @@ -159,36 +140,8 @@ void OSystem_SDL::initBackend() { if (_eventSource == 0) _eventSource = new SdlEventSource(); - int graphicsManagerType = 0; - if (_graphicsManager == 0) { -#ifdef USE_OPENGL - if (ConfMan.hasKey("gfx_mode")) { - Common::String gfxMode(ConfMan.get("gfx_mode")); - bool use_opengl = false; - const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - int i = 0; - while (mode->name) { - if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) { - _graphicsMode = i + _sdlModesCount; - use_opengl = true; - } - - mode++; - ++i; - } - - // If the gfx_mode is from OpenGL, create the OpenGL graphics manager - if (use_opengl) { - _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource); - graphicsManagerType = 1; - } - } -#endif - if (_graphicsManager == 0) { - _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - graphicsManagerType = 0; - } + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); } if (_savefileManager == 0) @@ -230,13 +183,7 @@ void OSystem_SDL::initBackend() { // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. - if (graphicsManagerType == 0) - ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#ifdef USE_OPENGL - else if (graphicsManagerType == 1) - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#endif - + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); } #if defined(USE_TASKBAR) @@ -531,160 +478,3 @@ Common::TimerManager *OSystem_SDL::getTimerManager() { return _timerManager; #endif } - -#ifdef USE_OPENGL - -const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { - return _graphicsModes; -} - -int OSystem_SDL::getDefaultGraphicsMode() const { - // Return the default graphics mode from the current graphics manager - if (_graphicsMode < _sdlModesCount) - return _graphicsManager->getDefaultGraphicsMode(); - else - return _graphicsManager->getDefaultGraphicsMode() + _sdlModesCount; -} - -bool OSystem_SDL::setGraphicsMode(int mode) { - const OSystem::GraphicsMode *srcMode; - int i; - - // Check if mode is from SDL or OpenGL - if (mode < _sdlModesCount) { - srcMode = SurfaceSdlGraphicsManager::supportedGraphicsModes(); - i = 0; - } else { - srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - i = _sdlModesCount; - } - - // Very hacky way to set up the old graphics manager state, in case we - // switch from SDL->OpenGL or OpenGL->SDL. - // - // This is a probably temporary workaround to fix bugs like #3368143 - // "SDL/OpenGL: Crash when switching renderer backend". - const int screenWidth = _graphicsManager->getWidth(); - const int screenHeight = _graphicsManager->getHeight(); - const bool arState = _graphicsManager->getFeatureState(kFeatureAspectRatioCorrection); - const bool fullscreen = _graphicsManager->getFeatureState(kFeatureFullscreenMode); - const bool cursorPalette = _graphicsManager->getFeatureState(kFeatureCursorPalette); -#ifdef USE_RGB_COLOR - const Graphics::PixelFormat pixelFormat = _graphicsManager->getScreenFormat(); -#endif - - bool switchedManager = false; - - // Loop through modes - while (srcMode->name) { - if (i == mode) { - // If the new mode and the current mode are not from the same graphics - // manager, delete and create the new mode graphics manager - if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { - debug(1, "switching to plain SDL graphics"); - delete _graphicsManager; - _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); - _graphicsManager->beginGFXTransaction(); - - switchedManager = true; - } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { - debug(1, "switching to OpenGL graphics"); - delete _graphicsManager; - _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource); - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); - _graphicsManager->beginGFXTransaction(); - - switchedManager = true; - } - - _graphicsMode = mode; - - if (switchedManager) { -#ifdef USE_RGB_COLOR - _graphicsManager->initSize(screenWidth, screenHeight, &pixelFormat); -#else - _graphicsManager->initSize(screenWidth, screenHeight, 0); -#endif - _graphicsManager->setFeatureState(kFeatureAspectRatioCorrection, arState); - _graphicsManager->setFeatureState(kFeatureFullscreenMode, fullscreen); - _graphicsManager->setFeatureState(kFeatureCursorPalette, cursorPalette); - - // Worst part about this right now, tell the cursor manager to - // resetup the cursor + cursor palette if necessarily - - // First we need to try to setup the old state on the new manager... - if (_graphicsManager->endGFXTransaction() != kTransactionSuccess) { - // Oh my god if this failed the client code might just explode. - return false; - } - - // Next setup the cursor again - CursorMan.pushCursor(0, 0, 0, 0, 0, 0); - CursorMan.popCursor(); - - // Next setup cursor palette if needed - if (cursorPalette) { - CursorMan.pushCursorPalette(0, 0, 0); - CursorMan.popCursorPalette(); - } - - _graphicsManager->beginGFXTransaction(); - // Oh my god if this failed the client code might just explode. - return _graphicsManager->setGraphicsMode(srcMode->id); - } else { - return _graphicsManager->setGraphicsMode(srcMode->id); - } - } - - i++; - srcMode++; - } - - return false; -} - -int OSystem_SDL::getGraphicsMode() const { - return _graphicsMode; -} - -void OSystem_SDL::setupGraphicsModes() { - const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); - const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - _sdlModesCount = 0; - _glModesCount = 0; - - // Count the number of graphics modes - const OSystem::GraphicsMode *srcMode = sdlGraphicsModes; - while (srcMode->name) { - _sdlModesCount++; - srcMode++; - } - srcMode = openglGraphicsModes; - while (srcMode->name) { - _glModesCount++; - srcMode++; - } - - // Allocate enough space for merged array of modes - _graphicsModes = new OSystem::GraphicsMode[_glModesCount + _sdlModesCount + 1]; - - // Copy SDL graphics modes - memcpy((void *)_graphicsModes, sdlGraphicsModes, _sdlModesCount * sizeof(OSystem::GraphicsMode)); - - // Copy OpenGL graphics modes - memcpy((void *)(_graphicsModes + _sdlModesCount), openglGraphicsModes, _glModesCount * sizeof(OSystem::GraphicsMode)); - - // Set a null mode at the end - memset((void *)(_graphicsModes + _sdlModesCount + _glModesCount), 0, sizeof(OSystem::GraphicsMode)); - - // Set new internal ids for all modes - int i = 0; - OSystem::GraphicsMode *mode = _graphicsModes; - while (mode->name) { - mode->id = i++; - mode++; - } -} - -#endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 840e73ff09..0012e88c51 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -104,23 +104,6 @@ protected: // Logging virtual Common::WriteStream *createLogFile() { return 0; } Backends::Log::Log *_logger; - -#ifdef USE_OPENGL - OSystem::GraphicsMode *_graphicsModes; - int _graphicsMode; - int _sdlModesCount; - int _glModesCount; - - /** - * Creates the merged graphics modes list - */ - virtual void setupGraphicsModes(); - - virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; - virtual int getDefaultGraphicsMode() const; - virtual bool setGraphicsMode(int mode); - virtual int getGraphicsMode() const; -#endif }; #endif -- cgit v1.2.3 From 5ce830b97643fc76bdcafdbbe09e226519a9d2e6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 18 Aug 2013 16:56:34 +0200 Subject: SDL: Add a OpenGL SDL backend and hook it into the SDL backend. The hooking code is nearly exactly the old hooking code. Only the OpenGL SDL creation has been adapted since it uses a different constructor now. --- backends/platform/sdl/sdl.cpp | 231 +++++++++++++++++++++++++++++++++++++++++- backends/platform/sdl/sdl.h | 19 ++++ 2 files changed, 246 insertions(+), 4 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 16fe88e990..1431e1fc5e 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -47,6 +47,10 @@ #include "backends/mutex/sdl/sdl-mutex.h" #include "backends/timer/sdl/sdl-timer.h" #include "backends/graphics/surfacesdl/surfacesdl-graphics.h" +#ifdef USE_OPENGL +#include "backends/graphics/openglsdl/openglsdl-graphics.h" +#include "graphics/cursorman.h" +#endif #include "icons/scummvm.xpm" @@ -60,6 +64,14 @@ OSystem_SDL::OSystem_SDL() : +#ifdef USE_OPENGL + _desktopWidth(0), + _desktopHeight(0), + _graphicsModes(0), + _graphicsMode(0), + _sdlModesCount(0), + _glModesCount(0), +#endif _inited(false), _initedSDL(false), _logger(0), @@ -100,6 +112,10 @@ OSystem_SDL::~OSystem_SDL() { delete _mutexManager; _mutexManager = 0; +#ifdef USE_OPENGL + delete[] _graphicsModes; +#endif + delete _logger; _logger = 0; @@ -129,6 +145,11 @@ void OSystem_SDL::init() { if (_taskbarManager == 0) _taskbarManager = new Common::TaskbarManager(); #endif + +#ifdef USE_OPENGL + // Setup a list with both SDL and OpenGL graphics modes + setupGraphicsModes(); +#endif } void OSystem_SDL::initBackend() { @@ -140,8 +161,46 @@ void OSystem_SDL::initBackend() { if (_eventSource == 0) _eventSource = new SdlEventSource(); + int graphicsManagerType = 0; + +#ifdef USE_OPENGL + // Query the desktop resolution. We simply hope nothing tried to change + // the resolution so far. + const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); + if (videoInfo && videoInfo->current_w > 0 && videoInfo->current_h > 0) { + _desktopWidth = videoInfo->current_w; + _desktopHeight = videoInfo->current_h; + } +#endif + if (_graphicsManager == 0) { - _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); +#ifdef USE_OPENGL + if (ConfMan.hasKey("gfx_mode")) { + Common::String gfxMode(ConfMan.get("gfx_mode")); + bool use_opengl = false; + const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); + int i = 0; + while (mode->name) { + if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) { + _graphicsMode = i + _sdlModesCount; + use_opengl = true; + } + + mode++; + ++i; + } + + // If the gfx_mode is from OpenGL, create the OpenGL graphics manager + if (use_opengl) { + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + graphicsManagerType = 1; + } + } +#endif + if (_graphicsManager == 0) { + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); + graphicsManagerType = 0; + } } if (_savefileManager == 0) @@ -183,7 +242,13 @@ void OSystem_SDL::initBackend() { // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. - ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); + if (graphicsManagerType == 0) + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#ifdef USE_OPENGL + else if (graphicsManagerType == 1) + ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#endif + } #if defined(USE_TASKBAR) @@ -208,8 +273,9 @@ void OSystem_SDL::initSDL() { if (ConfMan.hasKey("disable_sdl_parachute")) sdlFlags |= SDL_INIT_NOPARACHUTE; -#ifdef WEBOS - // WebOS needs this flag or otherwise the application won't start +#if defined(WEBOS) || defined(USE_OPENGL) + // WebOS needs this flag or otherwise the application won't start. + // OpenGL SDL needs this to query the desktop resolution on startup. sdlFlags |= SDL_INIT_VIDEO; #endif @@ -478,3 +544,160 @@ Common::TimerManager *OSystem_SDL::getTimerManager() { return _timerManager; #endif } + +#ifdef USE_OPENGL + +const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { + return _graphicsModes; +} + +int OSystem_SDL::getDefaultGraphicsMode() const { + // Return the default graphics mode from the current graphics manager + if (_graphicsMode < _sdlModesCount) + return _graphicsManager->getDefaultGraphicsMode(); + else + return _graphicsManager->getDefaultGraphicsMode() + _sdlModesCount; +} + +bool OSystem_SDL::setGraphicsMode(int mode) { + const OSystem::GraphicsMode *srcMode; + int i; + + // Check if mode is from SDL or OpenGL + if (mode < _sdlModesCount) { + srcMode = SurfaceSdlGraphicsManager::supportedGraphicsModes(); + i = 0; + } else { + srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); + i = _sdlModesCount; + } + + // Very hacky way to set up the old graphics manager state, in case we + // switch from SDL->OpenGL or OpenGL->SDL. + // + // This is a probably temporary workaround to fix bugs like #3368143 + // "SDL/OpenGL: Crash when switching renderer backend". + const int screenWidth = _graphicsManager->getWidth(); + const int screenHeight = _graphicsManager->getHeight(); + const bool arState = _graphicsManager->getFeatureState(kFeatureAspectRatioCorrection); + const bool fullscreen = _graphicsManager->getFeatureState(kFeatureFullscreenMode); + const bool cursorPalette = _graphicsManager->getFeatureState(kFeatureCursorPalette); +#ifdef USE_RGB_COLOR + const Graphics::PixelFormat pixelFormat = _graphicsManager->getScreenFormat(); +#endif + + bool switchedManager = false; + + // Loop through modes + while (srcMode->name) { + if (i == mode) { + // If the new mode and the current mode are not from the same graphics + // manager, delete and create the new mode graphics manager + if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { + debug(1, "switching to plain SDL graphics"); + delete _graphicsManager; + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); + _graphicsManager->beginGFXTransaction(); + + switchedManager = true; + } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { + debug(1, "switching to OpenGL graphics"); + delete _graphicsManager; + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); + _graphicsManager->beginGFXTransaction(); + + switchedManager = true; + } + + _graphicsMode = mode; + + if (switchedManager) { +#ifdef USE_RGB_COLOR + _graphicsManager->initSize(screenWidth, screenHeight, &pixelFormat); +#else + _graphicsManager->initSize(screenWidth, screenHeight, 0); +#endif + _graphicsManager->setFeatureState(kFeatureAspectRatioCorrection, arState); + _graphicsManager->setFeatureState(kFeatureFullscreenMode, fullscreen); + _graphicsManager->setFeatureState(kFeatureCursorPalette, cursorPalette); + + // Worst part about this right now, tell the cursor manager to + // resetup the cursor + cursor palette if necessarily + + // First we need to try to setup the old state on the new manager... + if (_graphicsManager->endGFXTransaction() != kTransactionSuccess) { + // Oh my god if this failed the client code might just explode. + return false; + } + + // Next setup the cursor again + CursorMan.pushCursor(0, 0, 0, 0, 0, 0); + CursorMan.popCursor(); + + // Next setup cursor palette if needed + if (cursorPalette) { + CursorMan.pushCursorPalette(0, 0, 0); + CursorMan.popCursorPalette(); + } + + _graphicsManager->beginGFXTransaction(); + // Oh my god if this failed the client code might just explode. + return _graphicsManager->setGraphicsMode(srcMode->id); + } else { + return _graphicsManager->setGraphicsMode(srcMode->id); + } + } + + i++; + srcMode++; + } + + return false; +} + +int OSystem_SDL::getGraphicsMode() const { + return _graphicsMode; +} + +void OSystem_SDL::setupGraphicsModes() { + const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); + const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); + _sdlModesCount = 0; + _glModesCount = 0; + + // Count the number of graphics modes + const OSystem::GraphicsMode *srcMode = sdlGraphicsModes; + while (srcMode->name) { + _sdlModesCount++; + srcMode++; + } + srcMode = openglGraphicsModes; + while (srcMode->name) { + _glModesCount++; + srcMode++; + } + + // Allocate enough space for merged array of modes + _graphicsModes = new OSystem::GraphicsMode[_glModesCount + _sdlModesCount + 1]; + + // Copy SDL graphics modes + memcpy((void *)_graphicsModes, sdlGraphicsModes, _sdlModesCount * sizeof(OSystem::GraphicsMode)); + + // Copy OpenGL graphics modes + memcpy((void *)(_graphicsModes + _sdlModesCount), openglGraphicsModes, _glModesCount * sizeof(OSystem::GraphicsMode)); + + // Set a null mode at the end + memset((void *)(_graphicsModes + _sdlModesCount + _glModesCount), 0, sizeof(OSystem::GraphicsMode)); + + // Set new internal ids for all modes + int i = 0; + OSystem::GraphicsMode *mode = _graphicsModes; + while (mode->name) { + mode->id = i++; + mode++; + } +} + +#endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 0012e88c51..590354b699 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -104,6 +104,25 @@ protected: // Logging virtual Common::WriteStream *createLogFile() { return 0; } Backends::Log::Log *_logger; + +#ifdef USE_OPENGL + int _desktopWidth, _desktopHeight; + + OSystem::GraphicsMode *_graphicsModes; + int _graphicsMode; + int _sdlModesCount; + int _glModesCount; + + /** + * Creates the merged graphics modes list + */ + virtual void setupGraphicsModes(); + + virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; + virtual int getDefaultGraphicsMode() const; + virtual bool setGraphicsMode(int mode); + virtual int getGraphicsMode() const; +#endif }; #endif -- cgit v1.2.3 From 6e46e9dfaf141fda10af798d9770b9f2b0555575 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Oct 2013 22:27:50 +0200 Subject: SDL: Clean up graphics manager switching slighty. Sadly this also requires us to extend GraphicsManager for this SDL specific feature. However, since that's only used in the SDL backend and Tizen it should be fine for now... --- backends/platform/sdl/sdl.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 1431e1fc5e..84187f9638 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -89,6 +89,9 @@ OSystem_SDL::~OSystem_SDL() { // Hence, we perform the destruction on our own. delete _savefileManager; _savefileManager = 0; + if (_graphicsManager) { + _graphicsManager->deactivateManager(); + } delete _graphicsManager; _graphicsManager = 0; delete _eventManager; @@ -161,8 +164,6 @@ void OSystem_SDL::initBackend() { if (_eventSource == 0) _eventSource = new SdlEventSource(); - int graphicsManagerType = 0; - #ifdef USE_OPENGL // Query the desktop resolution. We simply hope nothing tried to change // the resolution so far. @@ -193,13 +194,11 @@ void OSystem_SDL::initBackend() { // If the gfx_mode is from OpenGL, create the OpenGL graphics manager if (use_opengl) { _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); - graphicsManagerType = 1; } } #endif if (_graphicsManager == 0) { _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - graphicsManagerType = 0; } } @@ -242,13 +241,7 @@ void OSystem_SDL::initBackend() { // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. - if (graphicsManagerType == 0) - ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#ifdef USE_OPENGL - else if (graphicsManagerType == 1) - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#endif - + _graphicsManager->activateManager(); } #if defined(USE_TASKBAR) @@ -595,18 +588,16 @@ bool OSystem_SDL::setGraphicsMode(int mode) { // manager, delete and create the new mode graphics manager if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { debug(1, "switching to plain SDL graphics"); + _graphicsManager->deactivateManager(); delete _graphicsManager; _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); - _graphicsManager->beginGFXTransaction(); switchedManager = true; } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { debug(1, "switching to OpenGL graphics"); + _graphicsManager->deactivateManager(); delete _graphicsManager; _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); - _graphicsManager->beginGFXTransaction(); switchedManager = true; } @@ -614,6 +605,9 @@ bool OSystem_SDL::setGraphicsMode(int mode) { _graphicsMode = mode; if (switchedManager) { + _graphicsManager->activateManager(); + + _graphicsManager->beginGFXTransaction(); #ifdef USE_RGB_COLOR _graphicsManager->initSize(screenWidth, screenHeight, &pixelFormat); #else -- cgit v1.2.3 From 1a56b521b598efcb1587dd8934b6564cf5799b7b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Oct 2013 23:00:28 +0200 Subject: SDL: Always initialize video subsystem in initSDL. --- backends/platform/sdl/sdl.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 84187f9638..e8a7f7b9af 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -262,16 +262,15 @@ void OSystem_SDL::engineDone() { void OSystem_SDL::initSDL() { // Check if SDL has not been initialized if (!_initedSDL) { - uint32 sdlFlags = 0; + // We always initialize the video subsystem because we will need it to + // be initialized before the graphics managers to retrieve the desktop + // resolution, for example. WebOS also requires this initialization + // or otherwise the application won't start. + uint32 sdlFlags = SDL_INIT_VIDEO; + if (ConfMan.hasKey("disable_sdl_parachute")) sdlFlags |= SDL_INIT_NOPARACHUTE; -#if defined(WEBOS) || defined(USE_OPENGL) - // WebOS needs this flag or otherwise the application won't start. - // OpenGL SDL needs this to query the desktop resolution on startup. - sdlFlags |= SDL_INIT_VIDEO; -#endif - // Initialize SDL (SDL Subsystems are initiliazed in the corresponding sdl managers) if (SDL_Init(sdlFlags) == -1) error("Could not initialize SDL: %s", SDL_GetError()); @@ -279,6 +278,9 @@ void OSystem_SDL::initSDL() { // Enable unicode support if possible SDL_EnableUNICODE(1); + // Disable OS cursor + SDL_ShowCursor(SDL_DISABLE); + _initedSDL = true; } } -- cgit v1.2.3 From e91300f70cb17722347b809ffe94f0bc585655de Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Oct 2013 23:29:40 +0200 Subject: SDL: Clean up graphics mode handling for OpenGL backend. Instead of custom memory management Common::Array is used now. --- backends/platform/sdl/sdl.cpp | 27 ++++++++++----------------- backends/platform/sdl/sdl.h | 5 ++++- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index e8a7f7b9af..5aab1b7b3b 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -67,7 +67,7 @@ OSystem_SDL::OSystem_SDL() #ifdef USE_OPENGL _desktopWidth(0), _desktopHeight(0), - _graphicsModes(0), + _graphicsModes(), _graphicsMode(0), _sdlModesCount(0), _glModesCount(0), @@ -115,10 +115,6 @@ OSystem_SDL::~OSystem_SDL() { delete _mutexManager; _mutexManager = 0; -#ifdef USE_OPENGL - delete[] _graphicsModes; -#endif - delete _logger; _logger = 0; @@ -543,7 +539,7 @@ Common::TimerManager *OSystem_SDL::getTimerManager() { #ifdef USE_OPENGL const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { - return _graphicsModes; + return _graphicsModes.begin(); } int OSystem_SDL::getDefaultGraphicsMode() const { @@ -658,6 +654,8 @@ int OSystem_SDL::getGraphicsMode() const { } void OSystem_SDL::setupGraphicsModes() { + _graphicsModes.clear(); + const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); _sdlModesCount = 0; @@ -667,29 +665,24 @@ void OSystem_SDL::setupGraphicsModes() { const OSystem::GraphicsMode *srcMode = sdlGraphicsModes; while (srcMode->name) { _sdlModesCount++; + _graphicsModes.push_back(*srcMode); srcMode++; } srcMode = openglGraphicsModes; while (srcMode->name) { _glModesCount++; + _graphicsModes.push_back(*srcMode); srcMode++; } - // Allocate enough space for merged array of modes - _graphicsModes = new OSystem::GraphicsMode[_glModesCount + _sdlModesCount + 1]; - - // Copy SDL graphics modes - memcpy((void *)_graphicsModes, sdlGraphicsModes, _sdlModesCount * sizeof(OSystem::GraphicsMode)); - - // Copy OpenGL graphics modes - memcpy((void *)(_graphicsModes + _sdlModesCount), openglGraphicsModes, _glModesCount * sizeof(OSystem::GraphicsMode)); - // Set a null mode at the end - memset((void *)(_graphicsModes + _sdlModesCount + _glModesCount), 0, sizeof(OSystem::GraphicsMode)); + GraphicsMode nullMode; + memset(&nullMode, 0, sizeof(nullMode)); + _graphicsModes.push_back(nullMode); // Set new internal ids for all modes int i = 0; - OSystem::GraphicsMode *mode = _graphicsModes; + OSystem::GraphicsMode *mode = _graphicsModes.begin(); while (mode->name) { mode->id = i++; mode++; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 590354b699..6348519681 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,6 +30,8 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" +#include "common/array.h" + /** * Base OSystem class for all SDL ports. */ @@ -108,7 +110,8 @@ protected: #ifdef USE_OPENGL int _desktopWidth, _desktopHeight; - OSystem::GraphicsMode *_graphicsModes; + typedef Common::Array GraphicsModeArray; + GraphicsModeArray _graphicsModes; int _graphicsMode; int _sdlModesCount; int _glModesCount; -- cgit v1.2.3 From c5e2b5158c21ec97db40d933f7edd0543e6f286c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Oct 2013 23:39:46 +0200 Subject: SDL: Get rid of loop in OSystem_SDL::setGraphicsMode. --- backends/platform/sdl/sdl.cpp | 113 ++++++++++++++++++------------------------ backends/platform/sdl/sdl.h | 1 + 2 files changed, 50 insertions(+), 64 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 5aab1b7b3b..b0ebc476e1 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -551,16 +551,9 @@ int OSystem_SDL::getDefaultGraphicsMode() const { } bool OSystem_SDL::setGraphicsMode(int mode) { - const OSystem::GraphicsMode *srcMode; - int i; - - // Check if mode is from SDL or OpenGL - if (mode < _sdlModesCount) { - srcMode = SurfaceSdlGraphicsManager::supportedGraphicsModes(); - i = 0; - } else { - srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - i = _sdlModesCount; + // Check whether a invalid mode is requested. + if (mode < 0 || (uint)mode >= _graphicsModeIds.size()) { + return false; } // Very hacky way to set up the old graphics manager state, in case we @@ -579,74 +572,64 @@ bool OSystem_SDL::setGraphicsMode(int mode) { bool switchedManager = false; - // Loop through modes - while (srcMode->name) { - if (i == mode) { - // If the new mode and the current mode are not from the same graphics - // manager, delete and create the new mode graphics manager - if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { - debug(1, "switching to plain SDL graphics"); - _graphicsManager->deactivateManager(); - delete _graphicsManager; - _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - - switchedManager = true; - } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { - debug(1, "switching to OpenGL graphics"); - _graphicsManager->deactivateManager(); - delete _graphicsManager; - _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + // If the new mode and the current mode are not from the same graphics + // manager, delete and create the new mode graphics manager + if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { + debug(1, "switching to plain SDL graphics"); + _graphicsManager->deactivateManager(); + delete _graphicsManager; + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); - switchedManager = true; - } + switchedManager = true; + } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { + debug(1, "switching to OpenGL graphics"); + _graphicsManager->deactivateManager(); + delete _graphicsManager; + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + + switchedManager = true; + } - _graphicsMode = mode; + _graphicsMode = mode; - if (switchedManager) { - _graphicsManager->activateManager(); + if (switchedManager) { + _graphicsManager->activateManager(); - _graphicsManager->beginGFXTransaction(); + _graphicsManager->beginGFXTransaction(); #ifdef USE_RGB_COLOR - _graphicsManager->initSize(screenWidth, screenHeight, &pixelFormat); + _graphicsManager->initSize(screenWidth, screenHeight, &pixelFormat); #else - _graphicsManager->initSize(screenWidth, screenHeight, 0); + _graphicsManager->initSize(screenWidth, screenHeight, 0); #endif - _graphicsManager->setFeatureState(kFeatureAspectRatioCorrection, arState); - _graphicsManager->setFeatureState(kFeatureFullscreenMode, fullscreen); - _graphicsManager->setFeatureState(kFeatureCursorPalette, cursorPalette); + _graphicsManager->setFeatureState(kFeatureAspectRatioCorrection, arState); + _graphicsManager->setFeatureState(kFeatureFullscreenMode, fullscreen); + _graphicsManager->setFeatureState(kFeatureCursorPalette, cursorPalette); - // Worst part about this right now, tell the cursor manager to - // resetup the cursor + cursor palette if necessarily + // Worst part about this right now, tell the cursor manager to + // resetup the cursor + cursor palette if necessarily - // First we need to try to setup the old state on the new manager... - if (_graphicsManager->endGFXTransaction() != kTransactionSuccess) { - // Oh my god if this failed the client code might just explode. - return false; - } - - // Next setup the cursor again - CursorMan.pushCursor(0, 0, 0, 0, 0, 0); - CursorMan.popCursor(); + // First we need to try to setup the old state on the new manager... + if (_graphicsManager->endGFXTransaction() != kTransactionSuccess) { + // Oh my god if this failed the client code might just explode. + return false; + } - // Next setup cursor palette if needed - if (cursorPalette) { - CursorMan.pushCursorPalette(0, 0, 0); - CursorMan.popCursorPalette(); - } + // Next setup the cursor again + CursorMan.pushCursor(0, 0, 0, 0, 0, 0); + CursorMan.popCursor(); - _graphicsManager->beginGFXTransaction(); - // Oh my god if this failed the client code might just explode. - return _graphicsManager->setGraphicsMode(srcMode->id); - } else { - return _graphicsManager->setGraphicsMode(srcMode->id); - } + // Next setup cursor palette if needed + if (cursorPalette) { + CursorMan.pushCursorPalette(0, 0, 0); + CursorMan.popCursorPalette(); } - i++; - srcMode++; + _graphicsManager->beginGFXTransaction(); + // Oh my god if this failed the client code might just explode. + return _graphicsManager->setGraphicsMode(_graphicsModeIds[mode]); + } else { + return _graphicsManager->setGraphicsMode(_graphicsModeIds[mode]); } - - return false; } int OSystem_SDL::getGraphicsMode() const { @@ -655,6 +638,7 @@ int OSystem_SDL::getGraphicsMode() const { void OSystem_SDL::setupGraphicsModes() { _graphicsModes.clear(); + _graphicsModeIds.clear(); const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); @@ -684,6 +668,7 @@ void OSystem_SDL::setupGraphicsModes() { int i = 0; OSystem::GraphicsMode *mode = _graphicsModes.begin(); while (mode->name) { + _graphicsModeIds.push_back(mode->id); mode->id = i++; mode++; } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 6348519681..983b7a8237 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -112,6 +112,7 @@ protected: typedef Common::Array GraphicsModeArray; GraphicsModeArray _graphicsModes; + Common::Array _graphicsModeIds; int _graphicsMode; int _sdlModesCount; int _glModesCount; -- cgit v1.2.3 From 4080a7a3f642d7f155f3e706f0c084c3280f5d40 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 00:21:51 +0200 Subject: SDL: Get rid of _glModesCount. --- backends/platform/sdl/sdl.cpp | 18 +++++++----------- backends/platform/sdl/sdl.h | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index b0ebc476e1..620d3c58ee 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -69,8 +69,7 @@ OSystem_SDL::OSystem_SDL() _desktopHeight(0), _graphicsModes(), _graphicsMode(0), - _sdlModesCount(0), - _glModesCount(0), + _firstGLMode(0), #endif _inited(false), _initedSDL(false), @@ -179,7 +178,7 @@ void OSystem_SDL::initBackend() { int i = 0; while (mode->name) { if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) { - _graphicsMode = i + _sdlModesCount; + _graphicsMode = i + _firstGLMode; use_opengl = true; } @@ -544,10 +543,10 @@ const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { int OSystem_SDL::getDefaultGraphicsMode() const { // Return the default graphics mode from the current graphics manager - if (_graphicsMode < _sdlModesCount) + if (_graphicsMode < _firstGLMode) return _graphicsManager->getDefaultGraphicsMode(); else - return _graphicsManager->getDefaultGraphicsMode() + _sdlModesCount; + return _graphicsManager->getDefaultGraphicsMode() + _firstGLMode; } bool OSystem_SDL::setGraphicsMode(int mode) { @@ -574,14 +573,14 @@ bool OSystem_SDL::setGraphicsMode(int mode) { // If the new mode and the current mode are not from the same graphics // manager, delete and create the new mode graphics manager - if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { + if (_graphicsMode >= _firstGLMode && mode < _firstGLMode) { debug(1, "switching to plain SDL graphics"); _graphicsManager->deactivateManager(); delete _graphicsManager; _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); switchedManager = true; - } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { + } else if (_graphicsMode < _firstGLMode && mode >= _firstGLMode) { debug(1, "switching to OpenGL graphics"); _graphicsManager->deactivateManager(); delete _graphicsManager; @@ -642,19 +641,16 @@ void OSystem_SDL::setupGraphicsModes() { const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - _sdlModesCount = 0; - _glModesCount = 0; // Count the number of graphics modes const OSystem::GraphicsMode *srcMode = sdlGraphicsModes; while (srcMode->name) { - _sdlModesCount++; _graphicsModes.push_back(*srcMode); srcMode++; } + _firstGLMode = _graphicsModes.size(); srcMode = openglGraphicsModes; while (srcMode->name) { - _glModesCount++; _graphicsModes.push_back(*srcMode); srcMode++; } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 983b7a8237..6389bdfbee 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -114,8 +114,7 @@ protected: GraphicsModeArray _graphicsModes; Common::Array _graphicsModeIds; int _graphicsMode; - int _sdlModesCount; - int _glModesCount; + int _firstGLMode; /** * Creates the merged graphics modes list -- cgit v1.2.3 From 17cb26b93c5b6a00dcc9dc66d400e640fe16c097 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 00:34:06 +0200 Subject: SDL: Simplify initial graphics manager selection for OpenGL. --- backends/platform/sdl/sdl.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 620d3c58ee..113e77937e 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -172,26 +172,18 @@ void OSystem_SDL::initBackend() { if (_graphicsManager == 0) { #ifdef USE_OPENGL if (ConfMan.hasKey("gfx_mode")) { + // If the gfx_mode is from OpenGL, create the OpenGL graphics manager Common::String gfxMode(ConfMan.get("gfx_mode")); - bool use_opengl = false; - const OSystem::GraphicsMode *mode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - int i = 0; - while (mode->name) { - if (scumm_stricmp(mode->name, gfxMode.c_str()) == 0) { - _graphicsMode = i + _firstGLMode; - use_opengl = true; + for (uint i = _firstGLMode; i < _graphicsModeIds.size(); ++i) { + if (!scumm_stricmp(_graphicsModes[i].name, gfxMode.c_str())) { + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + _graphicsMode = i; + break; } - - mode++; - ++i; - } - - // If the gfx_mode is from OpenGL, create the OpenGL graphics manager - if (use_opengl) { - _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); } } #endif + if (_graphicsManager == 0) { _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); } -- cgit v1.2.3 From 38543f772c6b11cd1f5339cabac4c45f4d5e4db4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 00:50:35 +0200 Subject: SDL: Make setupGraphicsModes non-virtual. The logic of switching the managers is pretty much fixed at the same level and cannot be easily overwritten. --- backends/platform/sdl/sdl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 6389bdfbee..6c7f371f2e 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -119,7 +119,7 @@ protected: /** * Creates the merged graphics modes list */ - virtual void setupGraphicsModes(); + void setupGraphicsModes(); virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; -- cgit v1.2.3 From a9cb67df081cd8da44720d9c0b924ed22f7a38b7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 00:56:13 +0200 Subject: SDL: Only allow switching of SurfaceSDL <-> OpenGL when no custom manager is used. --- backends/platform/sdl/sdl.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 113e77937e..39865c85c6 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -144,10 +144,6 @@ void OSystem_SDL::init() { _taskbarManager = new Common::TaskbarManager(); #endif -#ifdef USE_OPENGL - // Setup a list with both SDL and OpenGL graphics modes - setupGraphicsModes(); -#endif } void OSystem_SDL::initBackend() { @@ -171,6 +167,14 @@ void OSystem_SDL::initBackend() { if (_graphicsManager == 0) { #ifdef USE_OPENGL + // Setup a list with both SDL and OpenGL graphics modes. We only do + // this whenever the subclass did not already set up an graphics + // manager yet. This is because we don't know the type of the graphics + // manager of the subclass, thus we cannot easily switch between the + // OpenGL one and the set up one. It also is to be expected that the + // subclass does not want any switching of graphics managers anyway. + setupGraphicsModes(); + if (ConfMan.hasKey("gfx_mode")) { // If the gfx_mode is from OpenGL, create the OpenGL graphics manager Common::String gfxMode(ConfMan.get("gfx_mode")); @@ -530,18 +534,30 @@ Common::TimerManager *OSystem_SDL::getTimerManager() { #ifdef USE_OPENGL const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { - return _graphicsModes.begin(); + if (_graphicsModes.empty()) { + return _graphicsManager->getSupportedGraphicsModes(); + } else { + return _graphicsModes.begin(); + } } int OSystem_SDL::getDefaultGraphicsMode() const { - // Return the default graphics mode from the current graphics manager - if (_graphicsMode < _firstGLMode) + if (_graphicsModes.empty()) { return _graphicsManager->getDefaultGraphicsMode(); - else - return _graphicsManager->getDefaultGraphicsMode() + _firstGLMode; + } else { + // Return the default graphics mode from the current graphics manager + if (_graphicsMode < _firstGLMode) + return _graphicsManager->getDefaultGraphicsMode(); + else + return _graphicsManager->getDefaultGraphicsMode() + _firstGLMode; + } } bool OSystem_SDL::setGraphicsMode(int mode) { + if (_graphicsModes.empty()) { + return _graphicsManager->setGraphicsMode(mode); + } + // Check whether a invalid mode is requested. if (mode < 0 || (uint)mode >= _graphicsModeIds.size()) { return false; @@ -624,7 +640,11 @@ bool OSystem_SDL::setGraphicsMode(int mode) { } int OSystem_SDL::getGraphicsMode() const { - return _graphicsMode; + if (_graphicsModes.empty()) { + return _graphicsManager->getGraphicsMode(); + } else { + return _graphicsMode; + } } void OSystem_SDL::setupGraphicsModes() { -- cgit v1.2.3 From d34c9d5bcbbad9fdde59143d15d7e18bc82231c1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 01:03:29 +0200 Subject: SDL: Do not require a static graphics mode list in OpenGL and SurfaceSDL. --- backends/platform/sdl/sdl.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 39865c85c6..327dfe21b9 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -651,21 +651,26 @@ void OSystem_SDL::setupGraphicsModes() { _graphicsModes.clear(); _graphicsModeIds.clear(); - const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); - const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); - // Count the number of graphics modes - const OSystem::GraphicsMode *srcMode = sdlGraphicsModes; + const OSystem::GraphicsMode *srcMode; + + GraphicsManager *manager = new SurfaceSdlGraphicsManager(_eventSource); + srcMode = manager->getSupportedGraphicsModes(); while (srcMode->name) { _graphicsModes.push_back(*srcMode); srcMode++; } + delete manager; + _firstGLMode = _graphicsModes.size(); - srcMode = openglGraphicsModes; + manager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); + srcMode = manager->getSupportedGraphicsModes(); while (srcMode->name) { _graphicsModes.push_back(*srcMode); srcMode++; } + delete manager; + manager = nullptr; // Set a null mode at the end GraphicsMode nullMode; -- cgit v1.2.3 From c323dedf3c5bc293e664d298b74be63658fc55bf Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 21 Oct 2013 01:10:09 +0200 Subject: SDL: Fix default graphics mode for switchable case. The former code (incorrectly) assumed that the getDefaultGraphicsMode returns the index in the table returned by getSupportedGraphicsModes. Now the correct ID is searched and then used. --- backends/platform/sdl/sdl.cpp | 18 ++++++++++++++++-- backends/platform/sdl/sdl.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 327dfe21b9..3272033df9 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -70,6 +70,8 @@ OSystem_SDL::OSystem_SDL() _graphicsModes(), _graphicsMode(0), _firstGLMode(0), + _defaultSDLMode(0), + _defaultGLMode(0), #endif _inited(false), _initedSDL(false), @@ -547,9 +549,9 @@ int OSystem_SDL::getDefaultGraphicsMode() const { } else { // Return the default graphics mode from the current graphics manager if (_graphicsMode < _firstGLMode) - return _graphicsManager->getDefaultGraphicsMode(); + return _defaultSDLMode; else - return _graphicsManager->getDefaultGraphicsMode() + _firstGLMode; + return _defaultGLMode; } } @@ -650,27 +652,39 @@ int OSystem_SDL::getGraphicsMode() const { void OSystem_SDL::setupGraphicsModes() { _graphicsModes.clear(); _graphicsModeIds.clear(); + _defaultSDLMode = _defaultGLMode = -1; // Count the number of graphics modes const OSystem::GraphicsMode *srcMode; + int defaultMode; GraphicsManager *manager = new SurfaceSdlGraphicsManager(_eventSource); srcMode = manager->getSupportedGraphicsModes(); + defaultMode = manager->getDefaultGraphicsMode(); while (srcMode->name) { + if (defaultMode == srcMode->id) { + _defaultSDLMode = _graphicsModes.size(); + } _graphicsModes.push_back(*srcMode); srcMode++; } delete manager; + assert(_defaultSDLMode != -1); _firstGLMode = _graphicsModes.size(); manager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); srcMode = manager->getSupportedGraphicsModes(); + defaultMode = manager->getDefaultGraphicsMode(); while (srcMode->name) { + if (defaultMode == srcMode->id) { + _defaultGLMode = _graphicsModes.size(); + } _graphicsModes.push_back(*srcMode); srcMode++; } delete manager; manager = nullptr; + assert(_defaultGLMode != -1); // Set a null mode at the end GraphicsMode nullMode; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 6c7f371f2e..814cdd7c1b 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -115,6 +115,8 @@ protected: Common::Array _graphicsModeIds; int _graphicsMode; int _firstGLMode; + int _defaultSDLMode; + int _defaultGLMode; /** * Creates the merged graphics modes list -- cgit v1.2.3 From 092d36f39204df71038a1567c0d4d55bf854b523 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 22 Oct 2013 12:24:20 +0200 Subject: SDL: Reduce code duplication a bit. Now instead of initializing this in OSystem_SDL::initSDL (and in subclasses overwriting this) we simply initialize it in OSystem_SDL::init. --- backends/platform/sdl/sdl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 3272033df9..c240727069 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -126,6 +126,12 @@ void OSystem_SDL::init() { // Initialize SDL initSDL(); + // Enable unicode support if possible + SDL_EnableUNICODE(1); + + // Disable OS cursor + SDL_ShowCursor(SDL_DISABLE); + if (!_logger) _logger = new Backends::Log::Log(this); @@ -268,12 +274,6 @@ void OSystem_SDL::initSDL() { if (SDL_Init(sdlFlags) == -1) error("Could not initialize SDL: %s", SDL_GetError()); - // Enable unicode support if possible - SDL_EnableUNICODE(1); - - // Disable OS cursor - SDL_ShowCursor(SDL_DISABLE); - _initedSDL = true; } } -- cgit v1.2.3 From ea6d38d5f3b123b765e5bf8e2dc4f957e4b43eb6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 24 Oct 2013 00:06:32 +0200 Subject: SDL: Make activateManager/deactivateManager SdlGraphicsManager specific. We can do this now that we can use virtual inheritance and dynamic_cast because we enabled RTTI. --- backends/platform/sdl/sdl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index c240727069..6175f07a53 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -91,7 +91,7 @@ OSystem_SDL::~OSystem_SDL() { delete _savefileManager; _savefileManager = 0; if (_graphicsManager) { - _graphicsManager->deactivateManager(); + dynamic_cast(_graphicsManager)->deactivateManager(); } delete _graphicsManager; _graphicsManager = 0; @@ -240,7 +240,7 @@ void OSystem_SDL::initBackend() { // so the virtual keyboard can be initialized, but we have to add the // graphics manager as an event observer after initializing the event // manager. - _graphicsManager->activateManager(); + dynamic_cast(_graphicsManager)->activateManager(); } #if defined(USE_TASKBAR) @@ -585,14 +585,14 @@ bool OSystem_SDL::setGraphicsMode(int mode) { // manager, delete and create the new mode graphics manager if (_graphicsMode >= _firstGLMode && mode < _firstGLMode) { debug(1, "switching to plain SDL graphics"); - _graphicsManager->deactivateManager(); + dynamic_cast(_graphicsManager)->deactivateManager(); delete _graphicsManager; _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); switchedManager = true; } else if (_graphicsMode < _firstGLMode && mode >= _firstGLMode) { debug(1, "switching to OpenGL graphics"); - _graphicsManager->deactivateManager(); + dynamic_cast(_graphicsManager)->deactivateManager(); delete _graphicsManager; _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); @@ -602,7 +602,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) { _graphicsMode = mode; if (switchedManager) { - _graphicsManager->activateManager(); + dynamic_cast(_graphicsManager)->activateManager(); _graphicsManager->beginGFXTransaction(); #ifdef USE_RGB_COLOR -- cgit v1.2.3 From de8da01b0e8a309b9ed3f5b0f152ebbcf8f4af37 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 3 Nov 2013 17:10:18 +0000 Subject: SDL: Remove side effect of setlocale() call to get Language. This is to fix bug #3615148 - "ALL: sscanf("%f"), atof() etc. not portable due to Locale" The side effect of setlocale("") is to change the active locale from the default of "C" to the detected system locale, but this changes the behaviour of sscanf() and several other functions in a system dependent and non-portable way. This has caused bugs in the ZVISION engine when running Zork Nemesis. The solution is to restore the default "C" locale after the call to get the language. Thanks to criezy for working out this fix. --- backends/platform/sdl/sdl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index c240727069..508c5f4e92 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -393,6 +393,11 @@ Common::String OSystem_SDL::getSystemLanguage() const { #else // WIN32 // Activating current locale settings const char *locale = setlocale(LC_ALL, ""); + + // Restore default C locale to prevent issues with + // portability of sscanf(), atof(), etc. + // See bug #3615148 + setlocale(LC_ALL, "C"); // Detect the language from the locale if (!locale) { -- cgit v1.2.3 From 919e577ba665002c1513b53a755cb1d663b99f7e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 3 Nov 2013 18:43:51 +0100 Subject: SDL: Fix invalid memory access in getSystemLanguage. A call to setlocale can invalidate the string a previous setlocale call returned. Instead of saving a pointer we copy the returned string now. This, for example, fixes invalid memory access on my system. See de8da01b0e8a309b9ed3f5b0f152ebbcf8f4af37 for the commit introducing the invalid memory access. --- backends/platform/sdl/sdl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 508c5f4e92..bc80d8ad6a 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -392,7 +392,7 @@ Common::String OSystem_SDL::getSystemLanguage() const { } #else // WIN32 // Activating current locale settings - const char *locale = setlocale(LC_ALL, ""); + const Common::String locale = setlocale(LC_ALL, ""); // Restore default C locale to prevent issues with // portability of sscanf(), atof(), etc. @@ -400,7 +400,7 @@ Common::String OSystem_SDL::getSystemLanguage() const { setlocale(LC_ALL, "C"); // Detect the language from the locale - if (!locale) { + if (locale.empty()) { return ModularBackend::getSystemLanguage(); } else { int length = 0; @@ -409,14 +409,14 @@ Common::String OSystem_SDL::getSystemLanguage() const { // ".UTF-8" or the like. We do this, since // our translation languages are usually // specified without any charset information. - for (int i = 0; locale[i]; ++i, ++length) { + for (int size = locale.size(); length < size; ++length) { // TODO: Check whether "@" should really be checked // here. - if (locale[i] == '.' || locale[i] == ' ' || locale[i] == '@') + if (locale[length] == '.' || locale[length] == ' ' || locale[length] == '@') break; } - return Common::String(locale, length); + return Common::String(locale.c_str(), length); } #endif // WIN32 #else // USE_DETECTLANG -- cgit v1.2.3 From 3950dad947e5f581ecfba8c7526555a5398d59d5 Mon Sep 17 00:00:00 2001 From: Kirben Date: Mon, 11 Nov 2013 23:53:53 +1100 Subject: SDL: Remove misleading comments, based on incomplete information at MSDN. GetLocalInfo is supported on Windows 95 onwards, but MSDN fails to mention older Windows versions. --- backends/platform/sdl/sdl.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index bc80d8ad6a..178eeb96af 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -369,17 +369,6 @@ Common::String OSystem_SDL::getSystemLanguage() const { const LCID languageIdentifier = GetThreadLocale(); - // GetLocalInfo is only supported starting from Windows 2000, according to this: - // http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx - // On the other hand the locale constants used, seem to exist on Windows 98 too, - // check this for that: http://msdn.microsoft.com/en-us/library/dd464799%28v=VS.85%29.aspx - // - // I am not exactly sure what is the truth now, it might be very well that this breaks - // support for systems older than Windows 2000.... - // - // TODO: Check whether this (or ScummVM at all ;-) works on a system with Windows 98 for - // example and if it does not and we still want Windows 9x support, we should definitly - // think of another solution. if (GetLocaleInfo(languageIdentifier, LOCALE_SISO639LANGNAME, langName, sizeof(langName)) != 0 && GetLocaleInfo(languageIdentifier, LOCALE_SISO3166CTRYNAME, ctryName, sizeof(ctryName)) != 0) { Common::String localeName = langName; -- cgit v1.2.3 From 8b9d4348f8e590de5693f6dd2ea0df0f5a4e445a Mon Sep 17 00:00:00 2001 From: D G Turner Date: Thu, 14 Nov 2013 18:35:03 +0000 Subject: SDL: Fix bug where config file path could exceed maximum path length. The fix is the change in the MAXPATHLEN check, but have also migrated this to Common::String to make the fix easier. Thanks to klusark for pointing out this problem. --- backends/platform/sdl/posix/posix.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 7a8b1e7b70..954f404ac6 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -80,15 +80,16 @@ bool OSystem_POSIX::hasFeature(Feature f) { } Common::String OSystem_POSIX::getDefaultConfigFileName() { - char configFile[MAXPATHLEN]; + Common::String configFile; // On POSIX type systems, by default we store the config file inside // to the HOME directory of the user. const char *home = getenv("HOME"); - if (home != NULL && strlen(home) < MAXPATHLEN) - snprintf(configFile, MAXPATHLEN, "%s/%s", home, _baseConfigName.c_str()); - else - strcpy(configFile, _baseConfigName.c_str()); + if (home != NULL && (strlen(home) + 1 + _baseConfigName.size()) < MAXPATHLEN) { + configFile = Common::String::format("%s/%s", home, _baseConfigName.c_str()); + } else { + configFile = _baseConfigName; + } return configFile; } -- cgit v1.2.3 From 4412e12debd77a5cef60054d2ad437a180d00817 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 21 Jan 2014 19:01:28 +0100 Subject: BUILD: Rename libunity support variable to "USE_UNITY" instead of "USE_TASKBAR_UNITY". This makes it consistent with other library support variables. --- backends/platform/sdl/posix/posix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 954f404ac6..1752153f29 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -50,7 +50,7 @@ void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); -#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) +#if defined(USE_TASKBAR) && defined(USE_UNITY) // Initialize taskbar manager _taskbarManager = new UnityTaskbarManager(); #endif @@ -67,7 +67,7 @@ void OSystem_POSIX::initBackend() { // Invoke parent implementation of this method OSystem_SDL::initBackend(); -#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) +#if defined(USE_TASKBAR) && defined(USE_UNITY) // Register the taskbar manager as an event source (this is necessary for the glib event loop to be run) _eventManager->getEventDispatcher()->registerSource((UnityTaskbarManager *)_taskbarManager, false); #endif -- cgit v1.2.3 From 2589228329759839b066aa9c6e4192095573812c Mon Sep 17 00:00:00 2001 From: D G Turner Date: Wed, 12 Feb 2014 12:05:48 +0000 Subject: SDL: Add debugging code to output SDL video driver name being used. --- backends/platform/sdl/sdl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 913ae51f69..f56c00eed5 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -274,6 +274,14 @@ void OSystem_SDL::initSDL() { if (SDL_Init(sdlFlags) == -1) error("Could not initialize SDL: %s", SDL_GetError()); + const int maxNameLen = 20; + char sdlDriverName[maxNameLen]; + sdlDriverName[0] = '\0'; + SDL_VideoDriverName(sdlDriverName, maxNameLen); + // Using printf rather than debug() here as debug()/logging + // is not active by this point. + printf("Using SDL Video Driver \"%s\" ...\n", sdlDriverName); + _initedSDL = true; } } -- cgit v1.2.3 From fc80f5a34688fa460cd221c8fb3c14f33a3d8d2f Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 16 Feb 2014 16:33:35 +0000 Subject: SDL: Move debugging code to output SDL video driver name to initBackend. The initBackend() function is called later after the command line is parsed and thus debug() prints can be used, which are much less noisy. --- backends/platform/sdl/sdl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index f56c00eed5..8116282c30 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -158,6 +158,14 @@ void OSystem_SDL::initBackend() { // Check if backend has not been initialized assert(!_inited); + const int maxNameLen = 20; + char sdlDriverName[maxNameLen]; + sdlDriverName[0] = '\0'; + SDL_VideoDriverName(sdlDriverName, maxNameLen); + // Using printf rather than debug() here as debug()/logging + // is not active by this point. + debug(1, "Using SDL Video Driver \"%s\"", sdlDriverName); + // Create the default event source, in case a custom backend // manager didn't provide one yet. if (_eventSource == 0) @@ -274,14 +282,6 @@ void OSystem_SDL::initSDL() { if (SDL_Init(sdlFlags) == -1) error("Could not initialize SDL: %s", SDL_GetError()); - const int maxNameLen = 20; - char sdlDriverName[maxNameLen]; - sdlDriverName[0] = '\0'; - SDL_VideoDriverName(sdlDriverName, maxNameLen); - // Using printf rather than debug() here as debug()/logging - // is not active by this point. - printf("Using SDL Video Driver \"%s\" ...\n", sdlDriverName); - _initedSDL = true; } } -- cgit v1.2.3 From 63304ee9ec4bf37cc96949f32f5c8dd53a6d3cc4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 18 Feb 2014 02:34:24 +0100 Subject: SDL: Make GPL headers consistent in themselves. --- backends/platform/sdl/amigaos/amigaos-main.cpp | 4 ++-- backends/platform/sdl/amigaos/amigaos.cpp | 4 ++-- backends/platform/sdl/amigaos/amigaos.h | 4 ++-- backends/platform/sdl/macosx/appmenu_osx.h | 4 ++-- backends/platform/sdl/macosx/appmenu_osx.mm | 4 ++-- backends/platform/sdl/macosx/macosx-main.cpp | 4 ++-- backends/platform/sdl/macosx/macosx.cpp | 4 ++-- backends/platform/sdl/macosx/macosx.h | 4 ++-- backends/platform/sdl/posix/posix-main.cpp | 4 ++-- backends/platform/sdl/posix/posix.cpp | 4 ++-- backends/platform/sdl/posix/posix.h | 4 ++-- backends/platform/sdl/ps3/ps3-main.cpp | 4 ++-- backends/platform/sdl/ps3/ps3.cpp | 4 ++-- backends/platform/sdl/ps3/ps3.h | 4 ++-- backends/platform/sdl/sdl-sys.h | 4 ++-- backends/platform/sdl/sdl.cpp | 4 ++-- backends/platform/sdl/sdl.h | 4 ++-- backends/platform/sdl/win32/win32-main.cpp | 4 ++-- backends/platform/sdl/win32/win32.cpp | 4 ++-- backends/platform/sdl/win32/win32.h | 4 ++-- 20 files changed, 40 insertions(+), 40 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/amigaos/amigaos-main.cpp b/backends/platform/sdl/amigaos/amigaos-main.cpp index da83756a40..0743b3f9a0 100644 --- a/backends/platform/sdl/amigaos/amigaos-main.cpp +++ b/backends/platform/sdl/amigaos/amigaos-main.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/amigaos/amigaos.cpp b/backends/platform/sdl/amigaos/amigaos.cpp index 94daacfd14..fdd26cd256 100644 --- a/backends/platform/sdl/amigaos/amigaos.cpp +++ b/backends/platform/sdl/amigaos/amigaos.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/amigaos/amigaos.h b/backends/platform/sdl/amigaos/amigaos.h index 391a0bfa9a..76cc656364 100644 --- a/backends/platform/sdl/amigaos/amigaos.h +++ b/backends/platform/sdl/amigaos/amigaos.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/macosx/appmenu_osx.h b/backends/platform/sdl/macosx/appmenu_osx.h index 005414b789..22088184fb 100644 --- a/backends/platform/sdl/macosx/appmenu_osx.h +++ b/backends/platform/sdl/macosx/appmenu_osx.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index 0d2a2ab7f2..d083fb8483 100644 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/macosx/macosx-main.cpp b/backends/platform/sdl/macosx/macosx-main.cpp index b89264f9e9..1b9fc1b82c 100644 --- a/backends/platform/sdl/macosx/macosx-main.cpp +++ b/backends/platform/sdl/macosx/macosx-main.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 85342d62fd..301dc44b7b 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index d9cb28b973..e5a72bf393 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp index 5f0914e04f..d07db11b0c 100644 --- a/backends/platform/sdl/posix/posix-main.cpp +++ b/backends/platform/sdl/posix/posix-main.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 1752153f29..a711c3a96b 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index 59909a958f..01a01528cd 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/ps3/ps3-main.cpp b/backends/platform/sdl/ps3/ps3-main.cpp index ba548a3749..92c4a02865 100644 --- a/backends/platform/sdl/ps3/ps3-main.cpp +++ b/backends/platform/sdl/ps3/ps3-main.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp index 33586ce693..f111379794 100644 --- a/backends/platform/sdl/ps3/ps3.cpp +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/ps3/ps3.h b/backends/platform/sdl/ps3/ps3.h index daed7599a9..d812a13548 100644 --- a/backends/platform/sdl/ps3/ps3.h +++ b/backends/platform/sdl/ps3/ps3.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h index eccf73815d..eec3741ed6 100644 --- a/backends/platform/sdl/sdl-sys.h +++ b/backends/platform/sdl/sdl-sys.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 8116282c30..41610dc0c7 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 814cdd7c1b..5dcc269e55 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/win32/win32-main.cpp b/backends/platform/sdl/win32/win32-main.cpp index 2b3e18e9f0..e5b26c3ff0 100644 --- a/backends/platform/sdl/win32/win32-main.cpp +++ b/backends/platform/sdl/win32/win32-main.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 453d566c7b..5f860ad32d 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index b56997a63b..d72d80bc26 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program 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 General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -- cgit v1.2.3 From 6d7fcdd2b544fa4eb29988bd627af94aa8238d6c Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 26 Jan 2014 20:40:36 +0000 Subject: OSX: Implement TaskbarManager for Mac OS X This implements count badge, progress bar, and icon overlay. It uses the NSDockTile API which is available since OS X 10.5. The code compiles and run on older system but without doing anything. --- backends/platform/sdl/macosx/macosx.cpp | 11 +++++++++++ backends/platform/sdl/macosx/macosx.h | 1 + 2 files changed, 12 insertions(+) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 301dc44b7b..924e33b6e3 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -31,6 +31,7 @@ #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" #include "backends/platform/sdl/macosx/appmenu_osx.h" #include "backends/updates/macosx/macosx-updates.h" +#include "backends/taskbar/macosx/macosx-taskbar.h" #include "common/archive.h" #include "common/config-manager.h" @@ -45,6 +46,16 @@ OSystem_MacOSX::OSystem_MacOSX() OSystem_POSIX("Library/Preferences/ScummVM Preferences") { } +void OSystem_MacOSX::init() { +#if defined(USE_TASKBAR) + // Initialize taskbar manager + _taskbarManager = new MacOSXTaskbarManager(); +#endif + + // Invoke parent implementation of this method + OSystem_POSIX::init(); +} + void OSystem_MacOSX::initBackend() { // Create the mixer manager if (_mixer == 0) { diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index e5a72bf393..50cef60353 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -35,6 +35,7 @@ public: virtual Common::String getSystemLanguage() const; + virtual void init(); virtual void initBackend(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); virtual void setupIcon(); -- cgit v1.2.3 From 7af36e97243ed1e94f8f7b75618aad979165e68c Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 1 Jun 2014 17:01:57 -0400 Subject: BACKENDS: Fix invalid buffer size in CFStringGetCString call --- backends/platform/sdl/macosx/macosx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform/sdl') diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 924e33b6e3..c48076c42f 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -145,7 +145,7 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { for (CFIndex i = 0 ; i < localizationsSize ; ++i) { CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(preferredLocalizations, i); char buffer[10]; - CFStringGetCString(language, buffer, 50, kCFStringEncodingASCII); + CFStringGetCString(language, buffer, sizeof(buffer), kCFStringEncodingASCII); int32 languageId = TransMan.findMatchingLanguage(buffer); if (languageId != -1) { CFRelease(preferredLocalizations); @@ -156,7 +156,7 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { if (localizationsSize > 0) { CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(preferredLocalizations, 0); char buffer[10]; - CFStringGetCString(language, buffer, 50, kCFStringEncodingASCII); + CFStringGetCString(language, buffer, sizeof(buffer), kCFStringEncodingASCII); CFRelease(preferredLocalizations); return buffer; } -- cgit v1.2.3