summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render')
-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
8 files changed, 45 insertions, 34 deletions
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