From a4e8ffe3dcfd5c0de4e2a59e59a8c944274703a6 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 26 Feb 2023 03:18:36 +1100 Subject: osd: Moved some windows-specific stuff into osd/windows/window.{h,cpp}. --- src/osd/modules/osdwindow.cpp | 3 --- src/osd/modules/osdwindow.h | 5 ----- src/osd/modules/render/drawbgfx.cpp | 2 +- src/osd/modules/render/drawd3d.cpp | 15 ++++++++------- src/osd/modules/render/drawgdi.cpp | 18 ++++++++++-------- src/osd/windows/window.cpp | 2 ++ src/osd/windows/window.h | 13 ++++++++++--- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/osd/modules/osdwindow.cpp b/src/osd/modules/osdwindow.cpp index 3b2c92c39ea..38b86e652e0 100644 --- a/src/osd/modules/osdwindow.cpp +++ b/src/osd/modules/osdwindow.cpp @@ -25,9 +25,6 @@ osd_window::osd_window( int index, const std::shared_ptr &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), diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index 13baf050cbb..f3d39878b5e 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -108,11 +108,6 @@ protected: 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: diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp index 9690b5e390e..f1a8d2611f5 100644 --- a/src/osd/modules/render/drawbgfx.cpp +++ b/src/osd/modules/render/drawbgfx.cpp @@ -334,7 +334,7 @@ bool video_bgfx::init_bgfx_library(osd_window &window) init.resolution.width = wdim.width(); init.resolution.height = wdim.height(); init.resolution.numBackBuffers = 1; - init.resolution.reset = BGFX_RESET_NONE; + init.resolution.reset = video_config.waitvsync ? BGFX_RESET_VSYNC : BGFX_RESET_NONE; if (!set_platform_data(init.platformData, window)) { osd_printf_error("Setting BGFX platform data failed\n"); diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp index 7b8bd082142..39fbc2408a2 100644 --- a/src/osd/modules/render/drawd3d.cpp +++ b/src/osd/modules/render/drawd3d.cpp @@ -630,7 +630,7 @@ int renderer_d3d9::initialize() int renderer_d3d9::pre_window_draw_check() { // if we're in the middle of resizing, leave things alone - if (window().m_resize_state == RESIZE_STATE_RESIZING) + if (dynamic_cast(window()).m_resize_state == win_window_info::RESIZE_STATE_RESIZING) return 0; // check if shaders should be toggled @@ -1407,30 +1407,31 @@ void renderer_d3d9::pick_best_mode() bool renderer_d3d9::update_window_size() { // get the current window bounds + auto &win = dynamic_cast(window()); RECT client; - GetClientRectExceptMenu(dynamic_cast(window()).platform_window(), &client, window().fullscreen()); + GetClientRectExceptMenu(win.platform_window(), &client, window().fullscreen()); // if we have a device and matching width/height, nothing to do if (m_device && rect_width(&client) == m_width && rect_height(&client) == m_height) { // clear out any pending resizing if the area didn't change - if (window().m_resize_state == RESIZE_STATE_PENDING) - window().m_resize_state = RESIZE_STATE_NORMAL; + if (win.m_resize_state == win_window_info::RESIZE_STATE_PENDING) + win.m_resize_state = win_window_info::RESIZE_STATE_NORMAL; return false; } // if we're in the middle of resizing, leave it alone as well - if (window().m_resize_state == RESIZE_STATE_RESIZING) + if (win.m_resize_state == win_window_info::RESIZE_STATE_RESIZING) return false; // set the new bounds and create the device again m_width = rect_width(&client); m_height = rect_height(&client); - if (device_create(dynamic_cast(window()).main_window()->platform_window())) + if (device_create(win.main_window()->platform_window())) return false; // reset the resize state to normal, and indicate we made a change - window().m_resize_state = RESIZE_STATE_NORMAL; + win.m_resize_state = win_window_info::RESIZE_STATE_NORMAL; return true; } diff --git a/src/osd/modules/render/drawgdi.cpp b/src/osd/modules/render/drawgdi.cpp index 69ac20434b3..f922ca24e8f 100644 --- a/src/osd/modules/render/drawgdi.cpp +++ b/src/osd/modules/render/drawgdi.cpp @@ -90,16 +90,18 @@ render_primitive_list *renderer_gdi::get_primitives() int renderer_gdi::draw(const int update) { + auto &win = dynamic_cast(window()); + // we don't have any special resize behaviors - if (window().m_resize_state == RESIZE_STATE_PENDING) - window().m_resize_state = RESIZE_STATE_NORMAL; + if (win.m_resize_state == win_window_info::RESIZE_STATE_PENDING) + win.m_resize_state = win_window_info::RESIZE_STATE_NORMAL; // get the target bounds RECT bounds; - GetClientRect(dynamic_cast(window()).platform_window(), &bounds); + GetClientRect(win.platform_window(), &bounds); // compute width/height/pitch of target - osd_dim const dimensions = window().get_size(); + osd_dim const dimensions = win.get_size(); int const width = dimensions.width(); int const height = dimensions.height(); int const pitch = (width + 3) & ~3; @@ -113,9 +115,9 @@ int renderer_gdi::draw(const int update) } // draw the primitives to the bitmap - window().m_primlist->acquire_lock(); - software_renderer::draw_primitives(*window().m_primlist, m_bmdata.get(), width, height, pitch); - window().m_primlist->release_lock(); + win.m_primlist->acquire_lock(); + software_renderer::draw_primitives(*win.m_primlist, m_bmdata.get(), width, height, pitch); + win.m_primlist->release_lock(); // fill in bitmap-specific info m_bminfo.bmiHeader.biWidth = pitch; @@ -123,7 +125,7 @@ int renderer_gdi::draw(const int update) // blit to the screen StretchDIBits( - window().m_dc, 0, 0, width, height, + win.m_dc, 0, 0, width, height, 0, 0, width, height, m_bmdata.get(), &m_bminfo, DIB_RGB_COLORS, SRCCOPY); diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index 7c1a6aa366b..387a7f6daba 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -212,6 +212,8 @@ win_window_info::win_window_info( , m_lastclickx(0) , m_lastclicky(0) , m_last_surrogate(0) + , m_dc(nullptr) + , m_resize_state(RESIZE_STATE_NORMAL) , m_main(nullptr) , m_attached_mode(false) { diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index aa56746a820..53021e43a78 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -33,9 +33,6 @@ // CONSTANTS //============================================================ -#define RESIZE_STATE_NORMAL 0 -#define RESIZE_STATE_RESIZING 1 -#define RESIZE_STATE_PENDING 2 @@ -54,6 +51,13 @@ enum class win_window_focus class win_window_info : public osd_window_t { public: + enum + { + RESIZE_STATE_NORMAL, + RESIZE_STATE_RESIZING, + RESIZE_STATE_PENDING + }; + win_window_info(running_machine &machine, render_module &renderprovider, int index, const std::shared_ptr &monitor, const osd_window_config *config); bool attached_mode() const { return m_attached_mode; } @@ -120,6 +124,9 @@ public: int m_lastclicky; char16_t m_last_surrogate; + HDC m_dc; // only used by GDI renderer! + int m_resize_state; + private: void draw_video_contents(HDC dc, bool update); int complete_create(); -- cgit v1.2.3