diff options
author | 2016-02-18 15:57:34 +0100 | |
---|---|---|
committer | 2016-02-21 03:03:23 +0100 | |
commit | 9a47a870df619656e9092f2f77622e84e640307a (patch) | |
tree | b8640bf79ffb55d0c9ed6fc27bbd4ce16a5e1a2e /src/osd/modules/osdwindow.h | |
parent | dadf8e7d79696996ab3ef840fe99a588ede538fa (diff) |
First take on render API reorg, nw
Diffstat (limited to 'src/osd/modules/osdwindow.h')
-rw-r--r-- | src/osd/modules/osdwindow.h | 135 |
1 files changed, 120 insertions, 15 deletions
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index d4c2a4101cc..69f3675d4d0 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -9,13 +9,122 @@ #ifndef __OSDWINDOW__ #define __OSDWINDOW__ -#include "video.h" -#include "render.h" +#include "emu.h" //============================================================ // TYPE DEFINITIONS //============================================================ +class osd_options; +class render_primitive_list; + +enum +{ + VIDEO_MODE_NONE, + VIDEO_MODE_GDI, + VIDEO_MODE_BGFX, +#if (USE_OPENGL) + VIDEO_MODE_OPENGL, +#endif + VIDEO_MODE_SDL2ACCEL, + VIDEO_MODE_D3D, + VIDEO_MODE_SOFT +}; + +class osd_dim +{ +public: + osd_dim(const int &w, const int &h) + : m_w(w), m_h(h) + { + } + int width() const { return m_w; } + int height() const { return m_h; } + + bool operator!=(const osd_dim &other) { return (m_w != other.width()) || (m_h != other.height()); } + bool operator==(const osd_dim &other) { return (m_w == other.width()) && (m_h == other.height()); } +private: + int m_w; + int m_h; +}; + +class osd_rect +{ +public: + osd_rect() + : m_x(0), m_y(0), m_d(0,0) + { + } + osd_rect(const int x, const int y, const int &w, const int &h) + : m_x(x), m_y(y), m_d(w,h) + { + } + osd_rect(const int x, const int y, const osd_dim &d) + : m_x(x), m_y(y), m_d(d) + { + } + int top() const { return m_y; } + int left() const { return m_x; } + int width() const { return m_d.width(); } + int height() const { return m_d.height(); } + + osd_dim dim() const { return m_d; } + + int bottom() const { return m_y + m_d.height(); } + int right() const { return m_x + m_d.width(); } + + osd_rect move_by(int dx, int dy) const { return osd_rect(m_x + dx, m_y + dy, m_d); } + osd_rect resize(int w, int h) const { return osd_rect(m_x, m_y, w, h); } + +private: + int m_x; + int m_y; + osd_dim m_d; +}; + +class osd_monitor_info +{ +public: + osd_monitor_info(void *handle, const char *monitor_device, float aspect) + : m_next(NULL), m_handle(handle), m_aspect(aspect) + { + strncpy(m_name, monitor_device, ARRAY_LENGTH(m_name) - 1); + } + + virtual ~osd_monitor_info() { } + + virtual void refresh() = 0; + + const void *oshandle() { return m_handle; } + + const osd_rect &position_size() { return m_pos_size; } + const osd_rect &usuable_position_size() { return m_usuable_pos_size; } + + const char *devicename() { return m_name[0] ? m_name : "UNKNOWN"; } + + float aspect(); + + void set_aspect(const float a) { m_aspect = a; } + bool is_primary() { return m_is_primary; } + + osd_monitor_info * next() { return m_next; } // pointer to next monitor in list + + static osd_monitor_info *pick_monitor(osd_options &options, int index); + static osd_monitor_info *list; + + // FIXME: should be private! + osd_monitor_info *m_next; // pointer to next monitor in list +protected: + osd_rect m_pos_size; + osd_rect m_usuable_pos_size; + bool m_is_primary; + char m_name[64]; +private: + + void * m_handle; // handle to the monitor + float m_aspect; // computed/configured aspect ratio of the physical device +}; + class osd_window_config { public: @@ -33,8 +142,7 @@ class osd_window public: osd_window() : -#ifdef OSD_SDL -#else +#ifndef OSD_SDL m_hwnd(0), m_dc(0), m_focus_hwnd(0), m_resize_state(0), #endif m_primlist(nullptr), @@ -110,27 +218,24 @@ public: /* Interface to be implemented by render code */ virtual int create() = 0; + virtual int init(running_machine &machine) = 0; virtual render_primitive_list *get_primitives() = 0; virtual int draw(const int update) = 0; -#ifdef OSD_SDL - virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0; -#else - virtual void save() = 0; - virtual void record() = 0; - virtual void toggle_fsfx() = 0; -#endif + virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) { return 0; }; + virtual void save() { }; + virtual void record() { }; + virtual void toggle_fsfx() { }; - virtual void destroy() = 0; + static osd_renderer* make_for_type(int mode, osd_window *window, int extra_flags = FLAG_NONE); protected: /* Internal flags */ static const int FI_CHANGED = 0x010000; private: - - osd_window *m_window; - int m_flags; + osd_window *m_window; + int m_flags; }; |