Converted blit13.h to templates and fixed a number of bugs around

different ycc formats. (nw)
This commit is contained in:
couriersud 2015-01-29 00:29:17 +01:00
parent 86819fa913
commit 0ef3771202
2 changed files with 202 additions and 182 deletions

View File

@ -5,42 +5,44 @@
// INLINE // INLINE
//============================================================ //============================================================
INLINE UINT32 premult32(UINT32 pixel) inline UINT32 premult32(const UINT32 pixel)
{ {
UINT8 a = (pixel >> 24) & 0xff; const UINT16 a = (pixel >> 24) & 0xff;
UINT8 r = (pixel >> 16) & 0xff; const UINT16 r = (pixel >> 16) & 0xff;
UINT8 g = (pixel >> 8) & 0xff; const UINT16 g = (pixel >> 8) & 0xff;
UINT8 b = (pixel >> 0) & 0xff; const UINT16 b = (pixel >> 0) & 0xff;
return 0xFF000000 | return 0xFF000000 |
(((UINT16)r * (UINT16)a) / 255) << 16 | ((r * a) / 255) << 16 |
(((UINT16)g * (UINT16)a) / 255) << 8 | ((g * a) / 255) << 8 |
(((UINT16)b * (UINT16)a) / 255); ((b * a) / 255);
} }
#define CLUL(x) ((int) (x) < 0 ? 0 : ((x) > 65535 ? 255 : (x)>>8)) inline UINT32 CLUL(const UINT32 x)
INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr)
{ {
unsigned int r, g, b, common; return ((INT32) x < 0) ? 0 : ((x > 65535) ? 255 : x >> 8);
}
common = 298 * y - 56992; inline UINT32 ycc_to_rgb(const UINT8 y, const UINT8 cb, const UINT8 cr)
r = (common + 409 * cr); {
g = (common - 100 * cb - 208 * cr + 91776); const UINT32 common = 298 * y - 56992;
b = (common + 516 * cb - 13696); const UINT32 r = (common + 409 * cr);
const UINT32 g = (common - 100 * cb - 208 * cr + 91776);
const UINT32 b = (common + 516 * cb - 13696);
return 0xff000000 | (CLUL(r)<<16) | (CLUL(g)<<8) | (CLUL(b)); return 0xff000000 | (CLUL(r)<<16) | (CLUL(g)<<8) | (CLUL(b));
} }
INLINE UINT32 pixel_ycc_to_rgb(UINT16 *pixel) inline UINT32 pixel_ycc_to_rgb(const UINT16 *pixel)
{ {
UINT32 p = *(UINT32 *)((FPTR) pixel & ~1);
const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
return ycc_to_rgb((*pixel >> 8) & 0xff, (p) & 0xff, (p>>16) & 0xff); return ycc_to_rgb((*pixel >> 8) & 0xff, (p) & 0xff, (p>>16) & 0xff);
} }
INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette) inline UINT32 pixel_ycc_to_rgb_pal(const UINT16 *pixel, const rgb_t *palette)
{ {
UINT32 p = *(UINT32 *)((FPTR) pixel & ~1); const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
return ycc_to_rgb(palette[(*pixel >> 8) & 0xff], (p) & 0xff, (p>>16) & 0xff); return ycc_to_rgb(palette[(*pixel >> 8) & 0xff], (p) & 0xff, (p>>16) & 0xff);
} }
@ -48,157 +50,173 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
// Pixel conversions // Pixel conversions
//============================================================ //============================================================
#define OP_ARGB32_ARGB32(_src) (_src)
#define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000) #define FUNC_DEF(source) op(const source &src, const rgb_t *palbase)
#define FUNCTOR(name, x...) \
template<typename _source, typename _dest> \
struct name { _dest FUNC_DEF(_source) { x } };
#define OP_RGB32PAL_ARGB32(_src) \ FUNCTOR(op_argb32_argb32, return src; )
(palbase[0x200 + (((_src) >> 16) & 0xff) ] | \ FUNCTOR(op_rgb32_argb32, return src | 0xff000000; )
palbase[0x100 + (((_src) >> 8) & 0xff) ] | \ FUNCTOR(op_pal16_argb32, return 0xff000000 |palbase[src]; )
palbase[((_src) & 0xff) ] | 0xff000000) FUNCTOR(op_pal16_rgb32, return palbase[src]; )
FUNCTOR(op_rgb32pal_argb32,
return palbase[0x200 + (((src) >> 16) & 0xff) ] |
palbase[0x100 + (((src) >> 8) & 0xff) ] |
palbase[((src) & 0xff) ] | 0xff000000; )
#define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src]) FUNCTOR(op_pal16a_argb32, return palbase[src]; )
#define OP_PAL16A_ARGB32(_src) (palbase[_src]) FUNCTOR(op_rgb15_argb32,
return 0xff000000 | ((src & 0x7c00) << 9) | ((src & 0x03e0) << 6)
| ((src & 0x001f) << 3) | ((((src & 0x7c00) << 9)
| ((src & 0x03e0) << 6) | ((src & 0x001f) << 3) >> 5) & 0x070707); )
#define OP_RGB15_ARGB32(_src) (0xff000000 | ((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) | \ FUNCTOR(op_rgb15pal_argb32,
((((_src & 0x7c00) << 9) | ((_src & 0x03e0) << 6) | ((_src & 0x001f) << 3) >> 5) & 0x070707)) return 0xff000000 | palbase[0x40 + ((src >> 10) & 0x1f)] |
palbase[0x20 + ((src >> 5) & 0x1f)] | palbase[0x00 + ((src >> 0) & 0x1f)]; )
#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \ FUNCTOR(op_argb32_rgb32, return premult32(src); )
palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)]) FUNCTOR(op_pal16a_rgb32, return premult32(palbase[src]); )
FUNCTOR(op_pal16_argb1555,
return (palbase[src]&0xf80000) >> 9 |
(palbase[src]&0x00f800) >> 6 |
(palbase[src]&0x0000f8) >> 3 | 0x8000; )
#define OP_ARGB32_RGB32(_pixel) premult32(_pixel) FUNCTOR(op_rgb15_argb1555, return src | 0x8000; )
#define OP_PAL16A_RGB32(_src) premult32(palbase[_src]) FUNCTOR(op_rgb15pal_argb1555,
return (palbase[src >> 10] & 0xf8) << 7 |
(palbase[(src >> 5) & 0x1f] & 0xf8) << 2 |
(palbase[src & 0x1f] & 0xf8) >> 3 | 0x8000; )
#define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \ FUNCTOR(op_yuv16_uyvy, return src; )
(palbase[_src]&0x00f800) >> 6 | \ FUNCTOR(op_yuv16pal_uyvy, return (palbase[(src >> 8) & 0xff] << 8) | (src & 0x00ff); )
(palbase[_src]&0x0000f8) >> 3 | 0x8000)
#define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000) // FIXME: wrong ... see non_pal version
FUNCTOR(op_yuv16pal_yvyu, return (palbase[(src >> 8) & 0xff] & 0xff) | ((src & 0xff) << 8); )
FUNCTOR(op_yuv16_yvyu, return ((src & 0xff00ff00) >> 8 ) | (src << 24) | ((src >> 8) & 0x00ff00); )
#define OP_RGB15PAL_ARGB1555(_src) ((palbase[(_src) >> 10] & 0xf8) << 7 | \ FUNCTOR(op_yuv16_yuy2, return ((src & 0xff00ff00) >> 8) | ((src & 0x00ff00ff) << 8); )
(palbase[((_src) >> 5) & 0x1f] & 0xf8) << 2 | \
(palbase[(_src) & 0x1f] & 0xf8) >> 3 | 0x8000)
#define OP_YUV16_UYVY(_src) (_src) FUNCTOR(op_yuv16pal_yuy2,
return (palbase[(src>>8) & 0xff]) |
(palbase[(src>>24) & 0xff]<<16) |
((src<<8)&0xff00ff00);)
#define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff)) FUNCTOR(op_yuv16_argb32,
return (UINT64) ycc_to_rgb((src >> 8) & 0xff, src & 0xff , (src>>16) & 0xff)
| ((UINT64)ycc_to_rgb((src >> 24) & 0xff, src & 0xff , (src>>16) & 0xff) << 32); )
#define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8)) FUNCTOR(op_yuv16pal_argb32,
return (UINT64)ycc_to_rgb(palbase[(src >> 8) & 0xff], src & 0xff , (src>>16) & 0xff)
| ((UINT64)ycc_to_rgb(palbase[(src >> 24) & 0xff], src & 0xff , (src>>16) & 0xff) << 32);)
#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8)) FUNCTOR(op_yuv16_argb32rot, return pixel_ycc_to_rgb(&src) ; )
#define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \ FUNCTOR(op_yuv16pal_argb32rot, return pixel_ycc_to_rgb_pal(&src, palbase); )
(((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) )
#define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \
(palbase[((_src)>>24) & 0xff]<<16) | \
(((_src)<<8)&0xff00ff00) )
#define OP_YUV16_ARGB32(_src) \
(UINT64) ycc_to_rgb(((_src) >> 8) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) \
| ((UINT64)ycc_to_rgb(((_src) >> 24) & 0xff, (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16PAL_ARGB32(_src) \
(UINT64)ycc_to_rgb(palbase[((_src) >> 8) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) \
| ((UINT64)ycc_to_rgb(palbase[((_src) >> 24) & 0xff], (_src) & 0xff , ((_src)>>16) & 0xff) << 32)
#define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src))
#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase)
//============================================================ //============================================================
// Copy and rotation // Copy and rotation
//============================================================ //============================================================
#define TEXCOPY_M( _name, _src_type, _dest_type, _op, _len_div) \ template<typename _src_type, typename _dest_type, typename _op, int _len_div>
INLINE void texcopy_##_name (const texture_info *texture, const render_texinfo *texsource) { \ void texcopy(const texture_info *texture, const render_texinfo *texsource)
ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ {
int x, y; \ ATTR_UNUSED const rgb_t *palbase = texsource->palette();
/* loop over Y */ \ int x, y;
for (y = 0; y < texsource->height; y++) { \ _op op;
_src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div); \ /* loop over Y */
_dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); \ for (y = 0; y < texsource->height; y++) {
x = texsource->width / (_len_div); \ _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div);
while (x > 0) { \ _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
*dst++ = _op(*src); \ x = texsource->width / (_len_div);
src++; \ while (x > 0) {
x--; \ *dst++ = op.op(*src, palbase);
} \ src++;
} \ x--;
}
}
} }
#define TEXCOPY( _name, _src_type, _dest_type, _op) \ #define TEXCOPYA(a, b, c, d) \
TEXCOPY_M( _name, _src_type, _dest_type, _op, 1) inline void texcopy_ ## a(const texture_info *texture, const render_texinfo *texsource) \
{ return texcopy<b, c, op_ ## a <b, c>, d>(texture, texsource); }
#define TEXROT( _name, _src_type, _dest_type, _op) \ template<typename _src_type, typename _dest_type, typename _op>
INLINE void texcopy_rot_##_name (const texture_info *texture, const render_texinfo *texsource) { \ void texcopy_rot(const texture_info *texture, const render_texinfo *texsource)
ATTR_UNUSED const rgb_t *palbase = texsource->palette(); \ {
int x, y; \ ATTR_UNUSED const rgb_t *palbase = texsource->palette();
const quad_setup_data *setup = &texture->m_setup; \ int x, y;
int dudx = setup->dudx; \ const quad_setup_data *setup = &texture->m_setup;
int dvdx = setup->dvdx; \ int dudx = setup->dudx;
/* loop over Y */ \ int dvdx = setup->dvdx;
for (y = 0; y < setup->rotheight; y++) { \ _op op;
INT32 curu = setup->startu + y * setup->dudy; \ /* loop over Y */
INT32 curv = setup->startv + y * setup->dvdy; \ for (y = 0; y < setup->rotheight; y++) {
_dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch); \ INT32 curu = setup->startu + y * setup->dudy;
x = setup->rotwidth; \ INT32 curv = setup->startv + y * setup->dvdy;
while (x>0) { \ _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
_src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16); \ x = setup->rotwidth;
*dst++ = _op(*src); \ while (x>0) {
curu += dudx; \ _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16);
curv += dvdx; \ *dst++ = op.op(*src, palbase);
x--; \ curu += dudx;
} \ curv += dvdx;
} \ x--;
}
}
} }
//TEXCOPY(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32) #define TEXROTA(a, b, c) \
inline void texcopy_rot_ ## a(const texture_info *texture, const render_texinfo *texsource) \
{ return texcopy_rot<b, c, op_ ## a <b, c> >(texture, texsource); }
TEXCOPY(rgb32_argb32, UINT32, UINT32, OP_RGB32_ARGB32) TEXCOPYA(rgb32_argb32, UINT32, UINT32, 1)
TEXCOPY(rgb32pal_argb32, UINT32, UINT32, OP_RGB32PAL_ARGB32) TEXCOPYA(rgb32pal_argb32, UINT32, UINT32, 1)
TEXCOPY(pal16_argb32, UINT16, UINT32, OP_PAL16_ARGB32) TEXCOPYA(pal16_argb32, UINT16, UINT32, 1)
TEXCOPY(pal16a_argb32, UINT16, UINT32, OP_PAL16A_ARGB32) TEXCOPYA(pal16a_argb32, UINT16, UINT32, 1)
TEXCOPY(rgb15_argb32, UINT16, UINT32, OP_RGB15_ARGB32) TEXCOPYA(rgb15_argb32, UINT16, UINT32, 1)
TEXCOPY(rgb15pal_argb32, UINT16, UINT32, OP_RGB15PAL_ARGB32) TEXCOPYA(rgb15pal_argb32, UINT16, UINT32, 1)
TEXCOPY(pal16_argb1555, UINT16, UINT16, OP_PAL16_ARGB1555) TEXCOPYA(pal16_argb1555, UINT16, UINT16, 1)
TEXCOPY(rgb15_argb1555, UINT16, UINT16, OP_RGB15_ARGB1555) TEXCOPYA(rgb15_argb1555, UINT16, UINT16, 1)
TEXCOPY(rgb15pal_argb1555, UINT16, UINT16, OP_RGB15PAL_ARGB1555) TEXCOPYA(rgb15pal_argb1555, UINT16, UINT16, 1)
TEXCOPY(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32) TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1)
TEXCOPY(pal16a_rgb32, UINT16, UINT32, OP_PAL16A_RGB32) TEXCOPYA(pal16a_rgb32, UINT16, UINT32, 1)
TEXCOPY_M(yuv16_argb32, UINT32, UINT64, OP_YUV16_ARGB32, 2) TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2)
TEXCOPY_M(yuv16pal_argb32, UINT32, UINT64, OP_YUV16PAL_ARGB32, 2) TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2)
//TEXCOPY(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY) //TEXCOPYA(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY)
TEXCOPY(yuv16pal_uyvy, UINT16, UINT16, OP_YUV16PAL_UYVY) TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1)
TEXCOPY(yuv16_yvyu, UINT16, UINT16, OP_YUV16_YVYU) TEXCOPYA(yuv16_yvyu, UINT32, UINT32, 2)
TEXCOPY(yuv16pal_yvyu, UINT16, UINT16, OP_YUV16PAL_YVYU) TEXCOPYA(yuv16pal_yvyu, UINT16, UINT16, 1)
TEXCOPY_M(yuv16_yuy2, UINT32, UINT32, OP_YUV16_YUY2, 2) TEXCOPYA(yuv16_yuy2, UINT32, UINT32, 2)
TEXCOPY_M(yuv16pal_yuy2, UINT32, UINT32, OP_YUV16PAL_YUY2, 2) TEXCOPYA(yuv16pal_yuy2, UINT32, UINT32, 2)
TEXROT(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32)
TEXROT(rgb32_argb32, UINT32, UINT32, OP_RGB32_ARGB32)
TEXROT(rgb32pal_argb32, UINT32, UINT32, OP_RGB32PAL_ARGB32)
TEXROT(pal16_argb32, UINT16, UINT32, OP_PAL16_ARGB32)
TEXROT(pal16a_argb32, UINT16, UINT32, OP_PAL16A_ARGB32)
TEXROT(rgb15_argb32, UINT16, UINT32, OP_RGB15_ARGB32)
TEXROT(rgb15pal_argb32, UINT16, UINT32, OP_RGB15PAL_ARGB32)
TEXROT(pal16_argb1555, UINT16, UINT16, OP_PAL16_ARGB1555) TEXROTA(argb32_argb32, UINT32, UINT32)
TEXROT(rgb15_argb1555, UINT16, UINT16, OP_RGB15_ARGB1555) TEXROTA(rgb32_argb32, UINT32, UINT32)
TEXROT(rgb15pal_argb1555, UINT16, UINT16, OP_RGB15PAL_ARGB1555) TEXROTA(pal16_argb32, UINT16, UINT32)
TEXROTA(pal16_rgb32, UINT16, UINT32)
TEXROT(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32) TEXROTA(rgb32pal_argb32, UINT32, UINT32)
TEXROT(pal16a_rgb32, UINT16, UINT32, OP_PAL16A_RGB32) TEXROTA(pal16a_argb32, UINT16, UINT32)
TEXROTA(rgb15_argb32, UINT16, UINT32)
TEXROTA(rgb15pal_argb32, UINT16, UINT32)
TEXROT(yuv16_argb32, UINT16, UINT32, OP_YUV16_ARGB32ROT) TEXROTA(pal16_argb1555, UINT16, UINT16)
TEXROT(yuv16pal_argb32, UINT16, UINT32, OP_YUV16PAL_ARGB32ROT) TEXROTA(rgb15_argb1555, UINT16, UINT16)
TEXROTA(rgb15pal_argb1555, UINT16, UINT16)
TEXROTA(argb32_rgb32, UINT32, UINT32)
TEXROTA(pal16a_rgb32, UINT16, UINT32)
TEXROTA(yuv16_argb32rot, UINT16, UINT32)
TEXROTA(yuv16pal_argb32rot, UINT16, UINT32)

