mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
introduced concept of an osd_renderer. Changed draw code to
inherit from this interface. (nw)
This commit is contained in:
parent
5848dc2013
commit
786cd2af66
@ -79,7 +79,7 @@ struct quad_setup_data
|
|||||||
// Textures
|
// Textures
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
struct sdl_info13;
|
class sdl_info13;
|
||||||
struct copy_info_t;
|
struct copy_info_t;
|
||||||
|
|
||||||
/* texture_info holds information about a texture */
|
/* texture_info holds information about a texture */
|
||||||
@ -139,15 +139,25 @@ private:
|
|||||||
#include "blit13.h"
|
#include "blit13.h"
|
||||||
|
|
||||||
/* sdl_info is the information about SDL for the current screen */
|
/* sdl_info is the information about SDL for the current screen */
|
||||||
struct sdl_info13
|
class sdl_info13 : public osd_renderer
|
||||||
{
|
{
|
||||||
sdl_info13()
|
public:
|
||||||
: m_blittimer(0), m_renderer(NULL),
|
sdl_info13(sdl_window_info *w)
|
||||||
|
: osd_renderer(w), m_blittimer(0), m_renderer(NULL),
|
||||||
m_hofs(0), m_vofs(0),
|
m_hofs(0), m_vofs(0),
|
||||||
m_resize_pending(0), m_resize_width(0), m_resize_height(0),
|
m_resize_pending(0), m_resize_width(0), m_resize_height(0),
|
||||||
m_last_blit_time(0), m_last_blit_pixels(0)
|
m_last_blit_time(0), m_last_blit_pixels(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
/* virtual */ int create(int width, int height);
|
||||||
|
/* virtual */ void resize(int width, int height);
|
||||||
|
/* virtual */ int draw(UINT32 dc, int update);
|
||||||
|
/* virtual */ void set_target_bounds();
|
||||||
|
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||||
|
/* virtual */ void destroy_all_textures();
|
||||||
|
/* virtual */ void destroy();
|
||||||
|
/* virtual */ void clear();
|
||||||
|
|
||||||
void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
|
void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
|
||||||
|
|
||||||
texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
|
texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
|
||||||
@ -198,15 +208,6 @@ struct copy_info_t {
|
|||||||
// core functions
|
// core functions
|
||||||
|
|
||||||
static void drawsdl2_exit(void);
|
static void drawsdl2_exit(void);
|
||||||
static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window);
|
|
||||||
static int drawsdl2_window_create(sdl_window_info *window, int width, int height);
|
|
||||||
static void drawsdl2_window_resize(sdl_window_info *window, int width, int height);
|
|
||||||
static void drawsdl2_window_destroy(sdl_window_info *window);
|
|
||||||
static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update);
|
|
||||||
static void drawsdl2_set_target_bounds(sdl_window_info *window);
|
|
||||||
static void drawsdl2_destroy_all_textures(sdl_window_info *window);
|
|
||||||
static void drawsdl2_window_clear(sdl_window_info *window);
|
|
||||||
static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// STATIC VARIABLES
|
// STATIC VARIABLES
|
||||||
@ -483,6 +484,11 @@ static void expand_copy_info(copy_info_t *list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static osd_renderer *drawsdl2_create(sdl_window_info *window)
|
||||||
|
{
|
||||||
|
return global_alloc(sdl_info13(window));
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: machine only used to access options.
|
// FIXME: machine only used to access options.
|
||||||
int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
|
int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
|
||||||
{
|
{
|
||||||
@ -490,7 +496,7 @@ int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
|
|||||||
|
|
||||||
// fill in the callbacks
|
// fill in the callbacks
|
||||||
callbacks->exit = drawsdl2_exit;
|
callbacks->exit = drawsdl2_exit;
|
||||||
callbacks->attach = drawsdl2_attach;
|
callbacks->create = drawsdl2_create;
|
||||||
|
|
||||||
osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
|
osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
|
||||||
|
|
||||||
@ -550,31 +556,11 @@ static void drawsdl2_exit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_attach
|
// sdl_info13::create
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window)
|
int sdl_info13::create(int width, int height)
|
||||||
{
|
{
|
||||||
// fill in the callbacks
|
|
||||||
window->create = drawsdl2_window_create;
|
|
||||||
window->resize = drawsdl2_window_resize;
|
|
||||||
window->set_target_bounds = drawsdl2_set_target_bounds;
|
|
||||||
window->draw = drawsdl2_window_draw;
|
|
||||||
window->destroy = drawsdl2_window_destroy;
|
|
||||||
window->destroy_all_textures = drawsdl2_destroy_all_textures;
|
|
||||||
window->clear = drawsdl2_window_clear;
|
|
||||||
window->xy_to_render_target = drawsdl2_xy_to_render_target;
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// drawsdl2_window_create
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
|
|
||||||
{
|
|
||||||
// allocate memory for our structures
|
|
||||||
sdl_info13 *sdl = global_alloc(sdl_info13);
|
|
||||||
|
|
||||||
/* FIXME: On Ubuntu and potentially other Linux OS you should use
|
/* FIXME: On Ubuntu and potentially other Linux OS you should use
|
||||||
* to disable panning. This has to be done before every invocation of mame.
|
* to disable panning. This has to be done before every invocation of mame.
|
||||||
*
|
*
|
||||||
@ -582,35 +568,33 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
osd_printf_verbose("Enter drawsdl2_window_create\n");
|
osd_printf_verbose("Enter sdl_info13::create\n");
|
||||||
|
|
||||||
window->m_dxdata = sdl;
|
UINT32 extra_flags = (window().fullscreen() ?
|
||||||
|
|
||||||
UINT32 extra_flags = (window->fullscreen() ?
|
|
||||||
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
|
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
#if defined(SDLMAME_WIN32)
|
#if defined(SDLMAME_WIN32)
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||||
#endif
|
#endif
|
||||||
// create the SDL window
|
// create the SDL window
|
||||||
window->m_sdl_window = SDL_CreateWindow(window->m_title,
|
window().m_sdl_window = SDL_CreateWindow(window().m_title,
|
||||||
window->monitor()->position_size().x, window->monitor()->position_size().y,
|
window().monitor()->position_size().x, window().monitor()->position_size().y,
|
||||||
width, height, extra_flags);
|
width, height, extra_flags);
|
||||||
|
|
||||||
if (window->fullscreen() && video_config.switchres)
|
if (window().fullscreen() && video_config.switchres)
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
//SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
|
//SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode);
|
||||||
SDL_GetWindowDisplayMode(window->m_sdl_window, &mode);
|
SDL_GetWindowDisplayMode(window().m_sdl_window, &mode);
|
||||||
sdl->m_original_mode = mode;
|
m_original_mode = mode;
|
||||||
mode.w = width;
|
mode.w = width;
|
||||||
mode.h = height;
|
mode.h = height;
|
||||||
if (window->m_refresh)
|
if (window().m_refresh)
|
||||||
mode.refresh_rate = window->m_refresh;
|
mode.refresh_rate = window().m_refresh;
|
||||||
#if 0
|
#if 0
|
||||||
if (window->depth)
|
if (window().depth)
|
||||||
{
|
{
|
||||||
switch (window->depth)
|
switch (window().depth)
|
||||||
{
|
{
|
||||||
case 15:
|
case 15:
|
||||||
mode.format = SDL_PIXELFORMAT_RGB555;
|
mode.format = SDL_PIXELFORMAT_RGB555;
|
||||||
@ -625,66 +609,64 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
|
|||||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
osd_printf_warning("Ignoring depth %d\n", window->depth);
|
osd_printf_warning("Ignoring depth %d\n", window().depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
|
SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode
|
||||||
#ifndef SDLMAME_WIN32
|
#ifndef SDLMAME_WIN32
|
||||||
/* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
|
/* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
|
||||||
* is in place after the mode switch - which will most likely be the case
|
* is in place after the mode switch - which will most likely be the case
|
||||||
* This is a hack to work around a deficiency in SDL2
|
* This is a hack to work around a deficiency in SDL2
|
||||||
*/
|
*/
|
||||||
SDL_WarpMouseInWindow(window->m_sdl_window, 1, 1);
|
SDL_WarpMouseInWindow(window().m_sdl_window, 1, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
|
//SDL_SetWindowDisplayMode(window().sdl_window, NULL); // Use desktop
|
||||||
}
|
}
|
||||||
// create renderer
|
// create renderer
|
||||||
|
|
||||||
if (video_config.waitvsync)
|
if (video_config.waitvsync)
|
||||||
sdl->m_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
else
|
else
|
||||||
sdl->m_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
|
m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
|
|
||||||
if (!sdl->m_renderer)
|
if (!m_renderer)
|
||||||
{
|
{
|
||||||
fatalerror("Error on creating renderer: %s\n", SDL_GetError());
|
fatalerror("Error on creating renderer: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
//SDL_SelectRenderer(window->sdl_window);
|
//SDL_SelectRenderer(window().sdl_window);
|
||||||
SDL_ShowWindow(window->m_sdl_window);
|
SDL_ShowWindow(window().m_sdl_window);
|
||||||
//SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
|
//SDL_SetWindowFullscreen(window().window_id, window().fullscreen);
|
||||||
SDL_RaiseWindow(window->m_sdl_window);
|
SDL_RaiseWindow(window().m_sdl_window);
|
||||||
|
|
||||||
SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
|
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||||
|
|
||||||
sdl->m_blittimer = 3;
|
m_blittimer = 3;
|
||||||
|
|
||||||
SDL_RenderPresent(sdl->m_renderer);
|
SDL_RenderPresent(m_renderer);
|
||||||
osd_printf_verbose("Leave drawsdl2_window_create\n");
|
osd_printf_verbose("Leave sdl_info13::create\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_window_resize
|
// sdl_info13::resize
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
|
void sdl_info13::resize(int width, int height)
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
m_resize_pending = 1;
|
||||||
|
m_resize_height = height;
|
||||||
|
m_resize_width = width;
|
||||||
|
|
||||||
sdl->m_resize_pending = 1;
|
window().m_width = width;
|
||||||
sdl->m_resize_height = height;
|
window().m_height = height;
|
||||||
sdl->m_resize_width = width;
|
|
||||||
|
|
||||||
window->m_width = width;
|
m_blittimer = 3;
|
||||||
window->m_height = height;
|
|
||||||
|
|
||||||
sdl->m_blittimer = 3;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,35 +674,33 @@ static void drawsdl2_window_resize(sdl_window_info *window, int width, int heigh
|
|||||||
// drawsdl_xy_to_render_target
|
// drawsdl_xy_to_render_target
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
|
int sdl_info13::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
|
||||||
|
|
||||||
*xt = x - sdl->m_hofs;
|
*xt = x - m_hofs;
|
||||||
*yt = y - sdl->m_vofs;
|
*yt = y - m_vofs;
|
||||||
if (*xt<0 || *xt >= window->m_blitwidth)
|
if (*xt<0 || *xt >= window().m_blitwidth)
|
||||||
return 0;
|
return 0;
|
||||||
if (*yt<0 || *yt >= window->m_blitheight)
|
if (*yt<0 || *yt >= window().m_blitheight)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_window_get_primitives
|
// sdl_info13::get_primitives
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl2_set_target_bounds(sdl_window_info *window)
|
void sdl_info13::set_target_bounds()
|
||||||
{
|
{
|
||||||
window->m_target->set_bounds(window->m_blitwidth, window->m_blitheight, window->monitor()->aspect());
|
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_window_draw
|
// sdl_info13::draw
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
int sdl_info13::draw(UINT32 dc, int update)
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
|
||||||
render_primitive *prim;
|
render_primitive *prim;
|
||||||
texture_info *texture=NULL;
|
texture_info *texture=NULL;
|
||||||
float vofs, hofs;
|
float vofs, hofs;
|
||||||
@ -731,26 +711,26 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl->m_resize_pending)
|
if (m_resize_pending)
|
||||||
{
|
{
|
||||||
SDL_SetWindowSize(window->m_sdl_window, sdl->m_resize_width, sdl->m_resize_height);
|
SDL_SetWindowSize(window().m_sdl_window, m_resize_width, m_resize_height);
|
||||||
SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
|
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||||
sdl->m_resize_pending = 0;
|
m_resize_pending = 0;
|
||||||
SDL_RenderSetViewport(sdl->m_renderer, NULL);
|
SDL_RenderSetViewport(m_renderer, NULL);
|
||||||
//sdlvideo_monitor_refresh(window->monitor());
|
//sdlvideo_monitor_refresh(window().monitor());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//SDL_SelectRenderer(window->sdl_window);
|
//SDL_SelectRenderer(window().sdl_window);
|
||||||
|
|
||||||
if (sdl->m_blittimer > 0)
|
if (m_blittimer > 0)
|
||||||
{
|
{
|
||||||
/* SDL Underlays need alpha = 0 ! */
|
/* SDL Underlays need alpha = 0 ! */
|
||||||
SDL_SetRenderDrawBlendMode(sdl->m_renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE);
|
||||||
//SDL_SetRenderDrawColor(0,0,0,255);
|
//SDL_SetRenderDrawColor(0,0,0,255);
|
||||||
SDL_SetRenderDrawColor(sdl->m_renderer, 0,0,0,0);
|
SDL_SetRenderDrawColor(m_renderer, 0,0,0,0);
|
||||||
SDL_RenderFillRect(sdl->m_renderer, NULL);
|
SDL_RenderFillRect(m_renderer, NULL);
|
||||||
sdl->m_blittimer--;
|
m_blittimer--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute centering parameters
|
// compute centering parameters
|
||||||
@ -760,34 +740,34 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
{
|
{
|
||||||
int ch, cw;
|
int ch, cw;
|
||||||
|
|
||||||
if ((window->fullscreen()) && (!video_config.switchres))
|
if ((window().fullscreen()) && (!video_config.switchres))
|
||||||
{
|
{
|
||||||
ch = window->monitor()->center_height();
|
ch = window().monitor()->center_height();
|
||||||
cw = window->monitor()->center_width();
|
cw = window().monitor()->center_width();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch = window->m_height;
|
ch = window().m_height;
|
||||||
cw = window->m_width;
|
cw = window().m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_config.centerv)
|
if (video_config.centerv)
|
||||||
{
|
{
|
||||||
vofs = (ch - window->m_blitheight) / 2.0f;
|
vofs = (ch - window().m_blitheight) / 2.0f;
|
||||||
}
|
}
|
||||||
if (video_config.centerh)
|
if (video_config.centerh)
|
||||||
{
|
{
|
||||||
hofs = (cw - window->m_blitwidth) / 2.0f;
|
hofs = (cw - window().m_blitwidth) / 2.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl->m_hofs = hofs;
|
m_hofs = hofs;
|
||||||
sdl->m_vofs = vofs;
|
m_vofs = vofs;
|
||||||
|
|
||||||
window->m_primlist->acquire_lock();
|
window().m_primlist->acquire_lock();
|
||||||
|
|
||||||
// now draw
|
// now draw
|
||||||
for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next())
|
for (prim = window().m_primlist->first(); prim != NULL; prim = prim->next())
|
||||||
{
|
{
|
||||||
Uint8 sr, sg, sb, sa;
|
Uint8 sr, sg, sb, sa;
|
||||||
|
|
||||||
@ -799,16 +779,16 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
sb = (int)(255.0f * prim->color.b);
|
sb = (int)(255.0f * prim->color.b);
|
||||||
sa = (int)(255.0f * prim->color.a);
|
sa = (int)(255.0f * prim->color.a);
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(sdl->m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
|
SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
|
||||||
SDL_SetRenderDrawColor(sdl->m_renderer, sr, sg, sb, sa);
|
SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa);
|
||||||
SDL_RenderDrawLine(sdl->m_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
|
SDL_RenderDrawLine(m_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
|
||||||
prim->bounds.x1 + hofs, prim->bounds.y1 + vofs);
|
prim->bounds.x1 + hofs, prim->bounds.y1 + vofs);
|
||||||
break;
|
break;
|
||||||
case render_primitive::QUAD:
|
case render_primitive::QUAD:
|
||||||
texture = sdl->texture_update(*prim);
|
texture = texture_update(*prim);
|
||||||
if (texture)
|
if (texture)
|
||||||
blit_pixels += (texture->raw_height() * texture->raw_width());
|
blit_pixels += (texture->raw_height() * texture->raw_width());
|
||||||
sdl->render_quad(texture, prim,
|
render_quad(texture, prim,
|
||||||
round_nearest(hofs + prim->bounds.x0),
|
round_nearest(hofs + prim->bounds.x0),
|
||||||
round_nearest(vofs + prim->bounds.y0));
|
round_nearest(vofs + prim->bounds.y0));
|
||||||
break;
|
break;
|
||||||
@ -817,56 +797,46 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->m_primlist->release_lock();
|
window().m_primlist->release_lock();
|
||||||
|
|
||||||
sdl->m_last_blit_pixels = blit_pixels;
|
m_last_blit_pixels = blit_pixels;
|
||||||
sdl->m_last_blit_time = -osd_ticks();
|
m_last_blit_time = -osd_ticks();
|
||||||
SDL_RenderPresent(sdl->m_renderer);
|
SDL_RenderPresent(m_renderer);
|
||||||
sdl->m_last_blit_time += osd_ticks();
|
m_last_blit_time += osd_ticks();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_window_clear
|
// sdl_info13::clear
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl2_window_clear(sdl_window_info *window)
|
void sdl_info13::clear()
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
m_blittimer = 2;
|
||||||
|
|
||||||
sdl->m_blittimer = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl2_window_destroy
|
// sdl_info13::destroy
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl2_window_destroy(sdl_window_info *window)
|
void sdl_info13::destroy()
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
|
||||||
|
|
||||||
// skip if nothing
|
|
||||||
if (sdl == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// free the memory in the window
|
// free the memory in the window
|
||||||
|
|
||||||
drawsdl2_destroy_all_textures(window);
|
destroy_all_textures();
|
||||||
|
|
||||||
if (window->fullscreen() && video_config.switchres)
|
if (window().fullscreen() && video_config.switchres)
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(window->m_sdl_window, 0); // Try to set mode
|
SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
|
||||||
SDL_SetWindowDisplayMode(window->m_sdl_window, &sdl->m_original_mode); // Try to set mode
|
SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode
|
||||||
SDL_SetWindowFullscreen(window->m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(window->m_sdl_window);
|
SDL_DestroyWindow(window().m_sdl_window);
|
||||||
|
|
||||||
global_free(sdl);
|
|
||||||
window->m_dxdata = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
@ -1188,19 +1158,14 @@ texture_info * sdl_info13::texture_update(const render_primitive &prim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void drawsdl2_destroy_all_textures(sdl_window_info *window)
|
void sdl_info13::destroy_all_textures()
|
||||||
{
|
{
|
||||||
sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
|
if(window().m_primlist)
|
||||||
|
|
||||||
if (sdl == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(window->m_primlist)
|
|
||||||
{
|
{
|
||||||
window->m_primlist->acquire_lock();
|
window().m_primlist->acquire_lock();
|
||||||
sdl->m_texlist.reset();
|
m_texlist.reset();
|
||||||
window->m_primlist->release_lock();
|
window().m_primlist->release_lock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sdl->m_texlist.reset();
|
m_texlist.reset();
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -46,8 +46,52 @@ struct sdl_scale_mode;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* sdl_info is the information about SDL for the current screen */
|
/* sdl_info is the information about SDL for the current screen */
|
||||||
struct sdl_info
|
class sdl_info : public osd_renderer
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
sdl_info(sdl_window_info *w)
|
||||||
|
: osd_renderer(w),
|
||||||
|
m_blittimer(0),
|
||||||
|
m_extra_flags(0),
|
||||||
|
|
||||||
|
#if (SDLMAME_SDL2)
|
||||||
|
m_sdl_renderer(NULL),
|
||||||
|
m_texture_id(NULL),
|
||||||
|
#else
|
||||||
|
m_sdlsurf(NULL),
|
||||||
|
m_yuvsurf(NULL),
|
||||||
|
#endif
|
||||||
|
m_yuv_lookup(NULL),
|
||||||
|
m_yuv_bitmap(NULL),
|
||||||
|
m_hw_scale_width(0),
|
||||||
|
m_hw_scale_height(0),
|
||||||
|
m_last_hofs(0),
|
||||||
|
m_last_vofs(0),
|
||||||
|
m_old_blitwidth(0),
|
||||||
|
m_old_blitheight(0)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
/* virtual */ int create(int width, int height);
|
||||||
|
/* virtual */ void resize(int width, int height);
|
||||||
|
/* virtual */ int draw(UINT32 dc, int update);
|
||||||
|
/* virtual */ void set_target_bounds();
|
||||||
|
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||||
|
/* virtual */ void destroy_all_textures();
|
||||||
|
/* virtual */ void destroy();
|
||||||
|
/* virtual */ void clear();
|
||||||
|
|
||||||
|
void yuv_init();
|
||||||
|
#if (SDLMAME_SDL2)
|
||||||
|
void setup_texture(int tempwidth, int tempheight);
|
||||||
|
#endif
|
||||||
|
void yuv_lookup_set(unsigned int pen, unsigned char red,
|
||||||
|
unsigned char green, unsigned char blue);
|
||||||
|
|
||||||
|
#if (!SDLMAME_SDL2)
|
||||||
|
void yuv_overlay_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
INT32 m_blittimer;
|
INT32 m_blittimer;
|
||||||
UINT32 m_extra_flags;
|
UINT32 m_extra_flags;
|
||||||
|
|
||||||
@ -101,23 +145,9 @@ struct sdl_scale_mode
|
|||||||
|
|
||||||
// core functions
|
// core functions
|
||||||
static void drawsdl_exit(void);
|
static void drawsdl_exit(void);
|
||||||
static void drawsdl_attach(sdl_draw_info *info, sdl_window_info *window);
|
|
||||||
static int drawsdl_window_create(sdl_window_info *window, int width, int height);
|
|
||||||
static void drawsdl_window_resize(sdl_window_info *window, int width, int height);
|
|
||||||
static void drawsdl_window_destroy(sdl_window_info *window);
|
|
||||||
static void drawsdl_set_target_bounds(sdl_window_info *window);
|
|
||||||
static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update);
|
|
||||||
static void drawsdl_destroy_all_textures(sdl_window_info *window);
|
|
||||||
static void drawsdl_window_clear(sdl_window_info *window);
|
|
||||||
static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
|
|
||||||
|
|
||||||
#if (SDLMAME_SDL2)
|
|
||||||
static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// YUV overlays
|
// YUV overlays
|
||||||
|
|
||||||
static void drawsdl_yuv_init(sdl_info *sdl);
|
|
||||||
static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
||||||
static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
||||||
static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
|
||||||
@ -190,11 +220,17 @@ int drawsdl_scale_mode(const char *s)
|
|||||||
// drawsdl_init
|
// drawsdl_init
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
|
static osd_renderer *drawsdl_create(sdl_window_info *window)
|
||||||
|
{
|
||||||
|
return global_alloc(sdl_info(window));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int drawsdl_init(sdl_draw_info *callbacks)
|
int drawsdl_init(sdl_draw_info *callbacks)
|
||||||
{
|
{
|
||||||
// fill in the callbacks
|
// fill in the callbacks
|
||||||
|
callbacks->create = drawsdl_create;
|
||||||
callbacks->exit = drawsdl_exit;
|
callbacks->exit = drawsdl_exit;
|
||||||
callbacks->attach = drawsdl_attach;
|
|
||||||
|
|
||||||
if (SDLMAME_SDL2)
|
if (SDLMAME_SDL2)
|
||||||
osd_printf_verbose("Using SDL multi-window soft driver (SDL 2.0+)\n");
|
osd_printf_verbose("Using SDL multi-window soft driver (SDL 2.0+)\n");
|
||||||
@ -212,28 +248,11 @@ static void drawsdl_exit(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
|
||||||
// drawsdl_attach
|
|
||||||
//============================================================
|
|
||||||
|
|
||||||
static void drawsdl_attach(sdl_draw_info *info, sdl_window_info *window)
|
|
||||||
{
|
|
||||||
// fill in the callbacks
|
|
||||||
window->create = drawsdl_window_create;
|
|
||||||
window->resize = drawsdl_window_resize;
|
|
||||||
window->set_target_bounds = drawsdl_set_target_bounds;
|
|
||||||
window->draw = drawsdl_window_draw;
|
|
||||||
window->destroy = drawsdl_window_destroy;
|
|
||||||
window->destroy_all_textures = drawsdl_destroy_all_textures;
|
|
||||||
window->clear = drawsdl_window_clear;
|
|
||||||
window->xy_to_render_target = drawsdl_xy_to_render_target;
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl_destroy_all_textures
|
// drawsdl_destroy_all_textures
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl_destroy_all_textures(sdl_window_info *window)
|
void sdl_info::destroy_all_textures()
|
||||||
{
|
{
|
||||||
/* nothing to be done in soft mode */
|
/* nothing to be done in soft mode */
|
||||||
}
|
}
|
||||||
@ -243,51 +262,50 @@ static void drawsdl_destroy_all_textures(sdl_window_info *window)
|
|||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight)
|
void sdl_info::setup_texture(int tempwidth, int tempheight)
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
UINT32 fmt;
|
UINT32 fmt;
|
||||||
|
|
||||||
// Determine preferred pixelformat and set up yuv if necessary
|
// Determine preferred pixelformat and set up yuv if necessary
|
||||||
SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
|
SDL_GetCurrentDisplayMode(window().monitor()->handle(), &mode);
|
||||||
|
|
||||||
if (sdl->m_yuv_bitmap)
|
if (m_yuv_bitmap)
|
||||||
{
|
{
|
||||||
global_free_array(sdl->m_yuv_bitmap);
|
global_free_array(m_yuv_bitmap);
|
||||||
sdl->m_yuv_bitmap = NULL;
|
m_yuv_bitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl_sm->is_scale)
|
if (sdl_sm->is_scale)
|
||||||
{
|
{
|
||||||
window->m_target->compute_minimum_size(sdl->m_hw_scale_width, sdl->m_hw_scale_height);
|
window().m_target->compute_minimum_size(m_hw_scale_width, m_hw_scale_height);
|
||||||
if (video_config.prescale)
|
if (video_config.prescale)
|
||||||
{
|
{
|
||||||
sdl->m_hw_scale_width *= video_config.prescale;
|
m_hw_scale_width *= video_config.prescale;
|
||||||
sdl->m_hw_scale_height *= video_config.prescale;
|
m_hw_scale_height *= video_config.prescale;
|
||||||
|
|
||||||
/* This must be a multiple of 2 */
|
/* This must be a multiple of 2 */
|
||||||
sdl->m_hw_scale_width = (sdl->m_hw_scale_width + 1) & ~1;
|
m_hw_scale_width = (m_hw_scale_width + 1) & ~1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl_sm->is_yuv)
|
if (sdl_sm->is_yuv)
|
||||||
sdl->m_yuv_bitmap = global_alloc_array(UINT16, sdl->m_hw_scale_width * sdl->m_hw_scale_height);
|
m_yuv_bitmap = global_alloc_array(UINT16, m_hw_scale_width * m_hw_scale_height);
|
||||||
|
|
||||||
fmt = (sdl_sm->pixel_format ? sdl_sm->pixel_format : mode.format);
|
fmt = (sdl_sm->pixel_format ? sdl_sm->pixel_format : mode.format);
|
||||||
|
|
||||||
if (sdl_sm->is_scale)
|
if (sdl_sm->is_scale)
|
||||||
{
|
{
|
||||||
int w = sdl->m_hw_scale_width * sdl_sm->mult_w;
|
int w = m_hw_scale_width * sdl_sm->mult_w;
|
||||||
int h = sdl->m_hw_scale_height * sdl_sm->mult_h;
|
int h = m_hw_scale_height * sdl_sm->mult_h;
|
||||||
|
|
||||||
sdl->m_texture_id = SDL_CreateTexture(sdl->m_sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
|
m_texture_id = SDL_CreateTexture(m_sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sdl->m_texture_id = SDL_CreateTexture(sdl->m_sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
|
m_texture_id = SDL_CreateTexture(m_sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
|
||||||
tempwidth, tempheight);
|
tempwidth, tempheight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,13 +316,12 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
|
|||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#if (!SDLMAME_SDL2)
|
#if (!SDLMAME_SDL2)
|
||||||
static void yuv_overlay_init(sdl_window_info *window)
|
void sdl_info::yuv_overlay_init()
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
||||||
int minimum_width, minimum_height;
|
int minimum_width, minimum_height;
|
||||||
|
|
||||||
window->m_target->compute_minimum_size(minimum_width, minimum_height);
|
window().m_target->compute_minimum_size(minimum_width, minimum_height);
|
||||||
|
|
||||||
if (video_config.prescale)
|
if (video_config.prescale)
|
||||||
{
|
{
|
||||||
@ -312,37 +329,37 @@ static void yuv_overlay_init(sdl_window_info *window)
|
|||||||
minimum_height *= video_config.prescale;
|
minimum_height *= video_config.prescale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl->yuvsurf != NULL)
|
if (m_yuvsurf != NULL)
|
||||||
{
|
{
|
||||||
SDL_FreeYUVOverlay(sdl->yuvsurf);
|
SDL_FreeYUVOverlay(m_yuvsurf);
|
||||||
sdl->yuvsurf = NULL;
|
m_yuvsurf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl->m_yuv_bitmap != NULL)
|
if (m_yuv_bitmap != NULL)
|
||||||
{
|
{
|
||||||
global_free_array(sdl->m_yuv_bitmap);
|
global_free_array(m_yuv_bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
osd_printf_verbose("SDL: Creating %d x %d YUV-Overlay ...\n", minimum_width, minimum_height);
|
osd_printf_verbose("SDL: Creating %d x %d YUV-Overlay ...\n", minimum_width, minimum_height);
|
||||||
|
|
||||||
sdl->m_yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height);
|
m_yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height);
|
||||||
|
|
||||||
sdl->yuvsurf = SDL_CreateYUVOverlay(minimum_width * sdl_sm->mult_w, minimum_height * sdl_sm->mult_h,
|
m_yuvsurf = SDL_CreateYUVOverlay(minimum_width * sdl_sm->mult_w, minimum_height * sdl_sm->mult_h,
|
||||||
sdl_sm->pixel_format, sdl->sdlsurf);
|
sdl_sm->pixel_format, m_sdlsurf);
|
||||||
|
|
||||||
if ( sdl->yuvsurf == NULL ) {
|
if ( m_yuvsurf == NULL ) {
|
||||||
osd_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError());
|
osd_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError());
|
||||||
//return 1;
|
//return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl->m_hw_scale_width = minimum_width;
|
m_hw_scale_width = minimum_width;
|
||||||
sdl->m_hw_scale_height = minimum_height;
|
m_hw_scale_height = minimum_height;
|
||||||
|
|
||||||
if (!shown_video_info)
|
if (!shown_video_info)
|
||||||
{
|
{
|
||||||
osd_printf_verbose("YUV Mode : %s\n", sdl_sm->name);
|
osd_printf_verbose("YUV Mode : %s\n", sdl_sm->name);
|
||||||
osd_printf_verbose("YUV Overlay Size : %d x %d\n", minimum_width, minimum_height);
|
osd_printf_verbose("YUV Overlay Size : %d x %d\n", minimum_width, minimum_height);
|
||||||
osd_printf_verbose("YUV Acceleration : %s\n", sdl->yuvsurf->hw_overlay ? "Hardware" : "Software");
|
osd_printf_verbose("YUV Acceleration : %s\n", m_yuvsurf->hw_overlay ? "Hardware" : "Software");
|
||||||
shown_video_info = 1;
|
shown_video_info = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,7 +370,7 @@ static void yuv_overlay_init(sdl_window_info *window)
|
|||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo *render_info)
|
static void drawsdl_show_info(struct SDL_RendererInfo *render_info)
|
||||||
{
|
{
|
||||||
#define RF_ENTRY(x) {x, #x }
|
#define RF_ENTRY(x) {x, #x }
|
||||||
static struct {
|
static struct {
|
||||||
@ -385,67 +402,60 @@ static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo *
|
|||||||
// drawsdl_window_create
|
// drawsdl_window_create
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static int drawsdl_window_create(sdl_window_info *window, int width, int height)
|
int sdl_info::create(int width, int height)
|
||||||
{
|
{
|
||||||
sdl_info *sdl;
|
|
||||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||||
|
|
||||||
// allocate memory for our structures
|
|
||||||
sdl = (sdl_info *) osd_malloc(sizeof(sdl_info));
|
|
||||||
memset(sdl, 0, sizeof(sdl_info));
|
|
||||||
|
|
||||||
window->m_dxdata = sdl;
|
|
||||||
|
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
|
|
||||||
/* set hints ... */
|
/* set hints ... */
|
||||||
|
|
||||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
|
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
|
||||||
|
|
||||||
sdl->m_extra_flags = (window->fullscreen() ?
|
m_extra_flags = (window().fullscreen() ?
|
||||||
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
|
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
|
||||||
| SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
|
| SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
window->m_sdl_window = SDL_CreateWindow(window->m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
window().m_sdl_window = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
width, height, sdl->m_extra_flags);
|
width, height, m_extra_flags);
|
||||||
|
|
||||||
if (window->fullscreen() && video_config.switchres)
|
if (window().fullscreen() && video_config.switchres)
|
||||||
{
|
{
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
|
SDL_GetCurrentDisplayMode(window().monitor()->handle(), &mode);
|
||||||
mode.w = width;
|
mode.w = width;
|
||||||
mode.h = height;
|
mode.h = height;
|
||||||
if (window->m_refresh)
|
if (window().m_refresh)
|
||||||
mode.refresh_rate = window->m_refresh;
|
mode.refresh_rate = window().m_refresh;
|
||||||
SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
|
SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SDL_SetWindowDisplayMode(window->m_sdl_window, NULL); // Use desktop
|
SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
|
||||||
|
|
||||||
SDL_ShowWindow(window->m_sdl_window);
|
SDL_ShowWindow(window().m_sdl_window);
|
||||||
|
|
||||||
SDL_SetWindowFullscreen(window->m_sdl_window, (SDL_bool) window->fullscreen());
|
SDL_SetWindowFullscreen(window().m_sdl_window, (SDL_bool) window().fullscreen());
|
||||||
SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
|
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||||
SDL_RaiseWindow(window->m_sdl_window);
|
SDL_RaiseWindow(window().m_sdl_window);
|
||||||
|
|
||||||
/* FIXME: Bug in SDL 1.3 */
|
/* FIXME: Bug in SDL 1.3 */
|
||||||
if (window->fullscreen())
|
if (window().fullscreen())
|
||||||
SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE);
|
SDL_SetWindowGrab(window().m_sdl_window, SDL_TRUE);
|
||||||
|
|
||||||
// create a texture
|
// create a texture
|
||||||
|
|
||||||
if (video_config.waitvsync)
|
if (video_config.waitvsync)
|
||||||
sdl->m_sdl_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
|
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
|
||||||
else
|
else
|
||||||
sdl->m_sdl_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
|
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
|
||||||
|
|
||||||
//SDL_SelectRenderer(window->sdl_window);
|
//SDL_SelectRenderer(window().sdl_window);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct SDL_RendererInfo render_info;
|
struct SDL_RendererInfo render_info;
|
||||||
|
|
||||||
SDL_GetRendererInfo(sdl->m_sdl_renderer, &render_info);
|
SDL_GetRendererInfo(m_sdl_renderer, &render_info);
|
||||||
drawsdl_show_info(window, &render_info);
|
drawsdl_show_info(&render_info);
|
||||||
|
|
||||||
// Check scale mode
|
// Check scale mode
|
||||||
|
|
||||||
@ -465,31 +475,31 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_texture(window, width, height);
|
setup_texture(width, height);
|
||||||
#else
|
#else
|
||||||
sdl->m_extra_flags = (window->fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
|
m_extra_flags = (window().fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
|
||||||
|
|
||||||
sdl->m_extra_flags |= sm->m_extra_flags;
|
m_extra_flags |= sm->m_extra_flags;
|
||||||
|
|
||||||
sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height,
|
m_sdlsurf = SDL_SetVideoMode(width, height,
|
||||||
0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->m_extra_flags);
|
0, SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags);
|
||||||
|
|
||||||
if (!sdl->sdlsurf)
|
if (!m_sdlsurf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
window->m_width = sdl->sdlsurf->w;
|
window().m_width = m_sdlsurf->w;
|
||||||
window->m_height = sdl->sdlsurf->h;
|
window().m_height = m_sdlsurf->h;
|
||||||
|
|
||||||
if (sm->is_yuv)
|
if (sm->is_yuv)
|
||||||
yuv_overlay_init(window);
|
yuv_overlay_init();
|
||||||
|
|
||||||
// set the window title
|
// set the window title
|
||||||
SDL_WM_SetCaption(window->m_title, "SDLMAME");
|
SDL_WM_SetCaption(window().m_title, "SDLMAME");
|
||||||
#endif
|
#endif
|
||||||
sdl->m_yuv_lookup = NULL;
|
m_yuv_lookup = NULL;
|
||||||
sdl->m_blittimer = 0;
|
m_blittimer = 0;
|
||||||
|
|
||||||
drawsdl_yuv_init(sdl);
|
yuv_init();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,34 +507,32 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
|
|||||||
// drawsdl_window_resize
|
// drawsdl_window_resize
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl_window_resize(sdl_window_info *window, int width, int height)
|
void sdl_info::resize(int width, int height)
|
||||||
{
|
{
|
||||||
#if (!SDLMAME_SDL2)
|
#if (!SDLMAME_SDL2)
|
||||||
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
|
||||||
#endif
|
#endif
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
SDL_SetWindowSize(window->m_sdl_window, width, height);
|
SDL_SetWindowSize(window().m_sdl_window, width, height);
|
||||||
SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
|
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
if (m_yuvsurf != NULL)
|
||||||
|
|
||||||
if (sdl->yuvsurf != NULL)
|
|
||||||
{
|
{
|
||||||
SDL_FreeYUVOverlay(sdl->yuvsurf);
|
SDL_FreeYUVOverlay(m_yuvsurf);
|
||||||
sdl->yuvsurf = NULL;
|
m_yuvsurf = NULL;
|
||||||
}
|
}
|
||||||
SDL_FreeSurface(sdl->sdlsurf);
|
SDL_FreeSurface(m_sdlsurf);
|
||||||
//printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height);
|
//printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height);
|
||||||
|
|
||||||
sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height, 0,
|
m_sdlsurf = SDL_SetVideoMode(width, height, 0,
|
||||||
SDL_SWSURFACE | SDL_ANYFORMAT | sdl->m_extra_flags);
|
SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags);
|
||||||
window->m_width = sdl->sdlsurf->w;
|
window().m_width = m_sdlsurf->w;
|
||||||
window->m_height = sdl->sdlsurf->h;
|
window().m_height = m_sdlsurf->h;
|
||||||
|
|
||||||
if (sdl_sm->is_yuv)
|
if (sdl_sm->is_yuv)
|
||||||
{
|
{
|
||||||
yuv_overlay_init(window);
|
yuv_overlay_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -535,81 +543,71 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height
|
|||||||
// drawsdl_window_destroy
|
// drawsdl_window_destroy
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl_window_destroy(sdl_window_info *window)
|
void sdl_info::destroy()
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
|
|
||||||
// skip if nothing
|
|
||||||
if (sdl == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
//SDL_SelectRenderer(window->sdl_window);
|
//SDL_SelectRenderer(window().sdl_window);
|
||||||
SDL_DestroyTexture(sdl->m_texture_id);
|
SDL_DestroyTexture(m_texture_id);
|
||||||
//SDL_DestroyRenderer(window->sdl_window);
|
//SDL_DestroyRenderer(window().sdl_window);
|
||||||
SDL_DestroyWindow(window->m_sdl_window);
|
SDL_DestroyWindow(window().m_sdl_window);
|
||||||
#else
|
#else
|
||||||
if (sdl->yuvsurf != NULL)
|
if (m_yuvsurf != NULL)
|
||||||
{
|
{
|
||||||
SDL_FreeYUVOverlay(sdl->yuvsurf);
|
SDL_FreeYUVOverlay(m_yuvsurf);
|
||||||
sdl->yuvsurf = NULL;
|
m_yuvsurf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdl->sdlsurf)
|
if (m_sdlsurf)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(sdl->sdlsurf);
|
SDL_FreeSurface(m_sdlsurf);
|
||||||
sdl->sdlsurf = NULL;
|
m_sdlsurf = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// free the memory in the window
|
// free the memory in the window
|
||||||
|
|
||||||
if (sdl->m_yuv_lookup != NULL)
|
if (m_yuv_lookup != NULL)
|
||||||
{
|
{
|
||||||
global_free_array(sdl->m_yuv_lookup);
|
global_free_array(m_yuv_lookup);
|
||||||
sdl->m_yuv_lookup = NULL;
|
m_yuv_lookup = NULL;
|
||||||
}
|
}
|
||||||
if (sdl->m_yuv_bitmap != NULL)
|
if (m_yuv_bitmap != NULL)
|
||||||
{
|
{
|
||||||
global_free_array(sdl->m_yuv_bitmap);
|
global_free_array(m_yuv_bitmap);
|
||||||
sdl->m_yuv_bitmap = NULL;
|
m_yuv_bitmap = NULL;
|
||||||
}
|
}
|
||||||
osd_free(sdl);
|
|
||||||
window->m_dxdata = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl_window_clear
|
// drawsdl_window_clear
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl_window_clear(sdl_window_info *window)
|
void sdl_info::clear()
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
m_blittimer = 3;
|
||||||
|
|
||||||
sdl->m_blittimer = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl_xy_to_render_target
|
// drawsdl_xy_to_render_target
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
|
int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||||
|
|
||||||
*xt = x - sdl->m_last_hofs;
|
*xt = x - m_last_hofs;
|
||||||
*yt = y - sdl->m_last_vofs;
|
*yt = y - m_last_vofs;
|
||||||
if (*xt<0 || *xt >= window->m_blitwidth)
|
if (*xt<0 || *xt >= window().m_blitwidth)
|
||||||
return 0;
|
return 0;
|
||||||
if (*yt<0 || *xt >= window->m_blitheight)
|
if (*yt<0 || *xt >= window().m_blitheight)
|
||||||
return 0;
|
return 0;
|
||||||
if (!sm->is_scale)
|
if (!sm->is_scale)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Rescale */
|
/* Rescale */
|
||||||
*xt = (*xt * sdl->m_hw_scale_width) / window->m_blitwidth;
|
*xt = (*xt * m_hw_scale_width) / window().m_blitwidth;
|
||||||
*yt = (*yt * sdl->m_hw_scale_height) / window->m_blitheight;
|
*yt = (*yt * m_hw_scale_height) / window().m_blitheight;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,24 +615,22 @@ static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, in
|
|||||||
// drawsdl_window_get_primitives
|
// drawsdl_window_get_primitives
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static void drawsdl_set_target_bounds(sdl_window_info *window)
|
void sdl_info::set_target_bounds()
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||||
|
|
||||||
if (!sm->is_scale)
|
if (!sm->is_scale)
|
||||||
window->m_target->set_bounds(window->m_blitwidth, window->m_blitheight, window->monitor()->aspect());
|
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||||
else
|
else
|
||||||
window->m_target->set_bounds(sdl->m_hw_scale_width, sdl->m_hw_scale_height);
|
window().m_target->set_bounds(m_hw_scale_width, m_hw_scale_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
// drawsdl_window_draw
|
// drawsdl_window_draw
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
int sdl_info::draw(UINT32 dc, int update)
|
||||||
{
|
{
|
||||||
sdl_info *sdl = (sdl_info *) window->m_dxdata;
|
|
||||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||||
UINT8 *surfptr;
|
UINT8 *surfptr;
|
||||||
INT32 pitch;
|
INT32 pitch;
|
||||||
@ -650,100 +646,97 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we haven't been created, just punt
|
|
||||||
if (sdl == NULL)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// lock it if we need it
|
// lock it if we need it
|
||||||
#if (!SDLMAME_SDL2)
|
#if (!SDLMAME_SDL2)
|
||||||
|
|
||||||
pitch = sdl->sdlsurf->pitch;
|
pitch = m_sdlsurf->pitch;
|
||||||
bpp = sdl->sdlsurf->format->BytesPerPixel;
|
bpp = m_sdlsurf->format->BytesPerPixel;
|
||||||
rmask = sdl->sdlsurf->format->Rmask;
|
rmask = m_sdlsurf->format->Rmask;
|
||||||
gmask = sdl->sdlsurf->format->Gmask;
|
gmask = m_sdlsurf->format->Gmask;
|
||||||
bmask = sdl->sdlsurf->format->Bmask;
|
bmask = m_sdlsurf->format->Bmask;
|
||||||
// amask = sdl->sdlsurf->format->Amask;
|
// amask = sdlsurf->format->Amask;
|
||||||
|
|
||||||
if (window->m_blitwidth != sdl->m_old_blitwidth || window->m_blitheight != sdl->m_old_blitheight)
|
if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight)
|
||||||
{
|
{
|
||||||
if (sm->is_yuv)
|
if (sm->is_yuv)
|
||||||
yuv_overlay_init(window);
|
yuv_overlay_init();
|
||||||
sdl->m_old_blitwidth = window->m_blitwidth;
|
m_old_blitwidth = window().m_blitwidth;
|
||||||
sdl->m_old_blitheight = window->m_blitheight;
|
m_old_blitheight = window().m_blitheight;
|
||||||
sdl->m_blittimer = 3;
|
m_blittimer = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_MUSTLOCK(sdl->sdlsurf)) SDL_LockSurface(sdl->sdlsurf);
|
if (SDL_MUSTLOCK(m_sdlsurf))
|
||||||
// Clear if necessary
|
SDL_LockSurface(m_sdlsurf);
|
||||||
|
|
||||||
if (sdl->m_blittimer > 0)
|
// Clear if necessary
|
||||||
|
if (m_blittimer > 0)
|
||||||
{
|
{
|
||||||
memset(sdl->sdlsurf->pixels, 0, window->m_height * sdl->sdlsurf->pitch);
|
memset(m_sdlsurf->pixels, 0, window().m_height * m_sdlsurf->pitch);
|
||||||
sdl->m_blittimer--;
|
m_blittimer--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sm->is_yuv)
|
if (sm->is_yuv)
|
||||||
{
|
{
|
||||||
SDL_LockYUVOverlay(sdl->yuvsurf);
|
SDL_LockYUVOverlay(m_yuvsurf);
|
||||||
surfptr = sdl->yuvsurf->pixels[0]; // (UINT8 *) sdl->m_yuv_bitmap;
|
surfptr = m_yuvsurf->pixels[0]; // (UINT8 *) m_yuv_bitmap;
|
||||||
pitch = sdl->yuvsurf->pitches[0]; // (UINT8 *) sdl->m_yuv_bitmap;
|
pitch = m_yuvsurf->pitches[0]; // (UINT8 *) m_yuv_bitmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
surfptr = (UINT8 *)sdl->sdlsurf->pixels;
|
surfptr = (UINT8 *)m_sdlsurf->pixels;
|
||||||
#else
|
#else
|
||||||
//SDL_SelectRenderer(window->sdl_window);
|
//SDL_SelectRenderer(window().sdl_window);
|
||||||
|
|
||||||
if (window->m_blitwidth != sdl->m_old_blitwidth || window->m_blitheight != sdl->m_old_blitheight)
|
if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight)
|
||||||
{
|
{
|
||||||
SDL_RenderSetViewport(sdl->m_sdl_renderer, NULL);
|
SDL_RenderSetViewport(m_sdl_renderer, NULL);
|
||||||
|
|
||||||
SDL_DestroyTexture(sdl->m_texture_id);
|
SDL_DestroyTexture(m_texture_id);
|
||||||
setup_texture(window, window->m_blitwidth, window->m_blitheight);
|
setup_texture(window().m_blitwidth, window().m_blitheight);
|
||||||
sdl->m_old_blitwidth = window->m_blitwidth;
|
m_old_blitwidth = window().m_blitwidth;
|
||||||
sdl->m_old_blitheight = window->m_blitheight;
|
m_old_blitheight = window().m_blitheight;
|
||||||
sdl->m_blittimer = 3;
|
m_blittimer = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Uint32 format;
|
Uint32 format;
|
||||||
int access, w, h;
|
int access, w, h;
|
||||||
|
|
||||||
SDL_QueryTexture(sdl->m_texture_id, &format, &access, &w, &h);
|
SDL_QueryTexture(m_texture_id, &format, &access, &w, &h);
|
||||||
SDL_PixelFormatEnumToMasks(format, &bpp, &rmask, &gmask, &bmask, &amask);
|
SDL_PixelFormatEnumToMasks(format, &bpp, &rmask, &gmask, &bmask, &amask);
|
||||||
bpp = bpp / 8; /* convert to bytes per pixels */
|
bpp = bpp / 8; /* convert to bytes per pixels */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear if necessary
|
// Clear if necessary
|
||||||
if (sdl->m_blittimer > 0)
|
if (m_blittimer > 0)
|
||||||
{
|
{
|
||||||
/* SDL Underlays need alpha = 0 ! */
|
/* SDL Underlays need alpha = 0 ! */
|
||||||
SDL_SetRenderDrawColor(sdl->m_sdl_renderer,0,0,0,0);
|
SDL_SetRenderDrawColor(m_sdl_renderer,0,0,0,0);
|
||||||
SDL_RenderFillRect(sdl->m_sdl_renderer,NULL);
|
SDL_RenderFillRect(m_sdl_renderer,NULL);
|
||||||
//SDL_RenderFill(0,0,0,0 /*255*/,NULL);
|
//SDL_RenderFill(0,0,0,0 /*255*/,NULL);
|
||||||
sdl->m_blittimer--;
|
m_blittimer--;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockTexture(sdl->m_texture_id, NULL, (void **) &surfptr, &pitch);
|
SDL_LockTexture(m_texture_id, NULL, (void **) &surfptr, &pitch);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// get ready to center the image
|
// get ready to center the image
|
||||||
vofs = hofs = 0;
|
vofs = hofs = 0;
|
||||||
blitwidth = window->m_blitwidth;
|
blitwidth = window().m_blitwidth;
|
||||||
blitheight = window->m_blitheight;
|
blitheight = window().m_blitheight;
|
||||||
|
|
||||||
// figure out what coordinate system to use for centering - in window mode it's always the
|
// 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
|
// SDL surface size. in fullscreen the surface covers all monitors, so center according to
|
||||||
// the first one only
|
// the first one only
|
||||||
if ((window->fullscreen()) && (!video_config.switchres))
|
if ((window().fullscreen()) && (!video_config.switchres))
|
||||||
{
|
{
|
||||||
ch = window->monitor()->center_height();
|
ch = window().monitor()->center_height();
|
||||||
cw = window->monitor()->center_width();
|
cw = window().monitor()->center_width();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch = window->m_height;
|
ch = window().m_height;
|
||||||
cw = window->m_width;
|
cw = window().m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not crash if the window's smaller than the blit area
|
// do not crash if the window's smaller than the blit area
|
||||||
@ -753,7 +746,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
}
|
}
|
||||||
else if (video_config.centerv)
|
else if (video_config.centerv)
|
||||||
{
|
{
|
||||||
vofs = (ch - window->m_blitheight) / 2;
|
vofs = (ch - window().m_blitheight) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blitwidth > cw)
|
if (blitwidth > cw)
|
||||||
@ -762,13 +755,13 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
}
|
}
|
||||||
else if (video_config.centerh)
|
else if (video_config.centerh)
|
||||||
{
|
{
|
||||||
hofs = (cw - window->m_blitwidth) / 2;
|
hofs = (cw - window().m_blitwidth) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl->m_last_hofs = hofs;
|
m_last_hofs = hofs;
|
||||||
sdl->m_last_vofs = vofs;
|
m_last_vofs = vofs;
|
||||||
|
|
||||||
window->m_primlist->acquire_lock();
|
window().m_primlist->acquire_lock();
|
||||||
|
|
||||||
// render to it
|
// render to it
|
||||||
if (!sm->is_yuv)
|
if (!sm->is_yuv)
|
||||||
@ -785,29 +778,29 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mamewidth = sdl->m_hw_scale_width;
|
mamewidth = m_hw_scale_width;
|
||||||
mameheight = sdl->m_hw_scale_height;
|
mameheight = m_hw_scale_height;
|
||||||
}
|
}
|
||||||
switch (rmask)
|
switch (rmask)
|
||||||
{
|
{
|
||||||
case 0x0000ff00:
|
case 0x0000ff00:
|
||||||
software_renderer<UINT32, 0,0,0, 8,16,24>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
software_renderer<UINT32, 0,0,0, 8,16,24>::draw_primitives(*window().m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x00ff0000:
|
case 0x00ff0000:
|
||||||
software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window().m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x000000ff:
|
case 0x000000ff:
|
||||||
software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window().m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf800:
|
case 0xf800:
|
||||||
software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
|
software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window().m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x7c00:
|
case 0x7c00:
|
||||||
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
|
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window().m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -817,34 +810,34 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert (sdl->m_yuv_bitmap != NULL);
|
assert (m_yuv_bitmap != NULL);
|
||||||
assert (surfptr != NULL);
|
assert (surfptr != NULL);
|
||||||
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, sdl->m_yuv_bitmap, sdl->m_hw_scale_width, sdl->m_hw_scale_height, sdl->m_hw_scale_width);
|
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window().m_primlist, m_yuv_bitmap, m_hw_scale_width, m_hw_scale_height, m_hw_scale_width);
|
||||||
sm->yuv_blit((UINT16 *)sdl->m_yuv_bitmap, sdl, surfptr, pitch);
|
sm->yuv_blit((UINT16 *)m_yuv_bitmap, this, surfptr, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->m_primlist->release_lock();
|
window().m_primlist->release_lock();
|
||||||
|
|
||||||
// unlock and flip
|
// unlock and flip
|
||||||
#if (!SDLMAME_SDL2)
|
#if (!SDLMAME_SDL2)
|
||||||
if (SDL_MUSTLOCK(sdl->sdlsurf)) SDL_UnlockSurface(sdl->sdlsurf);
|
if (SDL_MUSTLOCK(m_sdlsurf)) SDL_UnlockSurface(m_sdlsurf);
|
||||||
if (!sm->is_yuv)
|
if (!sm->is_yuv)
|
||||||
{
|
{
|
||||||
SDL_Flip(sdl->sdlsurf);
|
SDL_Flip(m_sdlsurf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
SDL_UnlockYUVOverlay(sdl->yuvsurf);
|
SDL_UnlockYUVOverlay(m_yuvsurf);
|
||||||
r.x=hofs;
|
r.x = hofs;
|
||||||
r.y=vofs;
|
r.y = vofs;
|
||||||
r.w=m_blitwidth;
|
r.w = blitwidth;
|
||||||
r.h=m_blitheight;
|
r.h = blitheight;
|
||||||
SDL_DisplayYUVOverlay(sdl->yuvsurf, &r);
|
SDL_DisplayYUVOverlay(m_yuvsurf, &r);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SDL_UnlockTexture(sdl->m_texture_id);
|
SDL_UnlockTexture(m_texture_id);
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
|
|
||||||
@ -852,10 +845,10 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
r.y=vofs;
|
r.y=vofs;
|
||||||
r.w=blitwidth;
|
r.w=blitwidth;
|
||||||
r.h=blitheight;
|
r.h=blitheight;
|
||||||
//printf("blitwidth %d %d - %d %d\n", blitwidth, blitheight, window->width, window->height);
|
//printf("blitwidth %d %d - %d %d\n", blitwidth, blitheight, window().width, window().height);
|
||||||
//SDL_UpdateTexture(sdl->sdltex, NULL, sdl->sdlsurf->pixels, pitch);
|
//SDL_UpdateTexture(sdltex, NULL, sdlsurf->pixels, pitch);
|
||||||
SDL_RenderCopy(sdl->m_sdl_renderer,sdl->m_texture_id, NULL, &r);
|
SDL_RenderCopy(m_sdl_renderer,m_texture_id, NULL, &r);
|
||||||
SDL_RenderPresent(sdl->m_sdl_renderer);
|
SDL_RenderPresent(m_sdl_renderer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -901,7 +894,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
#define YMASK (Y1MASK|Y2MASK)
|
#define YMASK (Y1MASK|Y2MASK)
|
||||||
#define UVMASK (UMASK|VMASK)
|
#define UVMASK (UMASK|VMASK)
|
||||||
|
|
||||||
static void yuv_lookup_set(sdl_info *sdl, unsigned int pen, unsigned char red,
|
void sdl_info::yuv_lookup_set(unsigned int pen, unsigned char red,
|
||||||
unsigned char green, unsigned char blue)
|
unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
UINT32 y,u,v;
|
UINT32 y,u,v;
|
||||||
@ -910,20 +903,20 @@ static void yuv_lookup_set(sdl_info *sdl, unsigned int pen, unsigned char red,
|
|||||||
|
|
||||||
/* Storing this data in YUYV order simplifies using the data for
|
/* Storing this data in YUYV order simplifies using the data for
|
||||||
YUY2, both with and without smoothing... */
|
YUY2, both with and without smoothing... */
|
||||||
sdl->m_yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT);
|
m_yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawsdl_yuv_init(sdl_info *sdl)
|
void sdl_info::yuv_init()
|
||||||
{
|
{
|
||||||
unsigned char r,g,b;
|
unsigned char r,g,b;
|
||||||
if (sdl->m_yuv_lookup == NULL)
|
if (m_yuv_lookup == NULL)
|
||||||
sdl->m_yuv_lookup = global_alloc_array(UINT32, 65536);
|
m_yuv_lookup = global_alloc_array(UINT32, 65536);
|
||||||
for (r = 0; r < 32; r++)
|
for (r = 0; r < 32; r++)
|
||||||
for (g = 0; g < 32; g++)
|
for (g = 0; g < 32; g++)
|
||||||
for (b = 0; b < 32; b++)
|
for (b = 0; b < 32; b++)
|
||||||
{
|
{
|
||||||
int idx = (r << 10) | (g << 5) | b;
|
int idx = (r << 10) | (g << 5) | b;
|
||||||
yuv_lookup_set(sdl, idx,
|
yuv_lookup_set(idx,
|
||||||
(r << 3) | (r >> 2),
|
(r << 3) | (r >> 2),
|
||||||
(g << 3) | (g >> 2),
|
(g << 3) | (g >> 2),
|
||||||
(b << 3) | (b >> 2));
|
(b << 3) | (b >> 2));
|
||||||
|
@ -1859,7 +1859,7 @@ void sdlinput_poll(running_machine &machine)
|
|||||||
int cx, cy;
|
int cx, cy;
|
||||||
osd_ticks_t click = osd_ticks() * 1000 / osd_ticks_per_second();
|
osd_ticks_t click = osd_ticks() * 1000 / osd_ticks_per_second();
|
||||||
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
|
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
|
||||||
if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) )
|
if (window != NULL && window->renderer().xy_to_render_target(event.button.x,event.button.y, &cx, &cy) )
|
||||||
{
|
{
|
||||||
ui_input_push_mouse_down_event(machine, window->m_target, cx, cy);
|
ui_input_push_mouse_down_event(machine, window->m_target, cx, cy);
|
||||||
// FIXME Parameter ?
|
// FIXME Parameter ?
|
||||||
@ -1893,7 +1893,7 @@ void sdlinput_poll(running_machine &machine)
|
|||||||
int cx, cy;
|
int cx, cy;
|
||||||
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
|
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
|
||||||
|
|
||||||
if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) )
|
if (window != NULL && window->renderer().xy_to_render_target(event.button.x,event.button.y, &cx, &cy) )
|
||||||
{
|
{
|
||||||
ui_input_push_mouse_up_event(machine, window->m_target, cx, cy);
|
ui_input_push_mouse_up_event(machine, window->m_target, cx, cy);
|
||||||
}
|
}
|
||||||
@ -1918,7 +1918,7 @@ void sdlinput_poll(running_machine &machine)
|
|||||||
int cx=-1, cy=-1;
|
int cx=-1, cy=-1;
|
||||||
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
|
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
|
||||||
|
|
||||||
if (window != NULL && window->xy_to_render_target(window, event.motion.x, event.motion.y, &cx, &cy) )
|
if (window != NULL && window->renderer().xy_to_render_target(event.motion.x, event.motion.y, &cx, &cy) )
|
||||||
ui_input_push_mouse_move_event(machine, window->m_target, cx, cy);
|
ui_input_push_mouse_move_event(machine, window->m_target, cx, cy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -483,8 +483,8 @@ static OSDWORK_CALLBACK( sdlwindow_resize_wt )
|
|||||||
|
|
||||||
ASSERT_WINDOW_THREAD();
|
ASSERT_WINDOW_THREAD();
|
||||||
|
|
||||||
window->destroy_all_textures(window);
|
window->renderer().destroy_all_textures();
|
||||||
window->resize(window, wp->new_width(), wp->new_height());
|
window->renderer().resize(wp->new_width(), wp->new_height());
|
||||||
|
|
||||||
window->blit_surface_size(wp->new_width(), wp->new_height());
|
window->blit_surface_size(wp->new_width(), wp->new_height());
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt )
|
|||||||
|
|
||||||
ASSERT_WINDOW_THREAD();
|
ASSERT_WINDOW_THREAD();
|
||||||
|
|
||||||
window->clear(window);
|
window->renderer().clear();
|
||||||
osd_free(wp);
|
osd_free(wp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -558,7 +558,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
|
|||||||
window->m_windowed_height = window->m_height;
|
window->m_windowed_height = window->m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->destroy(window);
|
window->renderer().destroy();
|
||||||
sdlinput_release_keys(wp->machine());
|
sdlinput_release_keys(wp->machine());
|
||||||
|
|
||||||
// toggle the window mode
|
// toggle the window mode
|
||||||
@ -582,7 +582,7 @@ static OSDWORK_CALLBACK( destroy_all_textures_wt )
|
|||||||
|
|
||||||
sdl_window_info *window = wp->window();
|
sdl_window_info *window = wp->window();
|
||||||
|
|
||||||
window->destroy_all_textures(window);
|
window->renderer().destroy_all_textures();
|
||||||
|
|
||||||
osd_free(wp);
|
osd_free(wp);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -722,7 +722,7 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
|
|||||||
*last_window_ptr = window;
|
*last_window_ptr = window;
|
||||||
last_window_ptr = &window->m_next;
|
last_window_ptr = &window->m_next;
|
||||||
|
|
||||||
draw.attach(&draw, window);
|
window->set_renderer(draw.create(window));
|
||||||
|
|
||||||
// create an event that we can use to skip blitting
|
// create an event that we can use to skip blitting
|
||||||
window->m_rendered_event = osd_event_alloc(FALSE, TRUE);
|
window->m_rendered_event = osd_event_alloc(FALSE, TRUE);
|
||||||
@ -781,7 +781,7 @@ static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt )
|
|||||||
ASSERT_WINDOW_THREAD();
|
ASSERT_WINDOW_THREAD();
|
||||||
|
|
||||||
// free the textures etc
|
// free the textures etc
|
||||||
window->destroy(window);
|
window->renderer().destroy();
|
||||||
|
|
||||||
// release all keys ...
|
// release all keys ...
|
||||||
sdlinput_release_keys(wp->machine());
|
sdlinput_release_keys(wp->machine());
|
||||||
@ -1027,7 +1027,7 @@ void sdl_window_info::video_window_update(running_machine &machine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure the target bounds are up-to-date, and then get the primitives
|
// ensure the target bounds are up-to-date, and then get the primitives
|
||||||
set_target_bounds(this);
|
renderer().set_target_bounds();
|
||||||
|
|
||||||
render_primitive_list &primlist = m_target->get_primitives();
|
render_primitive_list &primlist = m_target->get_primitives();
|
||||||
|
|
||||||
@ -1116,7 +1116,7 @@ static OSDWORK_CALLBACK( complete_create_wt )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialize the drawing backend
|
// initialize the drawing backend
|
||||||
if (window->create(window, tempwidth, tempheight))
|
if (window->renderer().create(tempwidth, tempheight))
|
||||||
return (void *) &result[1];
|
return (void *) &result[1];
|
||||||
|
|
||||||
// Make sure we have a consistent state
|
// Make sure we have a consistent state
|
||||||
@ -1147,7 +1147,7 @@ static void measure_fps(sdl_window_info *window, UINT32 dc, int update)
|
|||||||
|
|
||||||
t0 = osd_ticks();
|
t0 = osd_ticks();
|
||||||
|
|
||||||
window->draw(window, dc, update);
|
window->renderer().draw(dc, update);
|
||||||
|
|
||||||
frames++;
|
frames++;
|
||||||
currentTime = osd_ticks();
|
currentTime = osd_ticks();
|
||||||
@ -1198,7 +1198,7 @@ static OSDWORK_CALLBACK( draw_video_contents_wt )
|
|||||||
if( video_config.perftest )
|
if( video_config.perftest )
|
||||||
measure_fps(window, dc, update);
|
measure_fps(window, dc, update);
|
||||||
else
|
else
|
||||||
window->draw(window, dc, update);
|
window->renderer().draw(dc, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all done, ready for next */
|
/* all done, ready for next */
|
||||||
|
@ -40,13 +40,15 @@ public:
|
|||||||
osd_renderer(sdl_window_info *window)
|
osd_renderer(sdl_window_info *window)
|
||||||
: m_window(window) { }
|
: m_window(window) { }
|
||||||
|
|
||||||
|
virtual ~osd_renderer() { }
|
||||||
|
|
||||||
sdl_window_info &window() { return *m_window; }
|
sdl_window_info &window() { return *m_window; }
|
||||||
|
|
||||||
virtual int create(int width, int height) = 0;
|
virtual int create(int width, int height) = 0;
|
||||||
virtual void resize(int width, int height) = 0;
|
virtual void resize(int width, int height) = 0;
|
||||||
virtual int draw(UINT32 dc, int update) = 0;
|
virtual int draw(UINT32 dc, int update) = 0;
|
||||||
virtual void set_target_bounds() = 0;
|
virtual void set_target_bounds() = 0;
|
||||||
virtual int y_to_render_target(int x, int y, int *xt, int *yt) = 0;
|
virtual int xy_to_render_target(int x, int y, int *xt, int *yt) = 0;
|
||||||
virtual void destroy_all_textures() = 0;
|
virtual void destroy_all_textures() = 0;
|
||||||
virtual void destroy() = 0;
|
virtual void destroy() = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
@ -62,7 +64,7 @@ public:
|
|||||||
int index, const sdl_window_config *config)
|
int index, const sdl_window_config *config)
|
||||||
: m_next(NULL), m_minwidth(0), m_minheight(0),
|
: m_next(NULL), m_minwidth(0), m_minheight(0),
|
||||||
m_startmaximized(0),
|
m_startmaximized(0),
|
||||||
m_rendered_event(0), m_target(0), m_primlist(NULL), m_dxdata(NULL),
|
m_rendered_event(0), m_target(0), m_primlist(NULL),
|
||||||
m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0),
|
m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0),
|
||||||
m_start_viewscreen(0),
|
m_start_viewscreen(0),
|
||||||
#if (SDLMAME_SDL2)
|
#if (SDLMAME_SDL2)
|
||||||
@ -71,7 +73,7 @@ public:
|
|||||||
m_resize_height(0),
|
m_resize_height(0),
|
||||||
m_last_resize(0),
|
m_last_resize(0),
|
||||||
#else
|
#else
|
||||||
screen_width(0), screen_height(0),
|
m_screen_width(0), m_screen_height(0),
|
||||||
#endif
|
#endif
|
||||||
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0)
|
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0)
|
||||||
{
|
{
|
||||||
@ -89,15 +91,18 @@ public:
|
|||||||
m_windowed_height = config->height;
|
m_windowed_height = config->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~sdl_window_info()
|
||||||
|
{
|
||||||
|
global_free(m_renderer);
|
||||||
|
}
|
||||||
|
|
||||||
void video_window_update(running_machine &machine);
|
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 toggle_full_screen(running_machine &machine);
|
||||||
void modify_prescale(running_machine &machine, int dir);
|
void modify_prescale(running_machine &machine, int dir);
|
||||||
void window_resize(INT32 width, INT32 height);
|
void window_resize(INT32 width, INT32 height);
|
||||||
void window_clear();
|
void window_clear();
|
||||||
|
|
||||||
void video_window_destroy(running_machine &machine);
|
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_min_bounds(int *window_width, int *window_height, int constrain);
|
||||||
void get_max_bounds(int *window_width, int *window_height, int constrain);
|
void get_max_bounds(int *window_width, int *window_height, int constrain);
|
||||||
|
|
||||||
@ -111,17 +116,7 @@ public:
|
|||||||
void pick_best_mode(int *fswidth, int *fsheight);
|
void pick_best_mode(int *fswidth, int *fsheight);
|
||||||
int index() const { return m_index; }
|
int index() const { return m_index; }
|
||||||
|
|
||||||
#if 1
|
osd_renderer &renderer() { return *m_renderer; }
|
||||||
// Draw Callbacks
|
|
||||||
int (*create)(sdl_window_info *window, int m_width, int m_height);
|
|
||||||
void (*resize)(sdl_window_info *window, int m_width, int m_height);
|
|
||||||
int (*draw)(sdl_window_info *window, UINT32 dc, int update);
|
|
||||||
void (*set_target_bounds)(sdl_window_info *window);
|
|
||||||
int (*xy_to_render_target)(sdl_window_info *window, int x, int y, int *xt, int *yt);
|
|
||||||
void (*destroy_all_textures)(sdl_window_info *window);
|
|
||||||
void (*destroy)(sdl_window_info *window);
|
|
||||||
void (*clear)(sdl_window_info *window);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pointer to next window
|
// Pointer to next window
|
||||||
sdl_window_info * m_next;
|
sdl_window_info * m_next;
|
||||||
@ -143,9 +138,6 @@ public:
|
|||||||
render_target * m_target;
|
render_target * m_target;
|
||||||
render_primitive_list *m_primlist;
|
render_primitive_list *m_primlist;
|
||||||
|
|
||||||
// drawing data
|
|
||||||
void * m_dxdata;
|
|
||||||
|
|
||||||
// cache of physical m_width and m_height
|
// cache of physical m_width and m_height
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
@ -171,6 +163,10 @@ public:
|
|||||||
int m_screen_height;
|
int m_screen_height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void set_renderer(osd_renderer *renderer)
|
||||||
|
{
|
||||||
|
m_renderer = renderer;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment);
|
void constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment);
|
||||||
|
|
||||||
@ -186,8 +182,8 @@ private:
|
|||||||
|
|
||||||
struct sdl_draw_info
|
struct sdl_draw_info
|
||||||
{
|
{
|
||||||
|
osd_renderer *(*create)(sdl_window_info *window);
|
||||||
void (*exit)(void);
|
void (*exit)(void);
|
||||||
void (*attach)(sdl_draw_info *info, sdl_window_info *window);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user