aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-26 22:44:17 -0400
committerMatthew Hoops2011-08-26 22:44:17 -0400
commit4a69dc13d92e82fff85dc5a3a923b74ced259ffa (patch)
tree8945cd3745fd65f28b043caf7b1beddbbce2b2a1 /backends/platform/sdl
parentad293b249e74dd1cfbdbd721d02145efbdaf9eca (diff)
parent5e174cbfe466dbbe8e5470b0a00de1481b986181 (diff)
downloadscummvm-rg350-4a69dc13d92e82fff85dc5a3a923b74ced259ffa.tar.gz
scummvm-rg350-4a69dc13d92e82fff85dc5a3a923b74ced259ffa.tar.bz2
scummvm-rg350-4a69dc13d92e82fff85dc5a3a923b74ced259ffa.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/macosx/macosx.cpp6
-rw-r--r--backends/platform/sdl/sdl.cpp65
-rw-r--r--backends/platform/sdl/sdl.h6
3 files changed, 67 insertions, 10 deletions
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index ddfc99570a..d9de4e5e33 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -30,6 +30,7 @@
#include "backends/platform/sdl/macosx/macosx.h"
#include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h"
#include "backends/platform/sdl/macosx/appmenu_osx.h"
+#include "backends/updates/macosx/macosx-updates.h"
#include "common/archive.h"
#include "common/config-manager.h"
@@ -63,6 +64,11 @@ void OSystem_MacOSX::initBackend() {
// Replace the SDL generated menu items with our own translated ones on Mac OS X
replaceApplicationMenuItems();
+#ifdef USE_SPARKLE
+ // Initialize updates manager
+ _updateManager = new MacOSXUpdateManager();
+#endif
+
// Invoke parent implementation of this method
OSystem_POSIX::initBackend();
}
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index d05cca4d1f..8dff5cec05 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -49,6 +49,7 @@
#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"
@@ -174,7 +175,7 @@ void OSystem_SDL::initBackend() {
// If the gfx_mode is from OpenGL, create the OpenGL graphics manager
if (use_opengl) {
- _graphicsManager = new OpenGLSdlGraphicsManager();
+ _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource);
graphicsManagerType = 1;
}
}
@@ -472,7 +473,8 @@ uint32 OSystem_SDL::getMillis() {
}
void OSystem_SDL::delayMillis(uint msecs) {
- SDL_Delay(msecs);
+ if (!g_eventRec.processDelayMillis(msecs))
+ SDL_Delay(msecs);
}
void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
@@ -523,6 +525,22 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
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) {
@@ -534,16 +552,55 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
_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();
+ _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource);
((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver();
_graphicsManager->beginGFXTransaction();
+
+ switchedManager = true;
}
_graphicsMode = mode;
- return _graphicsManager->setGraphicsMode(srcMode->id);
+
+ 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++;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 395b2b3aac..22d79dbfe7 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -74,12 +74,6 @@ public:
virtual void getTimeAndDate(TimeDate &td) const;
virtual Audio::Mixer *getMixer();
- // HACK: Special SDL events types
- enum SdlEvent {
- kSdlEventExpose = 100,
- kSdlEventResize = 101
- };
-
protected:
bool _inited;
bool _initedSDL;