[Scummvm-git-logs] scummvm master -> 0fbfeaf21b32b3758a7f3aca184d39af76c07a2e
rsn8887
rsn8887 at users.noreply.github.com
Mon Mar 9 23:01:20 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7488e17c0a GUI: Allow shaders to be selected for individual targets
f2db412ba5 GUI: Store the shader name in the config file instead of the ID
0fbfeaf21b SDL: Move all shader code into PSP2SdlGraphicsManager
Commit: 7488e17c0a16018dd6e258fed893e74985fabaa7
https://github.com/scummvm/scummvm/commit/7488e17c0a16018dd6e258fed893e74985fabaa7
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-03-09T18:01:14-05:00
Commit Message:
GUI: Allow shaders to be selected for individual targets
Changed paths:
base/commandLine.cpp
base/main.cpp
engines/engine.cpp
gui/ThemeEngine.h
gui/editgamedialog.cpp
gui/editgamedialog.h
gui/options.cpp
gui/options.h
gui/themes/default.inc
gui/themes/scummclassic.zip
gui/themes/scummclassic/THEMERC
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
gui/themes/scummmodern.zip
gui/themes/scummmodern/THEMERC
gui/themes/scummmodern/scummmodern_layout.stx
gui/themes/scummmodern/scummmodern_layout_lowres.stx
gui/themes/scummremastered.zip
gui/themes/scummremastered/THEMERC
gui/themes/scummremastered/remastered_layout.stx
gui/themes/scummremastered/remastered_layout_lowres.stx
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index b05ec5ded8..23bc1ae11a 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -222,6 +222,7 @@ void registerDefaults() {
ConfMan.registerDefault("render_mode", "default");
ConfMan.registerDefault("desired_screen_aspect_ratio", "auto");
ConfMan.registerDefault("stretch_mode", "default");
+ ConfMan.registerDefault("shader", 0);
// Sound & Music
ConfMan.registerDefault("music_volume", 192);
diff --git a/base/main.cpp b/base/main.cpp
index 0b59e0710d..3f50ed4dff 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -339,6 +339,8 @@ static void setupGraphics(OSystem &system) {
system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
if (ConfMan.hasKey("stretch_mode"))
system.setStretchMode(ConfMan.get("stretch_mode").c_str());
+ if (ConfMan.hasKey("shader"))
+ system.setShader(ConfMan.getInt("shader"));
system.endGFXTransaction();
// When starting up launcher for the first time, the user might have specified
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 8d88b68796..fcd6df37d4 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -215,6 +215,9 @@ void initCommonGFX() {
if (gameDomain->contains("stretch_mode"))
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
+
+ if (gameDomain->contains("shader"))
+ g_system->setShader(ConfMan.getInt("shader"));
}
}
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 208b16260e..fd71734deb 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -37,7 +37,7 @@
#include "graphics/pixelformat.h"
-#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.34"
+#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.35"
class OSystem;
diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp
index 76a5e53ce8..a141fa105c 100644
--- a/gui/editgamedialog.cpp
+++ b/gui/editgamedialog.cpp
@@ -64,6 +64,7 @@ enum {
kSearchClearCmd = 'SRCL',
kCmdGlobalGraphicsOverride = 'OGFX',
+ kCmdGlobalShaderOverride = 'OSHD',
kCmdGlobalAudioOverride = 'OSFX',
kCmdGlobalMIDIOverride = 'OMID',
kCmdGlobalMT32Override = 'OM32',
@@ -197,6 +198,22 @@ EditGameDialog::EditGameDialog(const String &domain)
addGraphicControls(graphicsContainer, "GameOptions_Graphics_Container.");
+ //
+ // The shader tab (currently visible only for Vita platform), visibility checking by features
+ //
+
+ _globalShaderOverride = nullptr;
+ if (g_system->hasFeature(OSystem::kFeatureShader)) {
+ tab->addTab(_("Shader"), "GameOptions_Shader");
+
+ if (g_system->getOverlayWidth() > 320)
+ _globalShaderOverride = new CheckboxWidget(tab, "GameOptions_Shader.EnableTabCheckbox", _("Override global shader settings"), nullptr, kCmdGlobalShaderOverride);
+ else
+ _globalShaderOverride = new CheckboxWidget(tab, "GameOptions_Shader.EnableTabCheckbox", _c("Override global shader settings", "lowres"), nullptr, kCmdGlobalShaderOverride);
+
+ addShaderControls(tab, "GameOptions_Shader.");
+ }
+
//
// The Keymap tab
//
@@ -344,6 +361,11 @@ void EditGameDialog::open() {
ConfMan.hasKey("aspect_ratio", _domain);
_globalGraphicsOverride->setState(e);
+ if (g_system->hasFeature(OSystem::kFeatureShader)) {
+ e = ConfMan.hasKey("shader", _domain);
+ _globalShaderOverride->setState(e);
+ }
+
e = ConfMan.hasKey("music_driver", _domain) ||
ConfMan.hasKey("output_rate", _domain) ||
ConfMan.hasKey("opl_driver", _domain) ||
@@ -451,6 +473,10 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
setGraphicSettingsState(data != 0);
g_gui.scheduleTopDialogRedraw();
break;
+ case kCmdGlobalShaderOverride:
+ setShaderSettingsState(data != 0);
+ g_gui.scheduleTopDialogRedraw();
+ break;
case kCmdGlobalAudioOverride:
setAudioSettingsState(data != 0);
setSubtitleSettingsState(data != 0);
diff --git a/gui/editgamedialog.h b/gui/editgamedialog.h
index 8f74bebedb..8832865e51 100644
--- a/gui/editgamedialog.h
+++ b/gui/editgamedialog.h
@@ -84,6 +84,7 @@ protected:
PopUpWidget *_platformPopUp;
CheckboxWidget *_globalGraphicsOverride;
+ CheckboxWidget *_globalShaderOverride;
CheckboxWidget *_globalAudioOverride;
CheckboxWidget *_globalMIDIOverride;
CheckboxWidget *_globalMT32Override;
diff --git a/gui/options.cpp b/gui/options.cpp
index 1c6dda0bf5..aac3c59632 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -348,10 +348,15 @@ void OptionsDialog::build() {
}
// Shader options
- if (g_system->hasFeature(OSystem::kFeatureShader)) {
- if (_shaderPopUp) {
- int value = ConfMan.getInt("shader", _domain);
- _shaderPopUp->setSelected(value);
+ if (_shaderPopUp) {
+ _shaderPopUp->setSelected(0);
+
+ if (g_system->hasFeature(OSystem::kFeatureShader)) {
+ // TODO: Consider storing the name of the shader instead of the ID.
+ _shaderPopUp->setSelected(ConfMan.getInt("shader", _domain));
+ } else {
+ _shaderPopUpDesc->setVisible(false);
+ _shaderPopUp->setVisible(false);
}
}
@@ -534,6 +539,19 @@ void OptionsDialog::apply() {
}
}
+ // Shader options
+ if (_shaderPopUp) {
+ if (_enableShaderSettings) {
+ if (ConfMan.getInt("shader", _domain) != (int32)_shaderPopUp->getSelectedTag())
+ graphicsModeChanged = true;
+
+ // TODO: Consider storing the name of the shader instead of the ID.
+ ConfMan.setInt("shader", _shaderPopUp->getSelectedTag(), _domain);
+ } else {
+ ConfMan.removeKey("shader", _domain);
+ }
+ }
+
// Setup graphics again if needed
if (_domain == Common::ConfigManager::kApplicationDomain && graphicsModeChanged) {
g_system->beginGFXTransaction();
@@ -547,6 +565,8 @@ void OptionsDialog::apply() {
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen", _domain));
if (ConfMan.hasKey("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering", _domain));
+ if (ConfMan.hasKey("shader"))
+ g_system->setShader(ConfMan.getInt("shader", _domain));
OSystem::TransactionError gfxError = g_system->endGFXTransaction();
@@ -616,18 +636,6 @@ void OptionsDialog::apply() {
}
}
- // Shader options
- if (_enableShaderSettings) {
- if (g_system->hasFeature(OSystem::kFeatureShader)) {
- if (_shaderPopUp) {
- if (ConfMan.getInt("shader", _domain) != (int32)_shaderPopUp->getSelectedTag()) {
- ConfMan.setInt("shader", _shaderPopUp->getSelectedTag(), _domain);
- g_system->setShader(_shaderPopUp->getSelectedTag());
- }
- }
- }
- }
-
if (_keymapperWidget) {
bool changes = _keymapperWidget->save();
if (changes) {
@@ -909,6 +917,13 @@ void OptionsDialog::setGraphicSettingsState(bool enabled) {
_aspectCheckbox->setEnabled(enabled);
}
+void OptionsDialog::setShaderSettingsState(bool enabled) {
+ _enableShaderSettings = enabled;
+
+ _shaderPopUpDesc->setEnabled(enabled);
+ _shaderPopUp->setEnabled(enabled);
+}
+
void OptionsDialog::setAudioSettingsState(bool enabled) {
_enableAudioSettings = enabled;
_midiPopUpDesc->setEnabled(enabled);
@@ -1068,18 +1083,17 @@ void OptionsDialog::addKeyMapperControls(GuiObject *boss, const Common::String &
void OptionsDialog::addShaderControls(GuiObject *boss, const Common::String &prefix) {
// Shader selector
- if (g_system->hasFeature(OSystem::kFeatureShader)) {
- if (g_system->getOverlayWidth() > 320)
- _shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _("HW Shader:"), _("Different hardware shaders give different visual effects"));
- else
- _shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _c("HW Shader:", "lowres"), _("Different hardware shaders give different visual effects"));
- _shaderPopUp = new PopUpWidget(boss, prefix + "grShaderPopUp", _("Different shaders give different visual effects"));
- const OSystem::GraphicsMode *p = g_system->getSupportedShaders();
- while (p->name) {
- _shaderPopUp->appendEntry(p->name, p->id);
- p++;
- }
+ if (g_system->getOverlayWidth() > 320)
+ _shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _("HW Shader:"), _("Different hardware shaders give different visual effects"));
+ else
+ _shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _c("HW Shader:", "lowres"), _("Different hardware shaders give different visual effects"));
+ _shaderPopUp = new PopUpWidget(boss, prefix + "grShaderPopUp", _("Different shaders give different visual effects"));
+ const OSystem::GraphicsMode *p = g_system->getSupportedShaders();
+ while (p->name) {
+ _shaderPopUp->appendEntry(p->name, p->id);
+ p++;
}
+
_enableShaderSettings = true;
}
diff --git a/gui/options.h b/gui/options.h
index dd34ac9245..e012579d8a 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -107,6 +107,7 @@ protected:
void addEngineControls(GuiObject *boss, const Common::String &prefix, const ExtraGuiOptions &engineOptions);
void setGraphicSettingsState(bool enabled);
+ void setShaderSettingsState(bool enabled);
void setAudioSettingsState(bool enabled);
void setMIDISettingsState(bool enabled);
void setMT32SettingsState(bool enabled);
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index acc7608a0c..7e36996d45 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1857,6 +1857,14 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<import layout='Dialog.GlobalOptions_Graphics_Container' />"
"</layout>"
"</dialog>"
+"<dialog name='GameOptions_Shader' overlays='Dialog.GameOptions.TabWidget'>"
+"<layout type='vertical' padding='16,16,16,16' spacing='8'>"
+"<widget name='EnableTabCheckbox' "
+"type='Checkbox' "
+"/>"
+"<import layout='Dialog.GlobalOptions_Shader' />"
+"</layout>"
+"</dialog>"
"<dialog name='GameOptions_Audio' overlays='Dialog.GameOptions.TabWidget'>"
"<layout type='vertical' padding='16,16,16,16' spacing='8'>"
"<widget name='EnableTabCheckbox' "
@@ -3643,6 +3651,14 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<import layout='Dialog.GlobalOptions_Graphics_Container' />"
"</layout>"
"</dialog>"
+"<dialog name='GameOptions_Shader' overlays='Dialog.GameOptions.TabWidget'>"
+"<layout type='vertical' padding='8,8,8,8' spacing='6'>"
+"<widget name='EnableTabCheckbox' "
+"type='Checkbox' "
+"/>"
+"<import layout='Dialog.GlobalOptions_Shader' />"
+"</layout>"
+"</dialog>"
"<dialog name='GameOptions_Audio' overlays='Dialog.GameOptions.TabWidget'>"
"<layout type='vertical' padding='8,8,8,8' spacing='6'>"
"<widget name='EnableTabCheckbox' "
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 48685e6ed2..15040dfe63 100644
Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
diff --git a/gui/themes/scummclassic/THEMERC b/gui/themes/scummclassic/THEMERC
index 7e7c03909e..2bea7c2a2a 100644
--- a/gui/themes/scummclassic/THEMERC
+++ b/gui/themes/scummclassic/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.34:ScummVM Classic Theme:No Author]
+[SCUMMVM_STX0.8.35:ScummVM Classic Theme:No Author]
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index 7f107e71d3..ddd246e64e 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -1005,6 +1005,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
<widget name = 'EnableTabCheckbox'
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index 7b131f9aae..9b7aaca79c 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -1006,6 +1006,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
<widget name = 'EnableTabCheckbox'
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index a5459f544c..55845bb851 100644
Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
diff --git a/gui/themes/scummmodern/THEMERC b/gui/themes/scummmodern/THEMERC
index 5fc37c17d5..0d3fa6cec0 100644
--- a/gui/themes/scummmodern/THEMERC
+++ b/gui/themes/scummmodern/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.34:ScummVM Modern Theme:No Author]
+[SCUMMVM_STX0.8.35:ScummVM Modern Theme:No Author]
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index 1c00d44082..6b89f2c57a 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -1018,6 +1018,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
<widget name = 'EnableTabCheckbox'
diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
index 0b7a74bf73..f85df8647c 100644
--- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx
+++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -1005,6 +1005,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
<widget name = 'EnableTabCheckbox'
diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip
index 0870ecfafd..7907630550 100644
Binary files a/gui/themes/scummremastered.zip and b/gui/themes/scummremastered.zip differ
diff --git a/gui/themes/scummremastered/THEMERC b/gui/themes/scummremastered/THEMERC
index 1979c59560..20c006fb4e 100644
--- a/gui/themes/scummremastered/THEMERC
+++ b/gui/themes/scummremastered/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.8.34:ScummVM Modern Theme Remastered:No Author]
+[SCUMMVM_STX0.8.35:ScummVM Modern Theme Remastered:No Author]
diff --git a/gui/themes/scummremastered/remastered_layout.stx b/gui/themes/scummremastered/remastered_layout.stx
index 76789fb493..5a98890188 100644
--- a/gui/themes/scummremastered/remastered_layout.stx
+++ b/gui/themes/scummremastered/remastered_layout.stx
@@ -1018,6 +1018,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
<widget name = 'EnableTabCheckbox'
diff --git a/gui/themes/scummremastered/remastered_layout_lowres.stx b/gui/themes/scummremastered/remastered_layout_lowres.stx
index 0f06c3828f..99b3063625 100644
--- a/gui/themes/scummremastered/remastered_layout_lowres.stx
+++ b/gui/themes/scummremastered/remastered_layout_lowres.stx
@@ -1005,6 +1005,15 @@
</layout>
</dialog>
+ <dialog name = 'GameOptions_Shader' overlays = 'Dialog.GameOptions.TabWidget'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
+ <widget name = 'EnableTabCheckbox'
+ type = 'Checkbox'
+ />
+ <import layout = 'Dialog.GlobalOptions_Shader' />
+ </layout>
+ </dialog>
+
<dialog name = 'GameOptions_Audio' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '8, 8, 8, 8' spacing = '6'>
<widget name = 'EnableTabCheckbox'
Commit: f2db412ba543ef44152ba221c37a6a2e42c617ee
https://github.com/scummvm/scummvm/commit/f2db412ba543ef44152ba221c37a6a2e42c617ee
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-03-09T18:01:14-05:00
Commit Message:
GUI: Store the shader name in the config file instead of the ID
Changed paths:
backends/graphics/graphics.h
backends/graphics/psp2sdl/psp2sdl-graphics.cpp
backends/graphics/psp2sdl/psp2sdl-graphics.h
backends/modular-backend.cpp
backends/modular-backend.h
backends/platform/sdl/psp2/psp2.cpp
base/commandLine.cpp
base/main.cpp
common/system.cpp
common/system.h
engines/engine.cpp
gui/options.cpp
diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h
index 2f6cd0550f..f672fb2286 100644
--- a/backends/graphics/graphics.h
+++ b/backends/graphics/graphics.h
@@ -54,6 +54,7 @@ public:
static const OSystem::GraphicsMode no_shader[2] = {{"NONE", "Normal (no shader)", 0}, {0, 0, 0}};
return no_shader;
};
+ virtual int getDefaultShader() const { return 0; }
virtual bool setShader(int id) { return false; }
virtual int getShader() const { return 0; }
virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
index 2d26727ca6..2095d9bce7 100644
--- a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
+++ b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
@@ -86,10 +86,7 @@ PSP2SdlGraphicsManager::PSP2SdlGraphicsManager(SdlEventSource *sdlEventSource, S
_numShaders++;
p++;
}
- _currentShader = ConfMan.getInt("shader");
- if (_currentShader < 0 || _currentShader >= _numShaders) {
- _currentShader = 0;
- }
+ _currentShader = GFX_SHADER_NONE;
_shaders[0] = NULL;
@@ -140,6 +137,10 @@ const OSystem::GraphicsMode *PSP2SdlGraphicsManager::getSupportedShaders() const
return s_supportedShadersPSP2;
}
+int PSP2SdlGraphicsManager::getDefaultShader() const {
+ return GFX_SHADER_SHARP;
+}
+
void PSP2SdlGraphicsManager::unloadGFXMode() {
if (_screen) {
SDL_FreeSurface(_screen);
diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.h b/backends/graphics/psp2sdl/psp2sdl-graphics.h
index 715099620a..073fa10e5c 100644
--- a/backends/graphics/psp2sdl/psp2sdl-graphics.h
+++ b/backends/graphics/psp2sdl/psp2sdl-graphics.h
@@ -33,6 +33,7 @@ public:
virtual OSystem::TransactionError endGFXTransaction() override;
virtual const OSystem::GraphicsMode *getSupportedShaders() const override;
+ virtual int getDefaultShader() const override;
protected:
virtual void setGraphicsModeIntern() override;
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 963e987119..1117518ee0 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -83,6 +83,10 @@ const OSystem::GraphicsMode *ModularBackend::getSupportedShaders() const {
return _graphicsManager->getSupportedShaders();
}
+int ModularBackend::getDefaultShader() const {
+ return _graphicsManager->getDefaultShader();
+}
+
bool ModularBackend::setShader(int id) {
return _graphicsManager->setShader(id);
}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index a89df7debc..0db7002097 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -68,6 +68,7 @@ public:
virtual bool setGraphicsMode(int mode) override;
virtual int getGraphicsMode() const override;
virtual const GraphicsMode *getSupportedShaders() const override;
+ virtual int getDefaultShader() const override;
virtual int getShader() const override;
virtual bool setShader(int id) override;
virtual const GraphicsMode *getSupportedStretchModes() const override;
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index dd114d81d1..4b5fa80296 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -100,7 +100,6 @@ void OSystem_PSP2::initBackend() {
ConfMan.registerDefault("filtering", true);
ConfMan.registerDefault("kbdmouse_speed", 3);
ConfMan.registerDefault("joystick_deadzone", 2);
- ConfMan.registerDefault("shader", 0);
ConfMan.registerDefault("touchpad_mouse_mode", false);
ConfMan.registerDefault("frontpanel_touchpad_mode", false);
@@ -115,9 +114,6 @@ void OSystem_PSP2::initBackend() {
if (!ConfMan.hasKey("filtering")) {
ConfMan.setBool("filtering", true);
}
- if (!ConfMan.hasKey("shader")) {
- ConfMan.setInt("shader", 2);
- }
if (!ConfMan.hasKey("touchpad_mouse_mode")) {
ConfMan.setBool("touchpad_mouse_mode", false);
}
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 23bc1ae11a..8294f85a8b 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -222,7 +222,7 @@ void registerDefaults() {
ConfMan.registerDefault("render_mode", "default");
ConfMan.registerDefault("desired_screen_aspect_ratio", "auto");
ConfMan.registerDefault("stretch_mode", "default");
- ConfMan.registerDefault("shader", 0);
+ ConfMan.registerDefault("shader", "default");
// Sound & Music
ConfMan.registerDefault("music_volume", 192);
@@ -591,6 +591,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION("stretch-mode")
END_OPTION
+ DO_LONG_OPTION("shader")
+ END_OPTION
+
DO_OPTION_INT('m', "music-volume")
END_OPTION
diff --git a/base/main.cpp b/base/main.cpp
index 3f50ed4dff..17298927f1 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -340,7 +340,7 @@ static void setupGraphics(OSystem &system) {
if (ConfMan.hasKey("stretch_mode"))
system.setStretchMode(ConfMan.get("stretch_mode").c_str());
if (ConfMan.hasKey("shader"))
- system.setShader(ConfMan.getInt("shader"));
+ system.setShader(ConfMan.get("shader").c_str());
system.endGFXTransaction();
// When starting up launcher for the first time, the user might have specified
diff --git a/common/system.cpp b/common/system.cpp
index 8d1ab84a3d..c041f67fd0 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -148,6 +148,27 @@ bool OSystem::setGraphicsMode(const char *name) {
return false;
}
+bool OSystem::setShader(const char *name) {
+ if (!name)
+ return false;
+
+ // Special case for the 'default' filter
+ if (!scumm_stricmp(name, "default")) {
+ return setShader(getDefaultShader());
+ }
+
+ const GraphicsMode *sm = getSupportedShaders();
+
+ while (sm->name) {
+ if (!scumm_stricmp(sm->name, name)) {
+ return setShader(sm->id);
+ }
+ sm++;
+ }
+
+ return false;
+}
+
bool OSystem::setStretchMode(const char *name) {
if (!name)
return false;
diff --git a/common/system.h b/common/system.h
index 05db7e4e40..9922e92aab 100644
--- a/common/system.h
+++ b/common/system.h
@@ -645,6 +645,16 @@ public:
return no_shader;
}
+ /**
+ * Return the ID of the 'default' shader 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 shader mode is selected via
+ * the command line or a config file).
+ *
+ * @return the ID of the 'default' shader mode
+ */
+ virtual int getDefaultShader() const { return 0; }
+
/**
* Switch to the specified shader mode. If switching to the new mode
* failed, this method returns false.
@@ -654,6 +664,18 @@ public:
*/
virtual bool setShader(int id) { return false; }
+ /**
+ * Switch to the shader 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 shader mode
+ * @return true if the switch was successful, false otherwise
+ * @note This is implemented via the setShader(int) method, as well
+ * as getSupportedShaders() and getDefaultShader().
+ * In particular, backends do not have to overload this!
+ */
+ bool setShader(const char *name);
+
/**
* Determine which shader is currently active.
* @return the ID of the active shader
diff --git a/engines/engine.cpp b/engines/engine.cpp
index fcd6df37d4..80e5613f3c 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -217,7 +217,7 @@ void initCommonGFX() {
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
if (gameDomain->contains("shader"))
- g_system->setShader(ConfMan.getInt("shader"));
+ g_system->setShader(ConfMan.get("shader").c_str());
}
}
diff --git a/gui/options.cpp b/gui/options.cpp
index aac3c59632..d0837e563c 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -352,8 +352,17 @@ void OptionsDialog::build() {
_shaderPopUp->setSelected(0);
if (g_system->hasFeature(OSystem::kFeatureShader)) {
- // TODO: Consider storing the name of the shader instead of the ID.
- _shaderPopUp->setSelected(ConfMan.getInt("shader", _domain));
+ if (ConfMan.hasKey("shader", _domain)) {
+ const OSystem::GraphicsMode *sm = g_system->getSupportedShaders();
+ Common::String shader(ConfMan.get("shader", _domain));
+ int shaderCount = 1;
+ while (sm->name) {
+ shaderCount++;
+ if (scumm_stricmp(sm->name, shader.c_str()) == 0)
+ _shaderPopUp->setSelected(shaderCount);
+ sm++;
+ }
+ }
} else {
_shaderPopUpDesc->setVisible(false);
_shaderPopUp->setVisible(false);
@@ -542,11 +551,23 @@ void OptionsDialog::apply() {
// Shader options
if (_shaderPopUp) {
if (_enableShaderSettings) {
- if (ConfMan.getInt("shader", _domain) != (int32)_shaderPopUp->getSelectedTag())
- graphicsModeChanged = true;
+ bool isSet = false;
- // TODO: Consider storing the name of the shader instead of the ID.
- ConfMan.setInt("shader", _shaderPopUp->getSelectedTag(), _domain);
+ if ((int32)_shaderPopUp->getSelectedTag() >= 0) {
+ const OSystem::GraphicsMode *sm = g_system->getSupportedShaders();
+ while (sm->name) {
+ if (sm->id == (int)_shaderPopUp->getSelectedTag()) {
+ if (ConfMan.get("shader", _domain) != sm->name)
+ graphicsModeChanged = true;
+ ConfMan.set("shader", sm->name, _domain);
+ isSet = true;
+ break;
+ }
+ sm++;
+ }
+ }
+ if (!isSet)
+ ConfMan.removeKey("shader", _domain);
} else {
ConfMan.removeKey("shader", _domain);
}
@@ -566,7 +587,7 @@ void OptionsDialog::apply() {
if (ConfMan.hasKey("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering", _domain));
if (ConfMan.hasKey("shader"))
- g_system->setShader(ConfMan.getInt("shader", _domain));
+ g_system->setShader(ConfMan.get("shader", _domain).c_str());
OSystem::TransactionError gfxError = g_system->endGFXTransaction();
@@ -1082,6 +1103,10 @@ void OptionsDialog::addKeyMapperControls(GuiObject *boss, const Common::String &
}
void OptionsDialog::addShaderControls(GuiObject *boss, const Common::String &prefix) {
+ Common::String context;
+ if (g_system->getOverlayWidth() <= 320)
+ context = "lowres";
+
// Shader selector
if (g_system->getOverlayWidth() > 320)
_shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _("HW Shader:"), _("Different hardware shaders give different visual effects"));
@@ -1089,8 +1114,11 @@ void OptionsDialog::addShaderControls(GuiObject *boss, const Common::String &pre
_shaderPopUpDesc = new StaticTextWidget(boss, prefix + "grShaderPopUpDesc", _c("HW Shader:", "lowres"), _("Different hardware shaders give different visual effects"));
_shaderPopUp = new PopUpWidget(boss, prefix + "grShaderPopUp", _("Different shaders give different visual effects"));
const OSystem::GraphicsMode *p = g_system->getSupportedShaders();
+
+ _shaderPopUp->appendEntry(_("<default>"));
+ _shaderPopUp->appendEntry("");
while (p->name) {
- _shaderPopUp->appendEntry(p->name, p->id);
+ _shaderPopUp->appendEntry(_c(p->description, context), p->id);
p++;
}
Commit: 0fbfeaf21b32b3758a7f3aca184d39af76c07a2e
https://github.com/scummvm/scummvm/commit/0fbfeaf21b32b3758a7f3aca184d39af76c07a2e
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-03-09T18:01:14-05:00
Commit Message:
SDL: Move all shader code into PSP2SdlGraphicsManager
Changed paths:
backends/graphics/psp2sdl/psp2sdl-graphics.cpp
backends/graphics/psp2sdl/psp2sdl-graphics.h
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.h
diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
index 2095d9bce7..afe371ebf7 100644
--- a/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
+++ b/backends/graphics/psp2sdl/psp2sdl-graphics.cpp
@@ -141,6 +141,17 @@ int PSP2SdlGraphicsManager::getDefaultShader() const {
return GFX_SHADER_SHARP;
}
+int PSP2SdlGraphicsManager::getShader() const {
+ return _currentShader;
+}
+
+bool PSP2SdlGraphicsManager::setShader(int id) {
+ assert(id >= 0 && id < _numShaders);
+ _currentShader = id;
+ updateShader();
+ return true;
+}
+
void PSP2SdlGraphicsManager::unloadGFXMode() {
if (_screen) {
SDL_FreeSurface(_screen);
diff --git a/backends/graphics/psp2sdl/psp2sdl-graphics.h b/backends/graphics/psp2sdl/psp2sdl-graphics.h
index 073fa10e5c..e05a37a72b 100644
--- a/backends/graphics/psp2sdl/psp2sdl-graphics.h
+++ b/backends/graphics/psp2sdl/psp2sdl-graphics.h
@@ -34,16 +34,23 @@ public:
virtual OSystem::TransactionError endGFXTransaction() override;
virtual const OSystem::GraphicsMode *getSupportedShaders() const override;
virtual int getDefaultShader() const override;
+ virtual int getShader() const override;
+ virtual bool setShader(int id) override;
protected:
virtual void setGraphicsModeIntern() override;
virtual void unloadGFXMode() override;
virtual bool hotswapGFXMode() override;
- virtual void updateShader() override;
virtual SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) override;
virtual void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) override;
+
+private:
void PSP2_UpdateFiltering();
+ void updateShader();
+
+ int _currentShader;
+ int _numShaders;
vita2d_texture *_vitatex_hwscreen;
void *_sdlpixels_hwscreen;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index b0ccee4c47..cc8415a836 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -56,11 +56,6 @@
#define SDL_FULLSCREEN 0x40000000
#endif
-static const OSystem::GraphicsMode s_supportedShaders[] = {
- {"NONE", "Normal (no shader)", 0},
- {0, 0, 0}
-};
-
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", _s("Normal (no scaling)"), GFX_NORMAL},
#ifdef USE_SCALERS
@@ -209,13 +204,6 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#if SDL_VERSION_ATLEAST(2, 0, 0)
_videoMode.stretchMode = STRETCH_FIT;
#endif
-
- // the default backend has no shaders
- // shader number 0 is the entry NONE (no shader)
- // for an example on shader support,
- // consult the psp2sdl backend which inherits from this class
- _currentShader = 0;
- _numShaders = 1;
}
SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() {
@@ -730,8 +718,6 @@ ScalerProc *SurfaceSdlGraphicsManager::getGraphicsScalerProc(int mode) const {
void SurfaceSdlGraphicsManager::setGraphicsModeIntern() {
Common::StackLock lock(_graphicsMutex);
- updateShader();
-
ScalerProc *newScalerProc = getGraphicsScalerProc(_videoMode.mode);
if (!newScalerProc) {
@@ -765,21 +751,6 @@ int SurfaceSdlGraphicsManager::getGraphicsMode() const {
return _videoMode.mode;
}
-const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedShaders() const {
- return s_supportedShaders;
-}
-
-int SurfaceSdlGraphicsManager::getShader() const {
- return _currentShader;
-}
-
-bool SurfaceSdlGraphicsManager::setShader(int id) {
- assert(id >= 0 && id < _numShaders);
- _currentShader = id;
- updateShader();
- return true;
-}
-
#if SDL_VERSION_ATLEAST(2, 0, 0)
const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedStretchModes() const {
return s_supportedStretchModes;
@@ -1192,17 +1163,6 @@ void SurfaceSdlGraphicsManager::updateScreen() {
internUpdateScreen();
}
-void SurfaceSdlGraphicsManager::updateShader() {
- // shader init code goes here
- // currently only used on Vita port
- // the user-selected shaderID should be obtained via ConfMan.getInt("shader")
- // and the corresponding shader should then be activated here
- // this way the user can combine any software scaling (scalers)
- // with any hardware shading (shaders). The shaders could provide
- // scanline masks, overlays, but could also serve for
- // hardware-based up-scaling (sharp-bilinear-simple, etc.)
-}
-
void SurfaceSdlGraphicsManager::internUpdateScreen() {
SDL_Surface *srcSurf, *origSurf;
int height, width;
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h
index 89dcf92c7c..baf7c46c90 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.h
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h
@@ -91,9 +91,6 @@ public:
virtual Graphics::PixelFormat getScreenFormat() const override { return _screenFormat; }
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
#endif
- virtual const OSystem::GraphicsMode *getSupportedShaders() const override;
- virtual int getShader() const override;
- virtual bool setShader(int id) override;
#if SDL_VERSION_ATLEAST(2, 0, 0)
virtual const OSystem::GraphicsMode *getSupportedStretchModes() const override;
virtual int getDefaultStretchMode() const override;
@@ -339,9 +336,6 @@ protected:
int _screenChangeCount;
- int _currentShader;
- int _numShaders;
-
enum {
NUM_DIRTY_RECT = 100,
MAX_SCALING = 3
@@ -419,7 +413,6 @@ protected:
virtual void blitCursor();
virtual void internUpdateScreen();
- virtual void updateShader();
virtual bool loadGFXMode();
virtual void unloadGFXMode();
More information about the Scummvm-git-logs
mailing list