Previous 199869 Revisions Next

r34728 Thursday 29th January, 2015 at 22:25:01 UTC by Couriersud
Merge pull request #124 from 0-wiz-0/master

Define network API to use on NetBSD.
[src/osd/sdl]blit13.h draw13.c sdlmain.c video.h

trunk/src/osd/sdl/blit13.h
r243239r243240
55//  INLINE
66//============================================================
77
8INLINE UINT32 premult32(UINT32 pixel)
8inline UINT32 premult32(const UINT32 pixel)
99{
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;
1414
1515   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);
1919}
2020
21#define CLUL(x) ((int) (x) < 0 ? 0 : ((x) > 65535 ? 255 : (x)>>8))
21inline UINT32 CLUL(const UINT32 x)
22{
23   return ((INT32) x < 0) ? 0 : ((x > 65535) ? 255 : x >> 8);
24}
2225
23INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr)
26inline UINT32 ycc_to_rgb(const UINT8 y, const UINT8 cb, const UINT8 cr)
2427{
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);
2632
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
3233   return 0xff000000 | (CLUL(r)<<16) | (CLUL(g)<<8) | (CLUL(b));
3334}
3435
35INLINE UINT32 pixel_ycc_to_rgb(UINT16 *pixel)
36inline UINT32 pixel_ycc_to_rgb(const UINT16 *pixel)
3637{
37   UINT32 p = *(UINT32 *)((FPTR) pixel & ~1);
38
39   const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
3840   return ycc_to_rgb((*pixel >> 8) & 0xff, (p) & 0xff, (p>>16) & 0xff);
3941}
4042
41INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
43inline UINT32 pixel_ycc_to_rgb_pal(const UINT16 *pixel, const rgb_t *palette)
4244{
43   UINT32 p = *(UINT32 *)((FPTR) pixel & ~1);
45   const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
4446   return ycc_to_rgb(palette[(*pixel >> 8) & 0xff], (p) & 0xff, (p>>16) & 0xff);
4547}
4648
r243239r243240
4850//  Pixel conversions
4951//============================================================
5052
51#define OP_ARGB32_ARGB32(_src) (_src)
5253
53#define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000)
54#define FUNC_DEF(source) op(const source &src, const rgb_t *palbase) const
55#define FUNCTOR(name, x...) \
56    template<typename _source, typename _dest> \
57    struct name { _dest FUNC_DEF(_source) { x } };
5458
55#define OP_RGB32PAL_ARGB32(_src) \
56   (palbase[0x200 + (((_src) >> 16) & 0xff) ] | \
57      palbase[0x100 + (((_src) >> 8) & 0xff) ] | \
58      palbase[((_src) & 0xff) ] | 0xff000000)
59FUNCTOR(op_argb32_argb32, return src; )
60FUNCTOR(op_rgb32_argb32,  return src | 0xff000000; )
61FUNCTOR(op_pal16_argb32,  return 0xff000000 |palbase[src]; )
62FUNCTOR(op_pal16_rgb32,   return palbase[src]; )
63FUNCTOR(op_rgb32pal_argb32,
64    return palbase[0x200 + (((src) >> 16) & 0xff) ] |
65        palbase[0x100 + (((src) >> 8) & 0xff) ] |
66        palbase[((src) & 0xff) ] | 0xff000000; )
5967
60#define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src])
68FUNCTOR(op_pal16a_argb32, return palbase[src]; )
6169
62#define OP_PAL16A_ARGB32(_src) (palbase[_src])
70FUNCTOR(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); )
6374
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))
75FUNCTOR(op_rgb15pal_argb32,
76      return 0xff000000 | palbase[0x40 + ((src >> 10) & 0x1f)] |
77        palbase[0x20 + ((src >> 5) & 0x1f)] | palbase[0x00 + ((src >> 0) & 0x1f)]; )
6678
67#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \
68      palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)])
79FUNCTOR(op_argb32_rgb32, return premult32(src); )
80FUNCTOR(op_pal16a_rgb32, return premult32(palbase[src]); )
81FUNCTOR(op_pal16_argb1555,
82      return (palbase[src]&0xf80000) >> 9 |
83            (palbase[src]&0x00f800) >> 6 |
84            (palbase[src]&0x0000f8) >> 3 | 0x8000; )
6985
70#define OP_ARGB32_RGB32(_pixel) premult32(_pixel)
86FUNCTOR(op_rgb15_argb1555, return src | 0x8000; )
7187
72#define OP_PAL16A_RGB32(_src) premult32(palbase[_src])
88FUNCTOR(op_rgb15pal_argb1555,
89      return (palbase[src >> 10] & 0xf8) << 7 |
90            (palbase[(src >> 5) & 0x1f] & 0xf8) << 2 |
91            (palbase[src & 0x1f] & 0xf8) >> 3 | 0x8000; )
7392
74#define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \
75         (palbase[_src]&0x00f800) >> 6 | \
76         (palbase[_src]&0x0000f8) >> 3 | 0x8000)
93FUNCTOR(op_yuv16_uyvy, return src; )
94FUNCTOR(op_yuv16pal_uyvy, return (palbase[(src >> 8) & 0xff] << 8) | (src & 0x00ff); )
7795
78#define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000)
96// FIXME: wrong ... see non_pal version
97FUNCTOR(op_yuv16pal_yvyu, return (palbase[(src >> 8) & 0xff] & 0xff) | ((src & 0xff) << 8); )
98FUNCTOR(op_yuv16_yvyu, return ((src & 0xff00ff00) >> 8 ) | (src << 24) | ((src >> 8) & 0x00ff00); )
7999
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)
100FUNCTOR(op_yuv16_yuy2, return ((src & 0xff00ff00) >> 8) | ((src & 0x00ff00ff) << 8); )
83101
84#define OP_YUV16_UYVY(_src) (_src)
102FUNCTOR(op_yuv16pal_yuy2,
103      return  (palbase[(src>>8) & 0xff]) |
104            (palbase[(src>>24) & 0xff]<<16) |
105            ((src<<8)&0xff00ff00);)
85106
86#define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff))
107FUNCTOR(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); )
87110
88#define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8))
111FUNCTOR(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);)
89114
90#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8))
115FUNCTOR(op_yuv16_argb32rot, return pixel_ycc_to_rgb(&src) ; )
91116
92#define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \
93   (((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) )
117FUNCTOR(op_yuv16pal_argb32rot, return pixel_ycc_to_rgb_pal(&src, palbase); )
94118
95#define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \
96      (palbase[((_src)>>24) & 0xff]<<16) | \
97   (((_src)<<8)&0xff00ff00) )
119//============================================================
120//  Copy and rotation
121//============================================================
98122
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)
123struct blit_base {
102124
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)
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() { }
106129
107#define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src))
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};
108135
109#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase)
136template<typename _src_type, typename _dest_type, typename _op, int _len_div>
137struct blit_texcopy : public blit_base
138{
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    }
156private:
157    _op m_op;
158};
110159
111//============================================================
112//  Copy and rotation
113//============================================================
160#define TEXCOPYA(a, b, c, d) \
161      const struct blit_texcopy<b, c, op_ ## a <b, c>, d> texcopy_ ## a;
114162
115#define TEXCOPY_M( _name, _src_type, _dest_type,  _op, _len_div) \
116INLINE 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   } \
130}
163template<typename _src_type, typename _dest_type, typename _op>
164struct blit_texrot : public blit_base
165{
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   }
189private:
190    _op m_op;
191};
131192
132#define TEXCOPY( _name, _src_type, _dest_type,  _op) \
133   TEXCOPY_M( _name, _src_type, _dest_type,  _op, 1)
193#define TEXROTA(a, b, c) \
194      const struct blit_texrot<b, c, op_ ## a <b, c> > texcopy_rot_ ## a;
134195
135#define TEXROT( _name, _src_type, _dest_type, _op) \
136INLINE 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   } \
156}
196template<typename _src_type, typename _dest_type>
197struct 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};
157204
158//TEXCOPY(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32)
205#define TEXCOPYP(a, b, c) \
206      const struct blit_texpass<b, c> texcopy_ ## a;
159207
160TEXCOPY(rgb32_argb32,  UINT32, UINT32, OP_RGB32_ARGB32)
161TEXCOPY(rgb32pal_argb32,  UINT32, UINT32, OP_RGB32PAL_ARGB32)
162TEXCOPY(pal16_argb32,  UINT16, UINT32, OP_PAL16_ARGB32)
163TEXCOPY(pal16a_argb32,  UINT16, UINT32, OP_PAL16A_ARGB32)
164TEXCOPY(rgb15_argb32,  UINT16, UINT32, OP_RGB15_ARGB32)
165TEXCOPY(rgb15pal_argb32,  UINT16, UINT32, OP_RGB15PAL_ARGB32)
166208
167TEXCOPY(pal16_argb1555,  UINT16, UINT16, OP_PAL16_ARGB1555)
168TEXCOPY(rgb15_argb1555,  UINT16, UINT16, OP_RGB15_ARGB1555)
169TEXCOPY(rgb15pal_argb1555,  UINT16, UINT16, OP_RGB15PAL_ARGB1555)
209TEXCOPYA(rgb32_argb32,  UINT32, UINT32, 1)
210TEXCOPYP(rgb32_rgb32,   UINT32, UINT32)
170211
171TEXCOPY(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32)
172TEXCOPY(pal16a_rgb32,  UINT16, UINT32, OP_PAL16A_RGB32)
212TEXCOPYA(rgb32pal_argb32,  UINT32, UINT32, 1)
213TEXCOPYA(pal16_argb32,  UINT16, UINT32, 1)
214TEXCOPYA(pal16a_argb32,  UINT16, UINT32, 1)
215TEXCOPYA(rgb15_argb32,  UINT16, UINT32, 1)
216TEXCOPYA(rgb15pal_argb32,  UINT16, UINT32, 1)
173217
174TEXCOPY_M(yuv16_argb32, UINT32, UINT64, OP_YUV16_ARGB32, 2)
175TEXCOPY_M(yuv16pal_argb32, UINT32, UINT64, OP_YUV16PAL_ARGB32, 2)
218TEXCOPYA(pal16_argb1555,  UINT16, UINT16, 1)
219TEXCOPYA(rgb15_argb1555,  UINT16, UINT16, 1)
220TEXCOPYA(rgb15pal_argb1555,  UINT16, UINT16, 1)
176221
177//TEXCOPY(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY)
222TEXCOPYP(argb32_argb32,  UINT32, UINT32)
223TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1)
224TEXCOPYA(pal16a_rgb32,  UINT16, UINT32, 1)
178225
179TEXCOPY(yuv16pal_uyvy, UINT16, UINT16, OP_YUV16PAL_UYVY)
226TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2)
227TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2)
180228
181TEXCOPY(yuv16_yvyu, UINT16, UINT16, OP_YUV16_YVYU)
182TEXCOPY(yuv16pal_yvyu, UINT16, UINT16, OP_YUV16PAL_YVYU)
229TEXCOPYP(yuv16_uyvy, UINT16, UINT16)
230TEXCOPYP(rgb15_rgb555, UINT16, UINT16)
183231
184TEXCOPY_M(yuv16_yuy2, UINT32, UINT32, OP_YUV16_YUY2, 2)
185TEXCOPY_M(yuv16pal_yuy2, UINT32, UINT32, OP_YUV16PAL_YUY2, 2)
232TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1)
186233
234TEXCOPYA(yuv16_yvyu, UINT32, UINT32, 2)
235TEXCOPYA(yuv16pal_yvyu, UINT16, UINT16, 1)
187236
188TEXROT(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32)
189TEXROT(rgb32_argb32,  UINT32, UINT32, OP_RGB32_ARGB32)
190TEXROT(rgb32pal_argb32,  UINT32, UINT32, OP_RGB32PAL_ARGB32)
191TEXROT(pal16_argb32,  UINT16, UINT32, OP_PAL16_ARGB32)
192TEXROT(pal16a_argb32,  UINT16, UINT32, OP_PAL16A_ARGB32)
193TEXROT(rgb15_argb32,  UINT16, UINT32, OP_RGB15_ARGB32)
194TEXROT(rgb15pal_argb32,  UINT16, UINT32, OP_RGB15PAL_ARGB32)
237TEXCOPYA(yuv16_yuy2, UINT32, UINT32, 2)
238TEXCOPYA(yuv16pal_yuy2, UINT32, UINT32, 2)
195239
196TEXROT(pal16_argb1555,  UINT16, UINT16, OP_PAL16_ARGB1555)
197TEXROT(rgb15_argb1555,  UINT16, UINT16, OP_RGB15_ARGB1555)
198TEXROT(rgb15pal_argb1555,  UINT16, UINT16, OP_RGB15PAL_ARGB1555)
199240
200TEXROT(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32)
201TEXROT(pal16a_rgb32,  UINT16, UINT32, OP_PAL16A_RGB32)
202241
203TEXROT(yuv16_argb32, UINT16, UINT32, OP_YUV16_ARGB32ROT)
204TEXROT(yuv16pal_argb32, UINT16, UINT32, OP_YUV16PAL_ARGB32ROT)
242TEXROTA(argb32_argb32, UINT32, UINT32)
243TEXROTA(rgb32_argb32,  UINT32, UINT32)
244TEXROTA(pal16_argb32,  UINT16, UINT32)
245TEXROTA(pal16_rgb32,  UINT16, UINT32)
246
247TEXROTA(rgb32pal_argb32,  UINT32, UINT32)
248TEXROTA(pal16a_argb32,  UINT16, UINT32)
249TEXROTA(rgb15_argb32,  UINT16, UINT32)
250TEXROTA(rgb15pal_argb32,  UINT16, UINT32)
251
252TEXROTA(pal16_argb1555,  UINT16, UINT16)
253TEXROTA(rgb15_argb1555,  UINT16, UINT16)
254TEXROTA(rgb15pal_argb1555,  UINT16, UINT16)
255
256TEXROTA(argb32_rgb32, UINT32, UINT32)
257TEXROTA(pal16a_rgb32,  UINT16, UINT32)
258
259TEXROTA(yuv16_argb32rot, UINT16, UINT32)
260TEXROTA(yuv16pal_argb32rot, UINT16, UINT32)
trunk/src/osd/sdl/draw13.c
r243239r243240
2424#include "osdsdl.h"
2525#include "window.h"
2626
27
2728//============================================================
2829//  DEBUGGING
2930//============================================================
r243239r243240
4849
4950static inline bool is_opaque(const float &a)
5051{
51   return (a >= 1.0f);
52    return (a >= 1.0f);
5253}
5354
5455static inline bool is_transparent(const float &a)
5556{
56   return (a <  0.0001f);
57    return (a <  0.0001f);
5758}
5859
5960//============================================================
r243239r243240
6364
6465struct quad_setup_data
6566{
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);
67    quad_setup_data()
68    : dudx(0), dvdx(0), dudy(0), dvdy(0), startu(0), startv(0),
69      rotwidth(0), rotheight(0)
70    {}
71    void compute(const render_primitive &prim);
7172
7273   INT32           dudx, dvdx, dudy, dvdy;
7374   INT32           startu, startv;
7475   INT32           rotwidth, rotheight;
7576};
7677
77class texture_info;
78
79typedef void (*texture_copy_func)(const texture_info *texture, const render_texinfo *texsource);
80
81struct 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
9978//============================================================
10079//  Textures
10180//============================================================
10281
103struct sdl_info;
82struct sdl_info13;
83struct copy_info_t;
10484
10585/* texture_info holds information about a texture */
10686class texture_info
10787{
108   friend class simple_list<texture_info>;
88    friend class simple_list<texture_info>;
10989public:
110   texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
111   ~texture_info();
90    texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
91    ~texture_info();
11292
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);
93    void set_data(const render_texinfo &texsource, const UINT32 flags);
94    void render_quad(const render_primitive *prim, const int x, const int y);
95    bool matches(const render_primitive &prim, const quad_setup_data &setup);
11696
117   copy_info_t *compute_size_type();
97    copy_info_t *compute_size_type();
11898
11999   void                *m_pixels;            // pixels for the texture
120100   int                 m_pitch;
r243239r243240
125105   osd_ticks_t         m_last_access;
126106
127107   int raw_width() const { return m_texinfo.width; }
128   int raw_height() const { return m_texinfo.height; }
108    int raw_height() const { return m_texinfo.height; }
129109
130   texture_info *next() { return m_next; }
131   const render_texinfo &texinfo() const { return m_texinfo; }
132   render_texinfo &texinfo() { return m_texinfo; }
110    texture_info *next() { return m_next; }
111    const render_texinfo &texinfo() const { return m_texinfo; }
112    render_texinfo &texinfo() { return m_texinfo; }
133113
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   }
114    const HashT hash() const { return m_hash; }
115    const UINT32 flags() const { return m_flags; }
116    // FIXME:
117    const bool is_pixels_owned() const;
140118
141119private:
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
120    Uint32              m_sdl_access;
121    SDL_Renderer *      m_renderer;
122    render_texinfo      m_texinfo;            // copy of the texture info
123    HashT               m_hash;               // hash value for the texture (must be >= pointer size)
124    UINT32              m_flags;              // rendering flags
147125
148   SDL_Texture *       m_texture_id;
149   int                 m_is_rotated;
126    SDL_Texture *       m_texture_id;
127    bool                m_is_rotated;
150128
151   int                 m_format;             // texture format
152   SDL_BlendMode       m_sdl_blendmode;
129    int                 m_format;             // texture format
130    SDL_BlendMode       m_sdl_blendmode;
153131
154   texture_info *      m_next;               // next texture in the list
132    texture_info *      m_next;               // next texture in the list
155133};
156134
135//============================================================
136//  TEXCOPY FUNCS
137//============================================================
138
139#include "blit13.h"
140
157141/* sdl_info is the information about SDL for the current screen */
158struct sdl_info
142struct sdl_info13
159143{
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   {}
144    sdl_info13()
145    : m_blittimer(0), m_renderer(NULL),
146      m_hofs(0), m_vofs(0),
147      m_resize_pending(0), m_resize_width(0), m_resize_height(0),
148      m_last_blit_time(0), m_last_blit_pixels(0)
149    {}
166150
167   void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
151    void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
168152
169   texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
170   texture_info *texture_update(const render_primitive &prim);
153    texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
154    texture_info *texture_update(const render_primitive &prim);
171155
172156   INT32           m_blittimer;
173157
r243239r243240
191175   SDL_DisplayMode m_original_mode;
192176};
193177
178struct 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
194194//============================================================
195195//  PROTOTYPES
196196//============================================================
r243239r243240
209209static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
210210
211211//============================================================
212//  TEXCOPY FUNCS
213//============================================================
214
215#include "blit13.h"
216
217//============================================================
218212//  STATIC VARIABLES
219213//============================================================
220214
r243239r243240
222216#define BM_ALL (-1)
223217//( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD)
224218
225#define texcopy_NULL NULL
226#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}
227#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#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}
229222
230223static copy_info_t blit_info_default[] =
231224{
232225   /* no rotation */
233   ENTRY(ARGB32,           ARGB8888,   4, 0, NULL),
234   ENTRY_LR(ARGB32,        RGB888,     4, 0, argb32_rgb32),
226   ENTRY(ARGB32,            ARGB8888,   argb32_argb32),
227   ENTRY_LR(ARGB32,        RGB888,     argb32_rgb32),
235228   /* Entry primarily for directfb */
236   ENTRY_BM(ARGB32,        RGB888,     4, 0, argb32_rgb32, SDL_BLENDMODE_ADD),
237   ENTRY_BM(ARGB32,        RGB888,     4, 0, argb32_rgb32, SDL_BLENDMODE_MOD),
238   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),
239232
240   ENTRY(RGB32,            ARGB8888,   4, 0, rgb32_argb32),
241   ENTRY(RGB32,            RGB888,     4, 0, NULL),
233   ENTRY(RGB32,            ARGB8888,   rgb32_argb32),
234   ENTRY(RGB32,             RGB888,     rgb32_rgb32),
242235
243   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 0, rgb32pal_argb32),
244   ENTRY(RGB32_PALETTED,   RGB888,     4, 0, rgb32pal_argb32),
236   ENTRY(RGB32_PALETTED,   ARGB8888,   rgb32pal_argb32),
237   ENTRY(RGB32_PALETTED,   RGB888,     rgb32pal_argb32),
245238
246   ENTRY(YUY16,            UYVY,       2, 0, NULL /* yuv16_uyvy*/),
247   ENTRY(YUY16,            YUY2,       2, 0, yuv16_yuy2),
248   ENTRY(YUY16,            YVYU,       2, 0, yuv16_yvyu),
249   ENTRY(YUY16,            ARGB8888,   4, 0, yuv16_argb32),
250   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),
251244
252   ENTRY(YUY16_PALETTED,   UYVY,       2, 0, yuv16pal_uyvy),
253   ENTRY(YUY16_PALETTED,   YUY2,       2, 0, yuv16pal_yuy2),
254   ENTRY(YUY16_PALETTED,   YVYU,       2, 0, yuv16pal_yvyu),
255   ENTRY(YUY16_PALETTED,   ARGB8888,   4, 0, yuv16pal_argb32),
256   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),
257250
258   ENTRY(PALETTE16,        ARGB8888,   4, 0, pal16_argb32),
259   ENTRY(PALETTE16,        RGB888,     4, 0, pal16_argb32),
251   ENTRY(PALETTE16,        ARGB8888,   pal16_argb32),
252   ENTRY(PALETTE16,        RGB888,     pal16_argb32),
260253
261   ENTRY(RGB15,            RGB555,     2, 0, NULL /* rgb15_argb1555 */),
262   ENTRY(RGB15,            ARGB1555,   2, 0, rgb15_argb1555),
263   ENTRY(RGB15,            ARGB8888,   4, 0, rgb15_argb32),
264   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),
265258
266   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 0, rgb15pal_argb32),
267   ENTRY(RGB15_PALETTED,   RGB888,     4, 0, rgb15pal_argb32),
259   ENTRY(RGB15_PALETTED,   ARGB8888,   rgb15pal_argb32),
260   ENTRY(RGB15_PALETTED,   RGB888,     rgb15pal_argb32),
268261
269   ENTRY(PALETTE16A,       ARGB8888,   4, 0, pal16a_argb32),
270   ENTRY(PALETTE16A,       RGB888,     4, 0, pal16a_rgb32),
262   ENTRY(PALETTE16A,       ARGB8888,   pal16a_argb32),
263   ENTRY(PALETTE16A,       RGB888,     pal16a_rgb32),
271264
272265   /* rotation */
273   ENTRY(ARGB32,           ARGB8888,   4, 1, rot_argb32_argb32),
274   ENTRY_LR(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32),
266   ENTRY(ARGB32,           ARGB8888,   rot_argb32_argb32),
267   ENTRY_LR(ARGB32,        RGB888,     rot_argb32_rgb32),
275268   /* Entry primarily for directfb */
276   ENTRY_BM(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD),
277   ENTRY_BM(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD),
278   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),
279272
280   ENTRY(RGB32,            ARGB8888,   4, 1, rot_rgb32_argb32),
281   ENTRY(RGB32,            RGB888,     4, 1, rot_argb32_argb32),
273   ENTRY(RGB32,            ARGB8888,   rot_rgb32_argb32),
274   ENTRY(RGB32,            RGB888,     rot_argb32_argb32),
282275
283   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 1, rot_rgb32pal_argb32),
284   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),
285278
286   ENTRY(YUY16,            ARGB8888,   4, 1, rot_yuv16_argb32),
287   ENTRY(YUY16,            RGB888,     4, 1, rot_yuv16_argb32),
279   ENTRY(YUY16,            ARGB8888,   rot_yuv16_argb32rot),
280   ENTRY(YUY16,            RGB888,     rot_yuv16_argb32rot),
288281
289   ENTRY(YUY16_PALETTED,   ARGB8888,   4, 1, rot_yuv16pal_argb32),
290   ENTRY(YUY16_PALETTED,   RGB888,     4, 1, rot_yuv16pal_argb32),
282   ENTRY(YUY16_PALETTED,   ARGB8888,   rot_yuv16pal_argb32rot),
283   ENTRY(YUY16_PALETTED,   RGB888,     rot_yuv16pal_argb32rot),
291284
292   ENTRY(PALETTE16,        ARGB8888,   4, 1, rot_pal16_argb32),
293   ENTRY(PALETTE16,        RGB888,     4, 1, rot_pal16_argb32),
285   ENTRY(PALETTE16,        ARGB8888,   rot_pal16_argb32),
286   ENTRY(PALETTE16,        RGB888,     rot_pal16_argb32),
294287
295   ENTRY(RGB15,            RGB555,     2, 1, rot_rgb15_argb1555),
296   ENTRY(RGB15,            ARGB1555,   2, 1, rot_rgb15_argb1555),
297   ENTRY(RGB15,            ARGB8888,   4, 1, rot_rgb15_argb32),
298   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),
299292
300   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 1, rot_rgb15pal_argb32),
301   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),
302295
303   ENTRY(PALETTE16A,       ARGB8888,   4, 1, rot_pal16a_argb32),
304   ENTRY(PALETTE16A,       RGB888,     4, 1, rot_pal16a_rgb32),
296   ENTRY(PALETTE16A,       ARGB8888,   rot_pal16a_argb32),
297   ENTRY(PALETTE16A,       RGB888,     rot_pal16a_rgb32),
305298
306299{ -1 },
307300};
r243239r243240
394387   SDL_RenderCopy(m_renderer,  m_texture_id, NULL, &target_rect);
395388}
396389
397void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
390void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
398391{
399392   SDL_Rect target_rect;
400393
r243239r243240
548541      {
549542         if (bi->pixel_count)
550543            osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname,
551                  bi->rotate ? "rot" : "norot", bi->bm_mask, bi->samples,
544                  bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples,
552545                  (int) bi->perf);
553546         freeme = bi;
554547         bi = bi->next;
r243239r243240
580573static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
581574{
582575   // allocate memory for our structures
583   sdl_info *sdl = global_alloc(sdl_info);
576   sdl_info13 *sdl = global_alloc(sdl_info13);
584577
585578   /* FIXME: On Ubuntu and potentially other Linux OS you should use
586579    * to disable panning. This has to be done before every invocation of mame.
r243239r243240
596589   UINT32 extra_flags = (window->fullscreen() ?
597590         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
598591
592#if defined(SDLMAME_WIN32)
593   SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
594#endif
599595   // create the SDL window
600596   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
601597         width, height, extra_flags);
r243239r243240
610606      mode.h = height;
611607      if (window->refresh)
612608         mode.refresh_rate = window->refresh;
609#if 0
613610      if (window->depth)
614611      {
615612         switch (window->depth)
r243239r243240
630627            osd_printf_warning("Ignoring depth %d\n", window->depth);
631628         }
632629      }
630#endif
631
633632      SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
634633#ifndef SDLMAME_WIN32
635634      /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
r243239r243240
640639#endif
641640   }
642641   else
643      SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
644
642   {
643      //SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
644   }
645645   // create renderer
646646
647647   if (video_config.waitvsync)
r243239r243240
655655   }
656656
657657   //SDL_SelectRenderer(window->sdl_window);
658
659658   SDL_ShowWindow(window->sdl_window);
660659   //SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
661660   SDL_RaiseWindow(window->sdl_window);
661
662662   SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
663663
664664   sdl->m_blittimer = 3;
r243239r243240
674674
675675static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
676676{
677   sdl_info *sdl = (sdl_info *) window->dxdata;
677   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
678678
679679   sdl->m_resize_pending = 1;
680680   sdl->m_resize_height = height;
r243239r243240
693693
694694static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
695695{
696   sdl_info *sdl = (sdl_info *) window->dxdata;
696   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
697697
698698   *xt = x - sdl->m_hofs;
699699   *yt = y - sdl->m_vofs;
r243239r243240
719719
720720static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
721721{
722   sdl_info *sdl = (sdl_info *) window->dxdata;
722   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
723723   render_primitive *prim;
724724   texture_info *texture=NULL;
725725   float vofs, hofs;
r243239r243240
833833
834834static void drawsdl2_window_clear(sdl_window_info *window)
835835{
836   sdl_info *sdl = (sdl_info *) window->dxdata;
836   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
837837
838838   sdl->m_blittimer = 2;
839839}
r243239r243240
845845
846846static void drawsdl2_window_destroy(sdl_window_info *window)
847847{
848   sdl_info *sdl = (sdl_info *) window->dxdata;
848   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
849849
850850   // skip if nothing
851851   if (sdl == NULL)
r243239r243240
884884
885885   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
886886   {
887      if ((m_is_rotated == bi->rotate)
887      if ((m_is_rotated == bi->blitter->m_is_rot)
888888            && (m_sdl_blendmode == bi->bm_mask))
889889      {
890890         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
r243239r243240
905905   /* try last resort handlers */
906906   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
907907   {
908      if ((m_is_rotated == bi->rotate)
908      if ((m_is_rotated == bi->blitter->m_is_rot)
909909         && (m_sdl_blendmode == bi->bm_mask))
910910         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
911911            return bi;
r243239r243240
914914   return NULL;
915915}
916916
917// FIXME:
918const 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
917924//============================================================
918925//  texture_info::matches
919926//============================================================
r243239r243240
943950   m_flags = flags;
944951   m_texinfo = texsource;
945952   m_texinfo.seqid = -1; // force set data
946   m_is_rotated = FALSE;
953   m_is_rotated = false;
947954   m_setup = setup;
948955   m_sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags));
949956   m_pitch = 0;
r243239r243240
972979
973980   if (setup.rotwidth != m_texinfo.width || setup.rotheight != m_texinfo.height
974981         || setup.dudx < 0 || setup.dvdy < 0)
975      m_is_rotated = TRUE;
982      m_is_rotated = true;
976983   else
977      m_is_rotated = FALSE;
984      m_is_rotated = false;
978985
979986   //m_sdl_access = SDL_TEXTUREACCESS_STATIC;
980987   m_sdl_access = SDL_TEXTUREACCESS_STREAMING;
r243239r243240
9961003
9971004   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
9981005   {
999      if (m_copyinfo->func != NULL)
1000         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;
10011008      else
1002         m_pixels = NULL;
1009         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->blitter->m_dest_bpp);
10031010   }
10041011   m_last_access = osd_ticks();
10051012
r243239r243240
10211028   m_copyinfo->time -= osd_ticks();
10221029   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
10231030   {
1024      if ( m_copyinfo->func )
1031      if ( m_copyinfo->blitter->m_is_passthrough )
10251032      {
1026         m_pitch = m_setup.rotwidth * m_copyinfo->dst_bpp;
1027         m_copyinfo->func(this, &texsource);
1033         m_pixels = texsource.base;
1034         m_pitch = m_texinfo.rowpixels * m_copyinfo->blitter->m_dest_bpp;
10281035      }
10291036      else
10301037      {
1031         m_pixels = texsource.base;
1032         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);
10331040      }
10341041      SDL_UpdateTexture(m_texture_id, NULL, m_pixels, m_pitch);
10351042   }
10361043   else
10371044   {
10381045      SDL_LockTexture(m_texture_id, NULL, (void **) &m_pixels, &m_pitch);
1039      if ( m_copyinfo->func )
1040         m_copyinfo->func(this, &texsource);
1041      else
1046      if ( m_copyinfo->blitter->m_is_passthrough )
10421047      {
10431048         UINT8 *src = (UINT8 *) texsource.base;
10441049         UINT8 *dst = (UINT8 *) m_pixels;
1045         int spitch = texsource.rowpixels * m_copyinfo->dst_bpp;
1046         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;
10471052         int h = texsource.height;
10481053         while (h--) {
10491054            memcpy(dst, src, num);
r243239r243240
10511056            dst += m_pitch;
10521057         }
10531058      }
1059      else
1060         m_copyinfo->blitter->texop(this, &texsource);
10541061      SDL_UnlockTexture(m_texture_id);
10551062   }
10561063   m_copyinfo->time += osd_ticks();
r243239r243240
11111118//  texture_find
11121119//============================================================
11131120
1114texture_info *sdl_info::texture_find(const render_primitive &prim, const quad_setup_data &setup)
1121texture_info *sdl_info13::texture_find(const render_primitive &prim, const quad_setup_data &setup)
11151122{
11161123   HashT texhash = texture_compute_hash(prim.texture, prim.flags);
11171124   texture_info *texture;
r243239r243240
11481155//  texture_update
11491156//============================================================
11501157
1151texture_info * sdl_info::texture_update(const render_primitive &prim)
1158texture_info * sdl_info13::texture_update(const render_primitive &prim)
11521159{
11531160   quad_setup_data setup;
11541161   texture_info *texture;
r243239r243240
11821189
11831190static void drawsdl2_destroy_all_textures(sdl_window_info *window)
11841191{
1185   sdl_info *sdl = (sdl_info *) window->dxdata;
1192   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
11861193
11871194   if (sdl == NULL)
11881195      return;
trunk/src/osd/sdl/sdlmain.c
r243239r243240
564564
565565#if (SDLMAME_SDL2)
566566      stemp = options().render_driver();
567      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
567      if (stemp != NULL)
568568      {
569         osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
570         //osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
571         SDL_SetHint(SDL_HINT_RENDER_DRIVER, stemp);
569         if (strcmp(stemp, SDLOPTVAL_AUTO) != 0)
570         {
571            osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
572            //osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
573            SDL_SetHint(SDL_HINT_RENDER_DRIVER, stemp);
574         }
575         else
576         {
577#if defined(SDLMAME_WIN32)
578            // OpenGL renderer has less issues with mode switching on windows
579            osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", "opengl");
580            //osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
581            SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
582#endif
583         }
572584      }
573585#endif
574586
trunk/src/osd/sdl/video.h
r243239r243240
9191
9292   // global configuration
9393   int                 windowed;               // start windowed?
94   int                 prescale;               // prescale factor (not currently supported)
94   int                 prescale;               // prescale factor (supported by accel driver)
9595   int                 keepaspect;             // keep aspect ratio?
9696   int                 numscreens;             // number of screens
9797   int                 centerh;


Previous 199869 Revisions Next


© 1997-2024 The MAME Team