aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/sdl
diff options
context:
space:
mode:
authorJohannes Schickel2015-01-25 19:23:06 +0100
committerJohannes Schickel2015-01-25 19:26:15 +0100
commitd97889cea719dd5a5d129ceed7ecc809cd290f51 (patch)
tree3348d9b341d139bd1a04b7ceacbc4802ca6091c1 /backends/graphics/sdl
parent3a2db0135d93b5f12fd42f04db3b6ad9d40834d3 (diff)
downloadscummvm-rg350-d97889cea719dd5a5d129ceed7ecc809cd290f51.tar.gz
scummvm-rg350-d97889cea719dd5a5d129ceed7ecc809cd290f51.tar.bz2
scummvm-rg350-d97889cea719dd5a5d129ceed7ecc809cd290f51.zip
SDL: Cleanup graphics manager switching a bit.
Diffstat (limited to 'backends/graphics/sdl')
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp33
-rw-r--r--backends/graphics/sdl/sdl-graphics.h25
2 files changed, 58 insertions, 0 deletions
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index d42c88f5d6..58253c9509 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -69,3 +69,36 @@ void SdlGraphicsManager::warpMouseInWindow(uint x, uint y) {
void SdlGraphicsManager::iconifyWindow() {
SDL_WM_IconifyWindow();
}
+
+SdlGraphicsManager::State SdlGraphicsManager::getState() {
+ State state;
+
+ state.screenWidth = getWidth();
+ state.screenHeight = getHeight();
+ state.aspectRatio = getFeatureState(OSystem::kFeatureAspectRatioCorrection);
+ state.fullscreen = getFeatureState(OSystem::kFeatureFullscreenMode);
+ state.cursorPalette = getFeatureState(OSystem::kFeatureCursorPalette);
+#ifdef USE_RGB_COLOR
+ state.pixelFormat = getScreenFormat();
+#endif
+
+ return state;
+}
+
+bool SdlGraphicsManager::setState(const State &state) {
+ beginGFXTransaction();
+#ifdef USE_RGB_COLOR
+ initSize(state.screenWidth, state.screenHeight, &state.pixelFormat);
+#else
+ initSize(state.screenWidth, state.screenHeight, 0);
+#endif
+ setFeatureState(OSystem::kFeatureAspectRatioCorrection, state.aspectRatio);
+ setFeatureState(OSystem::kFeatureFullscreenMode, state.fullscreen);
+ setFeatureState(OSystem::kFeatureCursorPalette, state.cursorPalette);
+
+ if (endGFXTransaction() != OSystem::kTransactionSuccess) {
+ return false;
+ } else {
+ return true;
+ }
+}
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index 216fc2d200..3a53a4e40e 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -129,6 +129,31 @@ public:
*/
void iconifyWindow();
+ /**
+ * A (subset) of the graphic manager's state. This is used when switching
+ * between different SDL graphic managers on runtime.
+ */
+ struct State {
+ int screenWidth, screenHeight;
+ bool aspectRatio;
+ bool fullscreen;
+ bool cursorPalette;
+
+#ifdef USE_RGB_COLOR
+ Graphics::PixelFormat pixelFormat;
+#endif
+ };
+
+ /**
+ * Queries the current state of the graphic manager.
+ */
+ State getState();
+
+ /**
+ * Setup a basic state of the graphic manager.
+ */
+ bool setState(const State &state);
+
protected:
SdlEventSource *_eventSource;
};