trunk/src/osd/sdl/blit13.h
| r243235 | r243236 | |
| 51 | 51 | //============================================================ |
| 52 | 52 | |
| 53 | 53 | |
| 54 | | #define FUNC_DEF(source) op(const source &src, const rgb_t *palbase) |
| 54 | #define FUNC_DEF(source) op(const source &src, const rgb_t *palbase) const |
| 55 | 55 | #define FUNCTOR(name, x...) \ |
| 56 | 56 | template<typename _source, typename _dest> \ |
| 57 | 57 | struct name { _dest FUNC_DEF(_source) { x } }; |
| r243235 | r243236 | |
| 120 | 120 | // Copy and rotation |
| 121 | 121 | //============================================================ |
| 122 | 122 | |
| 123 | struct blit_base { |
| 124 | |
| 125 | blit_base(int dest_bpp, bool is_rot, bool is_passthrough) |
| 126 | : m_dest_bpp(dest_bpp), m_is_rot(is_rot), m_is_passthrough(is_passthrough) |
| 127 | { } |
| 128 | virtual ~blit_base() { } |
| 129 | |
| 130 | virtual void texop(const texture_info *texture, const render_texinfo *texsource) const = 0; |
| 131 | int m_dest_bpp; |
| 132 | bool m_is_rot; |
| 133 | bool m_is_passthrough; |
| 134 | }; |
| 135 | |
| 123 | 136 | template<typename _src_type, typename _dest_type, typename _op, int _len_div> |
| 124 | | void texcopy(const texture_info *texture, const render_texinfo *texsource) |
| 137 | struct blit_texcopy : public blit_base |
| 125 | 138 | { |
| 126 | | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); |
| 127 | | int x, y; |
| 128 | | _op op; |
| 129 | | /* loop over Y */ |
| 130 | | for (y = 0; y < texsource->height; y++) { |
| 131 | | _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div); |
| 132 | | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); |
| 133 | | x = texsource->width / (_len_div); |
| 134 | | while (x > 0) { |
| 135 | | *dst++ = op.op(*src, palbase); |
| 136 | | src++; |
| 137 | | x--; |
| 138 | | } |
| 139 | | } |
| 140 | | } |
| 139 | blit_texcopy() : blit_base(sizeof(_dest_type) / _len_div, false, false) { } |
| 140 | void texop(const texture_info *texture, const render_texinfo *texsource) const |
| 141 | { |
| 142 | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); |
| 143 | int x, y; |
| 144 | /* loop over Y */ |
| 145 | for (y = 0; y < texsource->height; y++) { |
| 146 | _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div); |
| 147 | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); |
| 148 | x = texsource->width / (_len_div); |
| 149 | while (x > 0) { |
| 150 | *dst++ = m_op.op(*src, palbase); |
| 151 | src++; |
| 152 | x--; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | private: |
| 157 | _op m_op; |
| 158 | }; |
| 141 | 159 | |
| 142 | 160 | #define TEXCOPYA(a, b, c, d) \ |
| 143 | | inline void texcopy_ ## a(const texture_info *texture, const render_texinfo *texsource) \ |
| 144 | | { return texcopy<b, c, op_ ## a <b, c>, d>(texture, texsource); } |
| 161 | const struct blit_texcopy<b, c, op_ ## a <b, c>, d> texcopy_ ## a; |
| 145 | 162 | |
| 146 | 163 | template<typename _src_type, typename _dest_type, typename _op> |
| 147 | | void texcopy_rot(const texture_info *texture, const render_texinfo *texsource) |
| 164 | struct blit_texrot : public blit_base |
| 148 | 165 | { |
| 149 | | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); |
| 150 | | int x, y; |
| 151 | | const quad_setup_data *setup = &texture->m_setup; |
| 152 | | int dudx = setup->dudx; |
| 153 | | int dvdx = setup->dvdx; |
| 154 | | _op op; |
| 155 | | /* loop over Y */ |
| 156 | | for (y = 0; y < setup->rotheight; y++) { |
| 157 | | INT32 curu = setup->startu + y * setup->dudy; |
| 158 | | INT32 curv = setup->startv + y * setup->dvdy; |
| 159 | | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); |
| 160 | | x = setup->rotwidth; |
| 161 | | while (x>0) { |
| 162 | | _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16); |
| 163 | | *dst++ = op.op(*src, palbase); |
| 164 | | curu += dudx; |
| 165 | | curv += dvdx; |
| 166 | | x--; |
| 167 | | } |
| 168 | | } |
| 169 | | } |
| 166 | blit_texrot() : blit_base(sizeof(_dest_type), true, false) { } |
| 167 | void texop(const texture_info *texture, const render_texinfo *texsource) const |
| 168 | { |
| 169 | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); |
| 170 | int x, y; |
| 171 | const quad_setup_data *setup = &texture->m_setup; |
| 172 | int dudx = setup->dudx; |
| 173 | int dvdx = setup->dvdx; |
| 174 | /* loop over Y */ |
| 175 | for (y = 0; y < setup->rotheight; y++) { |
| 176 | INT32 curu = setup->startu + y * setup->dudy; |
| 177 | INT32 curv = setup->startv + y * setup->dvdy; |
| 178 | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); |
| 179 | x = setup->rotwidth; |
| 180 | while (x>0) { |
| 181 | _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16); |
| 182 | *dst++ = m_op.op(*src, palbase); |
| 183 | curu += dudx; |
| 184 | curv += dvdx; |
| 185 | x--; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | private: |
| 190 | _op m_op; |
| 191 | }; |
| 170 | 192 | |
| 171 | 193 | #define TEXROTA(a, b, c) \ |
| 172 | | inline void texcopy_rot_ ## a(const texture_info *texture, const render_texinfo *texsource) \ |
| 173 | | { return texcopy_rot<b, c, op_ ## a <b, c> >(texture, texsource); } |
| 194 | const struct blit_texrot<b, c, op_ ## a <b, c> > texcopy_rot_ ## a; |
| 174 | 195 | |
| 196 | template<typename _src_type, typename _dest_type> |
| 197 | struct blit_texpass : public blit_base |
| 198 | { |
| 199 | blit_texpass() : blit_base(sizeof(_dest_type), false, true) { } |
| 200 | void texop(const texture_info *texture, const render_texinfo *texsource) const |
| 201 | { |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | #define TEXCOPYP(a, b, c) \ |
| 206 | const struct blit_texpass<b, c> texcopy_ ## a; |
| 207 | |
| 208 | |
| 175 | 209 | TEXCOPYA(rgb32_argb32, UINT32, UINT32, 1) |
| 210 | TEXCOPYP(rgb32_rgb32, UINT32, UINT32) |
| 211 | |
| 176 | 212 | TEXCOPYA(rgb32pal_argb32, UINT32, UINT32, 1) |
| 177 | 213 | TEXCOPYA(pal16_argb32, UINT16, UINT32, 1) |
| 178 | 214 | TEXCOPYA(pal16a_argb32, UINT16, UINT32, 1) |
| r243235 | r243236 | |
| 183 | 219 | TEXCOPYA(rgb15_argb1555, UINT16, UINT16, 1) |
| 184 | 220 | TEXCOPYA(rgb15pal_argb1555, UINT16, UINT16, 1) |
| 185 | 221 | |
| 222 | TEXCOPYP(argb32_argb32, UINT32, UINT32) |
| 186 | 223 | TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1) |
| 187 | 224 | TEXCOPYA(pal16a_rgb32, UINT16, UINT32, 1) |
| 188 | 225 | |
| 189 | 226 | TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2) |
| 190 | 227 | TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2) |
| 191 | 228 | |
| 192 | | //TEXCOPYA(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY) |
| 229 | TEXCOPYP(yuv16_uyvy, UINT16, UINT16) |
| 230 | TEXCOPYP(rgb15_rgb555, UINT16, UINT16) |
| 193 | 231 | |
| 194 | 232 | TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1) |
| 195 | 233 | |
trunk/src/osd/sdl/draw13.c
| r243235 | r243236 | |
| 24 | 24 | #include "osdsdl.h" |
| 25 | 25 | #include "window.h" |
| 26 | 26 | |
| 27 | |
| 27 | 28 | //============================================================ |
| 28 | 29 | // DEBUGGING |
| 29 | 30 | //============================================================ |
| r243235 | r243236 | |
| 74 | 75 | INT32 rotwidth, rotheight; |
| 75 | 76 | }; |
| 76 | 77 | |
| 77 | | class texture_info; |
| 78 | | |
| 79 | | typedef void (*texture_copy_func)(const texture_info *texture, const render_texinfo *texsource); |
| 80 | | |
| 81 | | struct copy_info_t { |
| 82 | | int src_fmt; |
| 83 | | Uint32 dst_fmt; |
| 84 | | int dst_bpp; |
| 85 | | int rotate; |
| 86 | | texture_copy_func func; |
| 87 | | Uint32 bm_mask; |
| 88 | | const char *srcname; |
| 89 | | const char *dstname; |
| 90 | | /* Statistics */ |
| 91 | | UINT64 pixel_count; |
| 92 | | INT64 time; |
| 93 | | int samples; |
| 94 | | int perf; |
| 95 | | /* list */ |
| 96 | | copy_info_t *next; |
| 97 | | }; |
| 98 | | |
| 99 | 78 | //============================================================ |
| 100 | 79 | // Textures |
| 101 | 80 | //============================================================ |
| 102 | 81 | |
| 103 | | struct sdl_info; |
| 82 | struct sdl_info13; |
| 83 | struct copy_info_t; |
| 104 | 84 | |
| 105 | 85 | /* texture_info holds information about a texture */ |
| 106 | 86 | class texture_info |
| r243235 | r243236 | |
| 134 | 114 | const HashT hash() const { return m_hash; } |
| 135 | 115 | const UINT32 flags() const { return m_flags; } |
| 136 | 116 | // FIXME: |
| 137 | | const bool is_pixels_owned() const { // do we own / allocated it ? |
| 138 | | return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 139 | | && (m_copyinfo->func != NULL)) ; |
| 140 | | } |
| 117 | const bool is_pixels_owned() const; |
| 141 | 118 | |
| 142 | 119 | private: |
| 143 | 120 | Uint32 m_sdl_access; |
| r243235 | r243236 | |
| 147 | 124 | UINT32 m_flags; // rendering flags |
| 148 | 125 | |
| 149 | 126 | SDL_Texture * m_texture_id; |
| 150 | | int m_is_rotated; |
| 127 | bool m_is_rotated; |
| 151 | 128 | |
| 152 | 129 | int m_format; // texture format |
| 153 | 130 | SDL_BlendMode m_sdl_blendmode; |
| r243235 | r243236 | |
| 155 | 132 | texture_info * m_next; // next texture in the list |
| 156 | 133 | }; |
| 157 | 134 | |
| 135 | //============================================================ |
| 136 | // TEXCOPY FUNCS |
| 137 | //============================================================ |
| 138 | |
| 139 | #include "blit13.h" |
| 140 | |
| 158 | 141 | /* sdl_info is the information about SDL for the current screen */ |
| 159 | | struct sdl_info |
| 142 | struct sdl_info13 |
| 160 | 143 | { |
| 161 | | sdl_info() |
| 144 | sdl_info13() |
| 162 | 145 | : m_blittimer(0), m_renderer(NULL), |
| 163 | 146 | m_hofs(0), m_vofs(0), |
| 164 | 147 | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| r243235 | r243236 | |
| 192 | 175 | SDL_DisplayMode m_original_mode; |
| 193 | 176 | }; |
| 194 | 177 | |
| 178 | struct copy_info_t { |
| 179 | int src_fmt; |
| 180 | Uint32 dst_fmt; |
| 181 | const blit_base *blitter; |
| 182 | Uint32 bm_mask; |
| 183 | const char *srcname; |
| 184 | const char *dstname; |
| 185 | /* Statistics */ |
| 186 | UINT64 pixel_count; |
| 187 | INT64 time; |
| 188 | int samples; |
| 189 | int perf; |
| 190 | /* list */ |
| 191 | copy_info_t *next; |
| 192 | }; |
| 193 | |
| 195 | 194 | //============================================================ |
| 196 | 195 | // PROTOTYPES |
| 197 | 196 | //============================================================ |
| r243235 | r243236 | |
| 210 | 209 | static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt); |
| 211 | 210 | |
| 212 | 211 | //============================================================ |
| 213 | | // TEXCOPY FUNCS |
| 214 | | //============================================================ |
| 215 | | |
| 216 | | #include "blit13.h" |
| 217 | | |
| 218 | | //============================================================ |
| 219 | 212 | // STATIC VARIABLES |
| 220 | 213 | //============================================================ |
| 221 | 214 | |
| r243235 | r243236 | |
| 223 | 216 | #define BM_ALL (-1) |
| 224 | 217 | //( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD) |
| 225 | 218 | |
| 226 | | #define texcopy_NULL NULL |
| 227 | | #define ENTRY(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, 0} |
| 228 | | #define ENTRY_BM(a,b,c,d,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0} |
| 229 | | #define ENTRY_LR(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1} |
| 219 | #define ENTRY(a,b,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, 0} |
| 220 | #define ENTRY_BM(a,b,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0} |
| 221 | #define ENTRY_LR(a,b,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1} |
| 230 | 222 | |
| 231 | | |
| 232 | 223 | static copy_info_t blit_info_default[] = |
| 233 | 224 | { |
| 234 | 225 | /* no rotation */ |
| 235 | | ENTRY(ARGB32, ARGB8888, 4, 0, NULL), |
| 236 | | ENTRY_LR(ARGB32, RGB888, 4, 0, argb32_rgb32), |
| 226 | ENTRY(ARGB32, ARGB8888, argb32_argb32), |
| 227 | ENTRY_LR(ARGB32, RGB888, argb32_rgb32), |
| 237 | 228 | /* Entry primarily for directfb */ |
| 238 | | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_ADD), |
| 239 | | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_MOD), |
| 240 | | ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_NONE), |
| 229 | ENTRY_BM(ARGB32, RGB888, argb32_rgb32, SDL_BLENDMODE_ADD), |
| 230 | ENTRY_BM(ARGB32, RGB888, argb32_rgb32, SDL_BLENDMODE_MOD), |
| 231 | ENTRY_BM(ARGB32, RGB888, argb32_rgb32, SDL_BLENDMODE_NONE), |
| 241 | 232 | |
| 242 | | ENTRY(RGB32, ARGB8888, 4, 0, rgb32_argb32), |
| 243 | | ENTRY(RGB32, RGB888, 4, 0, NULL), |
| 233 | ENTRY(RGB32, ARGB8888, rgb32_argb32), |
| 234 | ENTRY(RGB32, RGB888, rgb32_rgb32), |
| 244 | 235 | |
| 245 | | ENTRY(RGB32_PALETTED, ARGB8888, 4, 0, rgb32pal_argb32), |
| 246 | | ENTRY(RGB32_PALETTED, RGB888, 4, 0, rgb32pal_argb32), |
| 236 | ENTRY(RGB32_PALETTED, ARGB8888, rgb32pal_argb32), |
| 237 | ENTRY(RGB32_PALETTED, RGB888, rgb32pal_argb32), |
| 247 | 238 | |
| 248 | | ENTRY(YUY16, UYVY, 2, 0, NULL /* yuv16_uyvy*/), |
| 249 | | ENTRY(YUY16, YUY2, 2, 0, yuv16_yuy2), |
| 250 | | ENTRY(YUY16, YVYU, 2, 0, yuv16_yvyu), |
| 251 | | ENTRY(YUY16, ARGB8888, 4, 0, yuv16_argb32), |
| 252 | | ENTRY(YUY16, RGB888, 4, 0, yuv16_argb32), |
| 239 | ENTRY(YUY16, UYVY, yuv16_uyvy), |
| 240 | ENTRY(YUY16, YUY2, yuv16_yuy2), |
| 241 | ENTRY(YUY16, YVYU, yuv16_yvyu), |
| 242 | ENTRY(YUY16, ARGB8888, yuv16_argb32), |
| 243 | ENTRY(YUY16, RGB888, yuv16_argb32), |
| 253 | 244 | |
| 254 | | ENTRY(YUY16_PALETTED, UYVY, 2, 0, yuv16pal_uyvy), |
| 255 | | ENTRY(YUY16_PALETTED, YUY2, 2, 0, yuv16pal_yuy2), |
| 256 | | ENTRY(YUY16_PALETTED, YVYU, 2, 0, yuv16pal_yvyu), |
| 257 | | ENTRY(YUY16_PALETTED, ARGB8888, 4, 0, yuv16pal_argb32), |
| 258 | | ENTRY(YUY16_PALETTED, RGB888, 4, 0, yuv16pal_argb32), |
| 245 | ENTRY(YUY16_PALETTED, UYVY, yuv16pal_uyvy), |
| 246 | ENTRY(YUY16_PALETTED, YUY2, yuv16pal_yuy2), |
| 247 | ENTRY(YUY16_PALETTED, YVYU, yuv16pal_yvyu), |
| 248 | ENTRY(YUY16_PALETTED, ARGB8888, yuv16pal_argb32), |
| 249 | ENTRY(YUY16_PALETTED, RGB888, yuv16pal_argb32), |
| 259 | 250 | |
| 260 | | ENTRY(PALETTE16, ARGB8888, 4, 0, pal16_argb32), |
| 261 | | ENTRY(PALETTE16, RGB888, 4, 0, pal16_argb32), |
| 251 | ENTRY(PALETTE16, ARGB8888, pal16_argb32), |
| 252 | ENTRY(PALETTE16, RGB888, pal16_argb32), |
| 262 | 253 | |
| 263 | | ENTRY(RGB15, RGB555, 2, 0, NULL /* rgb15_argb1555 */), |
| 264 | | ENTRY(RGB15, ARGB1555, 2, 0, rgb15_argb1555), |
| 265 | | ENTRY(RGB15, ARGB8888, 4, 0, rgb15_argb32), |
| 266 | | ENTRY(RGB15, RGB888, 4, 0, rgb15_argb32), |
| 254 | ENTRY(RGB15, RGB555, rgb15_rgb555), |
| 255 | ENTRY(RGB15, ARGB1555, rgb15_argb1555), |
| 256 | ENTRY(RGB15, ARGB8888, rgb15_argb32), |
| 257 | ENTRY(RGB15, RGB888, rgb15_argb32), |
| 267 | 258 | |
| 268 | | ENTRY(RGB15_PALETTED, ARGB8888, 4, 0, rgb15pal_argb32), |
| 269 | | ENTRY(RGB15_PALETTED, RGB888, 4, 0, rgb15pal_argb32), |
| 259 | ENTRY(RGB15_PALETTED, ARGB8888, rgb15pal_argb32), |
| 260 | ENTRY(RGB15_PALETTED, RGB888, rgb15pal_argb32), |
| 270 | 261 | |
| 271 | | ENTRY(PALETTE16A, ARGB8888, 4, 0, pal16a_argb32), |
| 272 | | ENTRY(PALETTE16A, RGB888, 4, 0, pal16a_rgb32), |
| 262 | ENTRY(PALETTE16A, ARGB8888, pal16a_argb32), |
| 263 | ENTRY(PALETTE16A, RGB888, pal16a_rgb32), |
| 273 | 264 | |
| 274 | 265 | /* rotation */ |
| 275 | | ENTRY(ARGB32, ARGB8888, 4, 1, rot_argb32_argb32), |
| 276 | | ENTRY_LR(ARGB32, RGB888, 4, 1, rot_argb32_rgb32), |
| 266 | ENTRY(ARGB32, ARGB8888, rot_argb32_argb32), |
| 267 | ENTRY_LR(ARGB32, RGB888, rot_argb32_rgb32), |
| 277 | 268 | /* Entry primarily for directfb */ |
| 278 | | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD), |
| 279 | | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD), |
| 280 | | ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_NONE), |
| 269 | ENTRY_BM(ARGB32, RGB888, rot_argb32_rgb32, SDL_BLENDMODE_ADD), |
| 270 | ENTRY_BM(ARGB32, RGB888, rot_argb32_rgb32, SDL_BLENDMODE_MOD), |
| 271 | ENTRY_BM(ARGB32, RGB888, rot_argb32_rgb32, SDL_BLENDMODE_NONE), |
| 281 | 272 | |
| 282 | | ENTRY(RGB32, ARGB8888, 4, 1, rot_rgb32_argb32), |
| 283 | | ENTRY(RGB32, RGB888, 4, 1, rot_argb32_argb32), |
| 273 | ENTRY(RGB32, ARGB8888, rot_rgb32_argb32), |
| 274 | ENTRY(RGB32, RGB888, rot_argb32_argb32), |
| 284 | 275 | |
| 285 | | ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32), |
| 286 | | ENTRY(RGB32_PALETTED, RGB888, 4, 1, rot_rgb32pal_argb32), |
| 276 | ENTRY(RGB32_PALETTED, ARGB8888, rot_rgb32pal_argb32), |
| 277 | ENTRY(RGB32_PALETTED, RGB888, rot_rgb32pal_argb32), |
| 287 | 278 | |
| 288 | | ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32rot), |
| 289 | | ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32rot), |
| 279 | ENTRY(YUY16, ARGB8888, rot_yuv16_argb32rot), |
| 280 | ENTRY(YUY16, RGB888, rot_yuv16_argb32rot), |
| 290 | 281 | |
| 291 | | ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32rot), |
| 292 | | ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32rot), |
| 282 | ENTRY(YUY16_PALETTED, ARGB8888, rot_yuv16pal_argb32rot), |
| 283 | ENTRY(YUY16_PALETTED, RGB888, rot_yuv16pal_argb32rot), |
| 293 | 284 | |
| 294 | | ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32), |
| 295 | | ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32), |
| 285 | ENTRY(PALETTE16, ARGB8888, rot_pal16_argb32), |
| 286 | ENTRY(PALETTE16, RGB888, rot_pal16_argb32), |
| 296 | 287 | |
| 297 | | ENTRY(RGB15, RGB555, 2, 1, rot_rgb15_argb1555), |
| 298 | | ENTRY(RGB15, ARGB1555, 2, 1, rot_rgb15_argb1555), |
| 299 | | ENTRY(RGB15, ARGB8888, 4, 1, rot_rgb15_argb32), |
| 300 | | ENTRY(RGB15, RGB888, 4, 1, rot_rgb15_argb32), |
| 288 | ENTRY(RGB15, RGB555, rot_rgb15_argb1555), |
| 289 | ENTRY(RGB15, ARGB1555, rot_rgb15_argb1555), |
| 290 | ENTRY(RGB15, ARGB8888, rot_rgb15_argb32), |
| 291 | ENTRY(RGB15, RGB888, rot_rgb15_argb32), |
| 301 | 292 | |
| 302 | | ENTRY(RGB15_PALETTED, ARGB8888, 4, 1, rot_rgb15pal_argb32), |
| 303 | | ENTRY(RGB15_PALETTED, RGB888, 4, 1, rot_rgb15pal_argb32), |
| 293 | ENTRY(RGB15_PALETTED, ARGB8888, rot_rgb15pal_argb32), |
| 294 | ENTRY(RGB15_PALETTED, RGB888, rot_rgb15pal_argb32), |
| 304 | 295 | |
| 305 | | ENTRY(PALETTE16A, ARGB8888, 4, 1, rot_pal16a_argb32), |
| 306 | | ENTRY(PALETTE16A, RGB888, 4, 1, rot_pal16a_rgb32), |
| 296 | ENTRY(PALETTE16A, ARGB8888, rot_pal16a_argb32), |
| 297 | ENTRY(PALETTE16A, RGB888, rot_pal16a_rgb32), |
| 307 | 298 | |
| 308 | 299 | { -1 }, |
| 309 | 300 | }; |
| r243235 | r243236 | |
| 396 | 387 | SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect); |
| 397 | 388 | } |
| 398 | 389 | |
| 399 | | void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| 390 | void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y) |
| 400 | 391 | { |
| 401 | 392 | SDL_Rect target_rect; |
| 402 | 393 | |
| r243235 | r243236 | |
| 550 | 541 | { |
| 551 | 542 | if (bi->pixel_count) |
| 552 | 543 | osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, |
| 553 | | bi->rotate ? "rot" : "norot", bi->bm_mask, bi->samples, |
| 544 | bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples, |
| 554 | 545 | (int) bi->perf); |
| 555 | 546 | freeme = bi; |
| 556 | 547 | bi = bi->next; |
| r243235 | r243236 | |
| 582 | 573 | static int drawsdl2_window_create(sdl_window_info *window, int width, int height) |
| 583 | 574 | { |
| 584 | 575 | // allocate memory for our structures |
| 585 | | sdl_info *sdl = global_alloc(sdl_info); |
| 576 | sdl_info13 *sdl = global_alloc(sdl_info13); |
| 586 | 577 | |
| 587 | 578 | /* FIXME: On Ubuntu and potentially other Linux OS you should use |
| 588 | 579 | * to disable panning. This has to be done before every invocation of mame. |
| r243235 | r243236 | |
| 598 | 589 | UINT32 extra_flags = (window->fullscreen() ? |
| 599 | 590 | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); |
| 600 | 591 | |
| 592 | #if defined(SDLMAME_WIN32) |
| 593 | SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); |
| 594 | #endif |
| 601 | 595 | // create the SDL window |
| 602 | 596 | window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0, |
| 603 | 597 | width, height, extra_flags); |
| r243235 | r243236 | |
| 612 | 606 | mode.h = height; |
| 613 | 607 | if (window->refresh) |
| 614 | 608 | mode.refresh_rate = window->refresh; |
| 609 | #if 0 |
| 615 | 610 | if (window->depth) |
| 616 | 611 | { |
| 617 | 612 | switch (window->depth) |
| r243235 | r243236 | |
| 632 | 627 | osd_printf_warning("Ignoring depth %d\n", window->depth); |
| 633 | 628 | } |
| 634 | 629 | } |
| 630 | #endif |
| 631 | |
| 635 | 632 | SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode |
| 636 | 633 | #ifndef SDLMAME_WIN32 |
| 637 | 634 | /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution |
| r243235 | r243236 | |
| 642 | 639 | #endif |
| 643 | 640 | } |
| 644 | 641 | else |
| 645 | | SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop |
| 646 | | |
| 642 | { |
| 643 | //SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop |
| 644 | } |
| 647 | 645 | // create renderer |
| 648 | 646 | |
| 649 | 647 | if (video_config.waitvsync) |
| r243235 | r243236 | |
| 657 | 655 | } |
| 658 | 656 | |
| 659 | 657 | //SDL_SelectRenderer(window->sdl_window); |
| 660 | | |
| 661 | 658 | SDL_ShowWindow(window->sdl_window); |
| 662 | 659 | //SDL_SetWindowFullscreen(window->window_id, window->fullscreen); |
| 663 | 660 | SDL_RaiseWindow(window->sdl_window); |
| 661 | |
| 664 | 662 | SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); |
| 665 | 663 | |
| 666 | 664 | sdl->m_blittimer = 3; |
| r243235 | r243236 | |
| 676 | 674 | |
| 677 | 675 | static void drawsdl2_window_resize(sdl_window_info *window, int width, int height) |
| 678 | 676 | { |
| 679 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 677 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 680 | 678 | |
| 681 | 679 | sdl->m_resize_pending = 1; |
| 682 | 680 | sdl->m_resize_height = height; |
| r243235 | r243236 | |
| 695 | 693 | |
| 696 | 694 | static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt) |
| 697 | 695 | { |
| 698 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 696 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 699 | 697 | |
| 700 | 698 | *xt = x - sdl->m_hofs; |
| 701 | 699 | *yt = y - sdl->m_vofs; |
| r243235 | r243236 | |
| 721 | 719 | |
| 722 | 720 | static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update) |
| 723 | 721 | { |
| 724 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 722 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 725 | 723 | render_primitive *prim; |
| 726 | 724 | texture_info *texture=NULL; |
| 727 | 725 | float vofs, hofs; |
| r243235 | r243236 | |
| 835 | 833 | |
| 836 | 834 | static void drawsdl2_window_clear(sdl_window_info *window) |
| 837 | 835 | { |
| 838 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 836 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 839 | 837 | |
| 840 | 838 | sdl->m_blittimer = 2; |
| 841 | 839 | } |
| r243235 | r243236 | |
| 847 | 845 | |
| 848 | 846 | static void drawsdl2_window_destroy(sdl_window_info *window) |
| 849 | 847 | { |
| 850 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 848 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 851 | 849 | |
| 852 | 850 | // skip if nothing |
| 853 | 851 | if (sdl == NULL) |
| r243235 | r243236 | |
| 886 | 884 | |
| 887 | 885 | for (bi = blit_info[m_format]; bi != NULL; bi = bi->next) |
| 888 | 886 | { |
| 889 | | if ((m_is_rotated == bi->rotate) |
| 887 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 890 | 888 | && (m_sdl_blendmode == bi->bm_mask)) |
| 891 | 889 | { |
| 892 | 890 | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| r243235 | r243236 | |
| 907 | 905 | /* try last resort handlers */ |
| 908 | 906 | for (bi = blit_info[m_format]; bi != NULL; bi = bi->next) |
| 909 | 907 | { |
| 910 | | if ((m_is_rotated == bi->rotate) |
| 908 | if ((m_is_rotated == bi->blitter->m_is_rot) |
| 911 | 909 | && (m_sdl_blendmode == bi->bm_mask)) |
| 912 | 910 | if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname)) |
| 913 | 911 | return bi; |
| r243235 | r243236 | |
| 916 | 914 | return NULL; |
| 917 | 915 | } |
| 918 | 916 | |
| 917 | // FIXME: |
| 918 | const bool texture_info::is_pixels_owned() const |
| 919 | { // do we own / allocated it ? |
| 920 | return ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 921 | && (m_copyinfo->blitter->m_is_passthrough)); |
| 922 | } |
| 923 | |
| 919 | 924 | //============================================================ |
| 920 | 925 | // texture_info::matches |
| 921 | 926 | //============================================================ |
| r243235 | r243236 | |
| 945 | 950 | m_flags = flags; |
| 946 | 951 | m_texinfo = texsource; |
| 947 | 952 | m_texinfo.seqid = -1; // force set data |
| 948 | | m_is_rotated = FALSE; |
| 953 | m_is_rotated = false; |
| 949 | 954 | m_setup = setup; |
| 950 | 955 | m_sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags)); |
| 951 | 956 | m_pitch = 0; |
| r243235 | r243236 | |
| 974 | 979 | |
| 975 | 980 | if (setup.rotwidth != m_texinfo.width || setup.rotheight != m_texinfo.height |
| 976 | 981 | || setup.dudx < 0 || setup.dvdy < 0) |
| 977 | | m_is_rotated = TRUE; |
| 982 | m_is_rotated = true; |
| 978 | 983 | else |
| 979 | | m_is_rotated = FALSE; |
| 984 | m_is_rotated = false; |
| 980 | 985 | |
| 981 | 986 | //m_sdl_access = SDL_TEXTUREACCESS_STATIC; |
| 982 | 987 | m_sdl_access = SDL_TEXTUREACCESS_STREAMING; |
| r243235 | r243236 | |
| 998 | 1003 | |
| 999 | 1004 | if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 1000 | 1005 | { |
| 1001 | | if (m_copyinfo->func != NULL) |
| 1002 | | m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp); |
| 1006 | if (m_copyinfo->blitter->m_is_passthrough) |
| 1007 | m_pixels = NULL; |
| 1003 | 1008 | else |
| 1004 | | m_pixels = NULL; |
| 1009 | m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->blitter->m_dest_bpp); |
| 1005 | 1010 | } |
| 1006 | 1011 | m_last_access = osd_ticks(); |
| 1007 | 1012 | |
| r243235 | r243236 | |
| 1023 | 1028 | m_copyinfo->time -= osd_ticks(); |
| 1024 | 1029 | if (m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 1025 | 1030 | { |
| 1026 | | if ( m_copyinfo->func ) |
| 1031 | if ( m_copyinfo->blitter->m_is_passthrough ) |
| 1027 | 1032 | { |
| 1028 | | m_pitch = m_setup.rotwidth * m_copyinfo->dst_bpp; |
| 1029 | | m_copyinfo->func(this, &texsource); |
| 1033 | m_pixels = texsource.base; |
| 1034 | m_pitch = m_texinfo.rowpixels * m_copyinfo->blitter->m_dest_bpp; |
| 1030 | 1035 | } |
| 1031 | 1036 | else |
| 1032 | 1037 | { |
| 1033 | | m_pixels = texsource.base; |
| 1034 | | m_pitch = m_texinfo.rowpixels * m_copyinfo->dst_bpp; |
| 1038 | m_pitch = m_setup.rotwidth * m_copyinfo->blitter->m_dest_bpp; |
| 1039 | m_copyinfo->blitter->texop(this, &texsource); |
| 1035 | 1040 | } |
| 1036 | 1041 | SDL_UpdateTexture(m_texture_id, NULL, m_pixels, m_pitch); |
| 1037 | 1042 | } |
| 1038 | 1043 | else |
| 1039 | 1044 | { |
| 1040 | 1045 | SDL_LockTexture(m_texture_id, NULL, (void **) &m_pixels, &m_pitch); |
| 1041 | | if ( m_copyinfo->func ) |
| 1042 | | m_copyinfo->func(this, &texsource); |
| 1043 | | else |
| 1046 | if ( m_copyinfo->blitter->m_is_passthrough ) |
| 1044 | 1047 | { |
| 1045 | 1048 | UINT8 *src = (UINT8 *) texsource.base; |
| 1046 | 1049 | UINT8 *dst = (UINT8 *) m_pixels; |
| 1047 | | int spitch = texsource.rowpixels * m_copyinfo->dst_bpp; |
| 1048 | | int num = texsource.width * m_copyinfo->dst_bpp; |
| 1050 | int spitch = texsource.rowpixels * m_copyinfo->blitter->m_dest_bpp; |
| 1051 | int num = texsource.width * m_copyinfo->blitter->m_dest_bpp; |
| 1049 | 1052 | int h = texsource.height; |
| 1050 | 1053 | while (h--) { |
| 1051 | 1054 | memcpy(dst, src, num); |
| r243235 | r243236 | |
| 1053 | 1056 | dst += m_pitch; |
| 1054 | 1057 | } |
| 1055 | 1058 | } |
| 1059 | else |
| 1060 | m_copyinfo->blitter->texop(this, &texsource); |
| 1056 | 1061 | SDL_UnlockTexture(m_texture_id); |
| 1057 | 1062 | } |
| 1058 | 1063 | m_copyinfo->time += osd_ticks(); |
| r243235 | r243236 | |
| 1113 | 1118 | // texture_find |
| 1114 | 1119 | //============================================================ |
| 1115 | 1120 | |
| 1116 | | texture_info *sdl_info::texture_find(const render_primitive &prim, const quad_setup_data &setup) |
| 1121 | texture_info *sdl_info13::texture_find(const render_primitive &prim, const quad_setup_data &setup) |
| 1117 | 1122 | { |
| 1118 | 1123 | HashT texhash = texture_compute_hash(prim.texture, prim.flags); |
| 1119 | 1124 | texture_info *texture; |
| r243235 | r243236 | |
| 1150 | 1155 | // texture_update |
| 1151 | 1156 | //============================================================ |
| 1152 | 1157 | |
| 1153 | | texture_info * sdl_info::texture_update(const render_primitive &prim) |
| 1158 | texture_info * sdl_info13::texture_update(const render_primitive &prim) |
| 1154 | 1159 | { |
| 1155 | 1160 | quad_setup_data setup; |
| 1156 | 1161 | texture_info *texture; |
| r243235 | r243236 | |
| 1184 | 1189 | |
| 1185 | 1190 | static void drawsdl2_destroy_all_textures(sdl_window_info *window) |
| 1186 | 1191 | { |
| 1187 | | sdl_info *sdl = (sdl_info *) window->dxdata; |
| 1192 | sdl_info13 *sdl = (sdl_info13 *) window->dxdata; |
| 1188 | 1193 | |
| 1189 | 1194 | if (sdl == NULL) |
| 1190 | 1195 | return; |