diff options
author | Thierry Crozat | 2018-07-01 19:24:25 +0100 |
---|---|---|
committer | Thierry Crozat | 2018-07-08 16:54:51 +0100 |
commit | 8526c2c31a07e57f7166047a87474bffd82e8a03 (patch) | |
tree | 76fbe1cfb1ef04e573aa64687e3ced1071dece9f | |
parent | ff220fffa58142b5a049bcc5067538442ea7c677 (diff) | |
download | scummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.tar.gz scummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.tar.bz2 scummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.zip |
OSYSTEM: Add Stretch Mode API
-rw-r--r-- | backends/graphics/graphics.h | 7 | ||||
-rw-r--r-- | backends/modular-backend.cpp | 16 | ||||
-rw-r--r-- | backends/modular-backend.h | 4 | ||||
-rw-r--r-- | common/system.cpp | 21 | ||||
-rw-r--r-- | common/system.h | 53 |
5 files changed, 100 insertions, 1 deletions
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index d5c36c13c4..e7be2369ed 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -53,6 +53,13 @@ public: }; virtual bool setShader(int id) { return false; } virtual int getShader() const { return 0; } + virtual const OSystem::GraphicsMode *getSupportedStretchModes() const { + static const OSystem::GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }}; + return noStretchModes; + } + virtual int getDefaultStretchMode() const { return 0; } + virtual bool setStretchMode(int mode) { return false; } + virtual int getStretchMode() const { return 0; } #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const = 0; diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 944ddd5a47..2c6aaba5a8 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -93,6 +93,22 @@ int ModularBackend::getShader() const { return _graphicsManager->getShader(); } +const OSystem::GraphicsMode *ModularBackend::getSupportedStretchModes() const { + return _graphicsManager->getSupportedStretchModes(); +} + +int ModularBackend::getDefaultStretchMode() const { + return _graphicsManager->getDefaultStretchMode(); +} + +bool ModularBackend::setStretchMode(int mode) { + return _graphicsManager->setStretchMode(mode); +} + +int ModularBackend::getStretchMode() const { + return _graphicsManager->getStretchMode(); +} + void ModularBackend::resetGraphicsScale() { _graphicsManager->resetGraphicsScale(); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index fa34f2921f..ead559cd8b 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -69,6 +69,10 @@ public: virtual const GraphicsMode *getSupportedShaders() const override; virtual int getShader() const override; virtual bool setShader(int id) override; + virtual const GraphicsMode *getSupportedStretchModes() const override; + virtual int getDefaultStretchMode() const override; + virtual bool setStretchMode(int mode) override; + virtual int getStretchMode() const override; virtual void resetGraphicsScale() override; #ifdef USE_RGB_COLOR virtual Graphics::PixelFormat getScreenFormat() const override; diff --git a/common/system.cpp b/common/system.cpp index f4568c2240..51f41ecf1d 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -121,6 +121,27 @@ bool OSystem::setGraphicsMode(const char *name) { return false; } +bool OSystem::setStretchMode(const char *name) { + if (!name) + return false; + + // Special case for the 'default' filter + if (!scumm_stricmp(name, "default")) { + return setStretchMode(getDefaultStretchMode()); + } + + const GraphicsMode *sm = getSupportedStretchModes(); + + while (sm->name) { + if (!scumm_stricmp(sm->name, name)) { + return setStretchMode(sm->id); + } + sm++; + } + + return false; +} + void OSystem::fatalError() { quit(); exit(1); diff --git a/common/system.h b/common/system.h index 8866a4dcd2..158e75c643 100644 --- a/common/system.h +++ b/common/system.h @@ -607,6 +607,56 @@ public: virtual int getShader() const { return 0; } /** + * Retrieve a list of all stretch modes supported by this backend. + * It is completely up to the backend maintainer to decide what is + * appropriate here and what not. + * The list is terminated by an all-zero entry. + * @return a list of supported stretch modes + */ + virtual const GraphicsMode *getSupportedStretchModes() const { + static const GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }}; + return noStretchModes; + } + + /** + * Return the ID of the 'default' stretch mode. What exactly this means + * is up to the backend. This mode is set by the client code when no user + * overrides are present (i.e. if no custom stretch mode is selected via + * the command line or a config file). + * + * @return the ID of the 'default' graphics mode + */ + virtual int getDefaultStretchMode() const { return 0; } + + /** + * Switch to the specified stretch mode. If switching to the new mode + * failed, this method returns false. + * + * @param mode the ID of the new graphics mode + * @return true if the switch was successful, false otherwise + */ + virtual bool setStretchMode(int mode) { return false; } + + /** + * Switch to the stretch mode with the given name. If 'name' is unknown, + * or if switching to the new mode failed, this method returns false. + * + * @param name the name of the new stretch mode + * @return true if the switch was successful, false otherwise + * @note This is implemented via the setStretchMode(int) method, as well + * as getSupportedStretchModes() and getDefaultStretchMode(). + * In particular, backends do not have to overload this! + */ + bool setStretchMode(const char *name); + + /** + * Determine which stretch mode is currently active. + * @return the ID of the active stretch mode + */ + virtual int getStretchMode() const { return 0; } + + + /** * Set the size and color format of the virtual screen. Typical sizes include: * - 320x200 (e.g. for most SCUMM games, and Simon) * - 320x240 (e.g. for FM-TOWN SCUMM games) @@ -695,7 +745,8 @@ public: kTransactionModeSwitchFailed = (1 << 2), /**< Failed switching the GFX graphics mode (setGraphicsMode) */ kTransactionSizeChangeFailed = (1 << 3), /**< Failed switching the screen dimensions (initSize) */ kTransactionFormatNotSupported = (1 << 4), /**< Failed setting the color format */ - kTransactionFilteringFailed = (1 << 5) /**< Failed setting the filtering mode */ + kTransactionFilteringFailed = (1 << 5), /**< Failed setting the filtering mode */ + kTransactionStretchModeSwitchFailed = (1 << 6) /**< Failed setting the stretch mode */ }; /** |