Changed sdl_window_info to be closer to C++:

- Made some members private
- moved static functions into sdl_window_info
- extended work_param struct with constructors for better readability
This commit is contained in:
couriersud 2014-12-29 02:00:57 +01:00
parent 495fe0f2dd
commit 42c969c07e
8 changed files with 295 additions and 288 deletions

View File

@ -551,17 +551,17 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
window->dxdata = sdl;
sdl->extra_flags = (window->fullscreen ?
sdl->extra_flags = (window->fullscreen() ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
// create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, window->monitor->monitor_x, 0,
window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
width, height, sdl->extra_flags);
if (window->fullscreen && video_config.switchres)
if (window->fullscreen() && video_config.switchres)
{
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
mode.w = width;
mode.h = height;
if (window->refresh)
@ -665,15 +665,15 @@ static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, i
static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window)
{
if ((!window->fullscreen) || (video_config.switchres))
if ((!window->fullscreen()) || (video_config.switchres))
{
sdlwindow_blit_surface_size(window, window->width, window->height);
window->blit_surface_size(window->width, window->height);
}
else
{
sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
}
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
return window->target->get_primitives();
}
@ -721,10 +721,10 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
{
int ch, cw;
if ((window->fullscreen) && (!video_config.switchres))
if ((window->fullscreen()) && (!video_config.switchres))
{
ch = window->monitor->center_height;
cw = window->monitor->center_width;
ch = window->monitor()->center_height;
cw = window->monitor()->center_width;
}
else
{

View File

@ -493,7 +493,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
window->dxdata = sdl;
#if (SDLMAME_SDL2)
sdl->extra_flags = (window->fullscreen ?
sdl->extra_flags = (window->fullscreen() ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
sdl->extra_flags |= SDL_WINDOW_OPENGL;
@ -510,7 +510,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
//load_gl_lib(window->machine());
// create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, window->monitor->monitor_x, 0,
window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
width, height, sdl->extra_flags);
if (!window->sdl_window )
@ -519,10 +519,10 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
return 1;
}
if (window->fullscreen && video_config.switchres)
if (window->fullscreen() && video_config.switchres)
{
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
mode.w = width;
mode.h = height;
if (window->refresh)
@ -547,7 +547,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0);
#else
sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE);
sdl->extra_flags = (window->fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
sdl->extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF;
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
@ -794,15 +794,15 @@ static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, in
static render_primitive_list &drawogl_window_get_primitives(sdl_window_info *window)
{
if ((!window->fullscreen) || (video_config.switchres))
if ((!window->fullscreen()) || (video_config.switchres))
{
sdlwindow_blit_surface_size(window, window->width, window->height);
window->blit_surface_size(window->width, window->height);
}
else
{
sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
}
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
return window->target->get_primitives();
}
@ -1143,7 +1143,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
screen_device_iterator myiter(window->machine().root_device());
for (screen = myiter.first(); screen != NULL; screen = myiter.next())
{
if (window->index == 0)
if (window->index() == 0)
{
if ((screen->width() != window->screen_width) || (screen->height() != window->screen_height))
{
@ -1180,7 +1180,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
screen_device_iterator iter(window->machine().root_device());
for (screen = iter.first(); screen != NULL; screen = iter.next())
{
if (scrnum == window->index)
if (scrnum == window->index())
{
is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
break;
@ -1271,10 +1271,10 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{
int ch, cw;
if ((window->fullscreen) && (!video_config.switchres))
if ((window->fullscreen()) && (!video_config.switchres))
{
ch = window->monitor->center_height;
cw = window->monitor->center_width;
ch = window->monitor()->center_height;
cw = window->monitor()->center_width;
}
else
{

View File

@ -251,7 +251,7 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
UINT32 fmt;
// Determine preferred pixelformat and set up yuv if necessary
SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
if (sdl->yuv_bitmap)
{
@ -402,17 +402,17 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
sdl->extra_flags = (window->fullscreen ?
sdl->extra_flags = (window->fullscreen() ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
| SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
if (window->fullscreen && video_config.switchres)
if (window->fullscreen() && video_config.switchres)
{
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
mode.w = width;
mode.h = height;
if (window->refresh)
@ -424,12 +424,12 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
SDL_ShowWindow(window->sdl_window);
SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen);
SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen());
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
SDL_RaiseWindow(window->sdl_window);
/* FIXME: Bug in SDL 1.3 */
if (window->fullscreen)
if (window->fullscreen())
SDL_SetWindowGrab(window->sdl_window, SDL_TRUE);
// create a texture
@ -468,7 +468,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
setup_texture(window, width, height);
#else
sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE);
sdl->extra_flags = (window->fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
sdl->extra_flags |= sm->extra_flags;
@ -623,17 +623,17 @@ static render_primitive_list &drawsdl_window_get_primitives(sdl_window_info *win
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
if ((!window->fullscreen) || (video_config.switchres))
if ((!window->fullscreen()) || (video_config.switchres))
{
sdlwindow_blit_surface_size(window, window->width, window->height);
window->blit_surface_size(window->width, window->height);
}
else
{
sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
}
if (!sm->is_scale)
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
else
window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
@ -747,10 +747,10 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
// figure out what coordinate system to use for centering - in window mode it's always the
// SDL surface size. in fullscreen the surface covers all monitors, so center according to
// the first one only
if ((window->fullscreen) && (!video_config.switchres))
if ((window->fullscreen()) && (!video_config.switchres))
{
ch = window->monitor->center_height;
cw = window->monitor->center_width;
ch = window->monitor()->center_height;
cw = window->monitor()->center_width;
}
else
{

View File

@ -1566,7 +1566,7 @@ INLINE void resize_all_windows(void)
{
if (w->resize_width && w->resize_height && ((now - w->last_resize) > osd_ticks_per_second() / 10))
{
sdlwindow_resize(w, w->resize_width, w->resize_height);
w->window_resize(w->resize_width, w->resize_height);
w->resize_width = 0;
w->resize_height = 0;
}
@ -1941,7 +1941,7 @@ void sdlinput_poll(running_machine &machine)
machine.schedule_exit();
break;
case SDL_VIDEORESIZE:
sdlwindow_resize(sdl_window_list, event.resize.w, event.resize.h);
sdl_window_list->window_resize(event.resize.w, event.resize.h);
break;
#else
case SDL_TEXTINPUT:
@ -1973,7 +1973,7 @@ void sdlinput_poll(running_machine &machine)
app_has_mouse_focus = 0;
break;
case SDL_WINDOWEVENT_MOVED:
sdlwindow_clear(window);
window->window_clear();
focus_window = window;
break;
case SDL_WINDOWEVENT_RESIZED:
@ -1986,7 +1986,7 @@ void sdlinput_poll(running_machine &machine)
else
{
if (event.window.data1 != window->width || event.window.data2 != window->height)
sdlwindow_resize(window, event.window.data1, event.window.data2);
window->window_resize(event.window.data1, event.window.data2);
}
focus_window = window;
break;

View File

@ -77,6 +77,8 @@ USE_DISPATCH_GL = 1
# change for custom OS X installations
SDL_FRAMEWORK_PATH = /Library/Frameworks/
# SDL_LIBVER = sdl
###########################################################################
################## END USER-CONFIGURABLE OPTIONS ######################
###########################################################################

View File

@ -326,7 +326,7 @@ void sdl_osd_interface::update(bool skip_redraw)
{
// profiler_mark(PROFILER_BLIT);
for (window = sdl_window_list; window != NULL; window = window->next)
sdlwindow_video_window_update(machine(), window);
window->video_window_update(machine());
// profiler_mark(PROFILER_END);
}
@ -568,7 +568,7 @@ static void check_osd_inputs(running_machine &machine)
while (curwin != (sdl_window_info *)NULL)
{
sdlwindow_toggle_full_screen(machine, curwin);
curwin->toggle_full_screen(machine);
curwin = curwin->next;
}
}
@ -597,10 +597,10 @@ static void check_osd_inputs(running_machine &machine)
#endif
if (ui_input_pressed(machine, IPT_OSD_6))
sdlwindow_modify_prescale(machine, window, -1);
window->modify_prescale(machine, -1);
if (ui_input_pressed(machine, IPT_OSD_7))
sdlwindow_modify_prescale(machine, window, 1);
window->modify_prescale(machine, 1);
}
//============================================================

View File

@ -101,12 +101,39 @@ static SDL_threadID window_threadid;
static sdl_draw_info draw;
struct worker_param {
worker_param()
: m_window(NULL), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0)
{
}
worker_param(running_machine &amachine, sdl_window_info *awindow)
: m_window(awindow), m_list(NULL), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0)
{
}
worker_param(running_machine &amachine, sdl_window_info *awindow, render_primitive_list *alist)
: m_window(awindow), m_list(alist), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0)
{
}
worker_param(sdl_window_info *awindow, int anew_width, int anew_height)
: m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height)
{
}
worker_param(sdl_window_info *awindow)
: m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0)
{
}
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
sdl_window_info *window;
render_primitive_list *list;
sdl_window_info *window() const { assert(m_window != NULL); return m_window; }
render_primitive_list *list() const { return m_list; }
int new_width() const { return m_resize_new_width; }
int new_height() const { return m_resize_new_height; }
// FIXME: only needed for window set-up which returns an error.
void set_window(sdl_window_info *window) { m_window = window; }
private:
sdl_window_info *m_window;
render_primitive_list *m_list;
running_machine *m_machine;
int resize_new_width;
int resize_new_height;
int m_resize_new_width;
int m_resize_new_height;
};
@ -114,7 +141,6 @@ struct worker_param {
// PROTOTYPES
//============================================================
static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window);
static OSDWORK_CALLBACK( draw_video_contents_wt );
static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt );
static OSDWORK_CALLBACK( sdlwindow_resize_wt );
@ -122,40 +148,19 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt );
static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window);
static void sdlwindow_sync(void);
static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
static void *complete_create_wt(void *param, int threadid);
static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view);
//============================================================
// clear the worker_param structure, inline - faster than memset
//============================================================
INLINE void clear_worker_param(worker_param *wp)
{
wp->window=NULL;
wp->list=NULL;
wp->m_machine=NULL;
wp->resize_new_width=0;
wp->resize_new_height=0;
}
//============================================================
// execute_async
//============================================================
INLINE void execute_async(osd_work_callback callback, worker_param *wp)
INLINE void execute_async(osd_work_callback callback, const worker_param &wp)
{
worker_param *wp_temp = NULL;
worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
*wp_temp = wp;
if (wp)
{
wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
*wp_temp = *wp;
}
if (multithreading_enabled)
{
osd_work_item_queue(work_queue, callback, (void *) wp_temp, WORK_ITEM_FLAG_AUTO_RELEASE);
@ -163,12 +168,20 @@ INLINE void execute_async(osd_work_callback callback, worker_param *wp)
callback((void *) wp_temp, 0);
}
INLINE void execute_sync(osd_work_callback callback, const worker_param &wp)
{
worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
*wp_temp = wp;
callback((void *) wp_temp, 0);
}
//============================================================
// execute_async_wait
//============================================================
INLINE void execute_async_wait(osd_work_callback callback, worker_param *wp)
INLINE void execute_async_wait(osd_work_callback callback, const worker_param &wp)
{
execute_async(callback, wp);
sdlwindow_sync();
@ -294,6 +307,8 @@ static OSDWORK_CALLBACK( sdlwindow_exit_wt )
void sdl_osd_interface::window_exit()
{
worker_param wp_dummy;
ASSERT_MAIN_THREAD();
osd_printf_verbose("Enter sdlwindow_exit\n");
@ -303,7 +318,9 @@ void sdl_osd_interface::window_exit()
{
sdl_window_info *temp = sdl_window_list;
sdl_window_list = temp->next;
sdlwindow_video_window_destroy(machine(), temp);
temp->video_window_destroy(machine());
// free the window itself
global_free(temp);
}
// if we're multithreaded, clean up the window thread
@ -315,7 +332,7 @@ void sdl_osd_interface::window_exit()
// kill the drawers
(*draw.exit)();
execute_async_wait(&sdlwindow_exit_wt, NULL);
execute_async_wait(&sdlwindow_exit_wt, wp_dummy);
if (multithreading_enabled)
{
@ -338,7 +355,7 @@ INLINE int better_mode(int width0, int height0, int width1, int height1, float d
return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1;
}
void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height)
void sdl_window_info::blit_surface_size(int window_width, int window_height)
{
INT32 newwidth, newheight;
int xscale = 1, yscale = 1;
@ -347,14 +364,14 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int
INT32 target_height = window_height;
// start with the minimum size
window->target->compute_minimum_size(newwidth, newheight);
target->compute_minimum_size(newwidth, newheight);
// compute the appropriate visible area if we're trying to keepaspect
if (video_config.keepaspect)
{
// make sure the monitor is up-to-date
sdlvideo_monitor_refresh(window->monitor);
window->target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(window->monitor), window->target->orientation(), target_width, target_height);
sdlvideo_monitor_refresh(m_monitor);
target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(m_monitor), target->orientation(), target_width, target_height);
desired_aspect = (float)target_width / (float)target_height;
}
@ -406,15 +423,15 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int
}
//FIXME: really necessary to distinguish for yuv_modes ?
if (window->target->zoom_to_screen()
if (target->zoom_to_screen()
&& (video_config.scale_mode == VIDEO_SCALE_MODE_NONE ))
newwidth = window_width;
if ((window->blitwidth != newwidth) || (window->blitheight != newheight))
sdlwindow_clear(window);
if ((blitwidth != newwidth) || (blitheight != newheight))
window_clear();
window->blitwidth = newwidth;
window->blitheight = newheight;
blitwidth = newwidth;
blitheight = newheight;
}
@ -426,36 +443,29 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int
static OSDWORK_CALLBACK( sdlwindow_resize_wt )
{
worker_param * wp = (worker_param *) param;
sdl_window_info * window = wp->window;
sdl_window_info * window = wp->window();
ASSERT_WINDOW_THREAD();
window->destroy_all_textures(window);
window->resize(window, wp->resize_new_width, wp->resize_new_height);
window->resize(window, wp->new_width(), wp->new_height());
sdlwindow_blit_surface_size(window, wp->resize_new_width, wp->resize_new_height);
window->blit_surface_size(wp->new_width(), wp->new_height());
sdlwindow_clear(window);
window->window_clear();
osd_free(wp);
return NULL;
}
void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height)
void sdl_window_info::window_resize(INT32 width, INT32 height)
{
worker_param wp;
ASSERT_MAIN_THREAD();
if (width == window->width && height == window->height)
if (width == this->width && height == this->height)
return;
clear_worker_param(&wp);
wp.resize_new_width = width;
wp.resize_new_height = height;
wp.window = window;
execute_async_wait(&sdlwindow_resize_wt, &wp);
execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height));
}
@ -467,7 +477,7 @@ void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height)
static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt )
{
worker_param *wp = (worker_param *) param;
sdl_window_info *window = wp->window;
sdl_window_info *window = wp->window();
ASSERT_WINDOW_THREAD();
@ -476,20 +486,16 @@ static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt )
return NULL;
}
void sdlwindow_clear(sdl_window_info *window)
void sdl_window_info::window_clear()
{
worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param));
clear_worker_param(wp);
wp->window = window;
worker_param wp;
if (SDL_ThreadID() == main_threadid)
{
execute_async_wait(&sdlwindow_clear_surface_wt, wp);
osd_free(wp);
execute_async_wait(&sdlwindow_clear_surface_wt, worker_param(this));
}
else
sdlwindow_clear_surface_wt( (void *) wp, 0);
execute_sync(&sdlwindow_clear_surface_wt, worker_param(this));
}
@ -501,7 +507,7 @@ void sdlwindow_clear(sdl_window_info *window)
static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
{
worker_param *wp = (worker_param *) param;
sdl_window_info *window = wp->window;
sdl_window_info *window = wp->window();
ASSERT_WINDOW_THREAD();
@ -510,7 +516,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
return NULL;
// If we are going fullscreen (leaving windowed) remember our windowed size
if (!window->fullscreen)
if (!window->fullscreen())
{
window->windowed_width = window->width;
window->windowed_height = window->height;
@ -520,31 +526,25 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
sdlinput_release_keys(wp->machine());
// toggle the window mode
window->fullscreen = !window->fullscreen;
window->set_fullscreen(!window->fullscreen());
complete_create_wt(param, 0);
return NULL;
}
void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window)
void sdl_window_info::toggle_full_screen(running_machine &machine)
{
worker_param wp;
ASSERT_MAIN_THREAD();
clear_worker_param(&wp);
wp.window = window;
wp.m_machine = &machine;
execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp);
execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this));
}
static OSDWORK_CALLBACK( destroy_all_textures_wt )
{
worker_param *wp = (worker_param *) param;
sdl_window_info *window = wp->window;
sdl_window_info *window = wp->window();
window->destroy_all_textures(window);
@ -552,38 +552,33 @@ static OSDWORK_CALLBACK( destroy_all_textures_wt )
return NULL;
}
void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir)
void sdl_window_info::modify_prescale(running_machine &machine, int dir)
{
worker_param wp;
int new_prescale = window->prescale;
worker_param wp = worker_param(machine, this);
int new_prescale = prescale;
clear_worker_param(&wp);
if (dir > 0 && prescale < 3)
new_prescale = prescale + 1;
if (dir < 0 && prescale > 1)
new_prescale = prescale - 1;
wp.window = window;
wp.m_machine = &machine;
if (dir > 0 && window->prescale < 3)
new_prescale = window->prescale + 1;
if (dir < 0 && window->prescale > 1)
new_prescale = window->prescale - 1;
if (new_prescale != window->prescale)
if (new_prescale != prescale)
{
if (window->fullscreen && video_config.switchres)
if (m_fullscreen && video_config.switchres)
{
execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
execute_async_wait(&sdlwindow_video_window_destroy_wt, wp);
window->prescale = new_prescale;
prescale = new_prescale;
execute_async_wait(&complete_create_wt, &wp);
execute_async_wait(&complete_create_wt, wp);
}
else
{
execute_async_wait(destroy_all_textures_wt, &wp);
window->prescale = new_prescale;
execute_async_wait(destroy_all_textures_wt, wp);
prescale = new_prescale;
}
machine.ui().popup_time(1, "Prescale %d", window->prescale);
machine.ui().popup_time(1, "Prescale %d", prescale);
}
}
@ -611,7 +606,7 @@ static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_i
{
//FIXME: SDL1.3: really broken: the whole SDL code
// will only work correct with relative mouse movements ...
if (!window->fullscreen && !sdlinput_should_hide_mouse(machine))
if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine))
{
SDL_ShowCursor(SDL_ENABLE);
if (SDL_GetWindowGrab(window->sdl_window ))
@ -633,7 +628,7 @@ static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_i
// the possibility of losing control
if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED))
{
if ( window->fullscreen || sdlinput_should_hide_mouse(machine) )
if ( window->fullscreen() || sdlinput_should_hide_mouse(machine) )
{
SDL_ShowCursor(SDL_DISABLE);
if (!SDL_WM_GrabInput(SDL_GRAB_QUERY))
@ -659,7 +654,7 @@ static OSDWORK_CALLBACK( sdlwindow_update_cursor_state_wt )
worker_param * wp = (worker_param *) param;
//sdl_window_info * window = wp->window;
sdlwindow_update_cursor_state(*wp->m_machine, wp->window);
sdlwindow_update_cursor_state(wp->machine(), wp->window());
return NULL;
}
@ -678,33 +673,14 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
ASSERT_MAIN_THREAD();
clear_worker_param(wp);
// allocate a new window object
window = global_alloc_clear(sdl_window_info);
window->maxwidth = config->width;
window->maxheight = config->height;
window->depth = config->depth;
window->refresh = config->refresh;
window->monitor = monitor;
window->m_machine = &machine;
window->index = index;
//FIXME: these should be per_window in config-> or even better a bit set
window->fullscreen = !video_config.windowed;
window->prescale = video_config.prescale;
window = global_alloc(sdl_window_info(&machine, monitor, index, config));
// set the initial maximized state
// FIXME: Does not belong here
sdl_options &options = downcast<sdl_options &>(machine.options());
window->startmaximized = options.maximize();
if (!window->fullscreen)
{
window->windowed_width = config->width;
window->windowed_height = config->height;
}
// add us to the list
*last_window_ptr = window;
last_window_ptr = &window->next;
@ -726,8 +702,9 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
else
sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
wp->window = window;
wp->set_window(window);
// FIXME: pass error back in a different way
if (multithreading_enabled)
{
osd_work_item *wi;
@ -747,7 +724,9 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
return 0;
error:
sdlwindow_video_window_destroy(machine, window);
window->video_window_destroy(machine);
// free the window itself
global_free(window);
return 1;
}
@ -760,7 +739,7 @@ error:
static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt )
{
worker_param * wp = (worker_param *) param;
sdl_window_info * window = wp->window;
sdl_window_info * window = wp->window();
ASSERT_WINDOW_THREAD();
@ -775,10 +754,9 @@ static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt )
return NULL;
}
static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window)
void sdl_window_info::video_window_destroy(running_machine &machine)
{
sdl_window_info **prevptr;
worker_param wp;
ASSERT_MAIN_THREAD();
if (multithreading_enabled)
@ -790,26 +768,21 @@ static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_
// remove us from the list
for (prevptr = &sdl_window_list; *prevptr != NULL; prevptr = &(*prevptr)->next)
if (*prevptr == window)
if (*prevptr == this)
{
*prevptr = window->next;
*prevptr = this->next;
break;
}
// free the textures etc
clear_worker_param(&wp);
wp.window = window;
wp.m_machine = &machine;
execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this));
// free the render target, after the textures!
window->machine().render().target_free(window->target);
this->machine().render().target_free(target);
// free the event
osd_event_free(window->rendered_event);
osd_event_free(rendered_event);
// free the window itself
global_free(window);
}
@ -818,7 +791,7 @@ static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_
//============================================================
#if SDLMAME_SDL2
static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
{
int minimum_width, minimum_height, target_width, target_height;
int i;
@ -826,11 +799,11 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
float size_score, best_score = 0.0f;
// determine the minimum width/height for the selected target
window->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 * MAX(1, window->prescale);
target_height = minimum_height * MAX(1, window->prescale);
target_width = minimum_width * MAX(1, prescale);
target_height = minimum_height * MAX(1, prescale);
// if we're not stretching, allow some slop on the minimum since we can handle it
{
@ -838,7 +811,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
minimum_height -= 4;
}
num = SDL_GetNumDisplayModes(window->monitor->handle);
num = SDL_GetNumDisplayModes(m_monitor->handle);
if (num == 0)
{
@ -850,7 +823,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
for (i = 0; i < num; ++i)
{
SDL_DisplayMode mode;
SDL_GetDisplayMode(window->monitor->handle, i, &mode);
SDL_GetDisplayMode(m_monitor->handle, i, &mode);
// compute initial score based on difference between target and current
size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height));
@ -864,12 +837,12 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
size_score *= 0.1f;
// if we're looking for a particular mode, that's a winner
if (mode.w == window->maxwidth && mode.h == window->maxheight)
if (mode.w == m_maxwidth && mode.h == m_maxheight)
size_score = 2.0f;
// refresh adds some points
if (window->refresh)
size_score *= 1.0f / (1.0f + fabsf(window->refresh - mode.refresh_rate) / 10.0f);
if (refresh)
size_score *= 1.0f / (1.0f + fabsf(refresh - mode.refresh_rate) / 10.0f);
osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score);
@ -885,7 +858,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
}
}
#else
static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
{
int minimum_width, minimum_height, target_width, target_height;
int i;
@ -893,11 +866,11 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
SDL_Rect **modes;
// determine the minimum width/height for the selected target
window->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 * MAX(1, window->prescale);
target_height = minimum_height * MAX(1, window->prescale);
target_width = minimum_width * MAX(1, prescale);
target_height = minimum_height * MAX(1, prescale);
// if we're not stretching, allow some slop on the minimum since we can handle it
{
@ -913,7 +886,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
*/
modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
#else
modes = window->monitor->modes;
modes = window->m_monitor->modes;
#endif
if (modes == (SDL_Rect **)0)
@ -923,8 +896,8 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
}
else if (modes == (SDL_Rect **)-1) // all modes are possible
{
*fswidth = window->maxwidth;
*fsheight = window->maxheight;
*fswidth = m_maxwidth;
*fsheight = m_maxheight;
}
else
{
@ -942,7 +915,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
size_score *= 0.1f;
// if we're looking for a particular mode, that's a winner
if (modes[i]->w == window->maxwidth && modes[i]->h == window->maxheight)
if (modes[i]->w == m_maxwidth && modes[i]->h == m_maxheight)
size_score = 2.0f;
osd_printf_verbose("%4dx%4d -> %f\n", (int)modes[i]->w, (int)modes[i]->h, size_score);
@ -965,7 +938,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
// (main thread)
//============================================================
void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window)
void sdl_window_info::video_window_update(running_machine &machine)
{
osd_ticks_t event_wait_ticks;
ASSERT_MAIN_THREAD();
@ -973,37 +946,29 @@ void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *wi
// adjust the cursor state
//sdlwindow_update_cursor_state(machine, window);
{
worker_param wp;
clear_worker_param(&wp);
wp.window = window;
wp.m_machine = &machine;
execute_async(&sdlwindow_update_cursor_state_wt, &wp);
}
execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this));
// if we're visible and running and not in the middle of a resize, draw
if (window->target != NULL)
if (target != NULL)
{
int tempwidth, tempheight;
// see if the games video mode has changed
window->target->compute_minimum_size(tempwidth, tempheight);
if (tempwidth != window->minwidth || tempheight != window->minheight)
target->compute_minimum_size(tempwidth, tempheight);
if (tempwidth != m_minwidth || tempheight != m_minheight)
{
window->minwidth = tempwidth;
window->minheight = tempheight;
m_minwidth = tempwidth;
m_minheight = tempheight;
if (!window->fullscreen)
if (!this->m_fullscreen)
{
sdlwindow_blit_surface_size(window, window->width, window->height);
sdlwindow_resize(window, window->blitwidth, window->blitheight);
blit_surface_size(width, height);
window_resize(blitwidth, blitheight);
}
else if (video_config.switchres)
{
pick_best_mode(window, &tempwidth, &tempheight);
sdlwindow_resize(window, tempwidth, tempheight);
this->pick_best_mode(&tempwidth, &tempheight);
window_resize(tempwidth, tempheight);
}
}
@ -1012,23 +977,14 @@ void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *wi
else
event_wait_ticks = 0;
if (osd_event_wait(window->rendered_event, event_wait_ticks))
if (osd_event_wait(rendered_event, event_wait_ticks))
{
worker_param wp;
render_primitive_list *primlist;
clear_worker_param(&wp);
// ensure the target bounds are up-to-date, and then get the primitives
primlist = &window->get_primitives(window);
// ensure the target bounds are up-to-date, and then get the primitives
render_primitive_list *primlist = &get_primitives(this);
// and redraw now
wp.list = primlist;
wp.window = window;
wp.m_machine = &machine;
execute_async(&draw_video_contents_wt, &wp);
execute_async(&draw_video_contents_wt, worker_param(machine, this, primlist));
}
}
}
@ -1066,7 +1022,7 @@ static void set_starting_view(running_machine &machine, int index, sdl_window_in
static OSDWORK_CALLBACK( complete_create_wt )
{
worker_param * wp = (worker_param *) param;
sdl_window_info * window = wp->window;
sdl_window_info * window = wp->window();
int tempwidth, tempheight;
static int result[2] = {0,1};
@ -1074,15 +1030,15 @@ static OSDWORK_CALLBACK( complete_create_wt )
ASSERT_WINDOW_THREAD();
osd_free(wp);
if (window->fullscreen)
if (window->fullscreen())
{
// default to the current mode exactly
tempwidth = window->monitor->monitor_width;
tempheight = window->monitor->monitor_height;
tempwidth = window->monitor()->monitor_width;
tempheight = window->monitor()->monitor_height;
// if we're allowed to switch resolutions, override with something better
if (video_config.switchres)
pick_best_mode(window, &tempwidth, &tempheight);
window->pick_best_mode(&tempwidth, &tempheight);
}
else if (window->windowed_width)
{
@ -1095,7 +1051,7 @@ static OSDWORK_CALLBACK( complete_create_wt )
if (window->startmaximized)
{
tempwidth = tempheight = 0;
get_max_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
window->get_max_bounds(&tempwidth, &tempheight, video_config.keepaspect );
}
else
{
@ -1103,10 +1059,10 @@ static OSDWORK_CALLBACK( complete_create_wt )
instead of letting sdlwindow_blit_surface_size() resize it
this stops the window from "flashing" from the wrong aspect
size to the right one at startup. */
tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640;
tempheight = (window->maxheight != 0) ? window->maxheight : 480;
tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640;
tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480;
get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
window->get_min_bounds(&tempwidth, &tempheight, video_config.keepaspect );
}
}
@ -1174,14 +1130,14 @@ static OSDWORK_CALLBACK( draw_video_contents_wt )
UINT32 dc = 0;
int update = 1;
worker_param *wp = (worker_param *) param;
sdl_window_info *window = wp->window;
sdl_window_info *window = wp->window();
ASSERT_REDRAW_THREAD();
// Some configurations require events to be polled in the worker thread
sdlinput_process_events_buf(wp->machine());
window->primlist = wp->list;
window->primlist = wp->list();
// if no bitmap, just fill
if (window->primlist == NULL)
@ -1209,7 +1165,7 @@ static OSDWORK_CALLBACK( draw_video_contents_wt )
// (window thread)
//============================================================
static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width, int *window_height, int adjustment)
void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment)
{
INT32 extrawidth = 0;
INT32 extraheight = 0;
@ -1220,10 +1176,10 @@ static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width
float pixel_aspect;
// make sure the monitor is up-to-date
sdlvideo_monitor_refresh(window->monitor);
sdlvideo_monitor_refresh(m_monitor);
// get the pixel aspect ratio for the target monitor
pixel_aspect = sdlvideo_monitor_get_aspect(window->monitor);
pixel_aspect = sdlvideo_monitor_get_aspect(m_monitor);
// determine the proposed width/height
propwidth = *window_width - extrawidth;
@ -1235,21 +1191,21 @@ static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width
{
case WMSZ_BOTTOM:
case WMSZ_TOP:
window->target->compute_visible_area(10000, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight);
target->compute_visible_area(10000, propheight, pixel_aspect, target->orientation(), propwidth, propheight);
break;
case WMSZ_LEFT:
case WMSZ_RIGHT:
window->target->compute_visible_area(propwidth, 10000, pixel_aspect, window->target->orientation(), propwidth, propheight);
target->compute_visible_area(propwidth, 10000, pixel_aspect, target->orientation(), propwidth, propheight);
break;
default:
window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->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
window->target->compute_minimum_size(minwidth, minheight);
target->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
propwidth = MAX(propwidth, MIN_WINDOW_DIM);
@ -1260,21 +1216,21 @@ static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width
propheight = MAX(propheight, minheight);
// clamp against the maximum (fit on one screen for full screen mode)
if (window->fullscreen)
if (this->m_fullscreen)
{
maxwidth = window->monitor->center_width - extrawidth;
maxheight = window->monitor->center_height - extraheight;
maxwidth = m_monitor->center_width - extrawidth;
maxheight = m_monitor->center_height - extraheight;
}
else
{
maxwidth = window->monitor->center_width - extrawidth;
maxheight = window->monitor->center_height - extraheight;
maxwidth = m_monitor->center_width - extrawidth;
maxheight = m_monitor->center_height - extraheight;
// further clamp to the maximum width/height in the window
if (window->maxwidth != 0)
maxwidth = MIN(maxwidth, window->maxwidth + extrawidth);
if (window->maxheight != 0)
maxheight = MIN(maxheight, window->maxheight + extraheight);
if (this->m_maxwidth != 0)
maxwidth = MIN(maxwidth, this->m_maxwidth + extrawidth);
if (this->m_maxheight != 0)
maxheight = MIN(maxheight, this->m_maxheight + extraheight);
}
// clamp to the maximum
@ -1282,7 +1238,7 @@ static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width
propheight = MIN(propheight, maxheight);
// compute the visible area based on the proposed rectangle
window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), viswidth, visheight);
target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), viswidth, visheight);
*window_width = viswidth;
*window_height = visheight;
@ -1294,12 +1250,12 @@ static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width
// (window thread)
//============================================================
static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain)
void sdl_window_info::get_min_bounds(int *window_width, int *window_height, int constrain)
{
INT32 minwidth, minheight;
// get the minimum target size
window->target->compute_minimum_size(minwidth, minheight);
this->target->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM)
@ -1315,11 +1271,11 @@ static void get_min_bounds(sdl_window_info *window, int *window_width, int *wind
// first constrain with no height limit
test1w = minwidth; test1h = 10000;
constrain_to_aspect_ratio(window, &test1w, &test1h, WMSZ_BOTTOMRIGHT);
this->constrain_to_aspect_ratio(&test1w, &test1h, WMSZ_BOTTOMRIGHT);
// then constrain with no width limit
test2w = 10000; test2h = minheight;
constrain_to_aspect_ratio(window, &test2w, &test2h, WMSZ_BOTTOMRIGHT);
this->constrain_to_aspect_ratio(&test2w, &test2h, WMSZ_BOTTOMRIGHT);
// pick the larger
if ( test1w > test2w )
@ -1344,31 +1300,31 @@ static void get_min_bounds(sdl_window_info *window, int *window_width, int *wind
// (window thread)
//============================================================
static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain)
void sdl_window_info::get_max_bounds(int *window_width, int *window_height, int constrain)
{
INT32 maxwidth, maxheight;
// compute the maximum client area
maxwidth = window->monitor->center_width;
maxheight = window->monitor->center_height;
maxwidth = m_monitor->center_width;
maxheight = m_monitor->center_height;
// clamp to the window's max
if (window->maxwidth != 0)
if (this->m_maxwidth != 0)
{
int temp = window->maxwidth + WINDOW_DECORATION_WIDTH;
int temp = this->m_maxwidth + WINDOW_DECORATION_WIDTH;
if (temp < maxwidth)
maxwidth = temp;
}
if (window->maxheight != 0)
if (this->m_maxheight != 0)
{
int temp = window->maxheight + WINDOW_DECORATION_HEIGHT;
int temp = this->m_maxheight + WINDOW_DECORATION_HEIGHT;
if (temp < maxheight)
maxheight = temp;
}
// constrain to fit
if (constrain)
constrain_to_aspect_ratio(window, &maxwidth, &maxheight, WMSZ_BOTTOMRIGHT);
this->constrain_to_aspect_ratio(&maxwidth, &maxheight, WMSZ_BOTTOMRIGHT);
//else
{
maxwidth -= WINDOW_DECORATION_WIDTH;

View File

@ -34,12 +34,62 @@ typedef UINT32 HashT;
struct sdl_window_info
{
// Pointer to next window
sdl_window_info(running_machine *a_machine, sdl_monitor_info *a_monitor,
int index, const sdl_window_config *config)
: next(NULL), m_minwidth(0), m_minheight(0),
startmaximized(0),
rendered_event(0), target(0), primlist(NULL), dxdata(NULL),
width(0), height(0), blitwidth(0), blitheight(0),
start_viewscreen(0),
#if (SDLMAME_SDL2)
sdl_window(NULL),
resize_width(0),
resize_height(0),
last_resize(0),
#else
screen_width(0), screen_height(0),
#endif
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0)
{
m_maxwidth = config->width;
m_maxheight = config->height;
depth = config->depth;
refresh = config->refresh;
m_index = index;
//FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed;
prescale = video_config.prescale;
if (!m_fullscreen)
{
windowed_width = config->width;
windowed_height = config->height;
}
}
void video_window_update(running_machine &machine);
void blit_surface_size(int window_width, int window_height);
void toggle_full_screen(running_machine &machine);
void modify_prescale(running_machine &machine, int dir);
void window_resize(INT32 width, INT32 height);
void window_clear();
void video_window_destroy(running_machine &machine);
void pick_best_mode(int *fswidth, int *fsheight);
void get_min_bounds(int *window_width, int *window_height, int constrain);
void get_max_bounds(int *window_width, int *window_height, int constrain);
// Pointer to next window
sdl_window_info * next;
// Pointer to machine
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
running_machine * m_machine;
sdl_monitor_info *monitor() const { return m_monitor; }
int fullscreen() const { return m_fullscreen; }
int index() const { return m_index; }
void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; }
// Draw Callbacks
int (*create)(sdl_window_info *window, int width, int height);
@ -54,14 +104,9 @@ struct sdl_window_info
// window handle and info
char title[256];
// monitor info
sdl_monitor_info * monitor;
int fullscreen;
int index;
// diverse flags
int minwidth, minheight;
int maxwidth, maxheight;
int m_minwidth, m_minheight;
int m_maxwidth, m_maxheight;
int depth;
int refresh;
int windowed_width;
@ -100,6 +145,17 @@ struct sdl_window_info
int screen_width;
int screen_height;
#endif
private:
void constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment);
// Pointer to machine
running_machine * m_machine;
// monitor info
sdl_monitor_info * m_monitor;
int m_fullscreen;
int m_index;
};
struct sdl_draw_info
@ -121,13 +177,6 @@ extern sdl_window_info *sdl_window_list;
// creation/deletion of windows
int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window);
void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height);
void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window);
void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir);
void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height);
void sdlwindow_clear(sdl_window_info *window);
//============================================================
// PROTOTYPES - drawsdl.c