trunk/src/osd/sdl/blit13.h
| r243234 | r243235 | |
| 5 | 5 | // INLINE |
| 6 | 6 | //============================================================ |
| 7 | 7 | |
| 8 | | INLINE UINT32 premult32(UINT32 pixel) |
| 8 | inline UINT32 premult32(const UINT32 pixel) |
| 9 | 9 | { |
| 10 | | UINT8 a = (pixel >> 24) & 0xff; |
| 11 | | UINT8 r = (pixel >> 16) & 0xff; |
| 12 | | UINT8 g = (pixel >> 8) & 0xff; |
| 13 | | UINT8 b = (pixel >> 0) & 0xff; |
| 10 | const UINT16 a = (pixel >> 24) & 0xff; |
| 11 | const UINT16 r = (pixel >> 16) & 0xff; |
| 12 | const UINT16 g = (pixel >> 8) & 0xff; |
| 13 | const UINT16 b = (pixel >> 0) & 0xff; |
| 14 | 14 | |
| 15 | 15 | return 0xFF000000 | |
| 16 | | (((UINT16)r * (UINT16)a) / 255) << 16 | |
| 17 | | (((UINT16)g * (UINT16)a) / 255) << 8 | |
| 18 | | (((UINT16)b * (UINT16)a) / 255); |
| 16 | ((r * a) / 255) << 16 | |
| 17 | ((g * a) / 255) << 8 | |
| 18 | ((b * a) / 255); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | | #define CLUL(x) ((int) (x) < 0 ? 0 : ((x) > 65535 ? 255 : (x)>>8)) |
| 21 | inline UINT32 CLUL(const UINT32 x) |
| 22 | { |
| 23 | return ((INT32) x < 0) ? 0 : ((x > 65535) ? 255 : x >> 8); |
| 24 | } |
| 22 | 25 | |
| 23 | | INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr) |
| 26 | inline UINT32 ycc_to_rgb(const UINT8 y, const UINT8 cb, const UINT8 cr) |
| 24 | 27 | { |
| 25 | | unsigned int r, g, b, common; |
| 28 | const UINT32 common = 298 * y - 56992; |
| 29 | const UINT32 r = (common + 409 * cr); |
| 30 | const UINT32 g = (common - 100 * cb - 208 * cr + 91776); |
| 31 | const UINT32 b = (common + 516 * cb - 13696); |
| 26 | 32 | |
| 27 | | common = 298 * y - 56992; |
| 28 | | r = (common + 409 * cr); |
| 29 | | g = (common - 100 * cb - 208 * cr + 91776); |
| 30 | | b = (common + 516 * cb - 13696); |
| 31 | | |
| 32 | 33 | return 0xff000000 | (CLUL(r)<<16) | (CLUL(g)<<8) | (CLUL(b)); |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | | INLINE UINT32 pixel_ycc_to_rgb(UINT16 *pixel) |
| 36 | inline UINT32 pixel_ycc_to_rgb(const UINT16 *pixel) |
| 36 | 37 | { |
| 37 | | UINT32 p = *(UINT32 *)((FPTR) pixel & ~1); |
| 38 | |
| 39 | const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3); |
| 38 | 40 | return ycc_to_rgb((*pixel >> 8) & 0xff, (p) & 0xff, (p>>16) & 0xff); |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | | INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette) |
| 43 | inline UINT32 pixel_ycc_to_rgb_pal(const UINT16 *pixel, const rgb_t *palette) |
| 42 | 44 | { |
| 43 | | UINT32 p = *(UINT32 *)((FPTR) pixel & ~1); |
| 45 | const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3); |
| 44 | 46 | return ycc_to_rgb(palette[(*pixel >> 8) & 0xff], (p) & 0xff, (p>>16) & 0xff); |
| 45 | 47 | } |
| 46 | 48 | |
| r243234 | r243235 | |
| 48 | 50 | // Pixel conversions |
| 49 | 51 | //============================================================ |
| 50 | 52 | |
| 51 | | #define OP_ARGB32_ARGB32(_src) (_src) |
| 52 | 53 | |
| 53 | | #define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000) |
| 54 | #define FUNC_DEF(source) op(const source &src, const rgb_t *palbase) |
| 55 | #define FUNCTOR(name, x...) \ |
| 56 | template<typename _source, typename _dest> \ |
| 57 | struct name { _dest FUNC_DEF(_source) { x } }; |
| 54 | 58 | |
| 55 | | #define OP_RGB32PAL_ARGB32(_src) \ |
| 56 | | (palbase[0x200 + (((_src) >> 16) & 0xff) ] | \ |
| 57 | | palbase[0x100 + (((_src) >> 8) & 0xff) ] | \ |
| 58 | | palbase[((_src) & 0xff) ] | 0xff000000) |
| 59 | FUNCTOR(op_argb32_argb32, return src; ) |
| 60 | FUNCTOR(op_rgb32_argb32, return src | 0xff000000; ) |
| 61 | FUNCTOR(op_pal16_argb32, return 0xff000000 |palbase[src]; ) |
| 62 | FUNCTOR(op_pal16_rgb32, return palbase[src]; ) |
| 63 | FUNCTOR(op_rgb32pal_argb32, |
| 64 | return palbase[0x200 + (((src) >> 16) & 0xff) ] | |
| 65 | palbase[0x100 + (((src) >> 8) & 0xff) ] | |
| 66 | palbase[((src) & 0xff) ] | 0xff000000; ) |
| 59 | 67 | |
| 60 | | #define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src]) |
| 68 | FUNCTOR(op_pal16a_argb32, return palbase[src]; ) |
| 61 | 69 | |
| 62 | | #define OP_PAL16A_ARGB32(_src) (palbase[_src]) |
| 70 | FUNCTOR(op_rgb15_argb32, |
| 71 | return 0xff000000 | ((src & 0x7c00) << 9) | ((src & 0x03e0) << 6) |
| 72 | | ((src & 0x001f) << 3) | ((((src & 0x7c00) << 9) |
| 73 | | ((src & 0x03e0) << 6) | ((src & 0x001f) << 3) >> 5) & 0x070707); ) |
| 63 | 74 | |
| 64 | | #define OP_RGB15_ARGB32(_src) (0xff000000 | ((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) | \ |
| 65 | | ((((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) >> 5) & 0x070707)) |
| 75 | FUNCTOR(op_rgb15pal_argb32, |
| 76 | return 0xff000000 | palbase[0x40 + ((src >> 10) & 0x1f)] | |
| 77 | palbase[0x20 + ((src >> 5) & 0x1f)] | palbase[0x00 + ((src >> 0) & 0x1f)]; ) |
| 66 | 78 | |
| 67 | | #define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \ |
| 68 | | palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)]) |
| 79 | FUNCTOR(op_argb32_rgb32, return premult32(src); ) |
| 80 | FUNCTOR(op_pal16a_rgb32, return premult32(palbase[src]); ) |
| 81 | FUNCTOR(op_pal16_argb1555, |
| 82 | return (palbase[src]&0xf80000) >> 9 | |
| 83 | (palbase[src]&0x00f800) >> 6 | |
| 84 | (palbase[src]&0x0000f8) >> 3 | 0x8000; ) |
| 69 | 85 | |
| 70 | | #define OP_ARGB32_RGB32(_pixel) premult32(_pixel) |
| 86 | FUNCTOR(op_rgb15_argb1555, return src | 0x8000; ) |
| 71 | 87 | |
| 72 | | #define OP_PAL16A_RGB32(_src) premult32(palbase[_src]) |
| 88 | FUNCTOR(op_rgb15pal_argb1555, |
| 89 | return (palbase[src >> 10] & 0xf8) << 7 | |
| 90 | (palbase[(src >> 5) & 0x1f] & 0xf8) << 2 | |
| 91 | (palbase[src & 0x1f] & 0xf8) >> 3 | 0x8000; ) |
| 73 | 92 | |
| 74 | | #define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \ |
| 75 | | (palbase[_src]&0x00f800) >> 6 | \ |
| 76 | | (palbase[_src]&0x0000f8) >> 3 | 0x8000) |
| 93 | FUNCTOR(op_yuv16_uyvy, return src; ) |
| 94 | FUNCTOR(op_yuv16pal_uyvy, return (palbase[(src >> 8) & 0xff] << 8) | (src & 0x00ff); ) |
| 77 | 95 | |
| 78 | | #define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000) |
| 96 | // FIXME: wrong ... see non_pal version |
| 97 | FUNCTOR(op_yuv16pal_yvyu, return (palbase[(src >> 8) & 0xff] & 0xff) | ((src & 0xff) << 8); ) |
| 98 | FUNCTOR(op_yuv16_yvyu, return ((src & 0xff00ff00) >> 8 ) | (src << 24) | ((src >> 8) & 0x00ff00); ) |
| 79 | 99 | |
| 80 | | #define OP_RGB15PAL_ARGB1555(_src) ((palbase[(_src) >> 10] & 0xf8) << 7 | \ |
| 81 | | (palbase[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \ |
| 82 | | (palbase[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000) |
| 100 | FUNCTOR(op_yuv16_yuy2, return ((src & 0xff00ff00) >> 8) | ((src & 0x00ff00ff) << 8); ) |
| 83 | 101 | |
| 84 | | #define OP_YUV16_UYVY(_src) (_src) |
| 102 | FUNCTOR(op_yuv16pal_yuy2, |
| 103 | return (palbase[(src>>8) & 0xff]) | |
| 104 | (palbase[(src>>24) & 0xff]<<16) | |
| 105 | ((src<<8)&0xff00ff00);) |
| 85 | 106 | |
| 86 | | #define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff)) |
| 107 | FUNCTOR(op_yuv16_argb32, |
| 108 | return (UINT64) ycc_to_rgb((src >> 8) & 0xff, src & 0xff , (src>>16) & 0xff) |
| 109 | | ((UINT64)ycc_to_rgb((src >> 24) & 0xff, src & 0xff , (src>>16) & 0xff) << 32); ) |
| 87 | 110 | |
| 88 | | #define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8)) |
| 111 | FUNCTOR(op_yuv16pal_argb32, |
| 112 | return (UINT64)ycc_to_rgb(palbase[(src >> 8) & 0xff], src & 0xff , (src>>16) & 0xff) |
| 113 | | ((UINT64)ycc_to_rgb(palbase[(src >> 24) & 0xff], src & 0xff , (src>>16) & 0xff) << 32);) |
| 89 | 114 | |
| 90 | | #define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8)) |
| 115 | FUNCTOR(op_yuv16_argb32rot, return pixel_ycc_to_rgb(&src) ; ) |
| 91 | 116 | |
| 92 | | #define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \ |
| 93 | | (((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) ) |
| 117 | FUNCTOR(op_yuv16pal_argb32rot, return pixel_ycc_to_rgb_pal(&src, palbase); ) |
| 94 | 118 | |
| 95 | | #define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \ |
| 96 | | (palbase[((_src)>>24) & 0xff]<<16) | \ |
| 97 | | (((_src)<<8)&0xff00ff00) ) |
| 98 | | |
| 99 | | #define OP_YUV16_ARGB32(_src) \ |
| 100 | | (UINT64) ycc_to_rgb(((_src) >> 8) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) \ |
| 101 | | | ((UINT64)ycc_to_rgb(((_src) >> 24) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) << 32) |
| 102 | | |
| 103 | | #define OP_YUV16PAL_ARGB32(_src) \ |
| 104 | | (UINT64)ycc_to_rgb(palbase[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \ |
| 105 | | | ((UINT64)ycc_to_rgb(palbase[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32) |
| 106 | | |
| 107 | | #define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src)) |
| 108 | | |
| 109 | | #define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase) |
| 110 | | |
| 111 | 119 | //============================================================ |
| 112 | 120 | // Copy and rotation |
| 113 | 121 | //============================================================ |
| 114 | 122 | |
| 115 | | #define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \ |
| 116 | | INLINE void texcopy_##_name (const texture_info *texture, const render_texinfo *texsource) { \ |
| 117 | | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ |
| 118 | | int x, y; \ |
| 119 | | /* loop over Y */ \ |
| 120 | | for (y = 0; y < texsource->height; y++) { \ |
| 121 | | _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div); \ |
| 122 | | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); \ |
| 123 | | x = texsource->width / (_len_div); \ |
| 124 | | while (x > 0) { \ |
| 125 | | *dst++ = _op(*src); \ |
| 126 | | src++; \ |
| 127 | | x--; \ |
| 128 | | } \ |
| 129 | | } \ |
| 123 | template<typename _src_type, typename _dest_type, typename _op, int _len_div> |
| 124 | void texcopy(const texture_info *texture, const render_texinfo *texsource) |
| 125 | { |
| 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 | } |
| 130 | 140 | } |
| 131 | 141 | |
| 132 | | #define TEXCOPY( _name, _src_type, _dest_type, _op) \ |
| 133 | | TEXCOPY_M( _name, _src_type, _dest_type, _op, 1) |
| 142 | #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); } |
| 134 | 145 | |
| 135 | | #define TEXROT( _name, _src_type, _dest_type, _op) \ |
| 136 | | INLINE void texcopy_rot_##_name (const texture_info *texture, const render_texinfo *texsource) { \ |
| 137 | | ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ |
| 138 | | int x, y; \ |
| 139 | | const quad_setup_data *setup = &texture->m_setup; \ |
| 140 | | int dudx = setup->dudx; \ |
| 141 | | int dvdx = setup->dvdx; \ |
| 142 | | /* loop over Y */ \ |
| 143 | | for (y = 0; y < setup->rotheight; y++) { \ |
| 144 | | INT32 curu = setup->startu + y * setup->dudy; \ |
| 145 | | INT32 curv = setup->startv + y * setup->dvdy; \ |
| 146 | | _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); \ |
| 147 | | x = setup->rotwidth; \ |
| 148 | | while (x>0) { \ |
| 149 | | _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16); \ |
| 150 | | *dst++ = _op(*src); \ |
| 151 | | curu += dudx; \ |
| 152 | | curv += dvdx; \ |
| 153 | | x--; \ |
| 154 | | } \ |
| 155 | | } \ |
| 146 | template<typename _src_type, typename _dest_type, typename _op> |
| 147 | void texcopy_rot(const texture_info *texture, const render_texinfo *texsource) |
| 148 | { |
| 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 | } |
| 156 | 169 | } |
| 157 | 170 | |
| 158 | | //TEXCOPY(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32) |
| 171 | #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); } |
| 159 | 174 | |
| 160 | | TEXCOPY(rgb32_argb32, UINT32, UINT32, OP_RGB32_ARGB32) |
| 161 | | TEXCOPY(rgb32pal_argb32, UINT32, UINT32, OP_RGB32PAL_ARGB32) |
| 162 | | TEXCOPY(pal16_argb32, UINT16, UINT32, OP_PAL16_ARGB32) |
| 163 | | TEXCOPY(pal16a_argb32, UINT16, UINT32, OP_PAL16A_ARGB32) |
| 164 | | TEXCOPY(rgb15_argb32, UINT16, UINT32, OP_RGB15_ARGB32) |
| 165 | | TEXCOPY(rgb15pal_argb32, UINT16, UINT32, OP_RGB15PAL_ARGB32) |
| 175 | TEXCOPYA(rgb32_argb32, UINT32, UINT32, 1) |
| 176 | TEXCOPYA(rgb32pal_argb32, UINT32, UINT32, 1) |
| 177 | TEXCOPYA(pal16_argb32, UINT16, UINT32, 1) |
| 178 | TEXCOPYA(pal16a_argb32, UINT16, UINT32, 1) |
| 179 | TEXCOPYA(rgb15_argb32, UINT16, UINT32, 1) |
| 180 | TEXCOPYA(rgb15pal_argb32, UINT16, UINT32, 1) |
| 166 | 181 | |
| 167 | | TEXCOPY(pal16_argb1555, UINT16, UINT16, OP_PAL16_ARGB1555) |
| 168 | | TEXCOPY(rgb15_argb1555, UINT16, UINT16, OP_RGB15_ARGB1555) |
| 169 | | TEXCOPY(rgb15pal_argb1555, UINT16, UINT16, OP_RGB15PAL_ARGB1555) |
| 182 | TEXCOPYA(pal16_argb1555, UINT16, UINT16, 1) |
| 183 | TEXCOPYA(rgb15_argb1555, UINT16, UINT16, 1) |
| 184 | TEXCOPYA(rgb15pal_argb1555, UINT16, UINT16, 1) |
| 170 | 185 | |
| 171 | | TEXCOPY(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32) |
| 172 | | TEXCOPY(pal16a_rgb32, UINT16, UINT32, OP_PAL16A_RGB32) |
| 186 | TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1) |
| 187 | TEXCOPYA(pal16a_rgb32, UINT16, UINT32, 1) |
| 173 | 188 | |
| 174 | | TEXCOPY_M(yuv16_argb32, UINT32, UINT64, OP_YUV16_ARGB32, 2) |
| 175 | | TEXCOPY_M(yuv16pal_argb32, UINT32, UINT64, OP_YUV16PAL_ARGB32, 2) |
| 189 | TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2) |
| 190 | TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2) |
| 176 | 191 | |
| 177 | | //TEXCOPY(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY) |
| 192 | //TEXCOPYA(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY) |
| 178 | 193 | |
| 179 | | TEXCOPY(yuv16pal_uyvy, UINT16, UINT16, OP_YUV16PAL_UYVY) |
| 194 | TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1) |
| 180 | 195 | |
| 181 | | TEXCOPY(yuv16_yvyu, UINT16, UINT16, OP_YUV16_YVYU) |
| 182 | | TEXCOPY(yuv16pal_yvyu, UINT16, UINT16, OP_YUV16PAL_YVYU) |
| 196 | TEXCOPYA(yuv16_yvyu, UINT32, UINT32, 2) |
| 197 | TEXCOPYA(yuv16pal_yvyu, UINT16, UINT16, 1) |
| 183 | 198 | |
| 184 | | TEXCOPY_M(yuv16_yuy2, UINT32, UINT32, OP_YUV16_YUY2, 2) |
| 185 | | TEXCOPY_M(yuv16pal_yuy2, UINT32, UINT32, OP_YUV16PAL_YUY2, 2) |
| 199 | TEXCOPYA(yuv16_yuy2, UINT32, UINT32, 2) |
| 200 | TEXCOPYA(yuv16pal_yuy2, UINT32, UINT32, 2) |
| 186 | 201 | |
| 187 | 202 | |
| 188 | | TEXROT(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32) |
| 189 | | TEXROT(rgb32_argb32, UINT32, UINT32, OP_RGB32_ARGB32) |
| 190 | | TEXROT(rgb32pal_argb32, UINT32, UINT32, OP_RGB32PAL_ARGB32) |
| 191 | | TEXROT(pal16_argb32, UINT16, UINT32, OP_PAL16_ARGB32) |
| 192 | | TEXROT(pal16a_argb32, UINT16, UINT32, OP_PAL16A_ARGB32) |
| 193 | | TEXROT(rgb15_argb32, UINT16, UINT32, OP_RGB15_ARGB32) |
| 194 | | TEXROT(rgb15pal_argb32, UINT16, UINT32, OP_RGB15PAL_ARGB32) |
| 195 | 203 | |
| 196 | | TEXROT(pal16_argb1555, UINT16, UINT16, OP_PAL16_ARGB1555) |
| 197 | | TEXROT(rgb15_argb1555, UINT16, UINT16, OP_RGB15_ARGB1555) |
| 198 | | TEXROT(rgb15pal_argb1555, UINT16, UINT16, OP_RGB15PAL_ARGB1555) |
| 204 | TEXROTA(argb32_argb32, UINT32, UINT32) |
| 205 | TEXROTA(rgb32_argb32, UINT32, UINT32) |
| 206 | TEXROTA(pal16_argb32, UINT16, UINT32) |
| 207 | TEXROTA(pal16_rgb32, UINT16, UINT32) |
| 199 | 208 | |
| 200 | | TEXROT(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32) |
| 201 | | TEXROT(pal16a_rgb32, UINT16, UINT32, OP_PAL16A_RGB32) |
| 209 | TEXROTA(rgb32pal_argb32, UINT32, UINT32) |
| 210 | TEXROTA(pal16a_argb32, UINT16, UINT32) |
| 211 | TEXROTA(rgb15_argb32, UINT16, UINT32) |
| 212 | TEXROTA(rgb15pal_argb32, UINT16, UINT32) |
| 202 | 213 | |
| 203 | | TEXROT(yuv16_argb32, UINT16, UINT32, OP_YUV16_ARGB32ROT) |
| 204 | | TEXROT(yuv16pal_argb32, UINT16, UINT32, OP_YUV16PAL_ARGB32ROT) |
| 214 | TEXROTA(pal16_argb1555, UINT16, UINT16) |
| 215 | TEXROTA(rgb15_argb1555, UINT16, UINT16) |
| 216 | TEXROTA(rgb15pal_argb1555, UINT16, UINT16) |
| 217 | |
| 218 | TEXROTA(argb32_rgb32, UINT32, UINT32) |
| 219 | TEXROTA(pal16a_rgb32, UINT16, UINT32) |
| 220 | |
| 221 | TEXROTA(yuv16_argb32rot, UINT16, UINT32) |
| 222 | TEXROTA(yuv16pal_argb32rot, UINT16, UINT32) |
trunk/src/osd/sdl/draw13.c
| r243234 | r243235 | |
| 48 | 48 | |
| 49 | 49 | static inline bool is_opaque(const float &a) |
| 50 | 50 | { |
| 51 | | return (a >= 1.0f); |
| 51 | return (a >= 1.0f); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | static inline bool is_transparent(const float &a) |
| 55 | 55 | { |
| 56 | | return (a < 0.0001f); |
| 56 | return (a < 0.0001f); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | //============================================================ |
| r243234 | r243235 | |
| 63 | 63 | |
| 64 | 64 | struct quad_setup_data |
| 65 | 65 | { |
| 66 | | quad_setup_data() |
| 67 | | : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), |
| 68 | | rotwidth(0), rotheight(0) |
| 69 | | {} |
| 70 | | void compute(const render_primitive &prim); |
| 66 | quad_setup_data() |
| 67 | : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), |
| 68 | rotwidth(0), rotheight(0) |
| 69 | {} |
| 70 | void compute(const render_primitive &prim); |
| 71 | 71 | |
| 72 | 72 | INT32 dudx, dvdx, dudy, dvdy; |
| 73 | 73 | INT32 startu, startv; |
| r243234 | r243235 | |
| 105 | 105 | /* texture_info holds information about a texture */ |
| 106 | 106 | class texture_info |
| 107 | 107 | { |
| 108 | | friend class simple_list<texture_info>; |
| 108 | friend class simple_list<texture_info>; |
| 109 | 109 | public: |
| 110 | | texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); |
| 111 | | ~texture_info(); |
| 110 | texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); |
| 111 | ~texture_info(); |
| 112 | 112 | |
| 113 | | void set_data(const render_texinfo &texsource, const UINT32 flags); |
| 114 | | void render_quad(const render_primitive *prim, const int x, const int y); |
| 115 | | bool matches(const render_primitive &prim, const quad_setup_data &setup); |
| 113 | void set_data(const render_texinfo &texsource, const UINT32 flags); |
| 114 | void render_quad(const render_primitive *prim, const int x, const int y); |
| 115 | bool matches(const render_primitive &prim, const quad_setup_data &setup); |
| 116 | 116 | |
| 117 | | copy_info_t *compute_size_type(); |
| 117 | copy_info_t *compute_size_type(); |
| 118 | 118 | |
| 119 | 119 | void *m_pixels; // pixels for the texture |
| 120 | 120 | int m_pitch; |
| r243234 | r243235 | |
| 125 | 125 | osd_ticks_t m_last_access; |
| 126 | 126 | |
| 127 | 127 | int raw_width() const { return m_texinfo.width; } |
| 128 | | int raw_height() const { return m_texinfo.height; } |
| 128 | int raw_height() const { return m_texinfo.height; } |
| 129 | 129 | |
| 130 | | texture_info *next() { return m_next; } |
| 131 | | const render_texinfo &texinfo() const { return m_texinfo; } |
| 132 | | render_texinfo &texinfo() { return m_texinfo; } |
| 130 | texture_info *next() { return m_next; } |
| 131 | const render_texinfo &texinfo() const { return m_texinfo; } |
| 132 | render_texinfo &texinfo() { return m_texinfo; } |
| 133 | 133 | |
| 134 | | const HashT hash() const { return m_hash; } |
| 135 | | const UINT32 flags() const { return m_flags; } |
| 136 | | const bool is_pixels_owned() const { // do we own / allocated it ? |
| 137 | | return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) |
| 138 | | && (m_copyinfo->func != NULL)) ; |
| 139 | | } |
| 134 | const HashT hash() const { return m_hash; } |
| 135 | const UINT32 flags() const { return m_flags; } |
| 136 | // 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 | } |
| 140 | 141 | |
| 141 | 142 | private: |
| 142 | | Uint32 m_sdl_access; |
| 143 | | SDL_Renderer * m_renderer; |
| 144 | | render_texinfo m_texinfo; // copy of the texture info |
| 145 | | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 146 | | UINT32 m_flags; // rendering flags |
| 143 | Uint32 m_sdl_access; |
| 144 | SDL_Renderer * m_renderer; |
| 145 | render_texinfo m_texinfo; // copy of the texture info |
| 146 | HashT m_hash; // hash value for the texture (must be >= pointer size) |
| 147 | UINT32 m_flags; // rendering flags |
| 147 | 148 | |
| 148 | | SDL_Texture * m_texture_id; |
| 149 | | int m_is_rotated; |
| 149 | SDL_Texture * m_texture_id; |
| 150 | int m_is_rotated; |
| 150 | 151 | |
| 151 | | int m_format; // texture format |
| 152 | | SDL_BlendMode m_sdl_blendmode; |
| 152 | int m_format; // texture format |
| 153 | SDL_BlendMode m_sdl_blendmode; |
| 153 | 154 | |
| 154 | | texture_info * m_next; // next texture in the list |
| 155 | texture_info * m_next; // next texture in the list |
| 155 | 156 | }; |
| 156 | 157 | |
| 157 | 158 | /* sdl_info is the information about SDL for the current screen */ |
| 158 | 159 | struct sdl_info |
| 159 | 160 | { |
| 160 | | sdl_info() |
| 161 | | : m_blittimer(0), m_renderer(NULL), |
| 162 | | m_hofs(0), m_vofs(0), |
| 163 | | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 164 | | m_last_blit_time(0), m_last_blit_pixels(0) |
| 165 | | {} |
| 161 | sdl_info() |
| 162 | : m_blittimer(0), m_renderer(NULL), |
| 163 | m_hofs(0), m_vofs(0), |
| 164 | m_resize_pending(0), m_resize_width(0), m_resize_height(0), |
| 165 | m_last_blit_time(0), m_last_blit_pixels(0) |
| 166 | {} |
| 166 | 167 | |
| 167 | | void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); |
| 168 | void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); |
| 168 | 169 | |
| 169 | | texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); |
| 170 | | texture_info *texture_update(const render_primitive &prim); |
| 170 | texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); |
| 171 | texture_info *texture_update(const render_primitive &prim); |
| 171 | 172 | |
| 172 | 173 | INT32 m_blittimer; |
| 173 | 174 | |
| r243234 | r243235 | |
| 227 | 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} |
| 228 | 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} |
| 229 | 230 | |
| 231 | |
| 230 | 232 | static copy_info_t blit_info_default[] = |
| 231 | 233 | { |
| 232 | 234 | /* no rotation */ |
| r243234 | r243235 | |
| 283 | 285 | ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32), |
| 284 | 286 | ENTRY(RGB32_PALETTED, RGB888, 4, 1, rot_rgb32pal_argb32), |
| 285 | 287 | |
| 286 | | ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32), |
| 287 | | ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32), |
| 288 | ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32rot), |
| 289 | ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32rot), |
| 288 | 290 | |
| 289 | | ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32), |
| 290 | | ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32), |
| 291 | ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32rot), |
| 292 | ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32rot), |
| 291 | 293 | |
| 292 | 294 | ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32), |
| 293 | 295 | ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32), |