aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThierry Crozat2018-07-01 19:24:25 +0100
committerThierry Crozat2018-07-08 16:54:51 +0100
commit8526c2c31a07e57f7166047a87474bffd82e8a03 (patch)
tree76fbe1cfb1ef04e573aa64687e3ced1071dece9f /common
parentff220fffa58142b5a049bcc5067538442ea7c677 (diff)
downloadscummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.tar.gz
scummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.tar.bz2
scummvm-rg350-8526c2c31a07e57f7166047a87474bffd82e8a03.zip
OSYSTEM: Add Stretch Mode API
Diffstat (limited to 'common')
-rw-r--r--common/system.cpp21
-rw-r--r--common/system.h53
2 files changed, 73 insertions, 1 deletions
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 */
};
/**