Previous 199869 Revisions Next

r34727 Thursday 29th January, 2015 at 21:51:10 UTC by Thomas Klausner
Define network API to use on NetBSD.

Fixes build on NetBSD.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
[src/osd/sdl]blit13.h draw13.c drawogl.c drawsdl.c osdsdl.h sdl.mak sdlmain.c video.c video.h window.c

trunk/src/osd/sdl/blit13.h
r243238r243239
55//  INLINE
66//============================================================
77
8inline UINT32 premult32(const UINT32 pixel)
8INLINE UINT32 premult32(UINT32 pixel)
99{
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;
10   UINT8 a = (pixel >> 24) & 0xff;
11   UINT8 r = (pixel >> 16) & 0xff;
12   UINT8 g = (pixel >> 8) & 0xff;
13   UINT8 b = (pixel >> 0) & 0xff;
1414
1515   return 0xFF000000 |
16      ((r * a) / 255) << 16 |
17      ((g * a) / 255) << 8 |
18      ((b * a) / 255);
16      (((UINT16)r * (UINT16)a) / 255) << 16 |
17      (((UINT16)g * (UINT16)a) / 255) << 8 |
18      (((UINT16)b * (UINT16)a) / 255);
1919}
2020
21inline UINT32 CLUL(const UINT32 x)
22{
23   return ((INT32) x < 0) ? 0 : ((x > 65535) ? 255 : x >> 8);
24}
21#define CLUL(x) ((int) (x) < 0 ? 0 : ((x) > 65535 ? 255 : (x)>>8))
2522
26inline UINT32 ycc_to_rgb(const UINT8 y, const UINT8 cb, const UINT8 cr)
23INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr)
2724{
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);
25   unsigned int r, g, b, common;
3226
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
3332   return 0xff000000 | (CLUL(r)<<16) | (CLUL(g)<<8) | (CLUL(b));
3433}
3534
36inline UINT32 pixel_ycc_to_rgb(const UINT16 *pixel)
35INLINE UINT32 pixel_ycc_to_rgb(UINT16 *pixel)
3736{
38
39   const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
37   UINT32 p = *(UINT32 *)((FPTR) pixel & ~1);
4038   return ycc_to_rgb((*pixel >> 8) & 0xff, (p) & 0xff, (p>>16) & 0xff);
4139}
4240
43inline UINT32 pixel_ycc_to_rgb_pal(const UINT16 *pixel, const rgb_t *palette)
41INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette)
4442{
45   const UINT32 p = *(UINT32 *)((FPTR) pixel & ~3);
43   UINT32 p = *(UINT32 *)((FPTR) pixel & ~1);
4644   return ycc_to_rgb(palette[(*pixel >> 8) & 0xff], (p) & 0xff, (p>>16) & 0xff);
4745}
4846
r243238r243239
5048//  Pixel conversions
5149//============================================================
5250
51#define OP_ARGB32_ARGB32(_src) (_src)
5352
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 } };
53#define OP_RGB32_ARGB32(_src) ((_src) | 0xff000000)
5854
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; )
55#define OP_RGB32PAL_ARGB32(_src) \
56   (palbase[0x200 + (((_src) >> 16) & 0xff) ] | \
57      palbase[0x100 + (((_src) >> 8) & 0xff) ] | \
58      palbase[((_src) & 0xff) ] | 0xff000000)
6759
68FUNCTOR(op_pal16a_argb32, return palbase[src]; )
60#define OP_PAL16_ARGB32(_src) (0xff000000 | palbase[_src])
6961
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); )
62#define OP_PAL16A_ARGB32(_src) (palbase[_src])
7463
75FUNCTOR(op_rgb15pal_argb32,
76      return 0xff000000 | palbase[0x40 + ((src >> 10) & 0x1f)] |
77        palbase[0x20 + ((src >> 5) & 0x1f)] | palbase[0x00 + ((src >> 0) & 0x1f)]; )
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))
7866
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; )
67#define OP_RGB15PAL_ARGB32(_src) (0xff000000 | palbase[0x40 + ((_src >> 10) & 0x1f)] | \
68      palbase[0x20 + ((_src >> 5) & 0x1f)] | palbase[0x00 + ((_src >> 0) & 0x1f)])
8569
86FUNCTOR(op_rgb15_argb1555, return src | 0x8000; )
70#define OP_ARGB32_RGB32(_pixel) premult32(_pixel)
8771
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; )
72#define OP_PAL16A_RGB32(_src) premult32(palbase[_src])
9273
93FUNCTOR(op_yuv16_uyvy, return src; )
94FUNCTOR(op_yuv16pal_uyvy, return (palbase[(src >> 8) & 0xff] << 8) | (src & 0x00ff); )
74#define OP_PAL16_ARGB1555(_src) ((palbase[_src]&0xf80000) >> 9 | \
75         (palbase[_src]&0x00f800) >> 6 | \
76         (palbase[_src]&0x0000f8) >> 3 | 0x8000)
9577
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); )
78#define OP_RGB15_ARGB1555(_src) ((_src) | 0x8000)
9979
100FUNCTOR(op_yuv16_yuy2, return ((src & 0xff00ff00) >> 8) | ((src & 0x00ff00ff) << 8); )
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)
10183
102FUNCTOR(op_yuv16pal_yuy2,
103      return  (palbase[(src>>8) & 0xff]) |
104            (palbase[(src>>24) & 0xff]<<16) |
105            ((src<<8)&0xff00ff00);)
84#define OP_YUV16_UYVY(_src) (_src)
10685
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); )
86#define OP_YUV16PAL_UYVY(_src) ((palbase[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff))
11087
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);)
88#define OP_YUV16PAL_YVYU(_src) ((palbase[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8))
11489
115FUNCTOR(op_yuv16_argb32rot, return pixel_ycc_to_rgb(&src) ; )
90#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8))
11691
117FUNCTOR(op_yuv16pal_argb32rot, return pixel_ycc_to_rgb_pal(&src, palbase); )
92#define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \
93   (((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) )
11894
119//============================================================
120//  Copy and rotation
121//============================================================
95#define OP_YUV16PAL_YUY2(_src) ( (palbase[((_src)>>8) & 0xff]) | \
96      (palbase[((_src)>>24) & 0xff]<<16) | \
97   (((_src)<<8)&0xff00ff00) )
12298
123struct blit_base {
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)
124102
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() { }
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)
129106
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};
107#define OP_YUV16_ARGB32ROT(_src) pixel_ycc_to_rgb(&(_src))
135108
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};
109#define OP_YUV16PAL_ARGB32ROT(_src) pixel_ycc_to_rgb_pal(&(_src), palbase)
159110
160#define TEXCOPYA(a, b, c, d) \
161      const struct blit_texcopy<b, c, op_ ## a <b, c>, d> texcopy_ ## a;
111//============================================================
112//  Copy and rotation
113//============================================================
162114
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};
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}
192131
193#define TEXROTA(a, b, c) \
194      const struct blit_texrot<b, c, op_ ## a <b, c> > texcopy_rot_ ## a;
132#define TEXCOPY( _name, _src_type, _dest_type,  _op) \
133   TEXCOPY_M( _name, _src_type, _dest_type,  _op, 1)
195134
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};
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}
204157
205#define TEXCOPYP(a, b, c) \
206      const struct blit_texpass<b, c> texcopy_ ## a;
158//TEXCOPY(argb32_argb32, UINT32, UINT32, OP_ARGB32_ARGB32)
207159
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)
208166
209TEXCOPYA(rgb32_argb32,  UINT32, UINT32, 1)
210TEXCOPYP(rgb32_rgb32,   UINT32, UINT32)
167TEXCOPY(pal16_argb1555,  UINT16, UINT16, OP_PAL16_ARGB1555)
168TEXCOPY(rgb15_argb1555,  UINT16, UINT16, OP_RGB15_ARGB1555)
169TEXCOPY(rgb15pal_argb1555,  UINT16, UINT16, OP_RGB15PAL_ARGB1555)
211170
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)
171TEXCOPY(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32)
172TEXCOPY(pal16a_rgb32,  UINT16, UINT32, OP_PAL16A_RGB32)
217173
218TEXCOPYA(pal16_argb1555,  UINT16, UINT16, 1)
219TEXCOPYA(rgb15_argb1555,  UINT16, UINT16, 1)
220TEXCOPYA(rgb15pal_argb1555,  UINT16, UINT16, 1)
174TEXCOPY_M(yuv16_argb32, UINT32, UINT64, OP_YUV16_ARGB32, 2)
175TEXCOPY_M(yuv16pal_argb32, UINT32, UINT64, OP_YUV16PAL_ARGB32, 2)
221176
222TEXCOPYP(argb32_argb32,  UINT32, UINT32)
223TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1)
224TEXCOPYA(pal16a_rgb32,  UINT16, UINT32, 1)
177//TEXCOPY(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY)
225178
226TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2)
227TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2)
179TEXCOPY(yuv16pal_uyvy, UINT16, UINT16, OP_YUV16PAL_UYVY)
228180
229TEXCOPYP(yuv16_uyvy, UINT16, UINT16)
230TEXCOPYP(rgb15_rgb555, UINT16, UINT16)
181TEXCOPY(yuv16_yvyu, UINT16, UINT16, OP_YUV16_YVYU)
182TEXCOPY(yuv16pal_yvyu, UINT16, UINT16, OP_YUV16PAL_YVYU)
231183
232TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1)
184TEXCOPY_M(yuv16_yuy2, UINT32, UINT32, OP_YUV16_YUY2, 2)
185TEXCOPY_M(yuv16pal_yuy2, UINT32, UINT32, OP_YUV16PAL_YUY2, 2)
233186
234TEXCOPYA(yuv16_yvyu, UINT32, UINT32, 2)
235TEXCOPYA(yuv16pal_yvyu, UINT16, UINT16, 1)
236187
237TEXCOPYA(yuv16_yuy2, UINT32, UINT32, 2)
238TEXCOPYA(yuv16pal_yuy2, UINT32, UINT32, 2)
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)
239195
196TEXROT(pal16_argb1555,  UINT16, UINT16, OP_PAL16_ARGB1555)
197TEXROT(rgb15_argb1555,  UINT16, UINT16, OP_RGB15_ARGB1555)
198TEXROT(rgb15pal_argb1555,  UINT16, UINT16, OP_RGB15PAL_ARGB1555)
240199
200TEXROT(argb32_rgb32, UINT32, UINT32, OP_ARGB32_RGB32)
201TEXROT(pal16a_rgb32,  UINT16, UINT32, OP_PAL16A_RGB32)
241202
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)
203TEXROT(yuv16_argb32, UINT16, UINT32, OP_YUV16_ARGB32ROT)
204TEXROT(yuv16pal_argb32, UINT16, UINT32, OP_YUV16PAL_ARGB32ROT)
trunk/src/osd/sdl/draw13.c
r243238r243239
2424#include "osdsdl.h"
2525#include "window.h"
2626
27
2827//============================================================
2928//  DEBUGGING
3029//============================================================
r243238r243239
4948
5049static inline bool is_opaque(const float &a)
5150{
52    return (a >= 1.0f);
51   return (a >= 1.0f);
5352}
5453
5554static inline bool is_transparent(const float &a)
5655{
57    return (a <  0.0001f);
56   return (a <  0.0001f);
5857}
5958
6059//============================================================
r243238r243239
6463
6564struct quad_setup_data
6665{
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);
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);
7271
7372   INT32           dudx, dvdx, dudy, dvdy;
7473   INT32           startu, startv;
7574   INT32           rotwidth, rotheight;
7675};
7776
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
7899//============================================================
79100//  Textures
80101//============================================================
81102
82struct sdl_info13;
83struct copy_info_t;
103struct sdl_info;
84104
85105/* texture_info holds information about a texture */
86106class texture_info
87107{
88    friend class simple_list<texture_info>;
108   friend class simple_list<texture_info>;
89109public:
90    texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
91    ~texture_info();
110   texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
111   ~texture_info();
92112
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);
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);
96116
97    copy_info_t *compute_size_type();
117   copy_info_t *compute_size_type();
98118
99119   void                *m_pixels;            // pixels for the texture
100120   int                 m_pitch;
r243238r243239
105125   osd_ticks_t         m_last_access;
106126
107127   int raw_width() const { return m_texinfo.width; }
108    int raw_height() const { return m_texinfo.height; }
128   int raw_height() const { return m_texinfo.height; }
109129
110    texture_info *next() { return m_next; }
111    const render_texinfo &texinfo() const { return m_texinfo; }
112    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; }
113133
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;
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   }
118140
119141private:
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
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
125147
126    SDL_Texture *       m_texture_id;
127    bool                m_is_rotated;
148   SDL_Texture *       m_texture_id;
149   int                 m_is_rotated;
128150
129    int                 m_format;             // texture format
130    SDL_BlendMode       m_sdl_blendmode;
151   int                 m_format;             // texture format
152   SDL_BlendMode       m_sdl_blendmode;
131153
132    texture_info *      m_next;               // next texture in the list
154   texture_info *      m_next;               // next texture in the list
133155};
134156
135//============================================================
136//  TEXCOPY FUNCS
137//============================================================
138
139#include "blit13.h"
140
141157/* sdl_info is the information about SDL for the current screen */
142struct sdl_info13
158struct sdl_info
143159{
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    {}
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   {}
150166
151    void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
167   void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);
152168
153    texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
154    texture_info *texture_update(const render_primitive &prim);
169   texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
170   texture_info *texture_update(const render_primitive &prim);
155171
156172   INT32           m_blittimer;
157173
r243238r243239
175191   SDL_DisplayMode m_original_mode;
176192};
177193
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//============================================================
r243238r243239
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//============================================================
212218//  STATIC VARIABLES
213219//============================================================
214220
r243238r243239
216222#define BM_ALL (-1)
217223//( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD)
218224
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}
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}
222229
223230static copy_info_t blit_info_default[] =
224231{
225232   /* no rotation */
226   ENTRY(ARGB32,            ARGB8888,   argb32_argb32),
227   ENTRY_LR(ARGB32,        RGB888,     argb32_rgb32),
233   ENTRY(ARGB32,           ARGB8888,   4, 0, NULL),
234   ENTRY_LR(ARGB32,        RGB888,     4, 0, argb32_rgb32),
228235   /* Entry primarily for directfb */
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),
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),
232239
233   ENTRY(RGB32,            ARGB8888,   rgb32_argb32),
234   ENTRY(RGB32,             RGB888,     rgb32_rgb32),
240   ENTRY(RGB32,            ARGB8888,   4, 0, rgb32_argb32),
241   ENTRY(RGB32,            RGB888,     4, 0, NULL),
235242
236   ENTRY(RGB32_PALETTED,   ARGB8888,   rgb32pal_argb32),
237   ENTRY(RGB32_PALETTED,   RGB888,     rgb32pal_argb32),
243   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 0, rgb32pal_argb32),
244   ENTRY(RGB32_PALETTED,   RGB888,     4, 0, rgb32pal_argb32),
238245
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),
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),
244251
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),
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),
250257
251   ENTRY(PALETTE16,        ARGB8888,   pal16_argb32),
252   ENTRY(PALETTE16,        RGB888,     pal16_argb32),
258   ENTRY(PALETTE16,        ARGB8888,   4, 0, pal16_argb32),
259   ENTRY(PALETTE16,        RGB888,     4, 0, pal16_argb32),
253260
254   ENTRY(RGB15,             RGB555,     rgb15_rgb555),
255   ENTRY(RGB15,            ARGB1555,   rgb15_argb1555),
256   ENTRY(RGB15,            ARGB8888,   rgb15_argb32),
257   ENTRY(RGB15,            RGB888,     rgb15_argb32),
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),
258265
259   ENTRY(RGB15_PALETTED,   ARGB8888,   rgb15pal_argb32),
260   ENTRY(RGB15_PALETTED,   RGB888,     rgb15pal_argb32),
266   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 0, rgb15pal_argb32),
267   ENTRY(RGB15_PALETTED,   RGB888,     4, 0, rgb15pal_argb32),
261268
262   ENTRY(PALETTE16A,       ARGB8888,   pal16a_argb32),
263   ENTRY(PALETTE16A,       RGB888,     pal16a_rgb32),
269   ENTRY(PALETTE16A,       ARGB8888,   4, 0, pal16a_argb32),
270   ENTRY(PALETTE16A,       RGB888,     4, 0, pal16a_rgb32),
264271
265272   /* rotation */
266   ENTRY(ARGB32,           ARGB8888,   rot_argb32_argb32),
267   ENTRY_LR(ARGB32,        RGB888,     rot_argb32_rgb32),
273   ENTRY(ARGB32,           ARGB8888,   4, 1, rot_argb32_argb32),
274   ENTRY_LR(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32),
268275   /* Entry primarily for directfb */
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),
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),
272279
273   ENTRY(RGB32,            ARGB8888,   rot_rgb32_argb32),
274   ENTRY(RGB32,            RGB888,     rot_argb32_argb32),
280   ENTRY(RGB32,            ARGB8888,   4, 1, rot_rgb32_argb32),
281   ENTRY(RGB32,            RGB888,     4, 1, rot_argb32_argb32),
275282
276   ENTRY(RGB32_PALETTED,   ARGB8888,   rot_rgb32pal_argb32),
277   ENTRY(RGB32_PALETTED,   RGB888,     rot_rgb32pal_argb32),
283   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 1, rot_rgb32pal_argb32),
284   ENTRY(RGB32_PALETTED,   RGB888,     4, 1, rot_rgb32pal_argb32),
278285
279   ENTRY(YUY16,            ARGB8888,   rot_yuv16_argb32rot),
280   ENTRY(YUY16,            RGB888,     rot_yuv16_argb32rot),
286   ENTRY(YUY16,            ARGB8888,   4, 1, rot_yuv16_argb32),
287   ENTRY(YUY16,            RGB888,     4, 1, rot_yuv16_argb32),
281288
282   ENTRY(YUY16_PALETTED,   ARGB8888,   rot_yuv16pal_argb32rot),
283   ENTRY(YUY16_PALETTED,   RGB888,     rot_yuv16pal_argb32rot),
289   ENTRY(YUY16_PALETTED,   ARGB8888,   4, 1, rot_yuv16pal_argb32),
290   ENTRY(YUY16_PALETTED,   RGB888,     4, 1, rot_yuv16pal_argb32),
284291
285   ENTRY(PALETTE16,        ARGB8888,   rot_pal16_argb32),
286   ENTRY(PALETTE16,        RGB888,     rot_pal16_argb32),
292   ENTRY(PALETTE16,        ARGB8888,   4, 1, rot_pal16_argb32),
293   ENTRY(PALETTE16,        RGB888,     4, 1, rot_pal16_argb32),
287294
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),
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),
292299
293   ENTRY(RGB15_PALETTED,   ARGB8888,   rot_rgb15pal_argb32),
294   ENTRY(RGB15_PALETTED,   RGB888,     rot_rgb15pal_argb32),
300   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 1, rot_rgb15pal_argb32),
301   ENTRY(RGB15_PALETTED,   RGB888,     4, 1, rot_rgb15pal_argb32),
295302
296   ENTRY(PALETTE16A,       ARGB8888,   rot_pal16a_argb32),
297   ENTRY(PALETTE16A,       RGB888,     rot_pal16a_rgb32),
303   ENTRY(PALETTE16A,       ARGB8888,   4, 1, rot_pal16a_argb32),
304   ENTRY(PALETTE16A,       RGB888,     4, 1, rot_pal16a_rgb32),
298305
299306{ -1 },
300307};
r243238r243239
387394   SDL_RenderCopy(m_renderer,  m_texture_id, NULL, &target_rect);
388395}
389396
390void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
397void sdl_info::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
391398{
392399   SDL_Rect target_rect;
393400
r243238r243239
541548      {
542549         if (bi->pixel_count)
543550            osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname,
544                  bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples,
551                  bi->rotate ? "rot" : "norot", bi->bm_mask, bi->samples,
545552                  (int) bi->perf);
546553         freeme = bi;
547554         bi = bi->next;
r243238r243239
573580static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
574581{
575582   // allocate memory for our structures
576   sdl_info13 *sdl = global_alloc(sdl_info13);
583   sdl_info *sdl = global_alloc(sdl_info);
577584
578585   /* FIXME: On Ubuntu and potentially other Linux OS you should use
579586    * to disable panning. This has to be done before every invocation of mame.
r243238r243239
589596   UINT32 extra_flags = (window->fullscreen() ?
590597         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
591598
592#if defined(SDLMAME_WIN32)
593   SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
594#endif
595599   // create the SDL window
596   window->sdl_window = SDL_CreateWindow(window->title,
597         window->monitor()->position_size().x, window->monitor()->position_size().y,
600   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
598601         width, height, extra_flags);
599602
600603   if (window->fullscreen() && video_config.switchres)
r243238r243239
607610      mode.h = height;
608611      if (window->refresh)
609612         mode.refresh_rate = window->refresh;
610#if 0
611613      if (window->depth)
612614      {
613615         switch (window->depth)
r243238r243239
628630            osd_printf_warning("Ignoring depth %d\n", window->depth);
629631         }
630632      }
631#endif
632
633633      SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
634634#ifndef SDLMAME_WIN32
635635      /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
r243238r243239
640640#endif
641641   }
642642   else
643   {
644      //SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
645   }
643      SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
644
646645   // create renderer
647646
648647   if (video_config.waitvsync)
r243238r243239
656655   }
657656
658657   //SDL_SelectRenderer(window->sdl_window);
658
659659   SDL_ShowWindow(window->sdl_window);
660660   //SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
661661   SDL_RaiseWindow(window->sdl_window);
662
663662   SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
664663
665664   sdl->m_blittimer = 3;
r243238r243239
675674
676675static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
677676{
678   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
677   sdl_info *sdl = (sdl_info *) window->dxdata;
679678
680679   sdl->m_resize_pending = 1;
681680   sdl->m_resize_height = height;
r243238r243239
694693
695694static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
696695{
697   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
696   sdl_info *sdl = (sdl_info *) window->dxdata;
698697
699698   *xt = x - sdl->m_hofs;
700699   *yt = y - sdl->m_vofs;
r243238r243239
711710
712711static void drawsdl2_set_target_bounds(sdl_window_info *window)
713712{
714   window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
713   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
715714}
716715
717716//============================================================
r243238r243239
720719
721720static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
722721{
723   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
722   sdl_info *sdl = (sdl_info *) window->dxdata;
724723   render_primitive *prim;
725724   texture_info *texture=NULL;
726725   float vofs, hofs;
r243238r243239
762761
763762      if ((window->fullscreen()) && (!video_config.switchres))
764763      {
765         ch = window->monitor()->center_height();
766         cw = window->monitor()->center_width();
764         ch = window->monitor()->center_height;
765         cw = window->monitor()->center_width;
767766      }
768767      else
769768      {
r243238r243239
834833
835834static void drawsdl2_window_clear(sdl_window_info *window)
836835{
837   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
836   sdl_info *sdl = (sdl_info *) window->dxdata;
838837
839838   sdl->m_blittimer = 2;
840839}
r243238r243239
846845
847846static void drawsdl2_window_destroy(sdl_window_info *window)
848847{
849   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
848   sdl_info *sdl = (sdl_info *) window->dxdata;
850849
851850   // skip if nothing
852851   if (sdl == NULL)
r243238r243239
885884
886885   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
887886   {
888      if ((m_is_rotated == bi->blitter->m_is_rot)
887      if ((m_is_rotated == bi->rotate)
889888            && (m_sdl_blendmode == bi->bm_mask))
890889      {
891890         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
r243238r243239
906905   /* try last resort handlers */
907906   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
908907   {
909      if ((m_is_rotated == bi->blitter->m_is_rot)
908      if ((m_is_rotated == bi->rotate)
910909         && (m_sdl_blendmode == bi->bm_mask))
911910         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
912911            return bi;
r243238r243239
915914   return NULL;
916915}
917916
918// FIXME:
919const bool texture_info::is_pixels_owned() const
920{ // do we own / allocated it ?
921    return ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
922            && (m_copyinfo->blitter->m_is_passthrough));
923}
924
925917//============================================================
926918//  texture_info::matches
927919//============================================================
r243238r243239
951943   m_flags = flags;
952944   m_texinfo = texsource;
953945   m_texinfo.seqid = -1; // force set data
954   m_is_rotated = false;
946   m_is_rotated = FALSE;
955947   m_setup = setup;
956948   m_sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags));
957949   m_pitch = 0;
r243238r243239
980972
981973   if (setup.rotwidth != m_texinfo.width || setup.rotheight != m_texinfo.height
982974         || setup.dudx < 0 || setup.dvdy < 0)
983      m_is_rotated = true;
975      m_is_rotated = TRUE;
984976   else
985      m_is_rotated = false;
977      m_is_rotated = FALSE;
986978
987979   //m_sdl_access = SDL_TEXTUREACCESS_STATIC;
988980   m_sdl_access = SDL_TEXTUREACCESS_STREAMING;
r243238r243239
1004996
1005997   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
1006998   {
1007      if (m_copyinfo->blitter->m_is_passthrough)
1008         m_pixels = NULL;
999      if (m_copyinfo->func != NULL)
1000         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp);
10091001      else
1010         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->blitter->m_dest_bpp);
1002         m_pixels = NULL;
10111003   }
10121004   m_last_access = osd_ticks();
10131005
r243238r243239
10291021   m_copyinfo->time -= osd_ticks();
10301022   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
10311023   {
1032      if ( m_copyinfo->blitter->m_is_passthrough )
1024      if ( m_copyinfo->func )
10331025      {
1034         m_pixels = texsource.base;
1035         m_pitch = m_texinfo.rowpixels * m_copyinfo->blitter->m_dest_bpp;
1026         m_pitch = m_setup.rotwidth * m_copyinfo->dst_bpp;
1027         m_copyinfo->func(this, &texsource);
10361028      }
10371029      else
10381030      {
1039         m_pitch = m_setup.rotwidth * m_copyinfo->blitter->m_dest_bpp;
1040         m_copyinfo->blitter->texop(this, &texsource);
1031         m_pixels = texsource.base;
1032         m_pitch = m_texinfo.rowpixels * m_copyinfo->dst_bpp;
10411033      }
10421034      SDL_UpdateTexture(m_texture_id, NULL, m_pixels, m_pitch);
10431035   }
10441036   else
10451037   {
10461038      SDL_LockTexture(m_texture_id, NULL, (void **) &m_pixels, &m_pitch);
1047      if ( m_copyinfo->blitter->m_is_passthrough )
1039      if ( m_copyinfo->func )
1040         m_copyinfo->func(this, &texsource);
1041      else
10481042      {
10491043         UINT8 *src = (UINT8 *) texsource.base;
10501044         UINT8 *dst = (UINT8 *) m_pixels;
1051         int spitch = texsource.rowpixels * m_copyinfo->blitter->m_dest_bpp;
1052         int num = texsource.width * m_copyinfo->blitter->m_dest_bpp;
1045         int spitch = texsource.rowpixels * m_copyinfo->dst_bpp;
1046         int num = texsource.width * m_copyinfo->dst_bpp;
10531047         int h = texsource.height;
10541048         while (h--) {
10551049            memcpy(dst, src, num);
r243238r243239
10571051            dst += m_pitch;
10581052         }
10591053      }
1060      else
1061         m_copyinfo->blitter->texop(this, &texsource);
10621054      SDL_UnlockTexture(m_texture_id);
10631055   }
10641056   m_copyinfo->time += osd_ticks();
r243238r243239
11191111//  texture_find
11201112//============================================================
11211113
1122texture_info *sdl_info13::texture_find(const render_primitive &prim, const quad_setup_data &setup)
1114texture_info *sdl_info::texture_find(const render_primitive &prim, const quad_setup_data &setup)
11231115{
11241116   HashT texhash = texture_compute_hash(prim.texture, prim.flags);
11251117   texture_info *texture;
r243238r243239
11561148//  texture_update
11571149//============================================================
11581150
1159texture_info * sdl_info13::texture_update(const render_primitive &prim)
1151texture_info * sdl_info::texture_update(const render_primitive &prim)
11601152{
11611153   quad_setup_data setup;
11621154   texture_info *texture;
r243238r243239
11901182
11911183static void drawsdl2_destroy_all_textures(sdl_window_info *window)
11921184{
1193   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
1185   sdl_info *sdl = (sdl_info *) window->dxdata;
11941186
11951187   if (sdl == NULL)
11961188      return;
trunk/src/osd/sdl/drawogl.c
r243238r243239
558558   //load_gl_lib(window->machine());
559559
560560   // create the SDL window
561   window->sdl_window = SDL_CreateWindow(window->title,
562         window->monitor()->position_size().x, window->monitor()->position_size().y,
561   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
563562         width, height, sdl->extra_flags);
564563
565564   if  (!window->sdl_window )
r243238r243239
571570   if (window->fullscreen() && video_config.switchres)
572571   {
573572      SDL_DisplayMode mode;
574      SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
573      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
575574      mode.w = width;
576575      mode.h = height;
577576      if (window->refresh)
r243238r243239
843842
844843static void drawogl_set_target_bounds(sdl_window_info *window)
845844{
846   window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
845   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
847846}
848847
849848//============================================================
r243238r243239
13131312
13141313      if ((window->fullscreen()) && (!video_config.switchres))
13151314      {
1316         ch = window->monitor()->center_height();
1317         cw = window->monitor()->center_width();
1315         ch = window->monitor()->center_height;
1316         cw = window->monitor()->center_width;
13181317      }
13191318      else
13201319      {
trunk/src/osd/sdl/drawsdl.c
r243238r243239
251251   UINT32 fmt;
252252
253253   // Determine preferred pixelformat and set up yuv if necessary
254   SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
254   SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
255255
256256   if (sdl->yuv_bitmap)
257257   {
r243238r243239
412412   if (window->fullscreen() && video_config.switchres)
413413   {
414414      SDL_DisplayMode mode;
415      SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
415      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
416416      mode.w = width;
417417      mode.h = height;
418418      if (window->refresh)
r243238r243239
623623   const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
624624
625625   if (!sm->is_scale)
626      window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
626      window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
627627   else
628628      window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
629629}
r243238r243239
737737   // the first one only
738738   if ((window->fullscreen()) && (!video_config.switchres))
739739   {
740      ch = window->monitor()->center_height();
741      cw = window->monitor()->center_width();
740      ch = window->monitor()->center_height;
741      cw = window->monitor()->center_width;
742742   }
743743   else
744744   {
trunk/src/osd/sdl/osdsdl.h
r243238r243239
66#include "watchdog.h"
77#include "clifront.h"
88#include "modules/lib/osdobj_common.h"
9#include "video.h"
910#include "modules/osdmodule.h"
1011#include "modules/font/font_module.h"
1112
r243238r243239
214215private:
215216   virtual void osd_exit();
216217
218   void extract_window_config(int index, sdl_window_config *conf);
219
217220   // FIXME: remove machine usage
218221   void extract_video_config(running_machine &machine);
219222
trunk/src/osd/sdl/sdl.mak
r243238r243239
242242SYNC_IMPLEMENTATION = ntc
243243LIBS += -lutil
244244NO_USE_MIDI = 1
245SDL_NETWORK = pcap
245246endif
246247
247248ifeq ($(TARGETOS),solaris)
trunk/src/osd/sdl/sdlmain.c
r243238r243239
564564
565565#if (SDLMAME_SDL2)
566566      stemp = options().render_driver();
567      if (stemp != NULL)
567      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
568568      {
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         }
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);
584572      }
585573#endif
586574
trunk/src/osd/sdl/video.c
r243238r243239
6969#endif
7070#endif
7171
72sdl_monitor_info *sdl_monitor_info::primary_monitor = NULL;
73sdl_monitor_info *sdl_monitor_info::list = NULL;
74
7572//============================================================
7673//  LOCAL VARIABLES
7774//============================================================
7875
76static sdl_monitor_info *primary_monitor;
77static sdl_monitor_info *sdl_monitor_list;
78
7979//============================================================
8080//  PROTOTYPES
8181//============================================================
8282
83static void init_monitors(void);
84static sdl_monitor_info *pick_monitor(sdl_options &options, int index);
85
8386static void check_osd_inputs(running_machine &machine);
8487
8588static float get_aspect(const char *defdata, const char *data, int report_error);
r243238r243239
98101   extract_video_config(machine());
99102
100103   // set up monitors first
101   sdl_monitor_info::init();
104   init_monitors();
102105
103106   // we need the beam width in a float, contrary to what the core does.
104107   video_config.beamwidth = options().beam();
r243238r243239
112115   {
113116      sdl_window_config conf;
114117      memset(&conf, 0, sizeof(conf));
115      get_resolution(options().resolution(), options().resolution(index), &conf, TRUE);
116      if (sdlwindow_video_window_create(machine(), index, sdl_monitor_info::pick_monitor(options(), index), &conf))
118      extract_window_config(index, &conf);
119      if (sdlwindow_video_window_create(machine(), index, pick_monitor(options(), index), &conf))
117120         return false;
118121   }
119122
r243238r243239
128131void sdl_osd_interface::video_exit()
129132{
130133   window_exit();
131   sdl_monitor_info::exit();
134
135   // free all of our monitor information
136   while (sdl_monitor_list != NULL)
137   {
138      sdl_monitor_info *temp = sdl_monitor_list;
139      sdl_monitor_list = temp->next;
140      global_free(temp);
141   }
142
132143}
133144
134145
r243238r243239
136147//  sdlvideo_monitor_refresh
137148//============================================================
138149
139void sdl_monitor_info::refresh()
150void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
140151{
141152   #if (SDLMAME_SDL2)
142153   SDL_DisplayMode dmode;
143154
144155   #if defined(SDLMAME_WIN32)
145   SDL_GetDesktopDisplayMode(m_handle, &dmode);
156   SDL_GetDesktopDisplayMode(monitor->handle, &dmode);
146157   #else
147   SDL_GetCurrentDisplayMode(m_handle, &dmode);
158   SDL_GetCurrentDisplayMode(monitor->handle, &dmode);
148159   #endif
149   SDL_GetDisplayBounds(m_handle, &m_dimensions);
150   m_center_width = m_dimensions.w;
151   m_center_height = m_dimensions.h;
160   monitor->monitor_width = dmode.w;
161   monitor->monitor_height = dmode.h;
162   monitor->center_width = dmode.w;
163   monitor->center_height = dmode.h;
152164
153165   // FIXME: Use SDL_GetDisplayBounds(monitor->handle, &tt) to update monitor_x
154166   // SDL_Rect tt;
r243238r243239
157169   MONITORINFOEX info;
158170   info.cbSize = sizeof(info);
159171   GetMonitorInfo((HMONITOR)monitor->handle, (LPMONITORINFO)&info);
160   monitor->m_dimensions.x = monitor->m_dimensions.y = 0;
161   monitor->m_center_width = monitor->m_dimensions.w = info.rcMonitor.right - info.rcMonitor.left;
162   monitor->m_center_height = monitor->m_dimensions.h = info.rcMonitor.bottom - info.rcMonitor.top;
172   monitor->center_width = monitor->monitor_width = info.rcMonitor.right - info.rcMonitor.left;
173   monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
163174   char *temp = utf8_from_wstring(info.szDevice);
164175   strcpy(monitor->monitor_device, temp);
165176   osd_free(temp);
r243238r243239
274285//  sdlvideo_monitor_get_aspect
275286//============================================================
276287
277float sdl_monitor_info::aspect()
288float sdlvideo_monitor_get_aspect(sdl_monitor_info *monitor)
278289{
279290   // refresh the monitor information and compute the aspect
280   refresh();
281   // FIXME: returning 0 looks odd, video_config is bad
282291   if (video_config.keepaspect)
283292   {
284      return m_aspect / ((float)m_dimensions.w / (float)m_dimensions.h);
293      sdlvideo_monitor_refresh(monitor);
294      return monitor->aspect / ((float)monitor->monitor_width / (float)monitor->monitor_height);
285295   }
286296   return 0.0f;
287297}
288298
289299
290300
301//============================================================
302//  sdlvideo_monitor_from_handle
303//============================================================
291304
305sdl_monitor_info *sdlvideo_monitor_from_handle(UINT32 hmonitor)
306{
307   sdl_monitor_info *monitor;
308
309   // find the matching monitor
310   for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next)
311      if (monitor->handle == hmonitor)
312         return monitor;
313   return NULL;
314}
315
316
292317//============================================================
293318//  update
294319//============================================================
r243238r243239
406431//  init_monitors
407432//============================================================
408433
409void sdl_monitor_info::init()
434static void init_monitors(void)
410435{
411436   sdl_monitor_info **tailptr;
412437
413438   // make a list of monitors
414   sdl_monitor_info::list = NULL;
415   tailptr = &sdl_monitor_info::list;
439   sdl_monitor_list = NULL;
440   tailptr = &sdl_monitor_list;
416441
417442   #if (SDLMAME_SDL2)
418443   {
r243238r243239
427452
428453         // allocate a new monitor info
429454         monitor = global_alloc_clear(sdl_monitor_info);
430         monitor->m_handle = i;
431455
432         snprintf(monitor->m_monitor_device, sizeof(monitor->m_monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
456         snprintf(monitor->monitor_device, sizeof(monitor->monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
433457
434458         SDL_GetDesktopDisplayMode(i, &dmode);
435         SDL_GetDisplayBounds(i, &monitor->m_dimensions);
436         monitor->m_center_width = monitor->m_dimensions.w;
437         monitor->m_center_height = monitor->m_dimensions.h;
438
459         monitor->monitor_width = dmode.w;
460         monitor->monitor_height = dmode.h;
461         monitor->center_width = dmode.w;
462         monitor->center_height = dmode.h;
463         // FIXME: this should use SDL_GetDisplayBounds!
464         monitor->monitor_x = monx;
465         monitor->handle = i;
439466         // guess the aspect ratio assuming square pixels
440         monitor->m_aspect = (float)(dmode.w) / (float)(dmode.h);
467         monitor->aspect = (float)(dmode.w) / (float)(dmode.h);
468         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->monitor_device, dmode.w, dmode.h);
441469
442         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_monitor_device, dmode.w, dmode.h);
443
444470         monx += dmode.w;
445471
446472         // save the primary monitor handle
r243238r243239
460486   #endif
461487}
462488
463void sdl_monitor_info::exit()
464{
465   // free all of our monitor information
466   while (sdl_monitor_info::list != NULL)
467   {
468      sdl_monitor_info *temp = sdl_monitor_info::list;
469      sdl_monitor_info::list = temp->next;
470      global_free(temp);
471   }
472}
473489
474
475490//============================================================
476491//  pick_monitor
477492//============================================================
478493
479494#if (SDLMAME_SDL2) || defined(SDLMAME_WIN32)
480sdl_monitor_info *sdl_monitor_info::pick_monitor(sdl_options &options, int index)
495static sdl_monitor_info *pick_monitor(sdl_options &options, int index)
481496{
482497   sdl_monitor_info *monitor;
483498   const char *scrname, *scrname2;
r243238r243239
498513   // look for a match in the name first
499514   if (scrname != NULL)
500515   {
501      for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next)
516      for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next)
502517      {
503518         moncount++;
504         if (strcmp(scrname, monitor->device()) == 0)
519         if (strcmp(scrname, monitor->monitor_device) == 0)
505520            goto finishit;
506521      }
507522   }
508523
509524   // didn't find it; alternate monitors until we hit the jackpot
510525   index %= moncount;
511   for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next)
526   for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next)
512527      if (index-- == 0)
513528         goto finishit;
514529
r243238r243239
518533finishit:
519534   if (aspect != 0)
520535   {
521      monitor->set_aspect(aspect);
536      monitor->aspect = aspect;
522537   }
523538   return monitor;
524539}
r243238r243239
594609}
595610
596611//============================================================
612//  extract_window_config
613//============================================================
614
615void sdl_osd_interface::extract_window_config(int index, sdl_window_config *conf)
616{
617   // per-window options: extract the data
618   get_resolution(options().resolution(), options().resolution(index), conf, TRUE);
619}
620
621//============================================================
597622//  extract_video_config
598623//============================================================
599624
trunk/src/osd/sdl/video.h
r243238r243239
1212#ifndef __SDLVIDEO__
1313#define __SDLVIDEO__
1414
15#include "osdsdl.h"
16
1715//============================================================
1816//  CONSTANTS
1917//============================================================
r243238r243239
5856   int                 height;
5957};
6058
61class sdl_monitor_info
59struct sdl_monitor_info
6260{
63public:
6461   sdl_monitor_info  * next;                   // pointer to next monitor in list
65
66   const UINT64 handle() { return m_handle; }
67   const SDL_Rect &position_size() { refresh(); return m_dimensions; }
68
69   const char *device() { return m_monitor_device; }
70
71   float aspect();
72   int   center_width() { refresh(); return m_center_width; }
73   int center_height() { refresh(); return m_center_height; }
74
75   void set_aspect(const float aspect) { m_aspect = aspect; }
76
77   // STATIC
78   static void   init();
79   static void exit();
80   static sdl_monitor_info *pick_monitor(sdl_options &options, int index);
81
82private:
83   void refresh();
84
85   UINT64              m_handle;                 // handle to the monitor
86   SDL_Rect         m_dimensions;
87   char                m_monitor_device[64];
88   float               m_aspect;                 // computed/configured aspect ratio of the physical device
89   int                 m_center_width;           // width of first physical screen for centering
90   int                 m_center_height;          // height of first physical screen for centering
91
92   // STATIC
93   static sdl_monitor_info *primary_monitor;
94   static sdl_monitor_info *list;
95
62#ifdef PTR64
63   UINT64              handle;                 // handle to the monitor
64#else
65   UINT32              handle;                 // handle to the monitor
66#endif
67   int                 monitor_width;
68   int                 monitor_height;
69   char                monitor_device[64];
70   float               aspect;                 // computed/configured aspect ratio of the physical device
71   int                 center_width;           // width of first physical screen for centering
72   int                 center_height;          // height of first physical screen for centering
73   int                 monitor_x;              // X position of this monitor in virtual desktop space (SDL virtual space has them all horizontally stacked, not real geometry)
9674};
9775
9876
r243238r243239
11391
11492   // global configuration
11593   int                 windowed;               // start windowed?
116   int                 prescale;               // prescale factor (supported by accel driver)
94   int                 prescale;               // prescale factor (not currently supported)
11795   int                 keepaspect;             // keep aspect ratio?
11896   int                 numscreens;             // number of screens
11997   int                 centerh;
r243238r243239
159137
160138extern sdl_video_config video_config;
161139
140//============================================================
141//  PROTOTYPES
142//============================================================
143
144void sdlvideo_monitor_refresh(sdl_monitor_info *monitor);
145float sdlvideo_monitor_get_aspect(sdl_monitor_info *monitor);
146sdl_monitor_info *sdlvideo_monitor_from_handle(UINT32 monitor); //FIXME: Remove? not referenced
147
162148#endif
trunk/src/osd/sdl/window.c
r243238r243239
407407   if (video_config.keepaspect)
408408   {
409409      // make sure the monitor is up-to-date
410      target->compute_visible_area(target_width, target_height, m_monitor->aspect(), target->orientation(), target_width, target_height);
410      sdlvideo_monitor_refresh(m_monitor);
411      target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(m_monitor), target->orientation(), target_width, target_height);
411412      desired_aspect = (float)target_width / (float)target_height;
412413   }
413414
r243238r243239
848849      minimum_height -= 4;
849850   }
850851
851   num = SDL_GetNumDisplayModes(m_monitor->handle());
852   num = SDL_GetNumDisplayModes(m_monitor->handle);
852853
853854   if (num == 0)
854855   {
r243238r243239
860861      for (i = 0; i < num; ++i)
861862      {
862863         SDL_DisplayMode mode;
863         SDL_GetDisplayMode(m_monitor->handle(), i, &mode);
864         SDL_GetDisplayMode(m_monitor->handle, i, &mode);
864865
865866         // compute initial score based on difference between target and current
866867         size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height));
r243238r243239
10231024         }
10241025         else
10251026         {
1026            blit_surface_size(monitor()->center_width(), monitor()->center_height());
1027            blit_surface_size(monitor()->center_width, monitor()->center_height);
10271028         }
10281029
10291030         // ensure the target bounds are up-to-date, and then get the primitives
r243238r243239
10821083   if (window->fullscreen())
10831084   {
10841085      // default to the current mode exactly
1085      tempwidth = window->monitor()->position_size().w;
1086      tempheight = window->monitor()->position_size().h;
1086      tempwidth = window->monitor()->monitor_width;
1087      tempheight = window->monitor()->monitor_height;
10871088
10881089      // if we're allowed to switch resolutions, override with something better
10891090      if (video_config.switchres)
r243238r243239
12241225   INT32 viswidth, visheight;
12251226   float pixel_aspect;
12261227
1228   // make sure the monitor is up-to-date
1229   sdlvideo_monitor_refresh(m_monitor);
1230
12271231   // get the pixel aspect ratio for the target monitor
1228   pixel_aspect = m_monitor->aspect();
1232   pixel_aspect = sdlvideo_monitor_get_aspect(m_monitor);
12291233
12301234   // determine the proposed width/height
12311235   propwidth = *window_width - extrawidth;
r243238r243239
12641268   // clamp against the maximum (fit on one screen for full screen mode)
12651269   if (this->m_fullscreen)
12661270   {
1267      maxwidth = m_monitor->center_width() - extrawidth;
1268      maxheight = m_monitor->center_height() - extraheight;
1271      maxwidth = m_monitor->center_width - extrawidth;
1272      maxheight = m_monitor->center_height - extraheight;
12691273   }
12701274   else
12711275   {
1272      maxwidth = m_monitor->center_width() - extrawidth;
1273      maxheight = m_monitor->center_height() - extraheight;
1276      maxwidth = m_monitor->center_width - extrawidth;
1277      maxheight = m_monitor->center_height - extraheight;
12741278
12751279      // further clamp to the maximum width/height in the window
12761280      if (this->m_maxwidth != 0)
r243238r243239
13511355   INT32 maxwidth, maxheight;
13521356
13531357   // compute the maximum client area
1354   maxwidth = m_monitor->center_width();
1355   maxheight = m_monitor->center_height();
1358   maxwidth = m_monitor->center_width;
1359   maxheight = m_monitor->center_height;
13561360
13571361   // clamp to the window's max
13581362   if (this->m_maxwidth != 0)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team