Fix fullscreen toggle for the accel driver os OSX. [Couriersud]

This commit is contained in:
couriersud 2015-03-02 22:04:21 +01:00
parent de6b090917
commit 081cae6919
4 changed files with 87 additions and 42 deletions

View File

@ -136,14 +136,31 @@ private:
// TEXCOPY FUNCS // TEXCOPY FUNCS
//============================================================ //============================================================
enum SDL_TEXFORMAT_E
{
SDL_TEXFORMAT_ARGB32 = 0,
SDL_TEXFORMAT_RGB32,
SDL_TEXFORMAT_RGB32_PALETTED,
SDL_TEXFORMAT_YUY16,
SDL_TEXFORMAT_YUY16_PALETTED,
SDL_TEXFORMAT_PALETTE16,
SDL_TEXFORMAT_RGB15,
SDL_TEXFORMAT_RGB15_PALETTED,
SDL_TEXFORMAT_PALETTE16A,
SDL_TEXFORMAT_PALETTE16_ARGB1555,
SDL_TEXFORMAT_RGB15_ARGB1555,
SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555,
SDL_TEXFORMAT_LAST = SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555
};
#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 */
class sdl_info13 : public osd_renderer class sdl_info13 : public osd_renderer
{ {
public: public:
sdl_info13(osd_window *w) sdl_info13(osd_window *w, int extra_flags)
: osd_renderer(w, FLAG_NONE), m_sdl_renderer(NULL), m_blittimer(0), : osd_renderer(w, extra_flags), m_sdl_renderer(NULL), m_blittimer(0),
m_last_hofs(0), m_last_vofs(0), m_last_hofs(0), m_last_vofs(0),
m_width(0), m_height(0), m_width(0), m_height(0),
m_blit_dim(0,0), m_blit_dim(0,0),
@ -242,7 +259,6 @@ static void drawsdl2_exit(void);
// STATIC VARIABLES // STATIC VARIABLES
//============================================================ //============================================================
#define SDL_TEXFORMAT_LAST SDL_TEXFORMAT_PALETTE16A
#define BM_ALL (-1) #define BM_ALL (-1)
//( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD) //( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD)
@ -329,7 +345,8 @@ static copy_info_t blit_info_default[] =
{ -1 }, { -1 },
}; };
static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1]; static copy_info_t *blit_info[SDL_TEXFORMAT_LAST+1] = { NULL };
static bool blit_info_initialized = false;
//============================================================ //============================================================
// INLINES // INLINES
@ -512,27 +529,33 @@ static void expand_copy_info(copy_info_t *list)
static osd_renderer *drawsdl2_create(osd_window *window) static osd_renderer *drawsdl2_create(osd_window *window)
{ {
return global_alloc(sdl_info13(window)); if (!blit_info_initialized)
{
/* On OSX, calling this from drawsdl2_init will
* prohibit fullscreen toggling. It is than not possible
* to toggle from fullscreen to window mode.
*/
expand_copy_info(blit_info_default);
blit_info_initialized = true;
}
return global_alloc(sdl_info13(window, osd_renderer::FLAG_NONE));
} }
// FIXME: machine only used to access options. // FIXME: machine only used to access options.
int drawsdl2_init(running_machine &machine, osd_draw_callbacks *callbacks) int drawsdl2_init(running_machine &machine, osd_draw_callbacks *callbacks)
{ {
const char *stemp;
// fill in the callbacks // fill in the callbacks
callbacks->exit = drawsdl2_exit; callbacks->exit = drawsdl2_exit;
callbacks->create = drawsdl2_create; 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");
expand_copy_info(blit_info_default);
#if USE_OPENGL #if USE_OPENGL
// Load the GL library now - else MT will fail // Load the GL library now - else MT will fail
stemp = downcast<sdl_options &>(machine.options()).gl_lib(); const char *stemp = downcast<sdl_options &>(machine.options()).gl_lib();
#else #else
stemp = NULL; const char *stemp = NULL;
#endif #endif
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0) if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0)
stemp = NULL; stemp = NULL;
@ -555,19 +578,23 @@ static void drawsdl2_exit(void)
{ {
int i; int i;
copy_info_t *bi, *freeme; copy_info_t *bi, *freeme;
for (i = 0; i <= SDL_TEXFORMAT_LAST; i++) if (blit_info_initialized)
{ {
for (bi = blit_info[i]; bi != NULL; ) for (i = 0; i <= SDL_TEXFORMAT_LAST; i++)
{ {
if (bi->pixel_count) for (bi = blit_info[i]; bi != NULL; )
osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, {
bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples, if (bi->pixel_count)
(int) bi->perf); osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname,
freeme = bi; bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples,
bi = bi->next; (int) bi->perf);
global_free(freeme); freeme = bi;
bi = bi->next;
global_free(freeme);
}
blit_info[i] = NULL;
} }
blit_info[i] = NULL; blit_info_initialized = false;
} }
} }
@ -601,6 +628,36 @@ static void drawsdl2_exit(void)
// a // a
//============================================================ //============================================================
static void drawsdl_show_info(struct SDL_RendererInfo *render_info)
{
#define RF_ENTRY(x) {x, #x }
static struct {
int flag;
const char *name;
} rflist[] =
{
#if 0
RF_ENTRY(SDL_RENDERER_SINGLEBUFFER),
RF_ENTRY(SDL_RENDERER_PRESENTCOPY),
RF_ENTRY(SDL_RENDERER_PRESENTFLIP2),
RF_ENTRY(SDL_RENDERER_PRESENTFLIP3),
RF_ENTRY(SDL_RENDERER_PRESENTDISCARD),
#endif
RF_ENTRY(SDL_RENDERER_SOFTWARE),
RF_ENTRY(SDL_RENDERER_PRESENTVSYNC),
RF_ENTRY(SDL_RENDERER_ACCELERATED),
RF_ENTRY(SDL_RENDERER_TARGETTEXTURE),
{-1, NULL}
};
int i;
osd_printf_verbose("window: using renderer %s\n", render_info->name ? render_info->name : "<unknown>");
for (i = 0; rflist[i].name != NULL; i++)
if (render_info->flags & rflist[i].flag)
osd_printf_verbose("renderer: flag %s\n", rflist[i].name);
}
int sdl_info13::create() int sdl_info13::create()
{ {
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
@ -633,9 +690,14 @@ int sdl_info13::create()
m_blittimer = 3; m_blittimer = 3;
SDL_RenderPresent(m_sdl_renderer); //SDL_RenderPresent(m_sdl_renderer);
osd_printf_verbose("Leave sdl_info13::create\n"); osd_printf_verbose("Leave sdl_info13::create\n");
struct SDL_RendererInfo render_info;
SDL_GetRendererInfo(m_sdl_renderer, &render_info);
drawsdl_show_info(&render_info);
#else #else
#endif #endif
@ -651,6 +713,7 @@ void sdl_info13::destroy()
{ {
destroy_all_textures(); destroy_all_textures();
SDL_DestroyRenderer(m_sdl_renderer); SDL_DestroyRenderer(m_sdl_renderer);
m_sdl_renderer = NULL;
} }
@ -1108,7 +1171,6 @@ texture_info * sdl_info13::texture_update(const render_primitive &prim)
texture = global_alloc(texture_info(this, prim.texture, setup, prim.flags)); texture = global_alloc(texture_info(this, prim.texture, setup, prim.flags));
/* add us to the texture list */ /* add us to the texture list */
m_texlist.prepend(*texture); m_texlist.prepend(*texture);
} }
if (texture != NULL) if (texture != NULL)

