summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/render.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-09-16 02:55:04 +1000
committer Vas Crabb <vas@vastheman.com>2020-09-16 02:55:04 +1000
commit6adc5080154819eb7543cb35328082280804fb07 (patch)
tree7212c7a3869d9d3c6b92a955b0d856f20b08b0a6 /src/emu/render.h
parent523b1f11cffd7bfebb8ed0a7f35204f871dadeb0 (diff)
emu/rendlay.cpp: Added parameter animation and state masks.
Components may have multiple bounds and/or color child elements with state attributes, allowing for piecewise linear position/size/colour animation. Components may have a statemask attribute, allowing for things like using external images to draw a multi-segment LED/VFD display without requiring dozens of outputs for the individual lines or thousands of images for all possible states. (Texture caching still never releases anything, so MAME can still exceed the maximum number of textures, but that’s a separate issue.) Image components with alpha now blend over previously drawn components. Layouts have been changed to use yes/no for inputraw to match what's used for flipx/flipy. External layouts with 1/0 will still work, but complay.py will complain.
Diffstat (limited to 'src/emu/render.h')
-rw-r--r--src/emu/render.h46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/emu/render.h b/src/emu/render.h
index b0d0df82d3c..1545a3f041d 100644
--- a/src/emu/render.h
+++ b/src/emu/render.h
@@ -579,7 +579,6 @@ public:
// getters
running_machine &machine() const { return m_machine; }
int default_state() const { return m_defstate; }
- int maxstate() const { return m_maxstate; }
render_texture *state_texture(int state);
private:
@@ -603,17 +602,22 @@ private:
void normalize_bounds(float xoffs, float yoffs, float xscale, float yscale);
// getters
- int state() const { return m_state; }
- virtual int maxstate() const { return m_state; }
- const render_bounds &bounds() const { return m_bounds; }
- const render_color &color() const { return m_color; }
+ int statemask() const { return m_statemask; }
+ int stateval() const { return m_stateval; }
+ std::pair<int, bool> statewrap() const;
+ render_bounds overall_bounds() const;
+ render_bounds bounds(int state) const;
+ render_color color(int state) const;
// operations
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) = 0;
protected:
- // helpers
- void draw_text(render_font &font, bitmap_argb32 &dest, const rectangle &bounds, const char *str, int align);
+ // helper
+ virtual int maxstate() const { return -1; }
+
+ // drawing helpers
+ void draw_text(render_font &font, bitmap_argb32 &dest, const rectangle &bounds, const char *str, int align, const render_color &color);
void draw_segment_horizontal_caps(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, int caps, rgb_t color);
void draw_segment_horizontal(bitmap_argb32 &dest, int minx, int maxx, int midy, int width, rgb_t color);
void draw_segment_vertical_caps(bitmap_argb32 &dest, int miny, int maxy, int midx, int width, int caps, rgb_t color);
@@ -625,10 +629,27 @@ private:
void apply_skew(bitmap_argb32 &dest, int skewwidth);
private:
+ struct bounds_step
+ {
+ int state;
+ render_bounds bounds;
+ render_bounds delta;
+ };
+ using bounds_vector = std::vector<bounds_step>;
+
+ struct color_step
+ {
+ int state;
+ render_color color;
+ render_color delta;
+ };
+ using color_vector = std::vector<color_step>;
+
// internal state
- int m_state; // state where this component is visible (-1 means all states)
- render_bounds m_bounds; // bounds of the element
- render_color m_color; // color of the element
+ int const m_statemask; // bits of state used to control visibility
+ int const m_stateval; // masked state value to make component visible
+ bounds_vector m_bounds; // bounds of the element
+ color_vector m_color; // color of the element
};
// component implementations
@@ -677,8 +698,9 @@ private:
// internal state
running_machine & m_machine; // reference to the owning machine
std::vector<component::ptr> m_complist; // list of components
- int m_defstate; // default state of this element
- int m_maxstate; // maximum state value for all components
+ int const m_defstate; // default state of this element
+ int m_statemask; // mask to apply to state values
+ bool m_foldhigh; // whether we need to fold state values above the mask range
std::vector<texture> m_elemtex; // array of element textures used for managing the scaled bitmaps
};