mirror of
https://github.com/holub/mame
synced 2025-06-29 07:34:45 +03:00
Identified window properties/variables which are used by renderers.
Althought the code in window.h is far from nice currently it now allows to address one issue after the other. (nw)
This commit is contained in:
parent
a82dcde65d
commit
a0dccc50e1
@ -32,7 +32,35 @@ typedef UINT32 HashT;
|
||||
// TYPE DEFINITIONS
|
||||
//============================================================
|
||||
|
||||
class sdl_window_info;
|
||||
class osd_window
|
||||
{
|
||||
public:
|
||||
osd_window()
|
||||
: m_primlist(NULL),
|
||||
m_start_viewscreen(0)
|
||||
{}
|
||||
virtual ~osd_window() { }
|
||||
#ifdef OSD_SDL
|
||||
virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
|
||||
virtual sdl_monitor_info *monitor() const = 0;
|
||||
virtual render_target *target() = 0;
|
||||
virtual void get_size(int &w, int &h) = 0;
|
||||
virtual int fullscreen() const = 0;
|
||||
virtual int index() const = 0;
|
||||
virtual int prescale() const = 0;
|
||||
#if (SDLMAME_SDL2)
|
||||
virtual SDL_Window *sdl_window() = 0;
|
||||
#else
|
||||
virtual SDL_Surface *sdl_surface() = 0;
|
||||
#endif
|
||||
|
||||
virtual running_machine &machine() const = 0;
|
||||
|
||||
render_primitive_list *m_primlist;
|
||||
int m_start_viewscreen;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
class osd_renderer
|
||||
{
|
||||
@ -48,12 +76,12 @@ public:
|
||||
static const int FLAG_NEEDS_ASYNCBLIT = 0x0200;
|
||||
#endif
|
||||
|
||||
osd_renderer(sdl_window_info *window, const int flags)
|
||||
osd_renderer(osd_window *window, const int flags)
|
||||
: m_window(window), m_flags(flags) { }
|
||||
|
||||
virtual ~osd_renderer() { }
|
||||
|
||||
sdl_window_info &window() { return *m_window; }
|
||||
osd_window &window() { return *m_window; }
|
||||
int flags() const { return m_flags; }
|
||||
bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
|
||||
|
||||
@ -62,9 +90,18 @@ public:
|
||||
/* Interface to be implemented by render code */
|
||||
|
||||
virtual int create() = 0;
|
||||
virtual int draw(const UINT32 dc, const int update) = 0;
|
||||
virtual render_primitive_list *get_primitives() = 0;
|
||||
|
||||
#ifdef OSD_SDL
|
||||
virtual int draw(const UINT32 dc, const int update) = 0;
|
||||
virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0;
|
||||
#else
|
||||
virtual int draw(HDC dc, int update) = 0;
|
||||
virtual void save() = 0;
|
||||
virtual void record() = 0;
|
||||
virtual void toggle_fsfx() = 0;
|
||||
#endif
|
||||
|
||||
virtual void destroy() = 0;
|
||||
|
||||
protected:
|
||||
@ -76,19 +113,18 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
sdl_window_info *m_window;
|
||||
osd_window *m_window;
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
#define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid)
|
||||
|
||||
class sdl_window_info
|
||||
class sdl_window_info : public osd_window
|
||||
{
|
||||
public:
|
||||
sdl_window_info(running_machine &a_machine, int index, sdl_monitor_info *a_monitor,
|
||||
const sdl_window_config *config)
|
||||
: m_next(NULL), m_primlist(NULL),
|
||||
m_start_viewscreen(0),
|
||||
: osd_window(), m_next(NULL),
|
||||
// Following three are used by input code to defer resizes
|
||||
#if (SDLMAME_SDL2)
|
||||
m_resize_width(0),
|
||||
@ -164,9 +200,6 @@ public:
|
||||
// Pointer to next window
|
||||
sdl_window_info * m_next;
|
||||
|
||||
// FIXME: renderer should deal with this
|
||||
render_primitive_list *m_primlist;
|
||||
int m_start_viewscreen;
|
||||
#if (SDLMAME_SDL2)
|
||||
// These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
|
||||
int m_resize_width;
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
virtual ~renderer_bgfx() { }
|
||||
|
||||
virtual int init();
|
||||
virtual int create();
|
||||
virtual render_primitive_list *get_primitives();
|
||||
virtual int draw(HDC dc, int update);
|
||||
virtual void save() {};
|
||||
@ -87,7 +87,7 @@ static void drawbgfx_exit(void)
|
||||
// drawbgfx_window_init
|
||||
//============================================================
|
||||
|
||||
int renderer_bgfx::init()
|
||||
int renderer_bgfx::create()
|
||||
{
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
@ -124,8 +124,8 @@ render_primitive_list *renderer_bgfx::get_primitives()
|
||||
{
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().m_target->get_primitives();
|
||||
window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().target()->get_primitives();
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,7 +184,7 @@ static void drawd3d_exit(void);
|
||||
// drawd3d_window_init
|
||||
//============================================================
|
||||
|
||||
int d3d::renderer::init()
|
||||
int d3d::renderer::create()
|
||||
{
|
||||
if (!initialize())
|
||||
{
|
||||
@ -244,13 +244,13 @@ render_primitive_list *d3d::renderer::get_primitives()
|
||||
{
|
||||
RECT client;
|
||||
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
|
||||
if (rect_width(&client) > 0 && rect_height(&client) > 0)
|
||||
{
|
||||
window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
window().m_target->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh());
|
||||
window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
window().target()->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh());
|
||||
}
|
||||
return &window().m_target->get_primitives();
|
||||
return &window().target()->get_primitives();
|
||||
}
|
||||
|
||||
//============================================================
|
||||
@ -468,7 +468,7 @@ texture_manager::texture_manager(renderer *d3d)
|
||||
osd_printf_verbose("Direct3D: YUV format = %s\n", (m_yuv_format == D3DFMT_YUY2) ? "YUY2" : (m_yuv_format == D3DFMT_UYVY) ? "UYVY" : "RGB");
|
||||
|
||||
// set the max texture size
|
||||
d3d->window().m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height);
|
||||
d3d->window().target()->set_max_texture_size(m_texture_max_width, m_texture_max_height);
|
||||
osd_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height);
|
||||
}
|
||||
|
||||
@ -644,7 +644,7 @@ int renderer::initialize()
|
||||
return false;
|
||||
|
||||
// create the device immediately for the full screen case (defer for window mode)
|
||||
if (window().m_fullscreen && device_create())
|
||||
if (window().fullscreen() && device_create())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -678,7 +678,7 @@ int renderer::pre_window_draw_check()
|
||||
}
|
||||
|
||||
// in window mode, we need to track the window size
|
||||
if (!window().m_fullscreen || m_device == NULL)
|
||||
if (!window().fullscreen() || m_device == NULL)
|
||||
{
|
||||
// if the size changes, skip this update since the render target will be out of date
|
||||
if (update_window_size())
|
||||
@ -866,12 +866,12 @@ try_again:
|
||||
m_presentation.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
m_presentation.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
m_presentation.hDeviceWindow = window().m_hwnd;
|
||||
m_presentation.Windowed = !window().m_fullscreen || win_has_menu(&window());
|
||||
m_presentation.Windowed = !window().fullscreen() || window().win_has_menu();
|
||||
m_presentation.EnableAutoDepthStencil = FALSE;
|
||||
m_presentation.AutoDepthStencilFormat = D3DFMT_D16;
|
||||
m_presentation.Flags = 0;
|
||||
m_presentation.FullScreen_RefreshRateInHz = m_refresh;
|
||||
m_presentation.PresentationInterval = ((video_config.triplebuf && window().m_fullscreen) ||
|
||||
m_presentation.PresentationInterval = ((video_config.triplebuf && window().fullscreen()) ||
|
||||
video_config.waitvsync || video_config.syncrefresh) ?
|
||||
D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
@ -899,7 +899,7 @@ try_again:
|
||||
osd_printf_verbose("Direct3D: Device created at %dx%d\n", m_width, m_height);
|
||||
|
||||
// set the gamma if we need to
|
||||
if (window().m_fullscreen)
|
||||
if (window().fullscreen())
|
||||
{
|
||||
// only set the gamma if it's not 1.0f
|
||||
windows_options &options = downcast<windows_options &>(window().machine().options());
|
||||
@ -1064,7 +1064,8 @@ int renderer::device_verify_caps()
|
||||
int retval = 0;
|
||||
|
||||
m_shaders = global_alloc_clear(shaders);
|
||||
m_shaders->init(d3dintf, &window());
|
||||
// FIXME: Dynamic cast
|
||||
m_shaders->init(d3dintf, dynamic_cast<win_window_info *>(&window()));
|
||||
|
||||
DWORD tempcaps;
|
||||
HRESULT result = (*d3dintf->d3d.get_caps_dword)(d3dintf, m_adapter, D3DDEVTYPE_HAL, CAPS_MAX_PS30_INSN_SLOTS, &tempcaps);
|
||||
@ -1203,12 +1204,12 @@ int renderer::config_adapter_mode()
|
||||
}
|
||||
|
||||
// choose a resolution: window mode case
|
||||
if (!window().m_fullscreen || !video_config.switchres || win_has_menu(&window()))
|
||||
if (!window().fullscreen() || !video_config.switchres || window().win_has_menu())
|
||||
{
|
||||
RECT client;
|
||||
|
||||
// bounds are from the window client rect
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
|
||||
m_width = client.right - client.left;
|
||||
m_height = client.bottom - client.top;
|
||||
|
||||
@ -1244,7 +1245,7 @@ int renderer::config_adapter_mode()
|
||||
}
|
||||
|
||||
// see if we can handle the device type
|
||||
result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().m_fullscreen);
|
||||
result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().fullscreen());
|
||||
if (result != D3D_OK)
|
||||
{
|
||||
char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice);
|
||||
@ -1308,7 +1309,7 @@ void renderer::pick_best_mode()
|
||||
// note: technically we should not be calling this from an alternate window
|
||||
// thread; however, it is only done during init time, and the init code on
|
||||
// the main thread is waiting for us to finish, so it is safe to do so here
|
||||
window().m_target->compute_minimum_size(minwidth, minheight);
|
||||
window().target()->compute_minimum_size(minwidth, minheight);
|
||||
|
||||
// use those as the target for now
|
||||
INT32 target_width = minwidth;
|
||||
@ -1384,7 +1385,7 @@ int renderer::update_window_size()
|
||||
{
|
||||
// get the current window bounds
|
||||
RECT client;
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().m_fullscreen);
|
||||
GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen());
|
||||
|
||||
// if we have a device and matching width/height, nothing to do
|
||||
if (m_device != NULL && rect_width(&client) == m_width && rect_height(&client) == m_height)
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
renderer(win_window_info *window);
|
||||
virtual ~renderer();
|
||||
|
||||
virtual int init();
|
||||
virtual int create();
|
||||
virtual render_primitive_list *get_primitives();
|
||||
virtual int draw(HDC dc, int update);
|
||||
virtual void save();
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
|
||||
virtual ~renderer_dd() { }
|
||||
|
||||
virtual int init();
|
||||
virtual int create();
|
||||
virtual render_primitive_list *get_primitives();
|
||||
virtual int draw(HDC dc, int update);
|
||||
virtual void save() {};
|
||||
@ -258,7 +258,7 @@ static void drawdd_exit(void)
|
||||
// drawdd_window_init
|
||||
//============================================================
|
||||
|
||||
int renderer_dd::init()
|
||||
int renderer_dd::create()
|
||||
{
|
||||
// configure the adapter for the mode we want
|
||||
if (config_adapter_mode())
|
||||
@ -297,10 +297,10 @@ void renderer_dd::destroy()
|
||||
render_primitive_list *renderer_dd::get_primitives()
|
||||
{
|
||||
compute_blit_surface_size();
|
||||
window().m_target->set_bounds(blitwidth, blitheight, 0);
|
||||
window().m_target->set_max_update_rate((refresh == 0) ? origmode.dwRefreshRate : refresh);
|
||||
window().target()->set_bounds(blitwidth, blitheight, 0);
|
||||
window().target()->set_max_update_rate((refresh == 0) ? origmode.dwRefreshRate : refresh);
|
||||
|
||||
return &window().m_target->get_primitives();
|
||||
return &window().target()->get_primitives();
|
||||
}
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ int renderer_dd::draw(HDC dc, int update)
|
||||
if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result);
|
||||
|
||||
// sync to VBLANK
|
||||
if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().m_fullscreen || back == NULL))
|
||||
if ((video_config.waitvsync || video_config.syncrefresh) && window().machine().video().throttled() && (!window().fullscreen() || back == NULL))
|
||||
{
|
||||
result = IDirectDraw7_WaitForVerticalBlank(ddraw, DDWAITVB_BLOCKBEGIN, NULL);
|
||||
if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
|
||||
@ -469,7 +469,7 @@ int renderer_dd::ddraw_create()
|
||||
osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result);
|
||||
goto error;
|
||||
}
|
||||
result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
|
||||
result = IDirectDraw7_SetCooperativeLevel(ddraw, window().m_hwnd, DDSCL_SETDEVICEWINDOW | (window().fullscreen() ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
|
||||
if (result != DD_OK)
|
||||
{
|
||||
osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result);
|
||||
@ -477,7 +477,7 @@ int renderer_dd::ddraw_create()
|
||||
}
|
||||
|
||||
// full screen mode: set the resolution
|
||||
if (window().m_fullscreen && video_config.switchres)
|
||||
if (window().fullscreen() && video_config.switchres)
|
||||
{
|
||||
result = IDirectDraw7_SetDisplayMode(ddraw, width, height, 32, refresh, 0);
|
||||
if (result != DD_OK)
|
||||
@ -511,7 +511,7 @@ int renderer_dd::ddraw_create_surfaces()
|
||||
primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
|
||||
// for triple-buffered full screen mode, allocate flipping surfaces
|
||||
if (window().m_fullscreen && video_config.triplebuf)
|
||||
if (window().fullscreen() && video_config.triplebuf)
|
||||
{
|
||||
primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
|
||||
primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
|
||||
@ -524,7 +524,7 @@ int renderer_dd::ddraw_create_surfaces()
|
||||
|
||||
// full screen mode: get the back surface
|
||||
back = NULL;
|
||||
if (window().m_fullscreen && video_config.triplebuf)
|
||||
if (window().fullscreen() && video_config.triplebuf)
|
||||
{
|
||||
DDSCAPS2 caps = { DDSCAPS_BACKBUFFER };
|
||||
result = IDirectDrawSurface7_GetAttachedSurface(primary, &caps, &back);
|
||||
@ -564,11 +564,11 @@ int renderer_dd::ddraw_create_surfaces()
|
||||
goto error;
|
||||
|
||||
// create a clipper for windowed mode
|
||||
if (!window().m_fullscreen && create_clipper())
|
||||
if (!window().fullscreen() && create_clipper())
|
||||
goto error;
|
||||
|
||||
// full screen mode: set the gamma
|
||||
if (window().m_fullscreen)
|
||||
if (window().fullscreen())
|
||||
{
|
||||
// only set the gamma if it's not 1.0f
|
||||
windows_options &options = downcast<windows_options &>(window().machine().options());
|
||||
@ -825,7 +825,7 @@ void renderer_dd::compute_blit_surface_size()
|
||||
RECT client;
|
||||
|
||||
// start with the minimum size
|
||||
window().m_target->compute_minimum_size(newwidth, newheight);
|
||||
window().target()->compute_minimum_size(newwidth, newheight);
|
||||
|
||||
// get the window's client rectangle
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
@ -854,8 +854,8 @@ void renderer_dd::compute_blit_surface_size()
|
||||
// compute the appropriate visible area if we're trying to keepaspect
|
||||
if (video_config.keepaspect)
|
||||
{
|
||||
win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL);
|
||||
window().m_target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().m_target->orientation(), target_width, target_height);
|
||||
win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
|
||||
window().target()->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().target()->orientation(), target_width, target_height);
|
||||
desired_aspect = (float)target_width / (float)target_height;
|
||||
}
|
||||
|
||||
@ -920,7 +920,7 @@ void renderer_dd::calc_fullscreen_margins(DWORD desc_width, DWORD desc_height, R
|
||||
margins->right = desc_width;
|
||||
margins->bottom = desc_height;
|
||||
|
||||
if (win_has_menu(&window()))
|
||||
if (window().win_has_menu())
|
||||
{
|
||||
static int height_with_menubar = 0;
|
||||
if (height_with_menubar == 0)
|
||||
@ -944,7 +944,7 @@ void renderer_dd::calc_fullscreen_margins(DWORD desc_width, DWORD desc_height, R
|
||||
void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
|
||||
{
|
||||
IDirectDrawSurface7 *target = (back != NULL) ? back : primary;
|
||||
win_monitor_info *monitor = winwindow_video_window_monitor(&window(), NULL);
|
||||
win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL);
|
||||
DDBLTFX blitfx = { sizeof(DDBLTFX) };
|
||||
RECT clear, outer, dest, source;
|
||||
INT32 dstwidth, dstheight;
|
||||
@ -956,7 +956,7 @@ void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
|
||||
source.bottom = srcheight;
|
||||
|
||||
// compute outer rect -- windowed version
|
||||
if (!window().m_fullscreen)
|
||||
if (!window().fullscreen())
|
||||
{
|
||||
GetClientRect(window().m_hwnd, &outer);
|
||||
ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[0]);
|
||||
@ -999,7 +999,7 @@ void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
|
||||
else if (video_config.keepaspect)
|
||||
{
|
||||
// compute the appropriate visible area
|
||||
window().m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().m_target->orientation(), dstwidth, dstheight);
|
||||
window().target()->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().target()->orientation(), dstwidth, dstheight);
|
||||
}
|
||||
|
||||
// center within
|
||||
@ -1062,7 +1062,7 @@ void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
|
||||
if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result);
|
||||
|
||||
// page flip if triple buffered
|
||||
if (window().m_fullscreen && back != NULL)
|
||||
if (window().fullscreen() && back != NULL)
|
||||
{
|
||||
result = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
|
||||
if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
|
||||
@ -1112,7 +1112,7 @@ int renderer_dd::config_adapter_mode()
|
||||
}
|
||||
|
||||
// choose a resolution: full screen mode case
|
||||
if (window().m_fullscreen)
|
||||
if (window().fullscreen())
|
||||
{
|
||||
// default to the current mode exactly
|
||||
width = origmode.dwWidth;
|
||||
@ -1129,7 +1129,7 @@ int renderer_dd::config_adapter_mode()
|
||||
ddraw = NULL;
|
||||
|
||||
// if we're not changing resolutions, make sure we have a resolution we can handle
|
||||
if (!window().m_fullscreen || !video_config.switchres)
|
||||
if (!window().fullscreen() || !video_config.switchres)
|
||||
{
|
||||
switch (origmode.ddpfPixelFormat.dwRBitMask)
|
||||
{
|
||||
@ -1268,7 +1268,7 @@ void renderer_dd::pick_best_mode()
|
||||
// note: technically we should not be calling this from an alternate window
|
||||
// thread; however, it is only done during init time, and the init code on
|
||||
// the main thread is waiting for us to finish, so it is safe to do so here
|
||||
window().m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
|
||||
window().target()->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
|
||||
|
||||
// use those as the target for now
|
||||
einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
|
||||
@ -1296,7 +1296,7 @@ void renderer_dd::pick_best_mode()
|
||||
}
|
||||
|
||||
// fill in the rest of the data
|
||||
einfo.window = &window();
|
||||
einfo.window = dynamic_cast<win_window_info *>(&window());
|
||||
einfo.best_score = 0.0f;
|
||||
|
||||
// enumerate the modes
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
virtual ~renderer_gdi() { }
|
||||
|
||||
virtual int init();
|
||||
virtual int create();
|
||||
virtual render_primitive_list *get_primitives();
|
||||
virtual int draw(HDC dc, int update);
|
||||
virtual void save() {};
|
||||
@ -92,7 +92,7 @@ static void drawgdi_exit(void)
|
||||
// drawgdi_window_init
|
||||
//============================================================
|
||||
|
||||
int renderer_gdi::init()
|
||||
int renderer_gdi::create()
|
||||
{
|
||||
|
||||
// fill in the bitmap info header
|
||||
@ -133,8 +133,8 @@ render_primitive_list *renderer_gdi::get_primitives()
|
||||
{
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().m_target->get_primitives();
|
||||
window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().target()->get_primitives();
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
virtual ~renderer_none() { }
|
||||
|
||||
virtual int init();
|
||||
virtual int create();
|
||||
virtual render_primitive_list *get_primitives();
|
||||
virtual int draw(HDC dc, int update);
|
||||
virtual void save() { };
|
||||
@ -81,7 +81,7 @@ static void drawnone_exit(void)
|
||||
// drawnone_window_init
|
||||
//============================================================
|
||||
|
||||
int renderer_none::init()
|
||||
int renderer_none::create()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -106,8 +106,8 @@ render_primitive_list *renderer_none::get_primitives()
|
||||
{
|
||||
RECT client;
|
||||
GetClientRect(window().m_hwnd, &client);
|
||||
window().m_target->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().m_target->get_primitives();
|
||||
window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect());
|
||||
return &window().target()->get_primitives();
|
||||
}
|
||||
|
||||
|
||||
|
@ -574,7 +574,7 @@ bool wininput_should_hide_mouse(void)
|
||||
return false;
|
||||
|
||||
// if the window has a menu, no
|
||||
if (win_window_list != NULL && win_has_menu(win_window_list))
|
||||
if (win_window_list != NULL && win_window_list->win_has_menu())
|
||||
return false;
|
||||
|
||||
// otherwise, yes
|
||||
@ -1488,7 +1488,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
|
||||
device_info *devinfo;
|
||||
HRESULT result;
|
||||
|
||||
if (win_window_list != NULL && win_has_menu(win_window_list)) {
|
||||
if (win_window_list != NULL && win_window_list->win_has_menu()) {
|
||||
cooperative_level = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE;
|
||||
}
|
||||
// allocate and link in a new device
|
||||
|
@ -299,24 +299,16 @@ void windows_osd_interface::window_exit()
|
||||
win_window_info::win_window_info(running_machine &machine)
|
||||
: m_next(NULL),
|
||||
m_init_state(0),
|
||||
m_hwnd(0),
|
||||
m_focus_hwnd(0),
|
||||
m_startmaximized(0),
|
||||
m_isminimized(0),
|
||||
m_ismaximized(0),
|
||||
m_resize_state(0),
|
||||
m_monitor(0),
|
||||
m_fullscreen(0),
|
||||
m_fullscreen_safe(0),
|
||||
m_maxwidth(0),
|
||||
m_maxheight(0),
|
||||
m_refresh(0),
|
||||
m_aspect(0),
|
||||
m_render_lock(NULL),
|
||||
m_target(NULL),
|
||||
m_targetview(0),
|
||||
m_targetorient(0),
|
||||
m_primlist(NULL),
|
||||
m_lastclicktime(0),
|
||||
m_lastclickx(0),
|
||||
m_lastclicky(0),
|
||||
@ -620,7 +612,7 @@ void winwindow_update_cursor_state(running_machine &machine)
|
||||
// 2. we also hide the cursor in full screen mode and when the window doesn't have a menu
|
||||
// 3. we also hide the cursor in windowed mode if we're not paused and
|
||||
// the input system requests it
|
||||
if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!machine.paused() && wininput_should_hide_mouse())))
|
||||
if (winwindow_has_focus() && ((!video_config.windowed && !win_window_list->win_has_menu()) || (!machine.paused() && wininput_should_hide_mouse())))
|
||||
{
|
||||
win_window_info *window = win_window_list;
|
||||
RECT bounds;
|
||||
@ -849,22 +841,22 @@ void win_window_info::update()
|
||||
// (window thread)
|
||||
//============================================================
|
||||
|
||||
win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed)
|
||||
win_monitor_info *win_window_info::winwindow_video_window_monitor(const RECT *proposed)
|
||||
{
|
||||
win_monitor_info *monitor;
|
||||
|
||||
// in window mode, find the nearest
|
||||
if (!window->m_fullscreen)
|
||||
if (!m_fullscreen)
|
||||
{
|
||||
if (proposed != NULL)
|
||||
monitor = winvideo_monitor_from_handle(MonitorFromRect(proposed, MONITOR_DEFAULTTONEAREST));
|
||||
else
|
||||
monitor = winvideo_monitor_from_handle(MonitorFromWindow(window->m_hwnd, MONITOR_DEFAULTTONEAREST));
|
||||
monitor = winvideo_monitor_from_handle(MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST));
|
||||
}
|
||||
|
||||
// in full screen, just use the configured monitor
|
||||
else
|
||||
monitor = window->m_monitor;
|
||||
monitor = m_monitor;
|
||||
|
||||
// make sure we're up-to-date
|
||||
monitor->refresh();
|
||||
@ -1046,7 +1038,7 @@ INLINE int wnd_extra_width(win_window_info *window)
|
||||
RECT temprect = { 100, 100, 200, 200 };
|
||||
if (window->m_fullscreen)
|
||||
return 0;
|
||||
AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
|
||||
AdjustWindowRectEx(&temprect, WINDOW_STYLE, window->win_has_menu(), WINDOW_STYLE_EX);
|
||||
return rect_width(&temprect) - 100;
|
||||
}
|
||||
|
||||
@ -1062,7 +1054,7 @@ INLINE int wnd_extra_height(win_window_info *window)
|
||||
RECT temprect = { 100, 100, 200, 200 };
|
||||
if (window->m_fullscreen)
|
||||
return 0;
|
||||
AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
|
||||
AdjustWindowRectEx(&temprect, WINDOW_STYLE, window->win_has_menu(), WINDOW_STYLE_EX);
|
||||
return rect_height(&temprect) - 100;
|
||||
}
|
||||
|
||||
@ -1233,7 +1225,7 @@ static int complete_create(win_window_info *window)
|
||||
{
|
||||
// finish off by trying to initialize DirectX; if we fail, ignore it
|
||||
window->m_renderer = draw.create(window);
|
||||
if (window->m_renderer->init())
|
||||
if (window->m_renderer->create())
|
||||
return 1;
|
||||
ShowWindow(window->m_hwnd, SW_SHOW);
|
||||
}
|
||||
@ -1274,7 +1266,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar
|
||||
PAINTSTRUCT pstruct;
|
||||
HDC hdc = BeginPaint(wnd, &pstruct);
|
||||
draw_video_contents(window, hdc, TRUE);
|
||||
if (win_has_menu(window))
|
||||
if (window->win_has_menu())
|
||||
DrawMenuBar(window->m_hwnd);
|
||||
EndPaint(wnd, &pstruct);
|
||||
break;
|
||||
@ -1282,7 +1274,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar
|
||||
|
||||
// non-client paint: punt if full screen
|
||||
case WM_NCPAINT:
|
||||
if (!window->m_fullscreen || win_has_menu(window))
|
||||
if (!window->m_fullscreen || window->win_has_menu())
|
||||
return DefWindowProc(wnd, message, wparam, lparam);
|
||||
break;
|
||||
|
||||
@ -1515,7 +1507,7 @@ static void draw_video_contents(win_window_info *window, HDC dc, int update)
|
||||
|
||||
static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int adjustment)
|
||||
{
|
||||
win_monitor_info *monitor = winwindow_video_window_monitor(window, rect);
|
||||
win_monitor_info *monitor = window->winwindow_video_window_monitor(rect);
|
||||
INT32 extrawidth = wnd_extra_width(window);
|
||||
INT32 extraheight = wnd_extra_height(window);
|
||||
INT32 propwidth, propheight;
|
||||
@ -1828,7 +1820,7 @@ static void adjust_window_position_after_major_change(win_window_info *window)
|
||||
// in full screen, make sure it covers the primary display
|
||||
else
|
||||
{
|
||||
win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
|
||||
win_monitor_info *monitor = window->winwindow_video_window_monitor(NULL);
|
||||
newrect = monitor->info.rcMonitor;
|
||||
}
|
||||
|
||||
@ -1849,7 +1841,6 @@ static void adjust_window_position_after_major_change(win_window_info *window)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// set_fullscreen
|
||||
// (window thread)
|
||||
@ -1924,7 +1915,7 @@ static void set_fullscreen(win_window_info *window, int fullscreen)
|
||||
if (video_config.mode != VIDEO_MODE_NONE)
|
||||
ShowWindow(window->m_hwnd, SW_SHOW);
|
||||
window->m_renderer = draw.create(window);
|
||||
if (window->m_renderer->init())
|
||||
if (window->m_renderer->create())
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,59 @@
|
||||
|
||||
class win_window_info;
|
||||
|
||||
class osd_window
|
||||
{
|
||||
public:
|
||||
osd_window()
|
||||
:
|
||||
#ifdef OSD_SDL
|
||||
m_start_viewscreen(0),
|
||||
#else
|
||||
m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0),
|
||||
m_maxwidth(0), m_maxheight(0),
|
||||
m_refresh(0),
|
||||
#endif
|
||||
m_primlist(NULL)
|
||||
{}
|
||||
virtual ~osd_window() { }
|
||||
|
||||
virtual render_target *target() = 0;
|
||||
virtual int fullscreen() const = 0;
|
||||
virtual running_machine &machine() const = 0;
|
||||
|
||||
#ifdef OSD_SDL
|
||||
virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
|
||||
virtual sdl_monitor_info *monitor() const = 0;
|
||||
virtual void get_size(int &w, int &h) = 0;
|
||||
virtual int index() const = 0;
|
||||
virtual int prescale() const = 0;
|
||||
#if (SDLMAME_SDL2)
|
||||
virtual SDL_Window *sdl_window() = 0;
|
||||
#else
|
||||
virtual SDL_Surface *sdl_surface() = 0;
|
||||
#endif
|
||||
|
||||
int m_start_viewscreen;
|
||||
|
||||
#else
|
||||
virtual bool win_has_menu() = 0;
|
||||
virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0;
|
||||
|
||||
// window handle and info
|
||||
HWND m_hwnd;
|
||||
HWND m_focus_hwnd;
|
||||
|
||||
// monitor info
|
||||
win_monitor_info * m_monitor;
|
||||
int m_resize_state;
|
||||
int m_maxwidth, m_maxheight;
|
||||
int m_refresh;
|
||||
#endif
|
||||
|
||||
render_primitive_list * m_primlist;
|
||||
|
||||
};
|
||||
|
||||
class osd_renderer
|
||||
{
|
||||
public:
|
||||
@ -46,29 +99,48 @@ public:
|
||||
static const int FLAG_NEEDS_DOUBLEBUF = 0x0100;
|
||||
static const int FLAG_NEEDS_ASYNCBLIT = 0x0200;
|
||||
|
||||
osd_renderer(win_window_info *window, const int flags)
|
||||
osd_renderer(osd_window *window, const int flags)
|
||||
: m_window(window), m_flags(flags) { }
|
||||
|
||||
virtual ~osd_renderer() { }
|
||||
|
||||
win_window_info &window() { return *m_window; }
|
||||
osd_window &window() { return *m_window; }
|
||||
int flags() const { return m_flags; }
|
||||
bool check_flag(const int flag) { return ((m_flags & flag)) == flag; }
|
||||
bool has_flags(const int flag) { return ((m_flags & flag)) == flag; }
|
||||
|
||||
virtual int init() = 0;
|
||||
void notify_changed() { set_flags(FI_CHANGED); }
|
||||
|
||||
/* Interface to be implemented by render code */
|
||||
|
||||
virtual int create() = 0;
|
||||
virtual render_primitive_list *get_primitives() = 0;
|
||||
|
||||
#ifdef OSD_SDL
|
||||
virtual int draw(const UINT32 dc, const int update) = 0;
|
||||
virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0;
|
||||
#else
|
||||
virtual int draw(HDC dc, int update) = 0;
|
||||
virtual void save() = 0;
|
||||
virtual void record() = 0;
|
||||
virtual void toggle_fsfx() = 0;
|
||||
#endif
|
||||
|
||||
virtual void destroy() = 0;
|
||||
|
||||
protected:
|
||||
/* Internal flags */
|
||||
static const int FI_CHANGED = 0x010000;
|
||||
|
||||
void set_flags(int aflag) { m_flags |= aflag; }
|
||||
void clear_flags(int aflag) { m_flags &= ~aflag; }
|
||||
|
||||
private:
|
||||
win_window_info *m_window;
|
||||
|
||||
osd_window *m_window;
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
class win_window_info
|
||||
class win_window_info : public osd_window
|
||||
{
|
||||
public:
|
||||
win_window_info(running_machine &machine);
|
||||
@ -76,27 +148,31 @@ public:
|
||||
|
||||
running_machine &machine() const { return m_machine; }
|
||||
|
||||
render_target *target() { return m_target; }
|
||||
int fullscreen() const { return m_fullscreen; }
|
||||
|
||||
void update();
|
||||
|
||||
win_monitor_info *winwindow_video_window_monitor(const RECT *proposed);
|
||||
|
||||
bool win_has_menu()
|
||||
{
|
||||
return GetMenu(m_hwnd) ? true : false;
|
||||
}
|
||||
|
||||
win_window_info * m_next;
|
||||
volatile int m_init_state;
|
||||
|
||||
// window handle and info
|
||||
HWND m_hwnd;
|
||||
HWND m_focus_hwnd;
|
||||
char m_title[256];
|
||||
RECT m_non_fullscreen_bounds;
|
||||
int m_startmaximized;
|
||||
int m_isminimized;
|
||||
int m_ismaximized;
|
||||
int m_resize_state;
|
||||
|
||||
// monitor info
|
||||
win_monitor_info * m_monitor;
|
||||
int m_fullscreen;
|
||||
int m_fullscreen_safe;
|
||||
int m_maxwidth, m_maxheight;
|
||||
int m_refresh;
|
||||
float m_aspect;
|
||||
|
||||
// rendering info
|
||||
@ -105,7 +181,6 @@ public:
|
||||
int m_targetview;
|
||||
int m_targetorient;
|
||||
render_layer_config m_targetlayerconfig;
|
||||
render_primitive_list *m_primlist;
|
||||
|
||||
// input info
|
||||
DWORD m_lastclicktime;
|
||||
@ -145,7 +220,6 @@ void winwindow_video_window_create(running_machine &machine, int index, win_moni
|
||||
|
||||
BOOL winwindow_has_focus(void);
|
||||
void winwindow_update_cursor_state(running_machine &machine);
|
||||
win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed);
|
||||
|
||||
LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
@ -169,16 +243,6 @@ extern int win_create_menu(running_machine &machine, HMENU *menus);
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// win_has_menu
|
||||
//============================================================
|
||||
|
||||
INLINE BOOL win_has_menu(win_window_info *window)
|
||||
{
|
||||
return GetMenu(window->m_hwnd) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// rect_width / rect_height
|
||||
//============================================================
|
||||
|
Loading…
Reference in New Issue
Block a user