OSYSTEM: Add Stretch Mode API

This commit is contained in:
Thierry Crozat 2018-07-01 19:24:25 +01:00
parent ff220fffa5
commit 8526c2c31a
5 changed files with 100 additions and 1 deletions

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -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);

View file

@ -606,6 +606,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)
@ -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 */
};
/**