src/osd/sdl/scale2x.c
| r1896 | r1897 | |
| 1 | | #include "osdcomm.h" |
| 2 | | #include "mamecore.h" |
| 3 | | #include "window.h" |
| 4 | | #include "effect.h" |
| 5 | 1 | |
| 2 | #ifndef SDL_TEXFORMAT |
| 3 | |
| 6 | 4 | // 16 and 32 bpp versions of the core scale2x functions |
| 7 | 5 | // NOTE, advancemame has mmx asm versions of these, these could be easily |
| 8 | 6 | // integrated by someone interested, except for borderpix support. |
| 7 | |
| 8 | #ifdef FUNC_NAME |
| 9 | #undef FUNC_NAME |
| 10 | #endif |
| 11 | |
| 9 | 12 | #define DEST_TYPE UINT16 |
| 10 | 13 | #define FUNC_NAME(name) name ## _16bpp |
| 11 | 14 | #include "scale2x_core.c" |
| r1896 | r1897 | |
| 20 | 23 | #define EFFECT_DEST_NAME DEST_NAME(scaleXxX) |
| 21 | 24 | |
| 22 | 25 | #define SDL_TEXFORMAT SDL_TEXFORMAT_ARGB32 |
| 23 | | #include "effect_func.h" |
| 26 | #include "scale2x.c" |
| 24 | 27 | #undef SDL_TEXFORMAT |
| 25 | 28 | |
| 26 | 29 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32 |
| 27 | | #include "effect_func.h" |
| 30 | #include "scale2x.c" |
| 28 | 31 | #undef SDL_TEXFORMAT |
| 29 | 32 | |
| 30 | 33 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32_PALETTED |
| 31 | | #include "effect_func.h" |
| 34 | #include "scale2x.c" |
| 32 | 35 | #undef SDL_TEXFORMAT |
| 33 | 36 | |
| 34 | 37 | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16 |
| 35 | | #include "effect_func.h" |
| 38 | #include "scale2x.c" |
| 36 | 39 | #undef SDL_TEXFORMAT |
| 37 | 40 | |
| 38 | 41 | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16A |
| 39 | | #include "effect_func.h" |
| 42 | #include "scale2x.c" |
| 40 | 43 | #undef SDL_TEXFORMAT |
| 41 | 44 | |
| 42 | 45 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15 |
| 43 | | #include "effect_func.h" |
| 46 | #include "scale2x.c" |
| 44 | 47 | #undef SDL_TEXFORMAT |
| 45 | 48 | |
| 46 | 49 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED |
| 47 | | #include "effect_func.h" |
| 50 | #include "scale2x.c" |
| 48 | 51 | #undef SDL_TEXFORMAT |
| 49 | 52 | |
| 50 | 53 | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16_ARGB1555 |
| 51 | | #include "effect_func.h" |
| 54 | #include "scale2x.c" |
| 52 | 55 | #undef SDL_TEXFORMAT |
| 53 | 56 | |
| 54 | 57 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_ARGB1555 |
| 55 | | #include "effect_func.h" |
| 58 | #include "scale2x.c" |
| 56 | 59 | #undef SDL_TEXFORMAT |
| 57 | 60 | |
| 58 | 61 | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555 |
| 59 | | #include "effect_func.h" |
| 62 | #include "scale2x.c" |
| 60 | 63 | #undef SDL_TEXFORMAT |
| 61 | 64 | |
| 62 | 65 | #undef EFFECT_FUNC_NAME |
| r1896 | r1897 | |
| 69 | 72 | // |
| 70 | 73 | //============================================================ |
| 71 | 74 | |
| 72 | | void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource) |
| 75 | static void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource) |
| 73 | 76 | { |
| 74 | 77 | fatalerror("ERROR: Scale2X not supported for YUV textures\n"); |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | | void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource) |
| 80 | static void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource) |
| 78 | 81 | { |
| 79 | 82 | fatalerror("ERROR: Scale2X not supported for YUV textures\n"); |
| 80 | 83 | } |
| 84 | |
| 85 | #else // recursive include |
| 86 | |
| 87 | #include "texsrc.h" |
| 88 | |
| 89 | // texcopy function prototype |
| 90 | //void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texsource); |
| 91 | |
| 92 | static void EFFECT_FUNC_NAME(texture_info *texture, const render_texinfo *texsource) |
| 93 | { |
| 94 | int y; |
| 95 | DEST_TYPE *dst = (DEST_TYPE *)texture->data + texture->borderpix * texture->rawwidth; |
| 96 | TEXSRC_TYPE *src = (TEXSRC_TYPE *)texsource->base; |
| 97 | #ifndef SRC_EQUALS_DEST |
| 98 | int x; |
| 99 | DEST_TYPE *tmp, *effectbuf0, *effectbuf1, *effectbuf2; |
| 100 | #endif |
| 101 | |
| 102 | switch ((texture->xprescale << 8) | texture->yprescale) |
| 103 | { |
| 104 | case 0x0101: |
| 105 | case 0x0102: |
| 106 | case 0x0103: |
| 107 | case 0x0201: |
| 108 | case 0x0301: |
| 109 | FUNC_NAME(texcopy)(texture, texsource); |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | #ifndef SRC_EQUALS_DEST |
| 114 | // First convert to a temporary buffer so that we do not convert each |
| 115 | // pixel 4 times |
| 116 | effectbuf1 = (DEST_TYPE *)texture->effectbuf; |
| 117 | effectbuf2 = (DEST_TYPE *)texture->effectbuf + texsource->width; |
| 118 | effectbuf0 = (DEST_TYPE *)texture->effectbuf + 2 * texsource->width; |
| 119 | |
| 120 | tmp = effectbuf1; |
| 121 | for (x = 0; x < texsource->width; x++) |
| 122 | { |
| 123 | *tmp++ = TEXSRC_TO_DEST(*src); |
| 124 | src++; |
| 125 | } |
| 126 | |
| 127 | src = (TEXSRC_TYPE *)texsource->base + texsource->rowpixels; |
| 128 | tmp = effectbuf2; |
| 129 | for (x = 0; x < texsource->width; x++) |
| 130 | { |
| 131 | *tmp++ = TEXSRC_TO_DEST(*src); |
| 132 | src++; |
| 133 | } |
| 134 | EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf1, effectbuf2, texture, |
| 135 | texsource); |
| 136 | #else |
| 137 | EFFECT_DEST_NAME(&dst, src, src, src + texsource->rowpixels, |
| 138 | texture, texsource); |
| 139 | #endif |
| 140 | |
| 141 | // loop over Y |
| 142 | for (y = 1; y < (texsource->height-1); y++) |
| 143 | { |
| 144 | dst += texture->rawwidth; |
| 145 | #ifndef SRC_EQUALS_DEST |
| 146 | // First convert to a temporary buffer so that we do not |
| 147 | // convert each pixel 4 times |
| 148 | src = (TEXSRC_TYPE *)texsource->base + |
| 149 | (y + 1) * texsource->rowpixels; |
| 150 | tmp = effectbuf0; |
| 151 | effectbuf0 = effectbuf1; |
| 152 | effectbuf1 = effectbuf2; |
| 153 | effectbuf2 = tmp; |
| 154 | for (x = 0; x < texsource->width; x++) |
| 155 | { |
| 156 | *tmp++ = TEXSRC_TO_DEST(*src); |
| 157 | src++; |
| 158 | } |
| 159 | EFFECT_DEST_NAME(&dst, effectbuf0, effectbuf1, effectbuf2, texture, texsource); |
| 160 | #else |
| 161 | src += texsource->rowpixels; |
| 162 | EFFECT_DEST_NAME(&dst, src - texsource->rowpixels, src, |
| 163 | src + texsource->rowpixels, texture, texsource); |
| 164 | #endif |
| 165 | } |
| 166 | |
| 167 | // last line |
| 168 | dst += texture->rawwidth; |
| 169 | #ifndef SRC_EQUALS_DEST |
| 170 | EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf2, effectbuf2, texture, texsource); |
| 171 | #else |
| 172 | EFFECT_DEST_NAME(&dst, src, src + texsource->rowpixels, src + texsource->rowpixels, texture, texsource); |
| 173 | #endif |
| 174 | } |
| 175 | |
| 176 | #undef SDL_TEXFORMAT |
| 177 | |
| 178 | |
| 179 | #endif |
src/osd/sdl/drawogl.c
| r1896 | r1897 | |
| 121 | 121 | // OSD headers |
| 122 | 122 | #include "osdsdl.h" |
| 123 | 123 | #include "window.h" |
| 124 | | #include "effect.h" |
| 125 | 124 | |
| 126 | 125 | //============================================================ |
| 127 | 126 | // DEBUGGING |
| r1896 | r1897 | |
| 159 | 158 | return (HashT)texture->base ^ (flags & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | | INLINE void set_blendmode(sdl_info *sdl, int blendmode, texture_info *texture) |
| 161 | INLINE void set_blendmode(sdl_info *sdl, int blendmode) |
| 163 | 162 | { |
| 164 | 163 | // try to minimize texture state changes |
| 165 | 164 | if (blendmode != sdl->last_blendmode) |
| r1896 | r1897 | |
| 187 | 186 | } |
| 188 | 187 | } |
| 189 | 188 | |
| 189 | #if 0 |
| 190 | 190 | INLINE int better_mode(int width0, int height0, int width1, int height1, float desired_aspect) |
| 191 | 191 | { |
| 192 | 192 | float aspect0 = (float)width0 / (float)height0; |
| 193 | 193 | float aspect1 = (float)width1 / (float)height1; |
| 194 | 194 | return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1; |
| 195 | 195 | } |
| 196 | #endif |
| 196 | 197 | |
| 197 | 198 | INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr) |
| 198 | 199 | { |
| r1896 | r1897 | |
| 273 | 274 | |
| 274 | 275 | static int glsl_shader_feature = GLSL_SHADER_FEAT_PLAIN; |
| 275 | 276 | |
| 276 | | // texcopy functions |
| 277 | | void texcopy_argb32(texture_info *texture, const render_texinfo *texsource); |
| 278 | | void texcopy_rgb32(texture_info *texture, const render_texinfo *texsource); |
| 279 | | void texcopy_rgb32_paletted(texture_info *texture, const render_texinfo *texsource); |
| 280 | | void texcopy_palette16(texture_info *texture, const render_texinfo *texsource); |
| 281 | | void texcopy_palette16a(texture_info *texture, const render_texinfo *texsource); |
| 282 | | void texcopy_rgb15(texture_info *texture, const render_texinfo *texsource); |
| 283 | | void texcopy_rgb15_paletted(texture_info *texture, const render_texinfo *texsource); |
| 284 | | void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource); |
| 285 | | void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource); |
| 277 | //============================================================ |
| 278 | // TEXCOPY FUNCS |
| 279 | //============================================================ |
| 280 | |
| 281 | static void texcopy_argb32(texture_info *texture, const render_texinfo *texsource); |
| 282 | static void texcopy_rgb32(texture_info *texture, const render_texinfo *texsource); |
| 283 | static void texcopy_rgb32_paletted(texture_info *texture, const render_texinfo *texsource); |
| 284 | static void texcopy_palette16(texture_info *texture, const render_texinfo *texsource); |
| 285 | static void texcopy_palette16a(texture_info *texture, const render_texinfo *texsource); |
| 286 | static void texcopy_rgb15(texture_info *texture, const render_texinfo *texsource); |
| 287 | static void texcopy_rgb15_paletted(texture_info *texture, const render_texinfo *texsource); |
| 288 | static void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource); |
| 289 | static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource); |
| 286 | 290 | #ifdef SDLMAME_MACOSX |
| 287 | | void texcopy_yuv16_apple(texture_info *texture, const render_texinfo *texsource); |
| 288 | | void texcopy_yuv16_paletted_apple(texture_info *texture, const render_texinfo *texsource); |
| 291 | static void texcopy_yuv16_apple(texture_info *texture, const render_texinfo *texsource); |
| 292 | static void texcopy_yuv16_paletted_apple(texture_info *texture, const render_texinfo *texsource); |
| 289 | 293 | #endif |
| 290 | 294 | // 16 bpp destination texture texcopy functions |
| 291 | | void texcopy_palette16_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 292 | | void texcopy_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 293 | | void texcopy_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 295 | static void texcopy_palette16_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 296 | static void texcopy_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 297 | static void texcopy_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 294 | 298 | |
| 295 | | // textures |
| 299 | //============================================================ |
| 300 | // SCALE2x FUNCS |
| 301 | //============================================================ |
| 302 | |
| 303 | static void scale2x_argb32(texture_info *texture, const render_texinfo *texsource); |
| 304 | static void scale2x_rgb32(texture_info *texture, const render_texinfo *texsource); |
| 305 | static void scale2x_rgb32_paletted(texture_info *texture, const render_texinfo *texsource); |
| 306 | static void scale2x_palette16(texture_info *texture, const render_texinfo *texsource); |
| 307 | static void scale2x_palette16a(texture_info *texture, const render_texinfo *texsource); |
| 308 | static void scale2x_rgb15(texture_info *texture, const render_texinfo *texsource); |
| 309 | static void scale2x_rgb15_paletted(texture_info *texture, const render_texinfo *texsource); |
| 310 | static void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource); |
| 311 | static void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource); |
| 312 | static void scale2x_palette16_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 313 | static void scale2x_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 314 | static void scale2x_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource); |
| 315 | |
| 316 | //============================================================ |
| 317 | // Textures |
| 318 | //============================================================ |
| 319 | |
| 320 | static void texture_set_data(texture_info *texture, const render_texinfo *texsource); |
| 296 | 321 | static texture_info *texture_create(sdl_info *sdl, sdl_window_info *window, const render_texinfo *texsource, UINT32 flags); |
| 297 | | static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags); |
| 298 | 322 | static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim); |
| 299 | 323 | static texture_info * texture_update(sdl_info *sdl, sdl_window_info *window, const render_primitive *prim, int shaderIdx); |
| 300 | 324 | static void texture_all_disable(sdl_info *sdl); |
| 301 | 325 | static void texture_disable(sdl_info *sdl, texture_info * texture); |
| 302 | 326 | |
| 303 | 327 | //============================================================ |
| 304 | | // STATIC Variables |
| 328 | // STAgTIC Variables |
| 305 | 329 | //============================================================ |
| 306 | 330 | |
| 307 | 331 | static int shown_video_info = 0; |
| r1896 | r1897 | |
| 343 | 367 | */ |
| 344 | 368 | |
| 345 | 369 | #define OSD_GL(ret,func,params) \ |
| 346 | | if (!(func = SDL_GL_GetProcAddress( #func ) )) \ |
| 370 | if (!( func = (void *) SDL_GL_GetProcAddress( #func ) )) \ |
| 347 | 371 | { err++; mame_printf_error("GL function %s not found!\n", #func ); } |
| 348 | 372 | |
| 349 | 373 | #define OSD_GL_UNUSED(ret,func,params) |
| r1896 | r1897 | |
| 928 | 952 | blittimer = 2; |
| 929 | 953 | } |
| 930 | 954 | |
| 931 | | if ( !window->initialized || |
| 932 | | window->sdlsurf->w!= surf_w || window->sdlsurf->h!= surf_h |
| 933 | | ) |
| 934 | | { |
| 955 | if ( !window->initialized || |
| 956 | window->sdlsurf->w!= surf_w || window->sdlsurf->h!= surf_h ) |
| 957 | { |
| 935 | 958 | if ( !window->initialized ) |
| 936 | 959 | { |
| 937 | 960 | loadGLExtensions(sdl); |
| 938 | 961 | } |
| 962 | |
| 963 | surf_w=window->sdlsurf->w; |
| 964 | surf_h=window->sdlsurf->h; |
| 939 | 965 | |
| 940 | | surf_w=window->sdlsurf->w; |
| 941 | | surf_h=window->sdlsurf->h; |
| 966 | // we're doing nothing 3d, so the Z-buffer is currently not interesting |
| 967 | glDisable(GL_DEPTH_TEST); |
| 942 | 968 | |
| 943 | | // we're doing nothing 3d, so the Z-buffer is currently not interesting |
| 944 | | glDisable(GL_DEPTH_TEST); |
| 969 | if (options_get_bool(mame_options(), OPTION_ANTIALIAS)) |
| 970 | { |
| 971 | // enable antialiasing for lines |
| 972 | glEnable(GL_LINE_SMOOTH); |
| 973 | // enable antialiasing for points |
| 974 | glEnable(GL_POINT_SMOOTH); |
| 945 | 975 | |
| 946 | | if (options_get_bool(mame_options(), OPTION_ANTIALIAS)) |
| 947 | | { |
| 948 | | // enable antialiasing for lines |
| 949 | | glEnable(GL_LINE_SMOOTH); |
| 950 | | // enable antialiasing for points |
| 951 | | glEnable(GL_POINT_SMOOTH); |
| 952 | | |
| 953 | | // prefer quality to speed |
| 954 | | glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); |
| 955 | | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); |
| 956 | | } |
| 957 | | else |
| 958 | | { |
| 959 | | glDisable(GL_LINE_SMOOTH); |
| 960 | | glDisable(GL_POINT_SMOOTH); |
| 961 | | } |
| 962 | | |
| 963 | | // enable blending |
| 964 | | glEnable(GL_BLEND); |
| 965 | | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 966 | | sdl->last_blendmode = BLENDMODE_ALPHA; |
| 967 | | |
| 968 | | // set lines and points just barely above normal size to get proper results |
| 969 | | glLineWidth(video_config.beamwidth); |
| 970 | | glPointSize(video_config.beamwidth); |
| 971 | | |
| 972 | | // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like. |
| 973 | | // |
| 974 | | // (0,0) (w,0) |
| 975 | | // |~~~~~~~~~| |
| 976 | | // | | |
| 977 | | // | | |
| 978 | | // | | |
| 979 | | // |_________| |
| 980 | | // (0,h) (w,h) |
| 981 | | |
| 982 | | glViewport(0.0, 0.0, (GLsizei)window->sdlsurf->w, (GLsizei)window->sdlsurf->h); |
| 983 | | glMatrixMode(GL_PROJECTION); |
| 984 | | glLoadIdentity(); |
| 985 | | glOrtho(0.0, (GLdouble)window->sdlsurf->w, (GLdouble)window->sdlsurf->h, 0.0, 0.0, -1.0); |
| 976 | // prefer quality to speed |
| 977 | glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); |
| 978 | glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); |
| 979 | } |
| 980 | else |
| 981 | { |
| 982 | glDisable(GL_LINE_SMOOTH); |
| 983 | glDisable(GL_POINT_SMOOTH); |
| 984 | } |
| 985 | |
| 986 | // enable blending |
| 987 | glEnable(GL_BLEND); |
| 988 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 989 | sdl->last_blendmode = BLENDMODE_ALPHA; |
| 990 | |
| 991 | // set lines and points just barely above normal size to get proper results |
| 992 | glLineWidth(video_config.beamwidth); |
| 993 | glPointSize(video_config.beamwidth); |
| 994 | |
| 995 | // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like. |
| 996 | // |
| 997 | // (0,0) (w,0) |
| 998 | // |~~~~~~~~~| |
| 999 | // | | |
| 1000 | // | | |
| 1001 | // | | |
| 1002 | // |_________| |
| 1003 | // (0,h) (w,h) |
| 1004 | |
| 1005 | glViewport(0.0, 0.0, (GLsizei)window->sdlsurf->w, (GLsizei)window->sdlsurf->h); |
| 1006 | glMatrixMode(GL_PROJECTION); |
| 1007 | glLoadIdentity(); |
| 1008 | glOrtho(0.0, (GLdouble)window->sdlsurf->w, (GLdouble)window->sdlsurf->h, 0.0, 0.0, -1.0); |
| 986 | 1009 | glMatrixMode(GL_MODELVIEW); |
| 987 | | glLoadIdentity(); |
| 988 | | |
| 989 | | if ( ! window->initialized ) |
| 1010 | glLoadIdentity(); |
| 1011 | |
| 1012 | if ( ! window->initialized ) |
| 990 | 1013 | { |
| 991 | | glEnableClientState(GL_VERTEX_ARRAY); |
| 992 | | glVertexPointer(2, GL_FLOAT, 0, texVerticex); // no VBO, since it's too volatile |
| 993 | | |
| 1014 | glEnableClientState(GL_VERTEX_ARRAY); |
| 1015 | glVertexPointer(2, GL_FLOAT, 0, texVerticex); // no VBO, since it's too volatile |
| 1016 | |
| 994 | 1017 | window->initialized = 1; |
| 995 | | } |
| 996 | | } |
| 1018 | } |
| 1019 | } |
| 997 | 1020 | |
| 998 | 1021 | // compute centering parameters |
| 999 | 1022 | vofs = hofs = 0.0f; |
| r1896 | r1897 | |
| 1051 | 1074 | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1052 | 1075 | } |
| 1053 | 1076 | |
| 1054 | | if ( pendingPrimitive==GL_NO_PRIMITIVE ) |
| 1055 | | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags), 0); |
| 1077 | if ( pendingPrimitive==GL_NO_PRIMITIVE ) |
| 1078 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1056 | 1079 | |
| 1057 | 1080 | glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a); |
| 1058 | 1081 | |
| 1059 | | if(pendingPrimitive!=curPrimitive) |
| 1060 | | { |
| 1061 | | glBegin(curPrimitive); |
| 1062 | | pendingPrimitive=curPrimitive; |
| 1063 | | } |
| 1082 | if(pendingPrimitive!=curPrimitive) |
| 1083 | { |
| 1084 | glBegin(curPrimitive); |
| 1085 | pendingPrimitive=curPrimitive; |
| 1086 | } |
| 1064 | 1087 | |
| 1065 | 1088 | // check if it's really a point |
| 1066 | 1089 | if (curPrimitive==GL_POINTS) |
| 1067 | 1090 | { |
| 1068 | | glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs); |
| 1091 | glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs); |
| 1069 | 1092 | } |
| 1070 | 1093 | else |
| 1071 | 1094 | { |
| 1072 | | glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs); |
| 1073 | | glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs); |
| 1095 | glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs); |
| 1096 | glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs); |
| 1074 | 1097 | } |
| 1075 | 1098 | break; |
| 1076 | 1099 | |
| 1077 | 1100 | case RENDER_PRIMITIVE_QUAD: |
| 1078 | 1101 | |
| 1079 | | if(pendingPrimitive!=GL_NO_PRIMITIVE) |
| 1102 | if(pendingPrimitive!=GL_NO_PRIMITIVE) |
| 1080 | 1103 | { |
| 1081 | 1104 | glEnd(); |
| 1082 | 1105 | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1083 | 1106 | } |
| 1084 | 1107 | |
| 1085 | | glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a); |
| 1108 | glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a); |
| 1086 | 1109 | |
| 1087 | | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags), texture); |
| 1110 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1088 | 1111 | |
| 1089 | 1112 | texture = texture_update(sdl, window, prim, 0); |
| 1090 | 1113 | |
| r1896 | r1897 | |
| 1134 | 1157 | glDrawArrays(GL_QUADS, 0, 4); |
| 1135 | 1158 | } |
| 1136 | 1159 | |
| 1137 | | if ( texture ) |
| 1138 | | { |
| 1139 | | texture_disable(sdl, texture); |
| 1140 | | texture=NULL; |
| 1141 | | } |
| 1142 | | break; |
| 1160 | if ( texture ) |
| 1161 | { |
| 1162 | texture_disable(sdl, texture); |
| 1163 | texture=NULL; |
| 1164 | } |
| 1165 | break; |
| 1143 | 1166 | } |
| 1144 | 1167 | } |
| 1145 | 1168 | |
| 1146 | | if(pendingPrimitive!=GL_NO_PRIMITIVE) |
| 1147 | | { |
| 1148 | | glEnd(); |
| 1149 | | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1150 | | } |
| 1169 | if(pendingPrimitive!=GL_NO_PRIMITIVE) |
| 1170 | { |
| 1171 | glEnd(); |
| 1172 | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1173 | } |
| 1151 | 1174 | |
| 1152 | | |
| 1153 | 1175 | osd_lock_release(window->primlist->lock); |
| 1154 | 1176 | |
| 1155 | 1177 | SDL_GL_SwapBuffers(); |
| r1896 | r1897 | |
| 1603 | 1625 | return -1; |
| 1604 | 1626 | default: |
| 1605 | 1627 | mame_printf_error("GL FBO: incomplete, implementation ERROR\n"); |
| 1606 | | return -1; |
| 1628 | /* fall through */ |
| 1607 | 1629 | } |
| 1608 | 1630 | return -1; |
| 1609 | 1631 | } |
| r1896 | r1897 | |
| 2196 | 2218 | // texture_set_data |
| 2197 | 2219 | //============================================================ |
| 2198 | 2220 | |
| 2199 | | static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags) |
| 2221 | static void texture_set_data(texture_info *texture, const render_texinfo *texsource) |
| 2200 | 2222 | { |
| 2201 | 2223 | if ( texture->type == TEXTURE_TYPE_DYNAMIC ) |
| 2202 | 2224 | { |
| r1896 | r1897 | |
| 2204 | 2226 | assert(!texture->nocopy); |
| 2205 | 2227 | |
| 2206 | 2228 | texture->data = pfn_glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY); |
| 2207 | | } |
| 2229 | } |
| 2208 | 2230 | |
| 2209 | 2231 | // note that nocopy and borderpix are mutually exclusive, IOW |
| 2210 | 2232 | // they cannot be both true, thus this cannot lead to the |
| 2211 | | // borderpix code below writing to texsource->base . |
| 2212 | | if (texture->nocopy) |
| 2213 | | texture->data = texsource->base; |
| 2233 | // borderpix code below writing to texsource->base . |
| 2234 | if (texture->nocopy) |
| 2235 | texture->data = texsource->base; |
| 2214 | 2236 | |
| 2215 | 2237 | // always fill non-wrapping textures with an extra pixel on the top |
| 2216 | 2238 | if (texture->borderpix) |
| 2217 | | { |
| 2239 | { |
| 2218 | 2240 | memset(texture->data, 0, |
| 2219 | | (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2220 | | } |
| 2241 | (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); |
| 2242 | } |
| 2221 | 2243 | |
| 2222 | 2244 | // when nescesarry copy (and convert) the data |
| 2223 | 2245 | if (!texture->nocopy) |
| 2224 | | { |
| 2225 | | assert(texture->texCopyFn); |
| 2226 | | texture->texCopyFn(texture, texsource); |
| 2227 | | } |
| 2246 | { |
| 2247 | assert(texture->texCopyFn); |
| 2248 | texture->texCopyFn(texture, texsource); |
| 2249 | } |
| 2228 | 2250 | |
| 2229 | 2251 | // always fill non-wrapping textures with an extra pixel on the bottom |
| 2230 | 2252 | if (texture->borderpix) |
| r1896 | r1897 | |
| 2374 | 2396 | { |
| 2375 | 2397 | // 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) |
| 2376 | 2398 | // we must go CW here due to the mame bitmap order |
| 2377 | | texture->texCoord[0]=ustart + du * 0.0; |
| 2378 | | texture->texCoord[1]=vstart + dv * 1.0; |
| 2379 | | texture->texCoord[2]=ustart + du * 1.0; |
| 2380 | | texture->texCoord[3]=vstart + dv * 1.0; |
| 2381 | | texture->texCoord[4]=ustart + du * 1.0; |
| 2382 | | texture->texCoord[5]=vstart + dv * 0.0; |
| 2383 | | texture->texCoord[6]=ustart + du * 0.0; |
| 2384 | | texture->texCoord[7]=vstart + dv * 0.0; |
| 2399 | texture->texCoord[0]=ustart + du * 0.0f; |
| 2400 | texture->texCoord[1]=vstart + dv * 1.0f; |
| 2401 | texture->texCoord[2]=ustart + du * 1.0f; |
| 2402 | texture->texCoord[3]=vstart + dv * 1.0f; |
| 2403 | texture->texCoord[4]=ustart + du * 1.0f; |
| 2404 | texture->texCoord[5]=vstart + dv * 0.0f; |
| 2405 | texture->texCoord[6]=ustart + du * 0.0f; |
| 2406 | texture->texCoord[7]=vstart + dv * 0.0f; |
| 2385 | 2407 | } else { |
| 2386 | 2408 | // transformation: mamebm -> scrn |
| 2387 | 2409 | texture->texCoord[0]=ustart + du * prim->texcoords.tl.u; |
| r1896 | r1897 | |
| 2395 | 2417 | } |
| 2396 | 2418 | } |
| 2397 | 2419 | |
| 2398 | | static void texture_mpass_flip(sdl_info *sdl, sdl_window_info *window, texture_info *texture, int shaderIdx) |
| 2420 | static void texture_mpass_flip(sdl_info *sdl, texture_info *texture, int shaderIdx) |
| 2399 | 2421 | { |
| 2400 | 2422 | UINT32 mpass_src_idx = texture->mpass_dest_idx; |
| 2401 | 2423 | |
| r1896 | r1897 | |
| 2518 | 2540 | texture_shader_update(sdl, window, texture, shaderIdx); |
| 2519 | 2541 | if ( sdl->glsl_program_num>1 ) |
| 2520 | 2542 | { |
| 2521 | | texture_mpass_flip(sdl, window, texture, shaderIdx); |
| 2543 | texture_mpass_flip(sdl, texture, shaderIdx); |
| 2522 | 2544 | } |
| 2523 | 2545 | } |
| 2524 | 2546 | |
| r1896 | r1897 | |
| 2529 | 2551 | texture->texinfo.seqid = prim->texture.seqid; |
| 2530 | 2552 | |
| 2531 | 2553 | // if we found it, but with a different seqid, copy the data |
| 2532 | | texture_set_data(sdl, texture, &prim->texture, prim->flags); |
| 2554 | texture_set_data(texture, &prim->texture); |
| 2533 | 2555 | texBound=1; |
| 2534 | 2556 | } |
| 2535 | 2557 | } |
| r1896 | r1897 | |
| 2556 | 2578 | |
| 2557 | 2579 | static void texture_disable(sdl_info *sdl, texture_info * texture) |
| 2558 | 2580 | { |
| 2559 | | if ( texture->type == TEXTURE_TYPE_SHADER ) |
| 2560 | | { |
| 2561 | | assert ( sdl->useglsl ); |
| 2581 | if ( texture->type == TEXTURE_TYPE_SHADER ) |
| 2582 | { |
| 2583 | assert ( sdl->useglsl ); |
| 2562 | 2584 | pfn_glUseProgramObjectARB(0); // back to fixed function pipeline |
| 2563 | | } else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) |
| 2564 | | { |
| 2565 | | pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0); |
| 2566 | | glDisable(texture->texTarget); |
| 2567 | | } else { |
| 2568 | | glDisable(texture->texTarget); |
| 2569 | | } |
| 2585 | } else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) |
| 2586 | { |
| 2587 | pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0); |
| 2588 | glDisable(texture->texTarget); |
| 2589 | } else { |
| 2590 | glDisable(texture->texTarget); |
| 2591 | } |
| 2570 | 2592 | } |
| 2571 | 2593 | |
| 2572 | 2594 | static void texture_all_disable(sdl_info *sdl) |
| r1896 | r1897 | |
| 2698 | 2720 | // TEXCOPY FUNCS |
| 2699 | 2721 | //============================================================ |
| 2700 | 2722 | |
| 2701 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_ARGB32 |
| 2702 | 2723 | #include "texcopy.c" |
| 2703 | 2724 | |
| 2704 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32 |
| 2705 | | #include "texcopy.c" |
| 2706 | | |
| 2707 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32_PALETTED |
| 2708 | | #include "texcopy.c" |
| 2709 | | |
| 2710 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16 |
| 2711 | | #include "texcopy.c" |
| 2712 | | |
| 2713 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16A |
| 2714 | | #include "texcopy.c" |
| 2715 | | |
| 2716 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15 |
| 2717 | | #include "texcopy.c" |
| 2718 | | |
| 2719 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED |
| 2720 | | #include "texcopy.c" |
| 2721 | | |
| 2722 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16_ARGB1555 |
| 2723 | | #include "texcopy.c" |
| 2724 | | |
| 2725 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_ARGB1555 |
| 2726 | | #include "texcopy.c" |
| 2727 | | |
| 2728 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555 |
| 2729 | | #include "texcopy.c" |
| 2730 | | |
| 2731 | | #ifdef SDLMAME_MACOSX /* native MacOS X composite texture format */ |
| 2732 | | |
| 2733 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16 |
| 2734 | | #include "texcopy.c" |
| 2735 | | |
| 2736 | | #define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16_PALETTED |
| 2737 | | #include "texcopy.c" |
| 2738 | | |
| 2739 | | #endif |
| 2740 | | |
| 2741 | 2725 | //============================================================ |
| 2742 | | // MANUAL TEXCOPY FUNCS |
| 2743 | | // (YUY format is weird and doesn't fit the assumptions of the |
| 2744 | | // standard macros so we handle it here |
| 2726 | // SCALE2x FUNCS |
| 2745 | 2727 | //============================================================ |
| 2746 | 2728 | |
| 2747 | | void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource) |
| 2748 | | { |
| 2749 | | int x, y; |
| 2750 | | UINT32 *dst; |
| 2751 | | UINT16 *src; |
| 2752 | | |
| 2753 | | // loop over Y |
| 2754 | | for (y = 0; y < texsource->height; y++) |
| 2755 | | { |
| 2756 | | src = (UINT16 *)texsource->base + y * texsource->rowpixels; |
| 2757 | | dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth; |
| 2758 | | |
| 2759 | | // always fill non-wrapping textures with an extra pixel on the left |
| 2760 | | if (texture->borderpix) |
| 2761 | | *dst++ = 0; |
| 2762 | | |
| 2763 | | // we don't support prescale for YUV textures |
| 2764 | | for (x = 0; x < texsource->width/2; x++) |
| 2765 | | { |
| 2766 | | UINT16 srcpix0 = *src++; |
| 2767 | | UINT16 srcpix1 = *src++; |
| 2768 | | UINT8 cb = srcpix0 & 0xff; |
| 2769 | | UINT8 cr = srcpix1 & 0xff; |
| 2770 | | |
| 2771 | | *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr); |
| 2772 | | *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr); |
| 2773 | | } |
| 2774 | | break; |
| 2775 | | |
| 2776 | | // always fill non-wrapping textures with an extra pixel on the right |
| 2777 | | #if 0 |
| 2778 | | if (texture->borderpix) |
| 2779 | | *dst++ = 0; |
| 2780 | | #endif |
| 2781 | | } |
| 2782 | | } |
| 2783 | | |
| 2784 | | void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource) |
| 2785 | | { |
| 2786 | | int x, y; |
| 2787 | | UINT32 *dst; |
| 2788 | | UINT16 *src; |
| 2789 | | |
| 2790 | | // loop over Y |
| 2791 | | for (y = 0; y < texsource->height; y++) |
| 2792 | | { |
| 2793 | | src = (UINT16 *)texsource->base + y * texsource->rowpixels; |
| 2794 | | dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth; |
| 2795 | | |
| 2796 | | // always fill non-wrapping textures with an extra pixel on the left |
| 2797 | | if (texture->borderpix) |
| 2798 | | *dst++ = 0; |
| 2799 | | |
| 2800 | | // we don't support prescale for YUV textures |
| 2801 | | for (x = 0; x < texsource->width/2; x++) |
| 2802 | | { |
| 2803 | | UINT16 srcpix0 = *src++; |
| 2804 | | UINT16 srcpix1 = *src++; |
| 2805 | | UINT8 cb = srcpix0 & 0xff; |
| 2806 | | UINT8 cr = srcpix1 & 0xff; |
| 2807 | | |
| 2808 | | *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix0 >> 8)], cb, cr); |
| 2809 | | *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix1 >> 8)], cb, cr); |
| 2810 | | } |
| 2811 | | break; |
| 2812 | | |
| 2813 | | // always fill non-wrapping textures with an extra pixel on the right |
| 2814 | | #if 0 |
| 2815 | | if (texture->borderpix) |
| 2816 | | *dst++ = 0; |
| 2817 | | #endif |
| 2818 | | } |
| 2819 | | } |
| 2820 | | |
| 2729 | #include "scale2x.c" |
src/osd/sdl/window.c
| r1896 | r1897 | |
| 22 | 22 | #include <sys/time.h> |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | | #include "osd_opengl.h" |
| 26 | | |
| 27 | 25 | // standard C headers |
| 28 | 26 | #include <math.h> |
| 29 | 27 | #include <unistd.h> |
| r1896 | r1897 | |
| 32 | 30 | |
| 33 | 31 | #include "osdcomm.h" |
| 34 | 32 | #include "osdepend.h" |
| 35 | | //#include "driver.h" |
| 33 | #include "options.h" |
| 34 | #include "ui.h" |
| 36 | 35 | |
| 37 | 36 | // OSD headers |
| 38 | 37 | |
| 39 | 38 | #include "window.h" |
| 40 | | #include "video.h" |
| 41 | 39 | #include "input.h" |
| 42 | | #include "options.h" |
| 43 | | #include "ui.h" |
| 44 | 40 | #include "osdsdl.h" |
| 45 | 41 | |
| 46 | 42 | #ifdef MESS |
| r1896 | r1897 | |
| 58 | 54 | #define ASSERT_USE(x) assert(SDL_ThreadID() == x) |
| 59 | 55 | #endif |
| 60 | 56 | |
| 61 | | #define ASSERT_REDRAW_THREAD() ASSERT_USE(window_threadid) |
| 62 | | #define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid) |
| 63 | | #define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid) |
| 57 | #define ASSERT_REDRAW_THREAD() ASSERT_USE(window_threadid) |
| 58 | #define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid) |
| 59 | #define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid) |
| 64 | 60 | |
| 61 | #define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid) |
| 62 | |
| 65 | 63 | // minimum window dimension |
| 66 | 64 | #define MIN_WINDOW_DIM 200 |
| 67 | 65 | |
| r1896 | r1897 | |
| 97 | 95 | static int window_threadid; |
| 98 | 96 | static int dll_loaded; |
| 99 | 97 | |
| 100 | | |
| 101 | | static UINT32 last_update_time; |
| 102 | | |
| 103 | 98 | static const char *yuv_mode_names[] = { "none", "yv12", "yv12x2", "yuy2", "yuy2x2" }; |
| 104 | 99 | |
| 105 | 100 | // debugger |
| 106 | 101 | //static int in_background; |
| 107 | 102 | |
| 108 | | //static int ui_temp_pause; |
| 109 | | //static int ui_temp_was_paused; |
| 110 | | |
| 111 | | //static UINT32 last_update_time; |
| 112 | | |
| 113 | 103 | static sdl_draw_callbacks draw; |
| 114 | 104 | |
| 115 | 105 | typedef struct _worker_param worker_param; |
| r1896 | r1897 | |
| 128 | 118 | |
| 129 | 119 | static void sdlwindow_exit(running_machine *machine); |
| 130 | 120 | static void sdlwindow_video_window_destroy(sdl_window_info *window); |
| 131 | | static void *draw_video_contents_wt(void *param, int threadid); |
| 132 | | static void *sdlwindow_video_window_destroy_wt(void *param, int threadid); |
| 133 | | static void *sdlwindow_resize_wt(void *param, int threadid); |
| 134 | | static void *sdlwindow_toggle_full_screen_wt(void *param, int threadid); |
| 121 | static OSDWORK_CALLBACK( draw_video_contents_wt ); |
| 122 | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ); |
| 123 | static OSDWORK_CALLBACK( sdlwindow_resize_wt ); |
| 124 | static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ); |
| 135 | 125 | static void sdlwindow_clear_surface(sdl_window_info *window, int times); |
| 136 | 126 | static void sdlwindow_update_cursor_state(void); |
| 137 | 127 | static void sdlwindow_sync(void); |
| r1896 | r1897 | |
| 190 | 180 | // (window thread) |
| 191 | 181 | //============================================================ |
| 192 | 182 | |
| 193 | | static void *sdlwindow_thread_id(void *param, int threadid) |
| 183 | static OSDWORK_CALLBACK(sdlwindow_thread_id) |
| 194 | 184 | { |
| 195 | 185 | window_threadid = SDL_ThreadID(); |
| 196 | 186 | |
| r1896 | r1897 | |
| 279 | 269 | //============================================================ |
| 280 | 270 | |
| 281 | 271 | #ifdef SDLMAME_WIN32 |
| 282 | | static void *sdlwindow_exit_wt(void *param, int threadid) |
| 272 | static OSDWORK_CALLBACK( sdlwindow_exit_wt ) |
| 283 | 273 | { |
| 284 | 274 | SDL_Quit(); |
| 285 | 275 | return NULL; |
| r1896 | r1897 | |
| 473 | 463 | // (main thread) |
| 474 | 464 | //============================================================ |
| 475 | 465 | |
| 476 | | static void *sdlwindow_resize_wt(void *param, int threadid) |
| 466 | static OSDWORK_CALLBACK( sdlwindow_resize_wt ) |
| 477 | 467 | { |
| 478 | 468 | sdl_window_info *window = sdl_window_list; |
| 479 | 469 | worker_param *wp = (worker_param *) param; |
| r1896 | r1897 | |
| 525 | 515 | // (window thread) |
| 526 | 516 | //============================================================ |
| 527 | 517 | |
| 528 | | static void *sdlwindow_clear_surface_wt(void *param, int threadid) |
| 518 | static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt ) |
| 529 | 519 | { |
| 530 | 520 | worker_param *wp = (worker_param *) param; |
| 531 | 521 | //sdl_window_info *window = sdl_window_list; |
| r1896 | r1897 | |
| 570 | 560 | // (main thread) |
| 571 | 561 | //============================================================ |
| 572 | 562 | |
| 573 | | static void *sdlwindow_toggle_full_screen_wt(void *param, int threadid) |
| 563 | static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) |
| 574 | 564 | { |
| 575 | 565 | worker_param *wp = (worker_param *) param; |
| 576 | 566 | sdl_window_info *window = wp->window; |
| r1896 | r1897 | |
| 642 | 632 | } |
| 643 | 633 | } |
| 644 | 634 | |
| 645 | | static void *destroy_all_textures_wt(void *param, int threadid) |
| 635 | static OSDWORK_CALLBACK( destroy_all_textures_wt ) |
| 646 | 636 | { |
| 647 | 637 | worker_param *wp = (worker_param *) param; |
| 648 | 638 | |
| r1896 | r1897 | |
| 710 | 700 | if (new_prescale_effect != video_config.prescale_effect) |
| 711 | 701 | { |
| 712 | 702 | worker_param wp; |
| 713 | | sdl_window_info *window = sdl_window_list; |
| 714 | 703 | |
| 715 | 704 | clear_worker_param(&wp); |
| 716 | 705 | wp.window = window; |
| r1896 | r1897 | |
| 874 | 863 | // (main thread) |
| 875 | 864 | //============================================================ |
| 876 | 865 | |
| 877 | | static void *sdlwindow_video_window_destroy_wt(void *param, int threadid) |
| 866 | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ) |
| 878 | 867 | { |
| 879 | 868 | worker_param *wp = (worker_param *) param; |
| 880 | 869 | sdl_window_info *window = wp->window; |
| r1896 | r1897 | |
| 975 | 964 | for (i = 0; modes[i]; ++i) |
| 976 | 965 | { |
| 977 | 966 | // compute initial score based on difference between target and current |
| 978 | | size_score = 1.0f / (1.0f + fabs((INT32)modes[i]->w - target_width) + fabs((INT32)modes[i]->h - target_height)); |
| 967 | size_score = 1.0f / (1.0f + fabsf((INT32)modes[i]->w - target_width) + fabsf((INT32)modes[i]->h - target_height)); |
| 979 | 968 | |
| 980 | 969 | // if the mode is too small, give a big penalty |
| 981 | 970 | if (modes[i]->w < minimum_width || modes[i]->h < minimum_height) |
| r1896 | r1897 | |
| 1055 | 1044 | // while rendering is still in progress is all fine .. |
| 1056 | 1045 | #if 0 |
| 1057 | 1046 | // only block if we're throttled |
| 1058 | | if (video_config.throttle) // || timeGetTime() - last_update_time > 250) |
| 1047 | if (video_config.throttle) |
| 1059 | 1048 | osd_lock_acquire(window->render_lock); |
| 1060 | 1049 | else |
| 1061 | 1050 | #endif |
| r1896 | r1897 | |
| 1076 | 1065 | primlist = (*draw.window_get_primitives)(window); |
| 1077 | 1066 | |
| 1078 | 1067 | // and redraw now |
| 1079 | | last_update_time = SDL_GetTicks(); |
| 1068 | |
| 1080 | 1069 | wp.list = primlist; |
| 1081 | 1070 | wp.window = window; |
| 1082 | 1071 | |
| r1896 | r1897 | |
| 1175 | 1164 | // (window thread) |
| 1176 | 1165 | //============================================================ |
| 1177 | 1166 | |
| 1178 | | static void *complete_create_wt(void *param, int threadid) |
| 1167 | static OSDWORK_CALLBACK( complete_create_wt ) |
| 1179 | 1168 | { |
| 1180 | 1169 | |
| 1181 | 1170 | worker_param *wp = (worker_param *) param; |
| r1896 | r1897 | |
| 1323 | 1312 | } |
| 1324 | 1313 | #endif |
| 1325 | 1314 | |
| 1326 | | static void *draw_video_contents_wt(void * param, int threadid) |
| 1315 | static OSDWORK_CALLBACK( draw_video_contents_wt ) |
| 1327 | 1316 | { |
| 1328 | 1317 | #ifndef SDLMAME_WIN32 |
| 1329 | 1318 | const unsigned long frames_skip4fps = 100; |