summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2020-06-27 14:09:56 +0200
committer mooglyguy <therealmogminer@gmail.com>2020-06-27 14:09:56 +0200
commit15c1b81f5c33f1a852a3b9bc71561ac8f48de72d (patch)
treecbca5960e38c411e9b3defb5a3b6682ecc4da7bb
parent6443f8257cf727bbb6ff020fe9b1383db324823e (diff)
-render: Added optional per-frame update support to layout elements. [Ryan Holtz]rendlay_vid
-rw-r--r--src/emu/render.cpp17
-rw-r--r--src/emu/render.h14
-rw-r--r--src/emu/rendlay.cpp22
3 files changed, 45 insertions, 8 deletions
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index b6afedd8870..ebea5e01d9b 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -314,7 +314,7 @@ render_texture::~render_texture()
// it has been re-allocated
//-------------------------------------------------
-void render_texture::reset(render_manager &manager, texture_scaler_func scaler, void *param)
+void render_texture::reset(render_manager &manager, texture_scaler_func scaler, void *param, texture_dirty_func dirty)
{
m_manager = &manager;
if (scaler != nullptr)
@@ -323,6 +323,7 @@ void render_texture::reset(render_manager &manager, texture_scaler_func scaler,
m_scaler = scaler;
m_param = param;
}
+ m_dirty = dirty;
m_old_id = m_id;
m_id = ~0L;
}
@@ -463,7 +464,7 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
if (-1 == lowest)
throw emu_fatalerror("render_texture::get_scaled: Too many live texture instances!");
- // throw out any existing entries
+ // throw out any existing entries or update the current one if dirty
scaled = &m_scaled[lowest];
if (scaled->bitmap != nullptr)
{
@@ -478,6 +479,14 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
// let the scaler do the work
(*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
}
+ else if (m_dirty && (*m_dirty)(m_param))
+ {
+ scaled = &m_scaled[scalenum];
+ scaled->seqid = ++m_curseq;
+
+ // let the scaler do the work
+ (*m_scaler)(*scaled->bitmap, srcbitmap, m_sbounds, m_param);
+ }
// finally fill out the new info
primlist.add_reference(scaled->bitmap);
@@ -3095,11 +3104,11 @@ float render_manager::ui_aspect(render_container *rc)
// texture_alloc - allocate a new texture
//-------------------------------------------------
-render_texture *render_manager::texture_alloc(texture_scaler_func scaler, void *param)
+render_texture *render_manager::texture_alloc(texture_scaler_func scaler, void *param, texture_dirty_func dirty)
{
// allocate a new texture and reset it
render_texture *tex = m_texture_allocator.alloc();
- tex->reset(*this, scaler, param);
+ tex->reset(*this, scaler, param, dirty);
tex->set_id(m_texture_id);
m_texture_id++;
m_live_textures++;
diff --git a/src/emu/render.h b/src/emu/render.h
index b87d59f5bfa..b3396bcae21 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -164,7 +164,10 @@ constexpr u32 PRIMFLAG_GET_VECTORBUF(u32 x) { return (x & PRIMFLAG_VECTORBUF_MAS
//**************************************************************************
// texture scaling callback
-typedef void (*texture_scaler_func)(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
+typedef void (*texture_scaler_func)(bitmap_argb32& dest, bitmap_argb32& source, const rectangle& sbounds, void* param);
+
+// texture scaling callback
+typedef bool (*texture_dirty_func)(void* dirty_param);
// render_bounds - floating point bounding rectangle
struct render_bounds
@@ -372,7 +375,7 @@ class render_texture
~render_texture();
// reset before re-use
- void reset(render_manager &manager, texture_scaler_func scaler = nullptr, void *param = nullptr);
+ void reset(render_manager &manager, texture_scaler_func scaler = nullptr, void *param = nullptr, texture_dirty_func dirty = nullptr);
// release resources when freed
void release();
@@ -419,6 +422,9 @@ private:
void * m_param; // scaling callback parameter
u32 m_curseq; // current sequence number
scaled_texture m_scaled[MAX_TEXTURE_SCALES];// array of scaled variants of this texture
+
+ // dirty state
+ texture_dirty_func m_dirty; // dirty callback
};
@@ -598,6 +604,7 @@ private:
const render_bounds &bounds() const { return m_bounds; }
const render_color &color() const { return m_color; }
const char* artname() const { return m_artname; }
+ virtual bool is_dirty() const { return false; }
// operations
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) = 0;
@@ -661,6 +668,7 @@ private:
typedef std::map<std::string, make_component_func> make_component_map;
// internal helpers
+ static bool element_dirty(void* dirty_param);
static void element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
template <typename T> static component::ptr make_component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
template <int D> static component::ptr make_dotmatrix_component(environment &env, util::xml::data_node const &compnode, const char *artname, const char *dirname);
@@ -1082,7 +1090,7 @@ public:
render_container &ui_container() const { assert(m_ui_container != nullptr); return *m_ui_container; }
// textures
- render_texture *texture_alloc(texture_scaler_func scaler = nullptr, void *param = nullptr);
+ render_texture *texture_alloc(texture_scaler_func scaler = nullptr, void *param = nullptr, texture_dirty_func dirty = nullptr);
void texture_free(render_texture *texture);
// fonts
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 87b84b8c7f0..a233e24d305 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -1195,13 +1195,31 @@ render_texture *layout_element::state_texture(int state)
{
m_elemtex[state].m_element = this;
m_elemtex[state].m_state = state;
- m_elemtex[state].m_texture = machine().render().texture_alloc(element_scale, &m_elemtex[state]);
+ m_elemtex[state].m_texture = machine().render().texture_alloc(element_scale, &m_elemtex[state], element_dirty);
}
return m_elemtex[state].m_texture;
}
//-------------------------------------------------
+// element_dirty - return whether or not any
+// given components in the element needs an
+// update
+//-------------------------------------------------
+
+bool layout_element::element_dirty(void *dirty_param)
+{
+ texture* elemtex = (texture *)dirty_param;
+
+ // iterate over components that are part of the current state
+ for (auto& curcomp : elemtex->m_element->m_complist)
+ if (curcomp->is_dirty())
+ return true;
+
+ return false;
+}
+
+//-------------------------------------------------
// element_scale - scale an element by rendering
// all the components at the appropriate
// resolution
@@ -1328,6 +1346,8 @@ public:
m_file = std::make_unique<emu_file>(env.machine().options().art_path(), OPEN_FLAG_READ);
}
+ bool is_dirty() const override { return true; }
+
protected:
// overrides
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override