Get rid of menu_shader_set_modified - instead, add a single

'modified' variable to video_shader struct
This commit is contained in:
twinaphex 2020-03-06 17:05:20 +01:00
parent 814835aa8f
commit 1f553ac1c4
9 changed files with 47 additions and 57 deletions

View File

@ -142,7 +142,11 @@ struct video_shader
{
char prefix[64];
char path[PATH_MAX_LENGTH];
bool modern; /* Only used for XML shaders. */
/* indicative of whether shader was modified -
* for instance from the menus */
bool modified;
unsigned passes;
unsigned luts;
@ -154,9 +158,7 @@ struct video_shader
int history_size;
struct video_shader_pass pass[GFX_MAX_SHADERS];
struct video_shader_lut lut[GFX_MAX_TEXTURES];
struct video_shader_parameter parameters[GFX_MAX_PARAMETERS];
};

View File

@ -85,7 +85,7 @@ static int shader_action_parameter_left_internal(unsigned type, const char *labe
param_menu->current = param_prev->current;
menu_shader_set_modified(true);
shader->modified = true;
return ret;
}
@ -307,7 +307,7 @@ static int action_left_shader_scale_pass(unsigned type, const char *label,
shader_pass->fbo.scale_x = current_scale;
shader_pass->fbo.scale_y = current_scale;
menu_shader_set_modified(true);
shader->modified = true;
return 0;
}
@ -323,9 +323,8 @@ static int action_left_shader_filter_pass(unsigned type, const char *label,
if (!shader_pass)
return menu_cbs_exit();
shader_pass->filter = ((shader_pass->filter + delta) % 3);
menu_shader_set_modified(true);
shader_pass->filter = ((shader_pass->filter + delta) % 3);
shader->modified = true;
return 0;
}
@ -375,7 +374,7 @@ static int action_left_shader_num_passes(unsigned type, const char *label,
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
video_shader_resolve_parameters(NULL, shader);
menu_shader_set_modified(true);
shader->modified = true;
return 0;
}

View File

