From 88cecc521a573e0ccef13719f94d1ade97e82848 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 22 Aug 2018 22:51:44 -0400 Subject: [PATCH] Qt: hopefully parameters are fixed now part 2 --- menu/menu_shader.c | 2 +- ui/drivers/qt/shaderparamsdialog.cpp | 59 ++++++++++++++++++++++++---- ui/drivers/qt/shaderparamsdialog.h | 13 ++++++ 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/menu/menu_shader.c b/menu/menu_shader.c index f6855c82fa..379be3709e 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -303,7 +303,7 @@ bool menu_shader_manager_save_preset( { strlcpy(default_preset, "menu", sizeof(default_preset)); - strlcat(default_preset, + strlcat(default_preset, preset_ext, sizeof(default_preset)); } diff --git a/ui/drivers/qt/shaderparamsdialog.cpp b/ui/drivers/qt/shaderparamsdialog.cpp index 7c84106f3e..eceb0fa1a8 100644 --- a/ui/drivers/qt/shaderparamsdialog.cpp +++ b/ui/drivers/qt/shaderparamsdialog.cpp @@ -41,6 +41,33 @@ enum SHADER_PRESET_SAVE_NORMAL }; +ShaderPass::ShaderPass(struct video_shader_pass *passToCopy) : + pass(NULL) +{ + if (passToCopy) + { + pass = (struct video_shader_pass*)calloc(1, sizeof(*pass)); + memcpy(pass, passToCopy, sizeof(*pass)); + } +} + +ShaderPass::~ShaderPass() +{ + if (pass) + free(pass); +} + +ShaderPass& ShaderPass::operator=(const ShaderPass &other) +{ + if (this != &other && other.pass) + { + pass = (struct video_shader_pass*)calloc(1, sizeof(*pass)); + memcpy(pass, other.pass, sizeof(*pass)); + } + + return *this; +} + ShaderParamsDialog::ShaderParamsDialog(QWidget *parent) : QDialog(parent) ,m_layout() @@ -323,6 +350,7 @@ void ShaderParamsDialog::onShaderPassMoveDownClicked() if (video_shader) { + ShaderPass tempPass; int i; if (pass >= static_cast(video_shader->passes) - 1) @@ -342,11 +370,14 @@ void ShaderParamsDialog::onShaderPassMoveDownClicked() } } - std::swap(video_shader->pass[pass], video_shader->pass[pass + 1]); + tempPass = ShaderPass(&video_shader->pass[pass]); + memcpy(&video_shader->pass[pass], &video_shader->pass[pass + 1], sizeof(struct video_shader_pass)); + memcpy(&video_shader->pass[pass + 1], tempPass.pass, sizeof(struct video_shader_pass)); } if (menu_shader) { + ShaderPass tempPass; int i; if (pass >= static_cast(menu_shader->passes) - 1) @@ -366,10 +397,12 @@ void ShaderParamsDialog::onShaderPassMoveDownClicked() } } - std::swap(menu_shader->pass[pass], menu_shader->pass[pass + 1]); + tempPass = ShaderPass(&menu_shader->pass[pass]); + memcpy(&menu_shader->pass[pass], &menu_shader->pass[pass + 1], sizeof(struct video_shader_pass)); + memcpy(&menu_shader->pass[pass + 1], tempPass.pass, sizeof(struct video_shader_pass)); } - command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL); + reload(); } void ShaderParamsDialog::onShaderPassMoveUpClicked() @@ -401,13 +434,12 @@ void ShaderParamsDialog::onShaderPassMoveUpClicked() if (video_shader) { + ShaderPass tempPass; int i; if (pass > static_cast(video_shader->passes) - 1) return; - std::swap(video_shader->pass[pass - 1], video_shader->pass[pass]); - for (i = 0; i < static_cast(video_shader->num_parameters); i++) { struct video_shader_parameter *param = &video_shader->parameters[i]; @@ -421,17 +453,20 @@ void ShaderParamsDialog::onShaderPassMoveUpClicked() param->pass += 1; } } + + tempPass = ShaderPass(&video_shader->pass[pass - 1]); + memcpy(&video_shader->pass[pass - 1], &video_shader->pass[pass], sizeof(struct video_shader_pass)); + memcpy(&video_shader->pass[pass], tempPass.pass, sizeof(struct video_shader_pass)); } if (menu_shader) { + ShaderPass tempPass; int i; if (pass > static_cast(menu_shader->passes) - 1) return; - std::swap(menu_shader->pass[pass - 1], menu_shader->pass[pass]); - for (i = 0; i < static_cast(menu_shader->num_parameters); i++) { struct video_shader_parameter *param = &menu_shader->parameters[i]; @@ -445,9 +480,13 @@ void ShaderParamsDialog::onShaderPassMoveUpClicked() param->pass += 1; } } + + tempPass = ShaderPass(&menu_shader->pass[pass - 1]); + memcpy(&menu_shader->pass[pass - 1], &menu_shader->pass[pass], sizeof(struct video_shader_pass)); + memcpy(&menu_shader->pass[pass], tempPass.pass, sizeof(struct video_shader_pass)); } - command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL); + reload(); } void ShaderParamsDialog::onShaderLoadPresetClicked() @@ -1197,6 +1236,10 @@ void ShaderParamsDialog::addShaderParam(struct video_shader_parameter *param, in slider->setValue(value); slider->setProperty("param", parameter); + struct video_shader *video_shader = NULL; + + getShaders(NULL, &video_shader); + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onShaderParamSliderValueChanged(int))); box->addWidget(slider); diff --git a/ui/drivers/qt/shaderparamsdialog.h b/ui/drivers/qt/shaderparamsdialog.h index 309e785234..4a0732180c 100644 --- a/ui/drivers/qt/shaderparamsdialog.h +++ b/ui/drivers/qt/shaderparamsdialog.h @@ -4,6 +4,10 @@ #include #include +extern "C" { +#include "../.././gfx/video_shader_parse.h" +} + class QCloseEvent; class QResizeEvent; class QVBoxLayout; @@ -11,6 +15,15 @@ class QFormLayout; class QLayout; class QScrollArea; +class ShaderPass +{ +public: + ShaderPass(struct video_shader_pass *passToCopy = NULL); + ~ShaderPass(); + ShaderPass& operator=(const ShaderPass &other); + struct video_shader_pass *pass; +}; + class ShaderParamsDialog : public QDialog { Q_OBJECT