From fb0d7484bc2cf50cd4bda768fd00fd5d1ca60ab3 Mon Sep 17 00:00:00 2001 From: Couriersud Date: Sat, 12 Feb 2011 13:36:42 +0000 Subject: [PATCH] osd/sdl again compiles against latest SVN 1.3. SDL 1.3 still is WIP so expect more changes. No whatsnew. --- src/osd/sdl/draw13.c | 68 +++++++++++++++++++++------------------- src/osd/sdl/drawsdl.c | 42 +++++++++++++++---------- src/osd/sdl/sdlos_unix.c | 4 +-- src/osd/sdl/window.h | 1 + 4 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index a3ce7d25009..be73eeb742b 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -105,7 +105,7 @@ struct _texture_info int pitch; int pixels_own; // do we own / allocated it ? - SDL_TextureID texture_id; + SDL_Texture *texture_id; copy_info *copyinfo; Uint32 sdl_access; @@ -123,6 +123,7 @@ struct _sdl_info INT32 blittimer; UINT32 extra_flags; + SDL_Renderer *sdl_renderer; texture_info * texlist; // list of active textures INT32 texture_max_width; // texture maximum width INT32 texture_max_height; // texture maximum height @@ -328,7 +329,7 @@ INLINE SDL_BlendMode map_blendmode(int blendmode) return SDL_BLENDMODE_NONE; } -INLINE void set_coloralphamode(SDL_TextureID texture_id, const render_color *color) +INLINE void set_coloralphamode(SDL_Texture *texture_id, const render_color *color) { UINT32 sr = (UINT32)(255.0f * color->r); UINT32 sg = (UINT32)(255.0f * color->g); @@ -362,7 +363,7 @@ INLINE void set_coloralphamode(SDL_TextureID texture_id, const render_color *col INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive *prim, int x, int y) { - SDL_TextureID texture_id; + SDL_Texture *texture_id; SDL_Rect target_rect; target_rect.x = x; @@ -375,6 +376,7 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive * texture_id = texture->texture_id; texture->copyinfo->time -= osd_ticks(); +#if 0 if ((PRIMFLAG_GET_SCREENTEX(prim->flags)) && video_config.filter) { SDL_SetTextureScaleMode(texture->texture_id, SDL_SCALEMODE_BEST); @@ -383,9 +385,10 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive * { SDL_SetTextureScaleMode(texture->texture_id, SDL_SCALEMODE_NONE); } +#endif SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode); set_coloralphamode(texture_id, &prim->color); - SDL_RenderCopy(texture_id, NULL, &target_rect); + SDL_RenderCopy(sdl->sdl_renderer, texture_id, NULL, &target_rect); texture->copyinfo->time += osd_ticks(); texture->copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->rawwidth * texture->rawheight)); @@ -403,9 +406,9 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive * UINT32 sb = (UINT32)(255.0f * prim->color.b); UINT32 sa = (UINT32)(255.0f * prim->color.a); - SDL_SetRenderDrawBlendMode(map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); - SDL_SetRenderDrawColor(sr, sg, sb, sa); - SDL_RenderFillRect(&target_rect); + SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); + SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa); + SDL_RenderFillRect(sdl->sdl_renderer, &target_rect); } } @@ -426,10 +429,10 @@ static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sfor return 0; } #else -static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat) +static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32 access, const char *sformat) { int i; - SDL_TextureID texid; + SDL_Texture *texid; for (i=0; fmt_support[i].format != 0; i++) { if (format == fmt_support[i].format) @@ -440,7 +443,7 @@ static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sfor /* not tested yet */ fmt_support[i].format = format; fmt_support[i + 1].format = 0; - texid = SDL_CreateTexture(format, access, 16, 16); + texid = SDL_CreateTexture(renderer, format, access, 16, 16); if (texid) { fmt_support[i].status = 1; @@ -503,7 +506,7 @@ int draw13_init(running_machine &machine, sdl_draw_info *callbacks) // Load the GL library now - else MT will fail - stemp = options_get_string(machine.options(), SDLOPTION_GL_LIB); + stemp = options_get_string(&machine.options(), SDLOPTION_GL_LIB); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0) stemp = NULL; @@ -563,7 +566,6 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) { // allocate memory for our structures sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl)); - int result; mame_printf_verbose("Enter draw13_window_create\n"); @@ -572,7 +574,7 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) window->dxdata = sdl; sdl->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); // create the SDL window SDL_SelectVideoDisplay(window->monitor->handle); @@ -616,16 +618,16 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) // create renderer if (video_config.waitvsync) - result = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC); + sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | */SDL_RENDERER_PRESENTVSYNC); else - result = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD); + sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0); - if (result) + if (!sdl->sdl_renderer) { fatalerror("Error on creating renderer: %s \n", SDL_GetError()); } - SDL_SelectRenderer(window->sdl_window); + //SDL_SelectRenderer(window->sdl_window); SDL_ShowWindow(window->sdl_window); //SDL_SetWindowFullscreen(window->window_id, window->fullscreen); @@ -640,7 +642,7 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) sdl->texture_max_width = 64; sdl->texture_max_height = 64; - SDL_RenderPresent(); + SDL_RenderPresent(sdl->sdl_renderer); mame_printf_verbose("Leave draw13_window_create\n"); return 0; } @@ -723,15 +725,15 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->resize_pending = 0; } - SDL_SelectRenderer(window->sdl_window); + //SDL_SelectRenderer(window->sdl_window); if (sdl->blittimer > 0) { /* SDL Underlays need alpha = 0 ! */ - SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE); + SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, SDL_BLENDMODE_NONE); //SDL_SetRenderDrawColor(0,0,0,255); - SDL_SetRenderDrawColor(0,0,0,0); - SDL_RenderFillRect(NULL); + SDL_SetRenderDrawColor(sdl->sdl_renderer, 0,0,0,0); + SDL_RenderFillRect(sdl->sdl_renderer, NULL); sdl->blittimer--; } @@ -781,9 +783,9 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) sb = (int)(255.0f * prim->color.b); sa = (int)(255.0f * prim->color.a); - SDL_SetRenderDrawBlendMode(map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); - SDL_SetRenderDrawColor(sr, sg, sb, sa); - SDL_RenderDrawLine(prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, + SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags))); + SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa); + SDL_RenderDrawLine(sdl->sdl_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs, prim->bounds.x1 + hofs, prim->bounds.y1 + vofs); break; case render_primitive::QUAD: @@ -803,7 +805,7 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->last_blit_pixels = blit_pixels; sdl->last_blit_time = -osd_ticks(); - SDL_RenderPresent(); + SDL_RenderPresent(sdl->sdl_renderer); sdl->last_blit_time += osd_ticks(); return 0; @@ -852,7 +854,7 @@ static void draw13_window_destroy(sdl_window_info *window) // texture_compute_size and type //============================================================ -static copy_info *texture_compute_size_type(const render_texinfo *texsource, texture_info *texture, UINT32 flags) +static copy_info *texture_compute_size_type(SDL_Renderer *renderer, const render_texinfo *texsource, texture_info *texture, UINT32 flags) { copy_info *bi; copy_info *result = NULL; @@ -864,7 +866,7 @@ static copy_info *texture_compute_size_type(const render_texinfo *texsource, tex if ((texture->is_rotated == bi->rotate) && (texture->sdl_blendmode == bi->bm_mask)) { - if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) + if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname)) { if (bi->perf == 0) return bi; @@ -883,7 +885,7 @@ static copy_info *texture_compute_size_type(const render_texinfo *texsource, tex { if ((texture->is_rotated == bi->rotate) && (texture->sdl_blendmode == bi->bm_mask)) - if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) + if (RendererSupportsFormat(renderer, bi->dst_fmt, texture->sdl_access, bi->dstname)) return bi; } //FIXME: crash implement a -do nothing handler */ @@ -953,9 +955,9 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf mame_printf_warning("Trying to create texture with zero dim\n"); // compute the size - texture->copyinfo = texture_compute_size_type(texsource, texture, flags); + texture->copyinfo = texture_compute_size_type(sdl->sdl_renderer, texsource, texture, flags); - texture->texture_id = SDL_CreateTexture(texture->copyinfo->dst_fmt, texture->sdl_access, + texture->texture_id = SDL_CreateTexture(sdl->sdl_renderer, texture->copyinfo->dst_fmt, texture->sdl_access, texture->setup.rotwidth, texture->setup.rotheight); if (!texture->texture_id) @@ -999,7 +1001,7 @@ static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_ } else { - SDL_LockTexture(texture->texture_id, NULL, 1, (void **) &texture->pixels, &texture->pitch); + SDL_LockTexture(texture->texture_id, NULL, (void **) &texture->pixels, &texture->pitch); if ( texture->copyinfo->func ) texture->copyinfo->func(texture, texsource); else @@ -1091,7 +1093,7 @@ static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim, q /* would we choose another blitter ? */ if ((texture->copyinfo->samples & 0x1f) == 0x1f) { - if (texture->copyinfo != texture_compute_size_type(&texture->texinfo, texture, prim->flags)) + if (texture->copyinfo != texture_compute_size_type(sdl->sdl_renderer, &texture->texinfo, texture, prim->flags)) return NULL; #if 0 else diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c index 7cc5f1b5511..fdb600360e9 100644 --- a/src/osd/sdl/drawsdl.c +++ b/src/osd/sdl/drawsdl.c @@ -38,6 +38,13 @@ typedef struct _sdl_scale_mode sdl_scale_mode; +// FIXME: Only until there is a final decision from SAM on scalemodes +#if (SDL_VERSION_ATLEAST(1,3,0)) +#define SDL_SCALEMODE_NONE (0) +#define SDL_SCALEMODE_FAST (0) +#define SDL_SCALEMODE_BEST (0) +#endif + /* sdl_info is the information about SDL for the current screen */ typedef struct _sdl_info sdl_info; struct _sdl_info @@ -46,7 +53,7 @@ struct _sdl_info UINT32 extra_flags; #if (SDL_VERSION_ATLEAST(1,3,0)) - SDL_TextureID texture_id; + SDL_Texture *texture_id; #else // SDL surface SDL_Surface *sdlsurf; @@ -82,7 +89,8 @@ struct _sdl_scale_mode #if (!SDL_VERSION_ATLEAST(1,3,0)) int extra_flags; /* Texture/surface flags */ #else - SDL_ScaleMode sdl_scale_mode; /* sdl 1.3 scale mode */ + //SDL_ScaleMode sdl_scale_mode; /* sdl 1.3 scale mode */ + int sdl_scale_mode; /* got removed recently - trying to get it in again */ #endif int pixel_format; /* Pixel/Overlay format */ void (*yuv_blit)(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch); @@ -283,16 +291,16 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight int w = sdl->hw_scale_width * sdl_sm->mult_w; int h = sdl->hw_scale_height * sdl_sm->mult_h; - sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, w, h); + sdl->texture_id = SDL_CreateTexture(window->sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h); } else { - sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, + sdl->texture_id = SDL_CreateTexture(window->sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING, tempwidth, tempheight); } - SDL_SetTextureScaleMode(sdl->texture_id, sdl_sm->sdl_scale_mode); + //SDL_SetTextureScaleMode(window->sdl_renderer,sdl->texture_id, sdl_sm->sdl_scale_mode); } #endif @@ -365,11 +373,13 @@ static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo * 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_PRESENTVSYNC), RF_ENTRY(SDL_RENDERER_ACCELERATED), {-1, NULL} @@ -434,15 +444,15 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) // create a texture if (video_config.waitvsync) - SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC); + window->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC); else - SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD); + window->sdl_renderer = SDL_CreateRenderer(window->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; - SDL_GetRendererInfo(&render_info); + SDL_GetRendererInfo(window->sdl_renderer, &render_info); drawsdl_show_info(window, &render_info); @@ -543,7 +553,7 @@ static void drawsdl_window_destroy(sdl_window_info *window) return; #if (SDL_VERSION_ATLEAST(1,3,0)) - SDL_SelectRenderer(window->sdl_window); + //SDL_SelectRenderer(window->sdl_window); SDL_DestroyTexture(sdl->texture_id); //SDL_DestroyRenderer(window->sdl_window); SDL_DestroyWindow(window->sdl_window); @@ -696,7 +706,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) else surfptr = (UINT8 *)sdl->sdlsurf->pixels; #else - SDL_SelectRenderer(window->sdl_window); + //SDL_SelectRenderer(window->sdl_window); if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight) { @@ -720,13 +730,13 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) if (sdl->blittimer > 0) { /* SDL Underlays need alpha = 0 ! */ - SDL_SetRenderDrawColor(0,0,0,0); - SDL_RenderFillRect(NULL); + SDL_SetRenderDrawColor(window->sdl_renderer,0,0,0,0); + SDL_RenderFillRect(window->sdl_renderer,NULL); //SDL_RenderFill(0,0,0,0 /*255*/,NULL); sdl->blittimer--; } - SDL_LockTexture(sdl->texture_id, NULL, 1, (void **) &surfptr, &pitch); + SDL_LockTexture(sdl->texture_id, NULL, (void **) &surfptr, &pitch); #endif // get ready to center the image @@ -856,8 +866,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) r.h=blitheight; //printf("blitwidth %d %d - %d %d\n", blitwidth, blitheight, window->width, window->height); //SDL_UpdateTexture(sdl->sdltex, NULL, sdl->sdlsurf->pixels, pitch); - SDL_RenderCopy(sdl->texture_id, NULL, &r); - SDL_RenderPresent(); + SDL_RenderCopy(window->sdl_renderer,sdl->texture_id, NULL, &r); + SDL_RenderPresent(window->sdl_renderer); } #endif return 0; diff --git a/src/osd/sdl/sdlos_unix.c b/src/osd/sdl/sdlos_unix.c index c5a30e3a260..6d2d92032e5 100644 --- a/src/osd/sdl/sdlos_unix.c +++ b/src/osd/sdl/sdlos_unix.c @@ -154,9 +154,9 @@ char *osd_get_clipboard_text(void) if ( info.subsystem != SDL_SYSWM_X11 ) return NULL; #if (SDL_VERSION_ATLEAST(1,3,0)) - if ( (display = info.x11.display) == NULL ) + if ( (display = info.info.x11.display) == NULL ) return NULL; - if ( (our_win = info.x11.window) == None ) + if ( (our_win = info.info.x11.window) == None ) return NULL; #else if ( (display = info.info.x11.display) == NULL ) diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index 683432a230c..80a4b21a2af 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -96,6 +96,7 @@ struct _sdl_window_info #if (SDL_VERSION_ATLEAST(1,3,0)) // Needs to be here as well so we can identify window SDL_Window *sdl_window; + SDL_Renderer *sdl_renderer; // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE int resize_width; int resize_height;