View File

@ -48,12 +48,12 @@ enum
static inline bool is_opaque(const float &a) static inline bool is_opaque(const float &a)
{ {
return (a >= 1.0f); return (a >= 1.0f);
} }
static inline bool is_transparent(const float &a) static inline bool is_transparent(const float &a)
{ {
return (a < 0.0001f); return (a < 0.0001f);
} }
//============================================================ //============================================================
@ -63,11 +63,11 @@ static inline bool is_transparent(const float &a)
struct quad_setup_data struct quad_setup_data
{ {
quad_setup_data() quad_setup_data()
: dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0), : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
rotwidth(0), rotheight(0) rotwidth(0), rotheight(0)
{} {}
void compute(const render_primitive &prim); void compute(const render_primitive &prim);
INT32 dudx, dvdx, dudy, dvdy; INT32 dudx, dvdx, dudy, dvdy;
INT32 startu, startv; INT32 startu, startv;
@ -105,16 +105,16 @@ struct sdl_info;
/* texture_info holds information about a texture */ /* texture_info holds information about a texture */
class texture_info class texture_info
{ {
friend class simple_list<texture_info>; friend class simple_list<texture_info>;
public: public:
texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags); texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
~texture_info(); ~texture_info();
void set_data(const render_texinfo &texsource, const UINT32 flags); void set_data(const render_texinfo &texsource, const UINT32 flags);
void render_quad(const render_primitive *prim, const int x, const int y); void render_quad(const render_primitive *prim, const int x, const int y);
bool matches(const render_primitive &prim, const quad_setup_data &setup); bool matches(const render_primitive &prim, const quad_setup_data &setup);
copy_info_t *compute_size_type(); copy_info_t *compute_size_type();
void *m_pixels; // pixels for the texture void *m_pixels; // pixels for the texture
int m_pitch; int m_pitch;
@ -125,49 +125,50 @@ public:
osd_ticks_t m_last_access; osd_ticks_t m_last_access;
int raw_width() const { return m_texinfo.width; } int raw_width() const { return m_texinfo.width; }
int raw_height() const { return m_texinfo.height; } int raw_height() const { return m_texinfo.height; }
texture_info *next() { return m_next; } texture_info *next() { return m_next; }
const render_texinfo &texinfo() const { return m_texinfo; } const render_texinfo &texinfo() const { return m_texinfo; }
render_texinfo &texinfo() { return m_texinfo; } render_texinfo &texinfo() { return m_texinfo; }
const HashT hash() const { return m_hash; } const HashT hash() const { return m_hash; }
const UINT32 flags() const { return m_flags; } const UINT32 flags() const { return m_flags; }
const bool is_pixels_owned() const { // do we own / allocated it ? // FIXME:
return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC) const bool is_pixels_owned() const { // do we own / allocated it ?
&& (m_copyinfo->func != NULL)) ; return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
} && (m_copyinfo->func != NULL)) ;
}
private: private:
Uint32 m_sdl_access; Uint32 m_sdl_access;
SDL_Renderer * m_renderer; SDL_Renderer * m_renderer;
render_texinfo m_texinfo; // copy of the texture info render_texinfo m_texinfo; // copy of the texture info
HashT m_hash; // hash value for the texture (must be >= pointer size) HashT m_hash; // hash value for the texture (must be >= pointer size)
UINT32 m_flags; // rendering flags UINT32 m_flags; // rendering flags
SDL_Texture * m_texture_id; SDL_Texture * m_texture_id;
int m_is_rotated; int m_is_rotated;
int m_format; // texture format int m_format; // texture format
SDL_BlendMode m_sdl_blendmode; SDL_BlendMode m_sdl_blendmode;
texture_info * m_next; // next texture in the list texture_info * m_next; // next texture in the list
}; };
/* sdl_info is the information about SDL for the current screen */ /* sdl_info is the information about SDL for the current screen */
struct sdl_info struct sdl_info
{ {
sdl_info() sdl_info()
: m_blittimer(0), m_renderer(NULL), : m_blittimer(0), m_renderer(NULL),
m_hofs(0), m_vofs(0), m_hofs(0), m_vofs(0),
m_resize_pending(0), m_resize_width(0), m_resize_height(0), m_resize_pending(0), m_resize_width(0), m_resize_height(0),
m_last_blit_time(0), m_last_blit_pixels(0) m_last_blit_time(0), m_last_blit_pixels(0)
{} {}
void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y); void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup); texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
texture_info *texture_update(const render_primitive &prim); texture_info *texture_update(const render_primitive &prim);
INT32 m_blittimer; INT32 m_blittimer;
@ -227,6 +228,7 @@ static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, i
#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} #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}
#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} #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}
static copy_info_t blit_info_default[] = static copy_info_t blit_info_default[] =
{ {
/* no rotation */ /* no rotation */
@ -283,11 +285,11 @@ static copy_info_t blit_info_default[] =
ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32), ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32),
ENTRY(RGB32_PALETTED, RGB888, 4, 1, rot_rgb32pal_argb32), ENTRY(RGB32_PALETTED, RGB888, 4, 1, rot_rgb32pal_argb32),
ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32), ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32rot),
ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32), ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32rot),
ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32), ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32rot),
ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32), ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32rot),
ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32), ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32),
ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32), ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32),