summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/frontend/mame/ui/slider.h2
-rw-r--r--src/frontend/mame/ui/ui.cpp59
-rw-r--r--src/frontend/mame/ui/ui.h4
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp9
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.h2
-rw-r--r--src/osd/modules/render/bgfx/inputpair.cpp28
-rw-r--r--src/osd/modules/render/bgfx/inputpair.h3
-rw-r--r--src/osd/modules/render/bgfx/slider.cpp11
-rw-r--r--src/osd/modules/render/bgfx/slider.h10
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp11
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h5
11 files changed, 78 insertions, 66 deletions
diff --git a/src/frontend/mame/ui/slider.h b/src/frontend/mame/ui/slider.h
index 75f2bd3336e..5e0613743aa 100644
--- a/src/frontend/mame/ui/slider.h
+++ b/src/frontend/mame/ui/slider.h
@@ -32,7 +32,7 @@ struct slider_state
int32_t maxval; /* maximum value */
int32_t incval; /* increment value */
int id;
- char description[1]; /* textual description */
+ std::string description; /* textual description */
};
#endif // __UI_SLIDER__
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index a7434c6df54..b64ef909033 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -1332,10 +1332,9 @@ std::vector<ui::menu_item>& mame_ui_manager::get_slider_list(void)
// slider_alloc - allocate a new slider entry
//-------------------------------------------------
-slider_state* mame_ui_manager::slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
+std::unique_ptr<slider_state> mame_ui_manager::slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
{
- int size = sizeof(slider_state) + strlen(title);
- slider_state *state = (slider_state *)auto_alloc_array_clear(machine, uint8_t, size);
+ auto state = make_unique_clear<slider_state>();
state->minval = minval;
state->defval = defval;
@@ -1347,7 +1346,7 @@ slider_state* mame_ui_manager::slider_alloc(running_machine &machine, int id, co
state->arg = arg;
state->id = id;
- strcpy(state->description, title);
+ state->description = title;
return state;
}
@@ -1360,10 +1359,10 @@ slider_state* mame_ui_manager::slider_alloc(running_machine &machine, int id, co
std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine)
{
- std::vector<slider_state *> sliders;
+ m_sliders.clear();
// add overall volume
- sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr));
// add per-channel volume
mixer_input info;
@@ -1373,7 +1372,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
int32_t defval = 1000;
std::string str = string_format(_("%1$s Volume"), info.stream->input_name(info.inputnum));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_MIXERVOL + item, str.c_str(), 0, defval, maxval, 20, (void *)(uintptr_t)item));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_MIXERVOL + item, str.c_str(), 0, defval, maxval, 20, (void *)(uintptr_t)item));
}
// add analog adjusters
@@ -1384,7 +1383,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
{
if (field.type() == IPT_ADJUSTER)
{
- sliders.push_back(slider_alloc(machine, SLIDER_ID_ADJUSTER + slider_index++, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, (void *)&field));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_ADJUSTER + slider_index++, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, (void *)&field));
}
}
}
@@ -1397,7 +1396,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
{
void *param = (void *)&exec.device();
std::string str = string_format(_("Overclock CPU %1$s"), exec.device().tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param));
}
for (device_sound_interface &snd : sound_interface_iterator(machine.root_device()))
{
@@ -1406,7 +1405,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
{
void *param = (void *)&snd.device();
std::string str = string_format(_("Overclock %1$s sound"), snd.device().tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param));
}
}
}
@@ -1427,26 +1426,26 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
if (machine.options().cheat())
{
std::string str = string_format(_("%1$s Refresh Rate"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param));
}
// add standard brightness/contrast/gamma controls per-screen
std::string str = string_format(_("%1$s Brightness"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_BRIGHTNESS + slider_index, str.c_str(), 100, 1000, 2000, 10, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_BRIGHTNESS + slider_index, str.c_str(), 100, 1000, 2000, 10, param));
str = string_format(_("%1$s Contrast"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_CONTRAST + slider_index, str.c_str(), 100, 1000, 2000, 50, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_CONTRAST + slider_index, str.c_str(), 100, 1000, 2000, 50, param));
str = string_format(_("%1$s Gamma"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_GAMMA + slider_index, str.c_str(), 100, 1000, 3000, 50, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_GAMMA + slider_index, str.c_str(), 100, 1000, 3000, 50, param));
// add scale and offset controls per-screen
str = string_format(_("%1$s Horiz Stretch"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_XSCALE + slider_index, str.c_str(), 500, defxscale, 1500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_XSCALE + slider_index, str.c_str(), 500, defxscale, 1500, 2, param));
str = string_format(_("%1$s Horiz Position"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_XOFFSET + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_XOFFSET + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
str = string_format(_("%1$s Vert Stretch"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_YSCALE + slider_index, str.c_str(), 500, defyscale, 1500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_YSCALE + slider_index, str.c_str(), 500, defyscale, 1500, 2, param));
str = string_format(_("%1$s Vert Position"), screen_desc);
- sliders.push_back(slider_alloc(machine, SLIDER_ID_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
slider_index++;
}
@@ -1465,13 +1464,13 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
// add scale and offset controls per-overlay
std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XSCALE + slider_index, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XSCALE + slider_index, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, param));
str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YSCALE + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YSCALE + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XOFFSET + slider_index, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XOFFSET + slider_index, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, param));
str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
slider_index++;
}
}
@@ -1482,10 +1481,10 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
if (screen.screen_type() == SCREEN_TYPE_VECTOR)
{
// add vector control
- sliders.push_back(slider_alloc(machine, SLIDER_ID_FLICKER + slider_index, _("Vector Flicker"), 0, 0, 1000, 10, nullptr));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MIN + slider_index, _("Beam Width Minimum"), 100, 100, 1000, 1, nullptr));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MAX + slider_index, _("Beam Width Maximum"), 100, 100, 1000, 1, nullptr));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_INTENSITY + slider_index, _("Beam Intensity Weight"), -1000, 0, 1000, 10, nullptr));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_FLICKER + slider_index, _("Vector Flicker"), 0, 0, 1000, 10, nullptr));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MIN + slider_index, _("Beam Width Minimum"), 100, 100, 1000, 1, nullptr));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MAX + slider_index, _("Beam Width Maximum"), 100, 100, 1000, 1, nullptr));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_INTENSITY + slider_index, _("Beam Intensity Weight"), -1000, 0, 1000, 10, nullptr));
slider_index++;
break;
}
@@ -1501,22 +1500,22 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.player() == 0)
{
std::string str = string_format(_("Crosshair Scale %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y"));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_SCALE + slider_index, str.c_str(), -3000, 1000, 3000, 100, (void *)&field));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_SCALE + slider_index, str.c_str(), -3000, 1000, 3000, 100, (void *)&field));
str = string_format(_("Crosshair Offset %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y"));
- sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_OFFSET + slider_index, str.c_str(), -3000, 0, 3000, 100, (void *)&field));
+ m_sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_OFFSET + slider_index, str.c_str(), -3000, 0, 3000, 100, (void *)&field));
}
}
}
#endif
std::vector<ui::menu_item> items;
- for (slider_state *slider : sliders)
+ for (auto &slider : m_sliders)
{
ui::menu_item item;
item.text = slider->description;
item.subtext = "";
item.flags = 0;
- item.ref = slider;
+ item.ref = slider.get();
item.type = ui::menu_item_type::SLIDER;
items.push_back(item);
}
diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h
index 02695a56bf3..e7fa657a879 100644
--- a/src/frontend/mame/ui/ui.h
+++ b/src/frontend/mame/ui/ui.h
@@ -266,7 +266,7 @@ private:
// private methods
void exit();
- slider_state* slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
+ std::unique_ptr<slider_state> slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
// slider controls
virtual int32_t slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval) override;
@@ -296,6 +296,8 @@ private:
int32_t slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
#endif
+
+ std::vector<std::unique_ptr<slider_state>> m_sliders;
};
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index 653caf0626e..f3b12dfa125 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -394,9 +394,7 @@ void chain_manager::create_selection_slider(uint32_t screen_index)
return;
}
- std::string description = "Window " + std::to_string(m_window_index) + ", Screen " + std::to_string(screen_index) + " Effect:";
- size_t size = sizeof(slider_state) + description.length();
- slider_state *state = reinterpret_cast<slider_state *>(auto_alloc_array_clear(m_machine, uint8_t, size));
+ std::unique_ptr<slider_state> state = make_unique_clear<slider_state>();
state->minval = 0;
state->defval = m_current_chain[screen_index];
@@ -407,15 +405,16 @@ void chain_manager::create_selection_slider(uint32_t screen_index)
state->update = std::bind(&chain_manager::slider_changed, this, _1, _2, _3, _4, _5);
state->arg = this;
state->id = screen_index;
- strcpy(state->description, description.c_str());
+ state->description = "Window " + std::to_string(m_window_index) + ", Screen " + std::to_string(screen_index) + " Effect:";
ui::menu_item item;
item.text = state->description;
item.subtext = "";
item.flags = 0;
- item.ref = state;
+ item.ref = state.get();
item.type = ui::menu_item_type::SLIDER;
m_selection_sliders.push_back(item);
+ m_core_sliders.push_back(std::move(state));
}
uint32_t chain_manager::handle_screen_chains(uint32_t view, render_primitive *starting_prim, osd_window& window)
diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h
index 6306201f692..4c76a02ee25 100644
--- a/src/osd/modules/render/bgfx/chainmanager.h
+++ b/src/osd/modules/render/bgfx/chainmanager.h
@@ -26,6 +26,7 @@
class running_machine;
class osd_window;
+struct slider_state;
class slider_dirty_notifier;
class render_primitive;
@@ -103,6 +104,7 @@ private:
std::vector<bgfx_chain*> m_screen_chains;
std::vector<std::string> m_chain_names;
std::vector<ui::menu_item> m_selection_sliders;
+ std::vector<std::unique_ptr<slider_state>> m_core_sliders;
std::vector<int32_t> m_current_chain;
static const uint32_t CHAIN_NONE;
diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp
index 19d0136e72e..98d0594e27a 100644
--- a/src/osd/modules/render/bgfx/inputpair.cpp
+++ b/src/osd/modules/render/bgfx/inputpair.cpp
@@ -40,6 +40,10 @@ bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string tex
}
}
+bgfx_input_pair::~bgfx_input_pair()
+{
+}
+
void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const
{
assert(effect->uniform(m_sampler) != nullptr);
@@ -95,26 +99,24 @@ int32_t bgfx_input_pair::texture_changed(int32_t id, std::string *str, int32_t n
void bgfx_input_pair::create_selection_slider(uint32_t screen_index)
{
- std::string description = "Window " + std::to_string(chains().window_index()) + ", Screen " + std::to_string(screen_index) + " " + m_selection + ":";
- size_t size = sizeof(slider_state) + description.length();
- slider_state *state = reinterpret_cast<slider_state *>(auto_alloc_array_clear(chains().machine(), uint8_t, size));
+ m_slider_state = make_unique_clear<slider_state>();
- state->minval = 0;
- state->defval = m_current_texture;
- state->maxval = m_available_textures.size() - 1;
- state->incval = 1;
+ m_slider_state->minval = 0;
+ m_slider_state->defval = m_current_texture;
+ m_slider_state->maxval = m_available_textures.size() - 1;
+ m_slider_state->incval = 1;
using namespace std::placeholders;
- state->update = std::bind(&bgfx_input_pair::slider_changed, this, _1, _2, _3, _4, _5);
- state->arg = this;
- state->id = screen_index;
- strcpy(state->description, description.c_str());
+ m_slider_state->update = std::bind(&bgfx_input_pair::slider_changed, this, _1, _2, _3, _4, _5);
+ m_slider_state->arg = this;
+ m_slider_state->id = screen_index;
+ m_slider_state->description = "Window " + std::to_string(chains().window_index()) + ", Screen " + std::to_string(screen_index) + " " + m_selection + ":";
ui::menu_item item;
- item.text = state->description;
+ item.text = m_slider_state->description;
item.subtext = "";
item.flags = 0;
- item.ref = state;
+ item.ref = m_slider_state.get();
item.type = ui::menu_item_type::SLIDER;
m_selection_slider = item;
}
diff --git a/src/osd/modules/render/bgfx/inputpair.h b/src/osd/modules/render/bgfx/inputpair.h
index 534d4c47dfc..fb3fc58e1f7 100644
--- a/src/osd/modules/render/bgfx/inputpair.h
+++ b/src/osd/modules/render/bgfx/inputpair.h
@@ -19,6 +19,7 @@
#include "../frontend/mame/ui/menuitem.h"
#include "../frontend/mame/ui/sliderchangednotifier.h"
+struct slider_state;
class bgfx_effect;
class chain_manager;
@@ -26,6 +27,7 @@ class bgfx_input_pair : public slider_changed_notifier
{
public:
bgfx_input_pair(int index, std::string sampler, std::string texture, std::vector<std::string> available_textures, std::string selection, chain_manager& chains, uint32_t screen_index);
+ ~bgfx_input_pair();
void bind(bgfx_effect *effect, const int32_t screen) const;
int32_t texture_changed(int32_t index, std::string *str, int32_t newval);
@@ -49,6 +51,7 @@ private:
chain_manager& m_chains;
int32_t m_current_texture;
ui::menu_item m_selection_slider;
+ std::unique_ptr<slider_state> m_slider_state;
};
#endif // __DRAWBGFX_INPUT_PAIR__
diff --git a/src/osd/modules/render/bgfx/slider.cpp b/src/osd/modules/render/bgfx/slider.cpp
index 0b09dc579dc..0cc97275497 100644
--- a/src/osd/modules/render/bgfx/slider.cpp
+++ b/src/osd/modules/render/bgfx/slider.cpp
@@ -9,7 +9,7 @@
#include "emu.h"
#include "slider.h"
-#include "ui/uimain.h"
+#include "../frontend/mame/ui/slider.h"
bgfx_slider::bgfx_slider(running_machine &machine, std::string name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings)
: m_name(name)
@@ -30,7 +30,7 @@ bgfx_slider::bgfx_slider(running_machine &machine, std::string name, float min,
m_strings.push_back(string);
}
- m_slider_state = create_core_slider(machine);
+ m_slider_state = create_core_slider();
}
bgfx_slider::~bgfx_slider()
@@ -52,10 +52,9 @@ void bgfx_slider::import(float val)
slider_changed(m_machine, this, m_slider_state->id, nullptr, int32_t(floor(m_value / m_step + 0.5f)));
}
-slider_state* bgfx_slider::create_core_slider(running_machine& machine)
+std::unique_ptr<slider_state> bgfx_slider::create_core_slider()
{
- int size = sizeof(slider_state) + m_description.length();
- slider_state *state = reinterpret_cast<slider_state *>(auto_alloc_array_clear(machine, uint8_t, size));
+ auto state = make_unique_clear<slider_state>();
state->minval = int32_t(floor(m_min / m_step + 0.5f));
state->defval = int32_t(floor(m_default / m_step + 0.5f));
@@ -67,7 +66,7 @@ slider_state* bgfx_slider::create_core_slider(running_machine& machine)
state->arg = this;
state->id = 0;
- strcpy(state->description, m_description.c_str());
+ state->description = m_description;
return state;
}
diff --git a/src/osd/modules/render/bgfx/slider.h b/src/osd/modules/render/bgfx/slider.h
index 74f19c7e4bc..d59f8587bd3 100644
--- a/src/osd/modules/render/bgfx/slider.h
+++ b/src/osd/modules/render/bgfx/slider.h
@@ -16,7 +16,9 @@
#include <string>
#include <vector>
-#include "../frontend/mame/ui/slider.h"
+#include "../frontend/mame/ui/sliderchangednotifier.h"
+
+struct slider_state;
class bgfx_slider : public slider_changed_notifier
{
@@ -52,7 +54,7 @@ public:
slider_type type() const { return m_type; }
float value() const { return m_value; }
float uniform_value() const { return float(m_value); }
- slider_state* core_slider() const { return m_slider_state; }
+ slider_state *core_slider() const { return m_slider_state.get(); }
size_t size() const { return get_size_for_type(m_type); }
static size_t get_size_for_type(slider_type type);
@@ -61,7 +63,7 @@ public:
protected:
virtual int32_t slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, int32_t newval) override;
- slider_state* create_core_slider(running_machine &machine);
+ std::unique_ptr<slider_state> create_core_slider();
int32_t as_int() const { return int32_t(floor(m_value / m_step + 0.5f)); }
std::string m_name;
@@ -75,7 +77,7 @@ protected:
std::string m_description;
std::vector<std::string> m_strings;
float m_value;
- slider_state* m_slider_state;
+ std::unique_ptr<slider_state> m_slider_state;
running_machine&m_machine;
};
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 63045dc1fce..6a72e6f5369 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -1807,10 +1807,9 @@ static void get_vector(const char *data, int count, float *out, bool report_erro
// be done in a more ideal way.
//============================================================
-slider_state* shaders::slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
+std::unique_ptr<slider_state> shaders::slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
{
- int size = sizeof(slider_state) + strlen(title);
- slider_state *state = reinterpret_cast<slider_state *>(auto_alloc_array_clear(machine, uint8_t, size));
+ auto state = make_unique_clear<slider_state>();
state->minval = minval;
state->defval = defval;
@@ -1822,7 +1821,7 @@ slider_state* shaders::slider_alloc(running_machine &machine, int id, const char
state->arg = arg;
state->id = id;
- strcpy(state->description, title);
+ state->description = title;
return state;
}
@@ -2126,6 +2125,7 @@ void *shaders::get_slider_option(int id, int index)
void shaders::init_slider_list()
{
m_sliders.clear();
+ m_core_sliders.clear();
for (slider* slider : internal_sliders)
{
@@ -2184,7 +2184,7 @@ void shaders::init_slider_list()
break;
}
- slider_state* core_slider = slider_alloc(*machine, desc->id, name.c_str(), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg);
+ std::unique_ptr<slider_state> core_slider = slider_alloc(desc->id, name.c_str(), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg);
ui::menu_item item;
item.text = core_slider->description;
@@ -2193,6 +2193,7 @@ void shaders::init_slider_list()
item.ref = core_slider;
item.type = ui::menu_item_type::SLIDER;
m_sliders.push_back(item);
+ m_core_sliders.push_back(std::move(core_slider));
}
}
}
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index ed25d2c52e8..ff4c7527a52 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -21,6 +21,8 @@
// Typedefs for dynamically loaded functions
typedef HRESULT (WINAPI *d3dx_create_effect_from_file_fn)(LPDIRECT3DDEVICE9, LPCTSTR, const D3DXMACRO *, LPD3DXINCLUDE, DWORD, LPD3DXEFFECTPOOL, LPD3DXEFFECT *, LPD3DXBUFFER *);
+struct slider_state;
+
class effect;
class shaders;
@@ -309,7 +311,7 @@ public:
// slider-related functions
virtual int32_t slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, int32_t newval) override;
- slider_state* slider_alloc(running_machine &machine, int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
+ std::unique_ptr<slider_state> slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
void init_slider_list();
std::vector<ui::menu_item> get_slider_list() { return m_sliders; }
void *get_slider_option(int id, int index = 0);
@@ -396,6 +398,7 @@ private:
std::vector<slider*> internal_sliders;
std::vector<ui::menu_item> m_sliders;
+ std::vector<std::unique_ptr<slider_state>> m_core_sliders;
static slider_desc s_sliders[];
static hlsl_options last_options; // last used options