summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-01-04 23:09:05 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-01-04 23:09:05 -0500
commit7989b4ca46d339efc8fee611b306697d230e6012 (patch)
tree77c4f0e27201d6edc38ea0d8e46565bfeaeb2cb1 /src/osd
parent403f7a099af070e5a5eca1c7742d01933c94a774 (diff)
osdwindow.cpp: Centralize basic functions; de-virtualize various getters
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/mac/window.cpp108
-rw-r--r--src/osd/mac/window.h21
-rw-r--r--src/osd/modules/osdwindow.cpp62
-rw-r--r--src/osd/modules/osdwindow.h49
-rw-r--r--src/osd/modules/render/bgfx/view.cpp2
-rw-r--r--src/osd/modules/render/drawbgfx.cpp30
-rw-r--r--src/osd/sdl/window.cpp114
-rw-r--r--src/osd/sdl/window.h21
-rw-r--r--src/osd/uwp/window.cpp130
-rw-r--r--src/osd/uwp/window.h16
-rw-r--r--src/osd/windows/window.cpp151
-rw-r--r--src/osd/windows/window.h14
12 files changed, 249 insertions, 469 deletions
diff --git a/src/osd/mac/window.cpp b/src/osd/mac/window.cpp
index 43134e26963..cff0f5a8b79 100644
--- a/src/osd/mac/window.cpp
+++ b/src/osd/mac/window.cpp
@@ -307,25 +307,17 @@ int mac_window_info::window_init()
// set the initial maximized state
// FIXME: Does not belong here
- mac_options &options = downcast<mac_options &>(m_machine.options());
- m_startmaximized = options.maximize();
+ m_startmaximized = downcast<mac_options &>(machine().options()).maximize();
- // add us to the list
- osd_common_t::s_window_list.push_back(std::static_pointer_cast<mac_window_info>(shared_from_this()));
+ create_target();
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
- // load the layout
- m_target = m_machine.render().target_alloc();
-
- // set the specific view
- set_starting_view(m_index, options.view(), options.view(m_index));
-
// make the window title
if (video_config.numscreens == 1)
- sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name);
+ sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name);
else
- sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name, m_index);
+ sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name, index());
result = complete_create();
@@ -360,19 +352,6 @@ void mac_window_info::complete_destroy()
downcast<mac_osd_interface &>(machine().osd()).release_keys();
}
-void mac_window_info::destroy()
-{
- // remove us from the list
- osd_common_t::s_window_list.remove(std::static_pointer_cast<mac_window_info>(shared_from_this()));
-
- // free the textures etc
- complete_destroy();
-
- // free the render target, after the textures!
- machine().render().target_free(m_target);
- m_target = nullptr;
-}
-
//============================================================
// pick_best_mode
@@ -387,7 +366,7 @@ osd_dim mac_window_info::pick_best_mode()
osd_dim ret(0,0);
#if 0
// determine the minimum width/height for the selected target
- m_target->compute_minimum_size(minimum_width, minimum_height);
+ target()->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
target_width = minimum_width * std::max(1, prescale());
@@ -400,7 +379,7 @@ osd_dim mac_window_info::pick_best_mode()
}
// FIXME: this should be provided by monitor !
- num = SDL_GetNumDisplayModes(m_monitor->oshandle());
+ num = SDL_GetNumDisplayModes(monitor()->oshandle());
if (num == 0)
{
@@ -412,7 +391,7 @@ osd_dim mac_window_info::pick_best_mode()
for (i = 0; i < num; ++i)
{
SDL_DisplayMode mode;
- SDL_GetDisplayMode(m_monitor->oshandle(), i, &mode);
+ SDL_GetDisplayMode(monitor()->oshandle(), i, &mode);
// compute initial score based on difference between target and current
size_score = 1.0f / (1.0f + abs((int32_t)mode.w - target_width) + abs((int32_t)mode.h - target_height));
@@ -463,12 +442,12 @@ void mac_window_info::update()
update_cursor_state();
// if we're visible and running and not in the middle of a resize, draw
- if (m_target != nullptr)
+ if (target() != nullptr)
{
int tempwidth, tempheight;
// see if the games video mode has changed
- m_target->compute_minimum_size(tempwidth, tempheight);
+ target()->compute_minimum_size(tempwidth, tempheight);
if (osd_dim(tempwidth, tempheight) != m_minimum_dim)
{
m_minimum_dim = osd_dim(tempwidth, tempheight);
@@ -503,7 +482,7 @@ void mac_window_info::update()
// Check whether window has vector screens
{
- const screen_device *screen = screen_device_iterator(machine().root_device()).byindex(m_index);
+ const screen_device *screen = screen_device_iterator(machine().root_device()).byindex(index());
if ((screen != nullptr) && (screen->screen_type() == SCREEN_TYPE_VECTOR))
renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
else
@@ -533,27 +512,6 @@ void mac_window_info::update()
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void mac_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- // choose non-auto over auto
- if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
- view = defview;
-
- // query the video system to help us pick a view
- viewindex = target()->configured_view(view, index, video_config.numscreens);
-
- // set the view
- target()->set_view(viewindex);
-}
-
-
-//============================================================
// complete_create
//============================================================
@@ -608,11 +566,11 @@ int mac_window_info::complete_create()
set_platform_window(window);
// set main window
- if (m_index > 0)
+ if (index() > 0)
{
for (auto w : osd_common_t::s_window_list)
{
- if (w->m_index == 0)
+ if (w->index() == 0)
{
set_main_window(std::dynamic_pointer_cast<osd_window>(w));
break;
@@ -714,14 +672,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
int32_t viswidth, visheight;
int32_t adjwidth, adjheight;
float pixel_aspect;
- std::shared_ptr<osd_monitor_info> monitor = m_monitor;
// do not constrain aspect ratio for integer scaled views
- if (m_target->scale_mode() != SCALE_FRACTIONAL)
+ if (target()->scale_mode() != SCALE_FRACTIONAL)
return rect;
// get the pixel aspect ratio for the target monitor
- pixel_aspect = monitor->pixel_aspect();
+ pixel_aspect = monitor()->pixel_aspect();
// determine the proposed width/height
propwidth = rect.width() - extrawidth;
@@ -733,21 +690,21 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
- m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
- m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
default:
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
}
// get the minimum width/height for the current layout
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
propwidth = std::max(propwidth, MIN_WINDOW_DIM);
@@ -760,13 +717,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// clamp against the maximum (fit on one screen for full screen mode)
if (m_fullscreen)
{
- maxwidth = monitor->position_size().width() - extrawidth;
- maxheight = monitor->position_size().height() - extraheight;
+ maxwidth = monitor()->position_size().width() - extrawidth;
+ maxheight = monitor()->position_size().height() - extraheight;
}
else
{
- maxwidth = monitor->usuable_position_size().width() - extrawidth;
- maxheight = monitor->usuable_position_size().height() - extraheight;
+ maxwidth = monitor()->usuable_position_size().width() - extrawidth;
+ maxheight = monitor()->usuable_position_size().height() - extraheight;
// further clamp to the maximum width/height in the window
if (m_win_config.width != 0)
@@ -780,7 +737,7 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
@@ -828,7 +785,7 @@ osd_dim mac_window_info::get_min_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// get the minimum target size
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM)
@@ -841,7 +798,7 @@ osd_dim mac_window_info::get_min_bounds(int constrain)
minheight += wnd_extra_height();
// if we want it constrained, figure out which one is larger
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
{
// first constrain with no height limit
osd_rect test1(0,0,minwidth,10000);
@@ -894,8 +851,8 @@ osd_dim mac_window_info::get_max_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// compute the maximum client area
- // m_monitor->refresh();
- osd_rect maximum = m_monitor->usuable_position_size();
+ // monitor()->refresh();
+ osd_rect maximum = monitor()->usuable_position_size();
// clamp to the window's max
int tempw = maximum.width();
@@ -916,7 +873,7 @@ osd_dim mac_window_info::get_max_bounds(int constrain)
maximum = maximum.resize(tempw, temph);
// constrain to fit
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT);
// remove extra window stuff
@@ -934,22 +891,15 @@ mac_window_info::mac_window_info(
int index,
std::shared_ptr<osd_monitor_info> a_monitor,
const osd_window_config *config)
- : osd_window_t(*config)
- , m_next(nullptr)
+ : osd_window_t(a_machine, index, a_monitor, *config)
, m_startmaximized(0)
// Following three are used by input code to defer resizes
, m_minimum_dim(0, 0)
, m_windowed_dim(0, 0)
, m_rendered_event(0, 1)
- , m_target(nullptr)
- , m_machine(a_machine)
- , m_monitor(a_monitor)
- , m_fullscreen(0)
, m_mouse_captured(false)
, m_mouse_hidden(false)
{
- m_index = index;
-
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
diff --git a/src/osd/mac/window.h b/src/osd/mac/window.h
index 24e749a425b..8fed34e5f99 100644
--- a/src/osd/mac/window.h
+++ b/src/osd/mac/window.h
@@ -44,7 +44,7 @@ public:
void toggle_full_screen();
void modify_prescale(int dir);
void resize(int32_t width, int32_t height);
- void destroy() override;
+ void complete_destroy() override;
void capture_pointer() override;
void release_pointer() override;
@@ -57,17 +57,6 @@ public:
int xy_to_render_target(int x, int y, int *xt, int *yt);
- running_machine &machine() const override { return m_machine; }
- osd_monitor_info *monitor() const override { return m_monitor.get(); }
- int fullscreen() const override { return m_fullscreen; }
-
- render_target *target() override { return m_target; }
-
- int prescale() const { return m_prescale; }
-
- // Pointer to next window
- mac_window_info * m_next;
-
private:
// window handle and info
char m_title[256];
@@ -79,18 +68,15 @@ private:
// rendering info
osd_event m_rendered_event;
- render_target * m_target;
//int m_extra_flags;
// returns 0 on success, else 1
int complete_create();
- void complete_destroy();
private:
int wnd_extra_width();
int wnd_extra_height();
- void set_starting_view(int index, const char *defview, const char *view);
osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);
osd_dim get_min_bounds(int constrain);
osd_dim get_max_bounds(int constrain);
@@ -98,12 +84,7 @@ private:
osd_dim pick_best_mode();
void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; }
- // Pointer to machine
- running_machine & m_machine;
-
// monitor info
- std::shared_ptr<osd_monitor_info> m_monitor;
- int m_fullscreen;
bool m_mouse_captured;
bool m_mouse_hidden;
diff --git a/src/osd/modules/osdwindow.cpp b/src/osd/modules/osdwindow.cpp
index 64b6528f5f3..68bba4f90ae 100644
--- a/src/osd/modules/osdwindow.cpp
+++ b/src/osd/modules/osdwindow.cpp
@@ -56,3 +56,65 @@ std::unique_ptr<osd_renderer> osd_renderer::make_for_type(int mode, std::shared_
return nullptr;
}
}
+
+std::shared_ptr<osd_monitor_info> osd_window::monitor_from_rect(const osd_rect *proposed) const
+{
+ std::shared_ptr<osd_monitor_info> monitor;
+
+ // in window mode, find the nearest
+ if (!fullscreen())
+ {
+ if (proposed != nullptr)
+ {
+ monitor = m_monitor->module().monitor_from_rect(*proposed);
+ }
+ else
+ monitor = m_monitor->module().monitor_from_window(*this);
+ }
+ else
+ {
+ // in full screen, just use the configured monitor
+ monitor = m_monitor;
+ }
+
+ return monitor;
+}
+
+void osd_window::create_target()
+{
+ // add us to the list
+ osd_common_t::s_window_list.push_back(shared_from_this());
+
+ // load the layout
+ m_target = m_machine.render().target_alloc();
+
+ // set the specific view
+ osd_options &options = downcast<osd_options &>(m_machine.options());
+ set_starting_view(m_index, options.view(), options.view(m_index));
+}
+
+void osd_window::set_starting_view(int index, const char *defview, const char *view)
+{
+ // choose non-auto over auto
+ if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
+ view = defview;
+
+ // query the video system to help us pick a view
+ int viewindex = m_target->configured_view(view, index, video_config.numscreens);
+
+ // set the view
+ m_target->set_view(viewindex);
+}
+
+void osd_window::destroy()
+{
+ // remove us from the list
+ osd_common_t::s_window_list.remove(shared_from_this());
+
+ // free the textures etc
+ complete_destroy();
+
+ // free the render target, after the textures!
+ m_machine.render().target_free(m_target);
+ m_target = nullptr;
+}
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h
index ef0c600a72d..49ef2f8fad9 100644
--- a/src/osd/modules/osdwindow.h
+++ b/src/osd/modules/osdwindow.h
@@ -65,24 +65,28 @@ class osd_monitor_info;
class osd_window : public std::enable_shared_from_this<osd_window>
{
public:
- osd_window(const osd_window_config &config)
+ osd_window(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config)
:
#ifdef OSD_WINDOWS
m_dc(nullptr), m_resize_state(0),
#endif
+ m_target(nullptr),
m_primlist(nullptr),
m_win_config(config),
- m_index(0),
+ m_index(index),
+ m_fullscreen(false),
m_prescale(1),
+ m_machine(machine),
+ m_monitor(std::move(monitor)),
m_renderer(nullptr),
m_main(nullptr)
{}
virtual ~osd_window() { }
- virtual render_target *target() = 0;
- virtual int fullscreen() const = 0;
- virtual running_machine &machine() const = 0;
+ render_target *target() const { return m_target; }
+ int fullscreen() const { return m_fullscreen; }
+ running_machine &machine() const { return m_machine; }
bool has_renderer() const { return m_renderer != nullptr; }
osd_renderer &renderer() const { return *m_renderer; }
@@ -92,11 +96,12 @@ public:
}
void renderer_reset() { m_renderer.reset(); }
- int prescale() const { return m_prescale; };
+ int index() const { return m_index; }
+ int prescale() const { return m_prescale; }
float pixel_aspect() const;
- bool swap_xy()
+ bool swap_xy() const
{
bool orientation_swap_xy =
(machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
@@ -105,22 +110,25 @@ public:
return orientation_swap_xy ^ rotation_swap_xy;
};
- bool keepaspect()
+ bool keepaspect() const
{
- render_target *target = this->target();
- if (target != nullptr)
- return target->keepaspect();
+ if (m_target != nullptr)
+ return m_target->keepaspect();
else
return false;
}
virtual osd_dim get_size() = 0;
- virtual osd_monitor_info *monitor() const = 0;
+ osd_monitor_info *monitor() const { return m_monitor.get(); }
+ std::shared_ptr<osd_monitor_info> monitor_from_rect(const osd_rect *proposed) const;
std::shared_ptr<osd_window> main_window() const { return m_main; }
void set_main_window(std::shared_ptr<osd_window> main) { m_main = main; }
+ void create_target();
+ void destroy();
+
// Clips the pointer to the bounds of this window
virtual void capture_pointer() = 0;
@@ -131,22 +139,33 @@ public:
virtual void hide_pointer() = 0;
virtual void update() = 0;
- virtual void destroy() = 0;
+ virtual void complete_destroy() = 0;
#if defined(OSD_WINDOWS) || defined(OSD_UWP)
virtual bool win_has_menu() = 0;
#endif
+private:
+ void set_starting_view(int index, const char *defview, const char *view);
+
+public: // TODO: make these private
#ifdef OSD_WINDOWS
HDC m_dc; // only used by GDI renderer!
int m_resize_state;
#endif
+private:
+ render_target *m_target;
+public:
render_primitive_list *m_primlist;
osd_window_config m_win_config;
+private:
int m_index;
protected:
+ bool m_fullscreen;
int m_prescale;
private:
+ running_machine &m_machine;
+ std::shared_ptr<osd_monitor_info> m_monitor;
std::unique_ptr<osd_renderer> m_renderer;
std::shared_ptr<osd_window> m_main;
};
@@ -157,8 +176,8 @@ class osd_window_t : public osd_window
private:
TWindowHandle m_platform_window;
public:
- osd_window_t(const osd_window_config &config)
- : osd_window(config),
+ osd_window_t(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config &config)
+ : osd_window(machine, index, std::move(monitor), config),
m_platform_window(nullptr)
{
}
diff --git a/src/osd/modules/render/bgfx/view.cpp b/src/osd/modules/render/bgfx/view.cpp
index 893aa77c143..4385500edb1 100644
--- a/src/osd/modules/render/bgfx/view.cpp
+++ b/src/osd/modules/render/bgfx/view.cpp
@@ -13,7 +13,7 @@
void bgfx_view::update() {
std::shared_ptr<osd_window> win = m_renderer->assert_window();
- const uint32_t window_index = win->m_index;
+ const uint32_t window_index = win->index();
const uint32_t width = m_renderer->get_window_width(window_index);
const uint32_t height = m_renderer->get_window_height(window_index);
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index 39f11a26d37..7f0cd3d5936 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -234,9 +234,9 @@ int renderer_bgfx::create()
// create renderer
std::shared_ptr<osd_window> win = assert_window();
osd_dim wdim = win->get_size();
- m_width[win->m_index] = wdim.width();
- m_height[win->m_index] = wdim.height();
- if (win->m_index == 0)
+ m_width[win->index()] = wdim.width();
+ m_height[win->index()] = wdim.height();
+ if (win->index() == 0)
{
if (!s_window_set)
{
@@ -303,7 +303,7 @@ int renderer_bgfx::create()
printf("Unknown backend type '%s', going with auto-detection\n", backend.c_str());
}
bgfx::init(init);
- bgfx::reset(m_width[win->m_index], m_height[win->m_index], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
+ bgfx::reset(m_width[win->index()], m_height[win->index()], video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE);
// Enable debug text.
bgfx::setDebug(m_options.bgfx_debug() ? BGFX_DEBUG_STATS : BGFX_DEBUG_TEXT);
m_dimensions = osd_dim(m_width[0], m_height[0]);
@@ -315,18 +315,18 @@ int renderer_bgfx::create()
m_shaders = new shader_manager(m_options);
m_effects = new effect_manager(m_options, *m_shaders);
- if (win->m_index != 0)
+ if (win->index() != 0)
{
#ifdef OSD_WINDOWS
- m_framebuffer = m_targets->create_backbuffer(std::static_pointer_cast<win_window_info>(win)->platform_window(), m_width[win->m_index], m_height[win->m_index]);
+ m_framebuffer = m_targets->create_backbuffer(std::static_pointer_cast<win_window_info>(win)->platform_window(), m_width[win->index()], m_height[win->index()]);
#elif defined(OSD_UWP)
- m_framebuffer = m_targets->create_backbuffer(AsInspectable(std::static_pointer_cast<uwp_window_info>(win)->platform_window()), m_width[win->m_index], m_height[win->m_index]);
+ m_framebuffer = m_targets->create_backbuffer(AsInspectable(std::static_pointer_cast<uwp_window_info>(win)->platform_window()), m_width[win->index()], m_height[win->index()]);
#elif defined(OSD_MAC)
- m_framebuffer = m_targets->create_backbuffer(GetOSWindow(std::static_pointer_cast<mac_window_info>(win)->platform_window()), m_width[win->m_index], m_height[win->m_index]);
+ m_framebuffer = m_targets->create_backbuffer(GetOSWindow(std::static_pointer_cast<mac_window_info>(win)->platform_window()), m_width[win->index()], m_height[win->index()]);
#else
- m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window()), m_width[win->m_index], m_height[win->m_index]);
+ m_framebuffer = m_targets->create_backbuffer(sdlNativeWindowHandle(std::dynamic_pointer_cast<sdl_window_info>(win)->platform_window()), m_width[win->index()], m_height[win->index()]);
#endif
- bgfx::touch(win->m_index);
+ bgfx::touch(win->index());
if (m_ortho_view) {
m_ortho_view->set_backbuffer(m_framebuffer);
@@ -350,7 +350,7 @@ int renderer_bgfx::create()
fatalerror("BGFX: Unable to load required shaders. Please check and reinstall the %s folder\n", m_options.bgfx_path());
}
- m_chains = new chain_manager(win->machine(), m_options, *m_textures, *m_targets, *m_effects, win->m_index, *this);
+ m_chains = new chain_manager(win->machine(), m_options, *m_textures, *m_targets, *m_effects, win->index(), *this);
m_sliders_dirty = true;
uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT;
@@ -372,7 +372,7 @@ void renderer_bgfx::record()
{
std::shared_ptr<osd_window> win = assert_window();
- if (win->m_index > 0)
+ if (win->index() > 0)
{
return;
}
@@ -840,7 +840,7 @@ int renderer_bgfx::draw(int update)
{
std::shared_ptr<osd_window> win = assert_window();
- int window_index = win->m_index;
+ int window_index = win->index();
m_seen_views.clear();
if (m_ortho_view) {
@@ -972,7 +972,7 @@ void renderer_bgfx::update_recording()
void renderer_bgfx::add_audio_to_recording(const int16_t *buffer, int samples_this_frame)
{
std::shared_ptr<osd_window> win = assert_window();
- if (m_avi_writer != nullptr && m_avi_writer->recording() && win->m_index == 0)
+ if (m_avi_writer != nullptr && m_avi_writer->recording() && win->index() == 0)
{
m_avi_writer->audio_frame(buffer, samples_this_frame);
}
@@ -982,7 +982,7 @@ bool renderer_bgfx::update_dimensions()
{
std::shared_ptr<osd_window> win = assert_window();
- const uint32_t window_index = win->m_index;
+ const uint32_t window_index = win->index();
const uint32_t width = m_width[window_index];
const uint32_t height = m_height[window_index];
diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp
index b43d9299181..99c2f00e57f 100644
--- a/src/osd/sdl/window.cpp
+++ b/src/osd/sdl/window.cpp
@@ -403,31 +403,21 @@ int sdl_window_info::xy_to_render_target(int x, int y, int *xt, int *yt)
int sdl_window_info::window_init()
{
- int result;
-
// set the initial maximized state
// FIXME: Does not belong here
- sdl_options &options = downcast<sdl_options &>(m_machine.options());
- m_startmaximized = options.maximize();
+ m_startmaximized = downcast<sdl_options &>(machine().options()).maximize();
- // add us to the list
- osd_common_t::s_window_list.push_back(std::static_pointer_cast<sdl_window_info>(shared_from_this()));
+ create_target();
set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this()));
- // load the layout
- m_target = m_machine.render().target_alloc();
-
- // set the specific view
- set_starting_view(m_index, options.view(), options.view(m_index));
-
// make the window title
if (video_config.numscreens == 1)
- sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name);
+ sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name);
else
- sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name, m_index);
+ sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine().system().type.fullname(), machine().system().name, index());
- result = complete_create();
+ int result = complete_create();
// handle error conditions
if (result == 1)
@@ -463,21 +453,6 @@ void sdl_window_info::complete_destroy()
downcast<sdl_osd_interface &>(machine().osd()).release_keys();
}
-void sdl_window_info::destroy()
-{
- //osd_event_wait(window->rendered_event, osd_ticks_per_second()*10);
-
- // remove us from the list
- osd_common_t::s_window_list.remove(std::static_pointer_cast<sdl_window_info>(shared_from_this()));
-
- // free the textures etc
- complete_destroy();
-
- // free the render target, after the textures!
- machine().render().target_free(m_target);
- m_target = nullptr;
-}
-
//============================================================
// pick_best_mode
@@ -492,7 +467,7 @@ osd_dim sdl_window_info::pick_best_mode()
osd_dim ret(0,0);
// determine the minimum width/height for the selected target
- m_target->compute_minimum_size(minimum_width, minimum_height);
+ target()->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
target_width = minimum_width * std::max(1, prescale());
@@ -505,7 +480,7 @@ osd_dim sdl_window_info::pick_best_mode()
}
// FIXME: this should be provided by monitor !
- num = SDL_GetNumDisplayModes(m_monitor->oshandle());
+ num = SDL_GetNumDisplayModes(monitor()->oshandle());
if (num == 0)
{
@@ -517,7 +492,7 @@ osd_dim sdl_window_info::pick_best_mode()
for (i = 0; i < num; ++i)
{
SDL_DisplayMode mode;
- SDL_GetDisplayMode(m_monitor->oshandle(), i, &mode);
+ SDL_GetDisplayMode(monitor()->oshandle(), i, &mode);
// compute initial score based on difference between target and current
size_score = 1.0f / (1.0f + abs((int32_t)mode.w - target_width) + abs((int32_t)mode.h - target_height));
@@ -567,12 +542,12 @@ void sdl_window_info::update()
update_cursor_state();
// if we're visible and running and not in the middle of a resize, draw
- if (m_target != nullptr)
+ if (target() != nullptr)
{
int tempwidth, tempheight;
// see if the games video mode has changed
- m_target->compute_minimum_size(tempwidth, tempheight);
+ target()->compute_minimum_size(tempwidth, tempheight);
if (osd_dim(tempwidth, tempheight) != m_minimum_dim)
{
m_minimum_dim = osd_dim(tempwidth, tempheight);
@@ -607,7 +582,7 @@ void sdl_window_info::update()
// Check whether window has vector screens
{
- const screen_device *screen = screen_device_enumerator(machine().root_device()).byindex(m_index);
+ const screen_device *screen = screen_device_enumerator(machine().root_device()).byindex(index());
if ((screen != nullptr) && (screen->screen_type() == SCREEN_TYPE_VECTOR))
renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN);
else
@@ -637,27 +612,6 @@ void sdl_window_info::update()
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void sdl_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- // choose non-auto over auto
- if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
- view = defview;
-
- // query the video system to help us pick a view
- viewindex = target()->configured_view(view, index, video_config.numscreens);
-
- // set the view
- target()->set_view(viewindex);
-}
-
-
-//============================================================
// complete_create
//============================================================
@@ -793,11 +747,11 @@ int sdl_window_info::complete_create()
#endif
// set main window
- if (m_index > 0)
+ if (index() > 0)
{
for (auto w : osd_common_t::s_window_list)
{
- if (w->m_index == 0)
+ if (w->index() == 0)
{
set_main_window(std::dynamic_pointer_cast<osd_window>(w));
break;
@@ -900,14 +854,13 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
int32_t viswidth, visheight;
int32_t adjwidth, adjheight;
float pixel_aspect;
- std::shared_ptr<osd_monitor_info> monitor = m_monitor;
// do not constrain aspect ratio for integer scaled views
- if (m_target->scale_mode() != SCALE_FRACTIONAL)
+ if (target()->scale_mode() != SCALE_FRACTIONAL)
return rect;
// get the pixel aspect ratio for the target monitor
- pixel_aspect = monitor->pixel_aspect();
+ pixel_aspect = monitor()->pixel_aspect();
// determine the proposed width/height
propwidth = rect.width() - extrawidth;
@@ -919,21 +872,21 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
- m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
- m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
default:
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
}
// get the minimum width/height for the current layout
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
propwidth = std::max(propwidth, MIN_WINDOW_DIM);
@@ -946,13 +899,13 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// clamp against the maximum (fit on one screen for full screen mode)
if (m_fullscreen)
{
- maxwidth = monitor->position_size().width() - extrawidth;
- maxheight = monitor->position_size().height() - extraheight;
+ maxwidth = monitor()->position_size().width() - extrawidth;
+ maxheight = monitor()->position_size().height() - extraheight;
}
else
{
- maxwidth = monitor->usuable_position_size().width() - extrawidth;
- maxheight = monitor->usuable_position_size().height() - extraheight;
+ maxwidth = monitor()->usuable_position_size().width() - extrawidth;
+ maxheight = monitor()->usuable_position_size().height() - extraheight;
// further clamp to the maximum width/height in the window
if (m_win_config.width != 0)
@@ -966,7 +919,7 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
@@ -1014,7 +967,7 @@ osd_dim sdl_window_info::get_min_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// get the minimum target size
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM)
@@ -1027,7 +980,7 @@ osd_dim sdl_window_info::get_min_bounds(int constrain)
minheight += wnd_extra_height();
// if we want it constrained, figure out which one is larger
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
{
// first constrain with no height limit
osd_rect test1(0,0,minwidth,10000);
@@ -1079,8 +1032,8 @@ osd_dim sdl_window_info::get_max_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// compute the maximum client area
- // m_monitor->refresh();
- osd_rect maximum = m_monitor->usuable_position_size();
+ // monitor()->refresh();
+ osd_rect maximum = monitor()->usuable_position_size();
// clamp to the window's max
int tempw = maximum.width();
@@ -1101,7 +1054,7 @@ osd_dim sdl_window_info::get_max_bounds(int constrain)
maximum = maximum.resize(tempw, temph);
// constrain to fit
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT);
// remove extra window stuff
@@ -1119,23 +1072,16 @@ sdl_window_info::sdl_window_info(
int index,
std::shared_ptr<osd_monitor_info> a_monitor,
const osd_window_config *config)
- : osd_window_t(*config)
- , m_next(nullptr)
+ : osd_window_t(a_machine, index, std::move(a_monitor), *config)
, m_startmaximized(0)
// Following three are used by input code to defer resizes
, m_minimum_dim(0, 0)
, m_windowed_dim(0, 0)
, m_rendered_event(0, 1)
- , m_target(nullptr)
, m_extra_flags(0)
- , m_machine(a_machine)
- , m_monitor(a_monitor)
- , m_fullscreen(0)
, m_mouse_captured(false)
, m_mouse_hidden(false)
{
- m_index = index;
-
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h
index bfe32e6e8a0..4e39dcf63d0 100644
--- a/src/osd/sdl/window.h
+++ b/src/osd/sdl/window.h
@@ -49,7 +49,7 @@ public:
void toggle_full_screen();
void modify_prescale(int dir);
void resize(int32_t width, int32_t height);
- void destroy() override;
+ void complete_destroy() override;
void capture_pointer() override;
void release_pointer() override;
@@ -62,17 +62,6 @@ public:
int xy_to_render_target(int x, int y, int *xt, int *yt);
- running_machine &machine() const override { return m_machine; }
- osd_monitor_info *monitor() const override { return m_monitor.get(); }
- int fullscreen() const override { return m_fullscreen; }
-
- render_target *target() override { return m_target; }
-
- int prescale() const { return m_prescale; }
-
- // Pointer to next window
- sdl_window_info * m_next;
-
private:
// window handle and info
char m_title[256];
@@ -84,7 +73,6 @@ private:
// rendering info
osd_event m_rendered_event;
- render_target * m_target;
// Original display_mode
std::unique_ptr<SDL_DM_Wrapper> m_original_mode;
@@ -93,12 +81,10 @@ private:
// returns 0 on success, else 1
int complete_create();
- void complete_destroy();
private:
int wnd_extra_width();
int wnd_extra_height();
- void set_starting_view(int index, const char *defview, const char *view);
osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);
osd_dim get_min_bounds(int constrain);
osd_dim get_max_bounds(int constrain);
@@ -106,12 +92,7 @@ private:
osd_dim pick_best_mode();
void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; }
- // Pointer to machine
- running_machine & m_machine;
-
// monitor info
- std::shared_ptr<osd_monitor_info> m_monitor;
- int m_fullscreen;
bool m_mouse_captured;
bool m_mouse_hidden;
diff --git a/src/osd/uwp/window.cpp b/src/osd/uwp/window.cpp
index 9396e6ff308..94cf4558558 100644
--- a/src/osd/uwp/window.cpp
+++ b/src/osd/uwp/window.cpp
@@ -244,30 +244,27 @@ uwp_window_info::uwp_window_info(
running_machine &machine,
int index,
std::shared_ptr<osd_monitor_info> monitor,
- const osd_window_config *config) : osd_window_t(*config),
- m_next(nullptr),
+ const osd_window_config *config) : osd_window_t(machine, index, std::move(monitor), *config),
m_init_state(0),
m_startmaximized(0),
m_isminimized(0),
m_ismaximized(0),
- m_monitor(monitor),
- m_fullscreen(!video_config.windowed),
m_fullscreen_safe(0),
m_aspect(0),
- m_target(nullptr),
m_targetview(0),
m_targetorient(0),
m_targetvismask(0),
m_lastclicktime(std::chrono::system_clock::time_point::min()),
m_lastclickx(0),
- m_lastclicky(0),
- m_machine(machine)
+ m_lastclicky(0)
{
memset(m_title,0,sizeof(m_title));
m_non_fullscreen_bounds.left = 0;
m_non_fullscreen_bounds.top = 0;
m_non_fullscreen_bounds.right = 0;
m_non_fullscreen_bounds.bottom = 0;
+
+ m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
}
@@ -365,11 +362,11 @@ void uwp_window_info::create(running_machine &machine, int index, std::shared_pt
auto window = std::make_shared<uwp_window_info>(machine, index, monitor, config);
// set main window
- if (window->m_index > 0)
+ if (window->index() > 0)
{
for (auto w : osd_common_t::s_window_list)
{
- if (w->m_index == 0)
+ if (w->index() == 0)
{
window->set_main_window(std::static_pointer_cast<osd_window>(w));
break;
@@ -388,23 +385,13 @@ void uwp_window_info::create(running_machine &machine, int index, std::shared_pt
if (win->monitor() == monitor.get())
window->m_fullscreen_safe = FALSE;
- // add us to the list
- osd_common_t::s_window_list.push_back(window);
-
- // load the layout
- window->m_target = machine.render().target_alloc();
-
- // set the specific view
- windows_options &options = downcast<windows_options &>(machine.options());
-
- const char *defview = options.view();
- window->set_starting_view(index, defview, options.view(index));
+ window->create_target();
// remember the current values in case they change
- window->m_targetview = window->m_target->view();
- window->m_targetorient = window->m_target->orientation();
- window->m_targetlayerconfig = window->m_target->layer_config();
- window->m_targetvismask = window->m_target->visibility_mask();
+ window->m_targetview = window->target()->view();
+ window->m_targetorient = window->target()->orientation();
+ window->m_targetlayerconfig = window->target()->layer_config();
+ window->m_targetvismask = window->target()->visibility_mask();
// make the window title
if (video_config.numscreens == 1)
@@ -413,7 +400,7 @@ void uwp_window_info::create(running_machine &machine, int index, std::shared_pt
sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().type.fullname(), machine.system().name, index);
// set the initial maximized state
- window->m_startmaximized = options.maximize();
+ window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
window->m_init_state = window->complete_create() ? -1 : 1;
@@ -422,48 +409,18 @@ void uwp_window_info::create(running_machine &machine, int index, std::shared_pt
fatalerror("Unable to complete window creation\n");
}
-std::shared_ptr<osd_monitor_info> uwp_window_info::monitor_from_rect(const osd_rect* proposed) const
-{
- std::shared_ptr<osd_monitor_info> monitor;
-
- // in window mode, find the nearest
- if (!fullscreen())
- {
- if (proposed != nullptr)
- {
- monitor = m_monitor->module().monitor_from_rect(*proposed);
- }
- else
- monitor = m_monitor->module().monitor_from_window(*this);
- }
- else
- {
- // in full screen, just use the configured monitor
- monitor = m_monitor;
- }
-
- return monitor;
-}
-
//============================================================
// winwindow_video_window_destroy
// (main thread)
//============================================================
-void uwp_window_info::destroy()
+void uwp_window_info::complete_destroy()
{
assert(GetCurrentThreadId() == main_threadid);
- // remove us from the list
- osd_common_t::s_window_list.remove(shared_from_this());
-
// destroy the window
// if (platform_window<HWND>() != nullptr)
// DestroyWindow(platform_window<HWND>());
-
- // free the render target
- machine().render().target_free(m_target);
- m_target = nullptr;
}
@@ -478,10 +435,10 @@ void uwp_window_info::update()
assert(GetCurrentThreadId() == main_threadid);
// see if the target has changed significantly in window mode
- unsigned const targetview = m_target->view();
- int const targetorient = m_target->orientation();
- render_layer_config const targetlayerconfig = m_target->layer_config();
- u32 const targetvismask = m_target->visibility_mask();
+ unsigned const targetview = target()->view();
+ int const targetorient = target()->orientation();
+ render_layer_config const targetlayerconfig = target()->layer_config();
+ u32 const targetvismask = target()->visibility_mask();
if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask)
{
m_targetview = targetview;
@@ -500,7 +457,7 @@ void uwp_window_info::update()
}
// if we're visible and running and not in the middle of a resize, draw
- if (platform_window() != nullptr && m_target != nullptr && has_renderer())
+ if (platform_window() != nullptr && target() != nullptr && has_renderer())
{
bool got_lock = true;
auto clock = std::chrono::high_resolution_clock();
@@ -562,29 +519,6 @@ void uwp_window_info::draw_video_contents(bool update)
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void uwp_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- assert(GetCurrentThreadId() == main_threadid);
-
- // choose non-auto over auto
- if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
- view = defview;
-
- // query the video system to help us pick a view
- viewindex = target()->configured_view(view, index, video_config.numscreens);
-
- // set the view
- target()->set_view(viewindex);
-}
-
-
-//============================================================
// winwindow_ui_pause
// (main thread)
//============================================================
@@ -684,7 +618,7 @@ int uwp_window_info::complete_create()
assert(GetCurrentThreadId() == window_threadid);
// get the monitor bounds
- osd_rect monitorbounds = m_monitor->position_size();
+ osd_rect monitorbounds = monitor()->position_size();
auto coreWindow = Platform::Agile<CoreWindow>(CoreWindow::GetForCurrentThread());
set_platform_window(coreWindow);
@@ -747,7 +681,7 @@ osd_rect uwp_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
return rect;
// do not constrain aspect ratio for integer scaled views
- if (m_target->scale_mode() != SCALE_FRACTIONAL)
+ if (target()->scale_mode() != SCALE_FRACTIONAL)
return rect;
// get the pixel aspect ratio for the target monitor
@@ -763,21 +697,21 @@ osd_rect uwp_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
- m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
- m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
default:
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
}
// get the minimum width/height for the current layout
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
propwidth = std::max(propwidth, MIN_WINDOW_DIM);
@@ -810,7 +744,7 @@ osd_rect uwp_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
@@ -858,7 +792,7 @@ osd_dim uwp_window_info::get_min_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// get the minimum target size
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM)
@@ -871,7 +805,7 @@ osd_dim uwp_window_info::get_min_bounds(int constrain)
minheight += wnd_extra_height();
// if we want it constrained, figure out which one is larger
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
{
// first constrain with no height limit
osd_rect test1(0,0,minwidth,10000);
@@ -909,8 +843,8 @@ osd_dim uwp_window_info::get_max_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// compute the maximum client area
- //m_monitor->refresh();
- osd_rect maximum = m_monitor->usuable_position_size();
+ //monitor()->refresh();
+ osd_rect maximum = monitor()->usuable_position_size();
// clamp to the window's max
int tempw = maximum.width();
@@ -931,7 +865,7 @@ osd_dim uwp_window_info::get_max_bounds(int constrain)
maximum = maximum.resize(tempw, temph);
// constrain to fit
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT);
return maximum.dim();
@@ -1006,7 +940,7 @@ void uwp_window_info::maximize_window()
osd_dim newsize = get_max_bounds(keepaspect());
// center within the work area
- osd_rect work = m_monitor->usuable_position_size();
+ osd_rect work = monitor()->usuable_position_size();
osd_rect newrect = osd_rect(work.left() + (work.width() - newsize.width()) / 2,
work.top() + (work.height() - newsize.height()) / 2,
newsize);
@@ -1054,7 +988,7 @@ void uwp_window_info::adjust_window_position_after_major_change()
//newrect.width(), newrect.height(), 0);
// take note of physical window size (used for lightgun coordinate calculation)
- if (m_index == 0)
+ if (index() == 0)
{
win_physical_width = newrect.width();
win_physical_height = newrect.height();
diff --git a/src/osd/uwp/window.h b/src/osd/uwp/window.h
index a58a163284e..745f3df4767 100644
--- a/src/osd/uwp/window.h
+++ b/src/osd/uwp/window.h
@@ -49,11 +49,6 @@ class uwp_window_info : public osd_window_t<Platform::Agile<Windows::UI::Core::
public:
uwp_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
- running_machine &machine() const override { return m_machine; }
-
- virtual render_target *target() override { return m_target; }
- int fullscreen() const override { return m_fullscreen; }
-
void update() override;
virtual osd_dim get_size() override
@@ -72,9 +67,7 @@ public:
void show_pointer() override;
void hide_pointer() override;
- virtual osd_monitor_info *monitor() const override { return m_monitor.get(); }
-
- void destroy() override;
+ void complete_destroy() override;
// static
@@ -82,7 +75,6 @@ public:
// member variables
- uwp_window_info * m_next;
volatile int m_init_state;
// window handle and info
@@ -93,14 +85,11 @@ public:
int m_ismaximized;
// monitor info
- std::shared_ptr<osd_monitor_info> m_monitor;
- int m_fullscreen;
int m_fullscreen_safe;
float m_aspect;
// rendering info
std::mutex m_render_lock;
- render_target * m_target;
unsigned m_targetview;
int m_targetorient;
render_layer_config m_targetlayerconfig;
@@ -114,7 +103,6 @@ public:
private:
int complete_create();
void draw_video_contents(bool update);
- void set_starting_view(int index, const char *defview, const char *view);
int wnd_extra_width();
int wnd_extra_height();
osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);
@@ -130,8 +118,6 @@ private:
static POINT s_saved_cursor_pos;
static Windows::UI::Core::CoreCursor^ s_cursor;
-
- running_machine & m_machine;
};
struct osd_draw_callbacks
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index ca62d750f50..e185d006c5e 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -299,24 +299,19 @@ win_window_info::win_window_info(
int index,
std::shared_ptr<osd_monitor_info> monitor,
const osd_window_config *config)
- : osd_window_t(*config)
- , m_next(nullptr)
+ : osd_window_t(machine, index, std::move(monitor), *config)
, m_init_state(0)
, m_startmaximized(0)
, m_isminimized(0)
, m_ismaximized(0)
- , m_monitor(monitor)
- , m_fullscreen(!video_config.windowed)
, m_fullscreen_safe(0)
, m_aspect(0)
- , m_target(nullptr)
, m_targetview(0)
, m_targetorient(0)
, m_targetvismask(0)
, m_lastclicktime(std::chrono::steady_clock::time_point::min())
, m_lastclickx(0)
, m_lastclicky(0)
- , m_machine(machine)
, m_attached_mode(false)
{
memset(m_title,0,sizeof(m_title));
@@ -324,8 +319,9 @@ win_window_info::win_window_info(
m_non_fullscreen_bounds.top = 0;
m_non_fullscreen_bounds.right = 0;
m_non_fullscreen_bounds.bottom = 0;
+
+ m_fullscreen = !video_config.windowed;
m_prescale = video_config.prescale;
- m_index = index;
}
POINT win_window_info::s_saved_cursor_pos = { -1, -1 };
@@ -752,11 +748,11 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
auto window = std::make_shared<win_window_info>(machine, index, monitor, config);
// set main window
- if (window->m_index > 0)
+ if (window->index() > 0)
{
for (const auto &w : osd_common_t::s_window_list)
{
- if (w->m_index == 0)
+ if (w->index() == 0)
{
window->set_main_window(std::static_pointer_cast<osd_window>(w));
break;
@@ -775,23 +771,13 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
if (win->monitor() == monitor.get())
window->m_fullscreen_safe = FALSE;
- // add us to the list
- osd_common_t::s_window_list.push_back(window);
-
- // load the layout
- window->m_target = machine.render().target_alloc();
-
- // set the specific view
- auto &options = downcast<windows_options &>(machine.options());
-
- const char *defview = options.view();
- window->set_starting_view(index, defview, options.view(index));
+ create_target();
// remember the current values in case they change
- window->m_targetview = window->m_target->view();
- window->m_targetorient = window->m_target->orientation();
- window->m_targetlayerconfig = window->m_target->layer_config();
- window->m_targetvismask = window->m_target->visibility_mask();
+ window->m_targetview = window->target()->view();
+ window->m_targetorient = window->target()->orientation();
+ window->m_targetlayerconfig = window->target()->layer_config();
+ window->m_targetvismask = window->target()->visibility_mask();
// make the window title
if (video_config.numscreens == 1)
@@ -800,7 +786,7 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().type.fullname(), machine.system().name, index);
// set the initial maximized state
- window->m_startmaximized = options.maximize();
+ window->m_startmaximized = downcast<windows_options &>(machine.options()).maximize();
window->m_init_state = window->complete_create() ? -1 : 1;
@@ -809,48 +795,18 @@ void win_window_info::create(running_machine &machine, int index, std::shared_pt
fatalerror("Unable to complete window creation\n");
}
-std::shared_ptr<osd_monitor_info> win_window_info::monitor_from_rect(const osd_rect* proposed) const
-{
- std::shared_ptr<osd_monitor_info> monitor;
-
- // in window mode, find the nearest
- if (!fullscreen())
- {
- if (proposed != nullptr)
- {
- monitor = m_monitor->module().monitor_from_rect(*proposed);
- }
- else
- monitor = m_monitor->module().monitor_from_window(*this);
- }
- else
- {
- // in full screen, just use the configured monitor
- monitor = m_monitor;
- }
-
- return monitor;
-}
-
//============================================================
// winwindow_video_window_destroy
// (main thread)
//============================================================
-void win_window_info::destroy()
+void win_window_info::complete_destroy()
{
assert(GetCurrentThreadId() == main_threadid);
- // remove us from the list
- osd_common_t::s_window_list.remove(shared_from_this());
-
// destroy the window
if (platform_window() != nullptr)
DestroyWindow(platform_window());
-
- // free the render target
- machine().render().target_free(m_target);
- m_target = nullptr;
}
@@ -865,10 +821,10 @@ void win_window_info::update()
assert(GetCurrentThreadId() == main_threadid);
// see if the target has changed significantly in window mode
- unsigned const targetview = m_target->view();
- int const targetorient = m_target->orientation();
- render_layer_config const targetlayerconfig = m_target->layer_config();
- u32 const targetvismask = m_target->visibility_mask();
+ unsigned const targetview = target()->view();
+ int const targetorient = target()->orientation();
+ render_layer_config const targetlayerconfig = target()->layer_config();
+ u32 const targetvismask = target()->visibility_mask();
if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig || targetvismask != m_targetvismask)
{
m_targetview = targetview;
@@ -887,7 +843,7 @@ void win_window_info::update()
}
// if we're visible and running and not in the middle of a resize, draw
- if (platform_window() != nullptr && m_target != nullptr && has_renderer())
+ if (platform_window() != nullptr && target() != nullptr && has_renderer())
{
bool got_lock = true;
@@ -962,29 +918,6 @@ static void create_window_class()
//============================================================
-// set_starting_view
-// (main thread)
-//============================================================
-
-void win_window_info::set_starting_view(int index, const char *defview, const char *view)
-{
- int viewindex;
-
- assert(GetCurrentThreadId() == main_threadid);
-
- // choose non-auto over auto
- if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
- view = defview;
-
- // query the video system to help us pick a view
- viewindex = target()->configured_view(view, index, video_config.numscreens);
-
- // set the view
- target()->set_view(viewindex);
-}
-
-
-//============================================================
// winwindow_ui_pause
// (main thread)
//============================================================
@@ -1087,7 +1020,7 @@ int win_window_info::complete_create()
assert(GetCurrentThreadId() == window_threadid);
// get the monitor bounds
- osd_rect monitorbounds = m_monitor->position_size();
+ osd_rect monitorbounds = monitor()->position_size();
// create the window menu if needed
if (downcast<windows_options &>(machine().options()).menu())
@@ -1225,17 +1158,17 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
// input events
case WM_MOUSEMOVE:
- window->machine().ui_input().push_mouse_move_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_move_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_MOUSELEAVE:
- window->machine().ui_input().push_mouse_leave_event(window->m_target);
+ window->machine().ui_input().push_mouse_leave_event(window->target());
break;
case WM_LBUTTONDOWN:
{
auto const ticks = std::chrono::steady_clock::now();
- window->machine().ui_input().push_mouse_down_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_down_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
// check for a double-click - avoid overflow by adding times rather than subtracting
if (ticks < (window->m_lastclicktime + std::chrono::milliseconds(GetDoubleClickTime())) &&
@@ -1243,7 +1176,7 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
GET_Y_LPARAM(lparam) >= window->m_lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->m_lastclicky + 4)
{
window->m_lastclicktime = std::chrono::steady_clock::time_point::min();
- window->machine().ui_input().push_mouse_double_click_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_double_click_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
}
else
{
@@ -1255,26 +1188,26 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
break;
case WM_LBUTTONUP:
- window->machine().ui_input().push_mouse_up_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_up_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_RBUTTONDOWN:
- window->machine().ui_input().push_mouse_rdown_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_rdown_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_RBUTTONUP:
- window->machine().ui_input().push_mouse_rup_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
+ window->machine().ui_input().push_mouse_rup_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case WM_CHAR:
- window->machine().ui_input().push_char_event(window->m_target, (char32_t) wparam);
+ window->machine().ui_input().push_char_event(window->target(), (char32_t) wparam);
break;
case WM_MOUSEWHEEL:
{
UINT ucNumLines = 3; // default
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &ucNumLines, 0);
- window->machine().ui_input().push_mouse_wheel_event(window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines);
+ window->machine().ui_input().push_mouse_wheel_event(window->target(), GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam), GET_WHEEL_DELTA_WPARAM(wparam), ucNumLines);
break;
}
@@ -1392,8 +1325,8 @@ LRESULT CALLBACK win_window_info::video_window_proc(HWND wnd, UINT message, WPAR
* be preserved if set. If not, the standard aspect calculation
* should be used.
*/
- window->m_monitor->refresh();
- window->m_monitor->update_resolution(LOWORD(lparam), HIWORD(lparam));
+ window->monitor()->refresh();
+ window->monitor()->update_resolution(LOWORD(lparam), HIWORD(lparam));
break;
// set focus: if we're not the primary window, switch back
@@ -1472,7 +1405,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
return rect;
// do not constrain aspect ratio for integer scaled views
- if (m_target->scale_mode() != SCALE_FRACTIONAL)
+ if (target()->scale_mode() != SCALE_FRACTIONAL)
return rect;
// get the pixel aspect ratio for the target monitor
@@ -1488,21 +1421,21 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
- m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
- m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
default:
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight);
break;
}
// get the minimum width/height for the current layout
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// clamp against the maximum (fit on one screen for full screen mode)
if (fullscreen())
@@ -1539,7 +1472,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
- m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
+ target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight);
// compute the adjustments we need to make
adjwidth = (viswidth + extrawidth) - rect.width();
@@ -1587,7 +1520,7 @@ osd_dim win_window_info::get_min_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// get the minimum target size
- m_target->compute_minimum_size(minwidth, minheight);
+ target()->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIMX)
@@ -1600,7 +1533,7 @@ osd_dim win_window_info::get_min_bounds(int constrain)
minheight += wnd_extra_height();
// if we want it constrained, figure out which one is larger
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
{
// first constrain with no height limit
osd_rect test1(0,0,minwidth,10000);
@@ -1638,8 +1571,8 @@ osd_dim win_window_info::get_max_bounds(int constrain)
//assert(GetCurrentThreadId() == window_threadid);
// compute the maximum client area
- //m_monitor->refresh();
- osd_rect maximum = m_monitor->usuable_position_size();
+ //monitor()->refresh();
+ osd_rect maximum = monitor()->usuable_position_size();
// clamp to the window's max
int tempw = maximum.width();
@@ -1660,7 +1593,7 @@ osd_dim win_window_info::get_max_bounds(int constrain)
maximum = maximum.resize(tempw, temph);
// constrain to fit
- if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL)
+ if (constrain && target()->scale_mode() == SCALE_FRACTIONAL)
maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT);
return maximum.dim();
@@ -1737,7 +1670,7 @@ void win_window_info::maximize_window()
osd_dim newsize = get_max_bounds(keepaspect());
// center within the work area
- osd_rect work = m_monitor->usuable_position_size();
+ osd_rect work = monitor()->usuable_position_size();
osd_rect newrect = osd_rect(work.left() + (work.width() - newsize.width()) / 2,
work.top() + (work.height() - newsize.height()) / 2,
newsize);
@@ -1803,7 +1736,7 @@ void win_window_info::adjust_window_position_after_major_change()
newrect.width(), newrect.height(), 0);
// take note of physical window size (used for lightgun coordinate calculation)
- if (m_index == 0)
+ if (index() == 0)
osd_printf_verbose("Physical width %d, height %d\n", newrect.width(), newrect.height());
}
diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h
index 22065135efe..33001d721c3 100644
--- a/src/osd/windows/window.h
+++ b/src/osd/windows/window.h
@@ -55,10 +55,6 @@ class win_window_info : public osd_window_t<HWND>
public:
win_window_info(running_machine &machine, int index, std::shared_ptr<osd_monitor_info> monitor, const osd_window_config *config);
- running_machine &machine() const override { return m_machine; }
-
- virtual render_target *target() override { return m_target; }
- int fullscreen() const override { return m_fullscreen; }
bool attached_mode() const { return m_attached_mode; }
win_window_focus focus() const;
@@ -89,9 +85,7 @@ public:
void show_pointer() override;
void hide_pointer() override;
- virtual osd_monitor_info *monitor() const override { return m_monitor.get(); }
-
- void destroy() override;
+ void complete_destroy() override;
// static
@@ -103,7 +97,6 @@ public:
// member variables
- win_window_info * m_next;
volatile int m_init_state;
// window handle and info
@@ -114,14 +107,11 @@ public:
int m_ismaximized;
// monitor info
- std::shared_ptr<osd_monitor_info> m_monitor;
- int m_fullscreen;
int m_fullscreen_safe;
float m_aspect;
// rendering info
std::mutex m_render_lock;
- render_target * m_target;
unsigned m_targetview;
int m_targetorient;
render_layer_config m_targetlayerconfig;
@@ -135,7 +125,6 @@ public:
private:
void draw_video_contents(HDC dc, bool update);
int complete_create();
- void set_starting_view(int index, const char *defview, const char *view);
int wnd_extra_width();
int wnd_extra_height();
osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment);
@@ -154,7 +143,6 @@ private:
static Windows::UI::Core::CoreCursor^ s_cursor;
#endif
- running_machine & m_machine;
bool m_attached_mode;
};