osd: Moved some windows-specific stuff into osd/windows/window.{h,cpp}.

This commit is contained in:
Vas Crabb 2023-02-26 03:18:36 +11:00
parent df80004c3c
commit a4e8ffe3dc
7 changed files with 31 additions and 27 deletions

View File

@ -25,9 +25,6 @@ osd_window::osd_window(
int index, int index,
const std::shared_ptr<osd_monitor_info> &monitor, const std::shared_ptr<osd_monitor_info> &monitor,
const osd_window_config &config) : const osd_window_config &config) :
#ifdef OSD_WINDOWS
m_dc(nullptr), m_resize_state(0),
#endif
m_target(nullptr), m_target(nullptr),
m_primlist(nullptr), m_primlist(nullptr),
m_win_config(config), m_win_config(config),

View File

@ -108,11 +108,6 @@ protected:
private: private:
void set_starting_view(int index, const char *defview, const char *view); 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: private:
render_target *m_target; render_target *m_target;
public: public:

View File

@ -334,7 +334,7 @@ bool video_bgfx::init_bgfx_library(osd_window &window)
init.resolution.width = wdim.width(); init.resolution.width = wdim.width();
init.resolution.height = wdim.height(); init.resolution.height = wdim.height();
init.resolution.numBackBuffers = 1; 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)) if (!set_platform_data(init.platformData, window))
{ {
osd_printf_error("Setting BGFX platform data failed\n"); osd_printf_error("Setting BGFX platform data failed\n");

View File

@ -630,7 +630,7 @@ int renderer_d3d9::initialize()
int renderer_d3d9::pre_window_draw_check() int renderer_d3d9::pre_window_draw_check()
{ {
// if we're in the middle of resizing, leave things alone // if we're in the middle of resizing, leave things alone
if (window().m_resize_state == RESIZE_STATE_RESIZING) if (dynamic_cast<win_window_info &>(window()).m_resize_state == win_window_info::RESIZE_STATE_RESIZING)
return 0; return 0;
// check if shaders should be toggled // check if shaders should be toggled
@ -1407,30 +1407,31 @@ void renderer_d3d9::pick_best_mode()
bool renderer_d3d9::update_window_size() bool renderer_d3d9::update_window_size()
{ {
// get the current window bounds // get the current window bounds
auto &win = dynamic_cast<win_window_info &>(window());
RECT client; RECT client;
GetClientRectExceptMenu(dynamic_cast<win_window_info &>(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 we have a device and matching width/height, nothing to do
if (m_device && rect_width(&client) == m_width && rect_height(&client) == m_height) if (m_device && rect_width(&client) == m_width && rect_height(&client) == m_height)
{ {
// clear out any pending resizing if the area didn't change // clear out any pending resizing if the area didn't change
if (window().m_resize_state == RESIZE_STATE_PENDING) if (win.m_resize_state == win_window_info::RESIZE_STATE_PENDING)
window().m_resize_state = RESIZE_STATE_NORMAL; win.m_resize_state = win_window_info::RESIZE_STATE_NORMAL;
return false; return false;
} }
// if we're in the middle of resizing, leave it alone as well // 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; return false;
// set the new bounds and create the device again // set the new bounds and create the device again
m_width = rect_width(&client); m_width = rect_width(&client);
m_height = rect_height(&client); m_height = rect_height(&client);
if (device_create(dynamic_cast<win_window_info &>(window()).main_window()->platform_window())) if (device_create(win.main_window()->platform_window()))
return false; return false;
// reset the resize state to normal, and indicate we made a change // 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; return true;
} }

View File

@ -90,16 +90,18 @@ render_primitive_list *renderer_gdi::get_primitives()
int renderer_gdi::draw(const int update) int renderer_gdi::draw(const int update)
{ {
auto &win = dynamic_cast<win_window_info &>(window());
// we don't have any special resize behaviors // we don't have any special resize behaviors
if (window().m_resize_state == RESIZE_STATE_PENDING) if (win.m_resize_state == win_window_info::RESIZE_STATE_PENDING)
window().m_resize_state = RESIZE_STATE_NORMAL; win.m_resize_state = win_window_info::RESIZE_STATE_NORMAL;
// get the target bounds // get the target bounds
RECT bounds; RECT bounds;
GetClientRect(dynamic_cast<win_window_info &>(window()).platform_window(), &bounds); GetClientRect(win.platform_window(), &bounds);
// compute width/height/pitch of target // 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 width = dimensions.width();
int const height = dimensions.height(); int const height = dimensions.height();
int const pitch = (width + 3) & ~3; int const pitch = (width + 3) & ~3;
@ -113,9 +115,9 @@ int renderer_gdi::draw(const int update)
} }
// draw the primitives to the bitmap // draw the primitives to the bitmap
window().m_primlist->acquire_lock(); win.m_primlist->acquire_lock();
software_renderer<uint32_t, 0,0,0, 16,8,0>::draw_primitives(*window().m_primlist, m_bmdata.get(), width, height, pitch); software_renderer<uint32_t, 0,0,0, 16,8,0>::draw_primitives(*win.m_primlist, m_bmdata.get(), width, height, pitch);
window().m_primlist->release_lock(); win.m_primlist->release_lock();
// fill in bitmap-specific info // fill in bitmap-specific info
m_bminfo.bmiHeader.biWidth = pitch; m_bminfo.bmiHeader.biWidth = pitch;
@ -123,7 +125,7 @@ int renderer_gdi::draw(const int update)
// blit to the screen // blit to the screen
StretchDIBits( StretchDIBits(
window().m_dc, 0, 0, width, height, win.m_dc, 0, 0, width, height,
0, 0, width, height, 0, 0, width, height,
m_bmdata.get(), &m_bminfo, DIB_RGB_COLORS, SRCCOPY); m_bmdata.get(), &m_bminfo, DIB_RGB_COLORS, SRCCOPY);

View File

@ -212,6 +212,8 @@ win_window_info::win_window_info(
, m_lastclickx(0) , m_lastclickx(0)
, m_lastclicky(0) , m_lastclicky(0)
, m_last_surrogate(0) , m_last_surrogate(0)
, m_dc(nullptr)
, m_resize_state(RESIZE_STATE_NORMAL)
, m_main(nullptr) , m_main(nullptr)
, m_attached_mode(false) , m_attached_mode(false)
{ {

View File

@ -33,9 +33,6 @@
// CONSTANTS // 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<HWND> class win_window_info : public osd_window_t<HWND>
{ {
public: 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<osd_monitor_info> &monitor, const osd_window_config *config); win_window_info(running_machine &machine, render_module &renderprovider, int index, const std::shared_ptr<osd_monitor_info> &monitor, const osd_window_config *config);
bool attached_mode() const { return m_attached_mode; } bool attached_mode() const { return m_attached_mode; }
@ -120,6 +124,9 @@ public:
int m_lastclicky; int m_lastclicky;
char16_t m_last_surrogate; char16_t m_last_surrogate;
HDC m_dc; // only used by GDI renderer!
int m_resize_state;
private: private:
void draw_video_contents(HDC dc, bool update); void draw_video_contents(HDC dc, bool update);
int complete_create(); int complete_create();