diff options
author | Alejandro Marzini | 2010-07-13 04:31:15 +0000 |
---|---|---|
committer | Alejandro Marzini | 2010-07-13 04:31:15 +0000 |
commit | 609e08d5dbae3179eddf981abe73d69009432de4 (patch) | |
tree | cddbd0a0e69eaa53b85f98f96dc410a307773f08 /backends/graphics | |
parent | 8b6a670391f1b5103e3761d78eef8f41d64cf8cd (diff) | |
parent | 03c0faa5d76f547603ee6389cdf958e2a6f0f43d (diff) | |
download | scummvm-rg350-609e08d5dbae3179eddf981abe73d69009432de4.tar.gz scummvm-rg350-609e08d5dbae3179eddf981abe73d69009432de4.tar.bz2 scummvm-rg350-609e08d5dbae3179eddf981abe73d69009432de4.zip |
Merged from trunk, from Rev 49499 to HEAD
svn-id: r50840
Diffstat (limited to 'backends/graphics')
-rw-r--r-- | backends/graphics/graphics.h | 2 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 2 | ||||
-rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.cpp | 2 | ||||
-rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.h | 2 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 133 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.h | 9 |
6 files changed, 87 insertions, 63 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index 0ea425c9bc..9eb354aee4 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -48,7 +48,7 @@ public: virtual int getGraphicsMode() const = 0; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const = 0; - virtual Common::List<Graphics::PixelFormat> getSupportedFormats() = 0; + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0; #endif virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0; virtual int getScreenChangeID() const = 0; diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index f12e4b45d7..17d0b842e9 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -53,7 +53,7 @@ public: virtual int getGraphicsMode() const; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const; - virtual Common::List<Graphics::PixelFormat> getSupportedFormats() = 0; + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0; #endif virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL); virtual int getScreenChangeID() const; diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 6207561c07..b12c3af5cd 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -57,7 +57,7 @@ const Graphics::PixelFormat RGBList[] = { Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), // RGBA4444 }; -Common::List<Graphics::PixelFormat> OpenGLSdlGraphicsManager::getSupportedFormats() { +Common::List<Graphics::PixelFormat> OpenGLSdlGraphicsManager::getSupportedFormats() const { static Common::List<Graphics::PixelFormat> list; static bool inited = false; diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h index 0f69793c1b..56aae27ab7 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.h +++ b/backends/graphics/openglsdl/openglsdl-graphics.h @@ -45,7 +45,7 @@ public: virtual void init(); #ifdef USE_RGB_COLOR - virtual Common::List<Graphics::PixelFormat> getSupportedFormats(); + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; #endif virtual void warpMouse(int x, int y); diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index a554479756..e8251a779d 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -29,6 +29,7 @@ #include "common/system.h" #include "common/config-manager.h" #include "common/mutex.h" +#include "common/translation.h" #include "common/util.h" #ifdef USE_RGB_COLOR #include "common/list.h" @@ -41,7 +42,7 @@ #include "backends/events/sdl/sdl-events.h" static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { - {"1x", "Normal (no scaling)", GFX_NORMAL}, + {"1x", _s("Normal (no scaling)"), GFX_NORMAL}, #ifdef USE_SCALERS {"2x", "2x", GFX_DOUBLESIZE}, {"3x", "3x", GFX_TRIPLESIZE}, @@ -97,11 +98,11 @@ AspectRatio::AspectRatio(int w, int h) { } #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && defined(USE_SCALERS) -static const size_t AR_COUNT = 4; -static const char* desiredAspectRatioAsStrings[AR_COUNT] = { "auto", "4/3", "16/9", "16/10" }; -static const AspectRatio desiredAspectRatios[AR_COUNT] = { AspectRatio(0, 0), AspectRatio(4,3), AspectRatio(16,9), AspectRatio(16,10) }; - static AspectRatio getDesiredAspectRatio() { + const size_t AR_COUNT = 4; + const char* desiredAspectRatioAsStrings[AR_COUNT] = { "auto", "4/3", "16/9", "16/10" }; + const AspectRatio desiredAspectRatios[AR_COUNT] = { AspectRatio(0, 0), AspectRatio(4,3), AspectRatio(16,9), AspectRatio(16,10) }; + //TODO : We could parse an arbitrary string, if we code enough proper validation Common::String desiredAspectRatio = ConfMan.get("desired_screen_aspect_ratio"); @@ -359,45 +360,53 @@ OSystem::TransactionError SdlGraphicsManager::endGFXTransaction() { } #ifdef USE_RGB_COLOR -const Graphics::PixelFormat RGBList[] = { +Common::List<Graphics::PixelFormat> SdlGraphicsManager::getSupportedFormats() const { + assert(!_supportedFormats.empty()); + return _supportedFormats; +} + +void SdlGraphicsManager::detectSupportedFormats() { + + // Clear old list + _supportedFormats.clear(); + + // Some tables with standard formats that we always list + // as "supported". If frontend code tries to use one of + // these, we will perform the necessary format + // conversion in the background. Of course this incurs a + // performance hit, but on desktop ports this should not + // matter. We still push the currently active format to + // the front, so if frontend code just uses the first + // available format, it will get one that is "cheap" to + // use. + const Graphics::PixelFormat RGBList[] = { #ifdef ENABLE_32BIT - // RGBA8888, ARGB8888, RGB888 - Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), - Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), - Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), + // RGBA8888, ARGB8888, RGB888 + Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), + Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), + Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), #endif - // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444 - Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), - Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), - Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), - Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) -}; -const Graphics::PixelFormat BGRList[] = { + // RGB565, XRGB1555, RGB555, RGBA4444, ARGB4444 + Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), + Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15), + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) + }; + const Graphics::PixelFormat BGRList[] = { #ifdef ENABLE_32BIT - // ABGR8888, BGRA8888, BGR888 - Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), - Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0), - Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), + // ABGR8888, BGRA8888, BGR888 + Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), + Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0), + Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), #endif - // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444 - Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0), - Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), - Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), - Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12), - Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0) -}; - -// TODO: prioritize matching alpha masks -Common::List<Graphics::PixelFormat> SdlGraphicsManager::getSupportedFormats() { - static Common::List<Graphics::PixelFormat> list; - static bool inited = false; - - if (inited) - return list; - - bool BGR = false; - int listLength = ARRAYSIZE(RGBList); + // BGR565, XBGR1555, BGR555, ABGR4444, BGRA4444 + Graphics::PixelFormat(2, 5, 6, 5, 0, 0, 5, 11, 0), + Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15), + Graphics::PixelFormat(2, 5, 5, 5, 0, 0, 5, 10, 0), + Graphics::PixelFormat(2, 4, 4, 4, 4, 0, 4, 8, 12), + Graphics::PixelFormat(2, 4, 4, 4, 4, 4, 8, 12, 0) + }; Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); if (_hwscreen) { @@ -413,30 +422,30 @@ Common::List<Graphics::PixelFormat> SdlGraphicsManager::getSupportedFormats() { format.aLoss = 8; // Push it first, as the prefered format. - list.push_back(format); + _supportedFormats.push_back(format); + } - if (format.bShift > format.rShift) - BGR = true; + // TODO: prioritize matching alpha masks + int i; - // Mark that we don't need to do this any more. - inited = true; + // Push some RGB formats + for (i = 0; i < ARRAYSIZE(RGBList); i++) { + if (_hwscreen && (RGBList[i].bytesPerPixel > format.bytesPerPixel)) + continue; + if (RGBList[i] != format) + _supportedFormats.push_back(RGBList[i]); } - for (int i = 0; i < listLength; i++) { - if (inited && (RGBList[i].bytesPerPixel > format.bytesPerPixel)) + // Push some BGR formats + for (i = 0; i < ARRAYSIZE(BGRList); i++) { + if (_hwscreen && (BGRList[i].bytesPerPixel > format.bytesPerPixel)) continue; - if (BGR) { - if (BGRList[i] != format) - list.push_back(BGRList[i]); - list.push_back(RGBList[i]); - } else { - if (RGBList[i] != format) - list.push_back(RGBList[i]); - list.push_back(BGRList[i]); - } + if (BGRList[i] != format) + _supportedFormats.push_back(BGRList[i]); } - list.push_back(Graphics::PixelFormat::createFormatCLUT8()); - return list; + + // Finally, we always supposed 8 bit palette graphics + _supportedFormats.push_back(Graphics::PixelFormat::createFormatCLUT8()); } #endif @@ -718,6 +727,10 @@ bool SdlGraphicsManager::loadGFXMode() { _hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 16, _videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE ); +#ifdef USE_RGB_COLOR + detectSupportedFormats(); +#endif + if (_hwscreen == NULL) { // DON'T use error(), as this tries to bring up the debug // console, which WON'T WORK now that _hwscreen is hosed. @@ -1531,6 +1544,10 @@ void SdlGraphicsManager::setMousePos(int x, int y) { void SdlGraphicsManager::warpMouse(int x, int y) { int y1 = y; + // Don't change mouse position, when mouse is outside of our window (in case of windowed mode) + if (!(SDL_GetAppState( ) & SDL_APPMOUSEFOCUS)) + return; + if (_videoMode.aspectRatioCorrection && !_overlayVisible) y1 = real2Aspect(y); diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 4ca92e9d30..0218be55dc 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -87,7 +87,7 @@ public: virtual int getGraphicsMode() const; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; } - virtual Common::List<Graphics::PixelFormat> getSupportedFormats(); + virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; #endif virtual void initSize(uint w, uint h, const Graphics::PixelFormat *format = NULL); virtual int getScreenChangeID() const { return _screenChangeCount; } @@ -160,6 +160,13 @@ protected: #ifdef USE_RGB_COLOR Graphics::PixelFormat _screenFormat; Graphics::PixelFormat _cursorFormat; + Common::List<Graphics::PixelFormat> _supportedFormats; + + /** + * Update the list of supported pixel formats. + * This method is invoked by loadGFXMode(). + */ + void detectSupportedFormats(); #endif /** Temporary screen (for scalers) */ |