summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/rendlay.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-10-30 03:11:15 +1100
committer Vas Crabb <vas@vastheman.com>2023-10-30 03:11:15 +1100
commite4ceeee56741ebf1e72c2d2a33f94dfa1d251c11 (patch)
treed520a5fe0f93db9016bedae33a46dab2e3a893a6 /src/emu/rendlay.cpp
parent08a9011cfba71c153a2c958328545408f9c1b00e (diff)
Added some additional layout functionality and script bindings.
Also corrected some copy/paste errors in documentation, and bumped documentation version as it now describes features that will appear in an upcoming release.
Diffstat (limited to 'src/emu/rendlay.cpp')
-rw-r--r--src/emu/rendlay.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 9c720f2ae8e..d320999bd96 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -1277,6 +1277,7 @@ layout_element::layout_element(environment &env, util::xml::data_node const &ele
, m_defstate(env.get_attribute_int(elemnode, "defstate", -1))
, m_statemask(0)
, m_foldhigh(false)
+ , m_invalidated(false)
{
// parse components in order
bool first = true;
@@ -1647,6 +1648,17 @@ render_texture *layout_element::state_texture(int state)
//-------------------------------------------------
+// set_draw_callback - set handler called after
+// drawing components
+//-------------------------------------------------
+
+void layout_element::set_draw_callback(draw_delegate &&handler)
+{
+ m_draw = std::move(handler);
+}
+
+
+//-------------------------------------------------
// preload - perform expensive loading upfront
// for all components
//-------------------------------------------------
@@ -1659,6 +1671,25 @@ void layout_element::preload()
//-------------------------------------------------
+// prepare - perform additional tasks before
+// drawing a frame
+//-------------------------------------------------
+
+void layout_element::prepare()
+{
+ if (m_invalidated)
+ {
+ m_invalidated = false;
+ for (texture &tex : m_elemtex)
+ {
+ machine().render().texture_free(tex.m_texture);
+ tex.m_texture = nullptr;
+ }
+ }
+}
+
+
+//-------------------------------------------------
// element_scale - scale an element by rendering
// all the components at the appropriate
// resolution
@@ -1674,6 +1705,10 @@ void layout_element::element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, c
if ((elemtex.m_state & curcomp->statemask()) == curcomp->stateval())
curcomp->draw(elemtex.m_element->machine(), dest, elemtex.m_state);
}
+
+ // if there's a callback for additional drawing, invoke it
+ if (!elemtex.m_element->m_draw.isnull())
+ elemtex.m_element->m_draw(elemtex.m_state, dest);
}
@@ -3490,7 +3525,7 @@ layout_element::texture::texture(texture &&that) : texture()
layout_element::texture::~texture()
{
- if (m_element != nullptr)
+ if (m_element)
m_element->machine().render().texture_free(m_texture);
}
@@ -3986,6 +4021,7 @@ layout_view::layout_view(
: m_effaspect(1.0f)
, m_name(make_name(env, viewnode))
, m_unqualified_name(env.get_attribute_string(viewnode, "name"))
+ , m_elemmap(elemmap)
, m_defvismask(0U)
, m_has_art(false)
{
@@ -4132,6 +4168,21 @@ bool layout_view::has_visible_screen(screen_device const &screen) const
//-------------------------------------------------
+// prepare_items - perform additional tasks
+// before rendering a frame
+//-------------------------------------------------
+
+void layout_view::prepare_items()
+{
+ if (!m_prepare_items.isnull())
+ m_prepare_items();
+
+ for (auto &[name, element] : m_elemmap)
+ element.prepare();
+}
+
+
+//-------------------------------------------------
// recompute - recompute the bounds and aspect
// ratio of a view and all of its contained items
//-------------------------------------------------