View File

@ -166,7 +166,6 @@ enum
// MACROS // MACROS
//============================================================ //============================================================
#ifdef OSD_WINDOWS
// texture formats // texture formats
// This used to be an enum, but these are now defines so we can use them as // This used to be an enum, but these are now defines so we can use them as
// preprocessor conditionals // preprocessor conditionals
@ -179,6 +178,7 @@ enum
#define SDL_TEXFORMAT_RGB15 (6) #define SDL_TEXFORMAT_RGB15 (6)
#define SDL_TEXFORMAT_RGB15_PALETTED (7) #define SDL_TEXFORMAT_RGB15_PALETTED (7)
#define SDL_TEXFORMAT_PALETTE16A (8) #define SDL_TEXFORMAT_PALETTE16A (8)
#if 0
// special texture formats for 16bpp texture destination support, do not use // special texture formats for 16bpp texture destination support, do not use
// to address the tex properties / tex functions arrays! // to address the tex properties / tex functions arrays!
#define SDL_TEXFORMAT_PALETTE16_ARGB1555 (16) #define SDL_TEXFORMAT_PALETTE16_ARGB1555 (16)

View File

@ -508,6 +508,7 @@ void sdl_info::destroy()
global_free_array(m_yuv_bitmap); global_free_array(m_yuv_bitmap);
m_yuv_bitmap = NULL; m_yuv_bitmap = NULL;
} }
SDL_DestroyRenderer(m_sdl_renderer);
} }
//============================================================ //============================================================

View File

@ -29,24 +29,6 @@ enum {
#define VIDEO_SCALE_MODE_NONE (0) #define VIDEO_SCALE_MODE_NONE (0)
// texture formats
// This used to be an enum, but these are now defines so we can use them as
// preprocessor conditionals
#define SDL_TEXFORMAT_ARGB32 (0) // non-16-bit textures or specials
#define SDL_TEXFORMAT_RGB32 (1)
#define SDL_TEXFORMAT_RGB32_PALETTED (2)
#define SDL_TEXFORMAT_YUY16 (3)
#define SDL_TEXFORMAT_YUY16_PALETTED (4)
#define SDL_TEXFORMAT_PALETTE16 (5)
#define SDL_TEXFORMAT_RGB15 (6)
#define SDL_TEXFORMAT_RGB15_PALETTED (7)
#define SDL_TEXFORMAT_PALETTE16A (8)
// special texture formats for 16bpp texture destination support, do not use
// to address the tex properties / tex functions arrays!
#define SDL_TEXFORMAT_PALETTE16_ARGB1555 (16)
#define SDL_TEXFORMAT_RGB15_ARGB1555 (17)
#define SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555 (18)
#define GLSL_SHADER_MAX 10 #define GLSL_SHADER_MAX 10
//============================================================ //============================================================