@ -1731,7 +1731,7 @@ static int generic_action_ok(const char *path,
sizeof(shader_pass->source.path));
video_shader_resolve_parameters(NULL, shader);
menu_shader_set_modified(true);
shader->modified = true;
}
}
#endif
@ -5733,7 +5733,7 @@ static int action_ok_push_dropdown_item_video_shader_num_pass(const char *path,
video_shader_resolve_parameters(NULL, shader);
menu_shader_set_modified(true);
shader->modified = true;
return action_cancel_pop_default(NULL, NULL, 0, 0);
#else
@ -5764,7 +5764,7 @@ static int action_ok_push_dropdown_item_video_shader_param_generic(const char *p
param_prev->current = val;
param_menu->current = param_prev->current;
menu_shader_set_modified(true);
shader->modified = true;
return action_cancel_pop_default(NULL, NULL, 0, 0);
#else

View File

@ -84,8 +84,7 @@ static int generic_shader_action_parameter_right_internal(unsigned type, const c
ret = generic_shader_action_parameter_right(param_prev, type, label, wraparound);
param_menu->current = param_prev->current;
menu_shader_set_modified(true);
shader->modified = true;
return ret;
}
@ -316,7 +315,7 @@ static int action_right_shader_scale_pass(unsigned type, const char *label,
shader_pass->fbo.valid = current_scale;
shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = current_scale;
menu_shader_set_modified(true);
shader->modified = true;
return 0;
}
@ -332,9 +331,9 @@ static int action_right_shader_filter_pass(unsigned type, const char *label,
if (!shader_pass)
return menu_cbs_exit();
shader_pass->filter = ((shader_pass->filter + delta) % 3);
shader_pass->filter = ((shader_pass->filter + delta) % 3);
menu_shader_set_modified(true);
shader->modified = true;
return 0;
}
@ -383,7 +382,7 @@ static int action_right_shader_num_passes(unsigned type, const char *label,
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
video_shader_resolve_parameters(NULL, shader);
menu_shader_set_modified(true);
shader->modified = true;
return 0;
}

View File

@ -6462,8 +6462,8 @@ void general_write_handler(rarch_setting_t *setting)
settings_t *settings = config_get_ptr();
struct video_shader *shader = menu_shader_get();
shader->passes = 0;
menu_shader_set_modified(true);
shader->passes = 0;
shader->modified = true;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);

View File

@ -38,13 +38,6 @@
/* Menu shader */
static struct video_shader *menu_driver_shader = NULL;
/* indicative of whether shader was modified from the menus: */
static bool menu_driver_shader_modified = true;
void menu_shader_set_modified(bool modified)
{
menu_driver_shader_modified = modified;
}
static enum rarch_shader_type shader_types[] =
{
@ -136,7 +129,7 @@ bool menu_shader_manager_init(void)
if (video_shader_read_conf_preset(conf, menu_shader))
video_shader_resolve_parameters(conf, menu_shader);
menu_driver_shader_modified = false;
menu_shader->modified = false;
config_file_free(conf);
}
@ -247,7 +240,7 @@ static bool menu_shader_manager_save_preset_internal(
if (type == RARCH_SHADER_NONE)
return false;
if (menu_driver_shader_modified)
if (shader->modified)
save_reference = false;
if (!string_is_empty(basename))
@ -556,7 +549,7 @@ int menu_shader_manager_clear_num_passes(struct video_shader *shader)
video_shader_resolve_parameters(NULL, shader);
menu_driver_shader_modified = true;
shader->modified = true;
return 0;
}
@ -574,7 +567,7 @@ int menu_shader_manager_clear_parameter(struct video_shader *shader,
param->current = MIN(MAX(param->minimum,
param->current), param->maximum);
menu_driver_shader_modified = true;
shader->modified = true;
return 0;
}
@ -590,7 +583,7 @@ int menu_shader_manager_clear_pass_filter(struct video_shader *shader,
shader_pass->filter = RARCH_FILTER_UNSPEC;
menu_driver_shader_modified = true;
shader->modified = true;
return 0;
}
@ -608,7 +601,7 @@ void menu_shader_manager_clear_pass_scale(struct video_shader *shader,
shader_pass->fbo.scale_y = 0;
shader_pass->fbo.valid = false;
menu_driver_shader_modified = true;
shader->modified = true;
}
void menu_shader_manager_clear_pass_path(struct video_shader *shader,
@ -620,7 +613,7 @@ void menu_shader_manager_clear_pass_path(struct video_shader *shader,
if (shader_pass)
*shader_pass->source.path = '\0';
menu_driver_shader_modified = true;
shader->modified = true;
}
/**

View File

@ -141,8 +141,6 @@ bool menu_shader_manager_auto_preset_exists(
const char *dir_video_shader,
const char *dir_menu_config);
void menu_shader_set_modified(bool modified);
RETRO_END_DECLS
#endif

View File

@ -5527,7 +5527,7 @@ bool retroarch_apply_shader(enum rarch_shader_type type, const char *preset_path
/* reflect in shader manager */
if (menu_shader_manager_set_preset(menu_shader_get(), type, preset_path, false))
if (!string_is_empty(preset_path))
menu_shader_set_modified(false);
menu_shader_get()->modified = false;
#endif
if (message)

View File

@ -265,7 +265,7 @@ void ShaderParamsDialog::onFilterComboBoxIndexChanged(int)
if (video_shader)
video_shader->pass[pass].filter = filter;
menu_shader_set_modified(true);
video_shader->modified = true;
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
}
@ -321,7 +321,7 @@ void ShaderParamsDialog::onScaleComboBoxIndexChanged(int)
video_shader->pass[pass].fbo.valid = scale;
}
menu_shader_set_modified(true);
video_shader->modified = true;
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
}
@ -399,7 +399,7 @@ void ShaderParamsDialog::onShaderPassMoveDownClicked()
memcpy(&menu_shader->pass[pass + 1], tempPass.pass, sizeof(struct video_shader_pass));
}
menu_shader_set_modified(true);
menu_shader->modified = true;
reload();
}
@ -474,7 +474,7 @@ void ShaderParamsDialog::onShaderPassMoveUpClicked()
memcpy(&menu_shader->pass[pass], tempPass.pass, sizeof(struct video_shader_pass));
}
menu_shader_set_modified(true);
menu_shader->modified = true;
reload();
}
@ -560,9 +560,9 @@ void ShaderParamsDialog::onShaderResetPass(int pass)
param->current = param->initial;
}
}
menu_shader_set_modified(true);
video_shader->modified = true;
}
reload();
}
@ -606,9 +606,9 @@ void ShaderParamsDialog::onShaderResetParameter(QString parameter)
if (param)
param->current = param->initial;
}
menu_shader_set_modified(true);
video_shader->modified = true;
}
reload();
}
@ -665,9 +665,8 @@ void ShaderParamsDialog::onShaderAddPassClicked()
else
return;
menu_shader_set_modified(true);
shader_pass = &menu_shader->pass[menu_shader->passes - 1];
menu_shader->modified = true;
shader_pass = &menu_shader->pass[menu_shader->passes - 1];
if (!shader_pass)
return;
@ -841,9 +840,8 @@ void ShaderParamsDialog::onShaderRemoveAllPassesClicked()
if (!menu_shader)
return;
menu_shader->passes = 0;
menu_shader_set_modified(true);
menu_shader->passes = 0;
menu_shader->modified = true;
onShaderApplyClicked();
}
@ -890,7 +888,7 @@ void ShaderParamsDialog::onShaderRemovePass(int pass)
menu_shader->passes--;
menu_shader_set_modified(true);
menu_shader->modified = true;
onShaderApplyClicked();
}
@ -1427,7 +1425,7 @@ void ShaderParamsDialog::onShaderParamCheckBoxClicked()
param->current = (checkBox->isChecked() ? param->maximum : param->minimum);
}
menu_shader_set_modified(true);
video_shader->modified = true;
}
}
@ -1492,9 +1490,10 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int)
newValue = round(newValue / param->step) * param->step;
param->current = newValue;
}
video_shader->modified = true;
}
menu_shader_set_modified(true);
}
if (spinBoxVariant.isValid())
@ -1599,9 +1598,9 @@ void ShaderParamsDialog::onShaderParamSpinBoxValueChanged(int value)
slider->setValue(newValue);
slider->blockSignals(false);
}
}
menu_shader_set_modified(true);
video_shader->modified = true;
}
}
}
@ -1682,8 +1681,8 @@ void ShaderParamsDialog::onShaderParamDoubleSpinBoxValueChanged(double value)
slider->setValue(newValue);
slider->blockSignals(false);
}
}
menu_shader_set_modified(true);
video_shader->modified = true;
}
}
}