Previous 199869 Revisions Next

r34724 Thursday 29th January, 2015 at 20:14:00 UTC by Couriersud
Some fixes for multimonitor fullscreen on linux and windows. In
virtualbox, even switchres now works for two monitors. That doesn't
imply it will work on real hardware. The probability is higher :-)
On windows, default render driver now is "opengl" since direct3d
wouldn't work reliably.
This functionality currently is limited to to the "-video accel" driver.
More userspace blitting enhancements. [Couriersud]
[src/osd/sdl]blit13.h draw13.c sdlmain.c

trunk/src/osd/sdl/blit13.h
r243235r243236
5151//============================================================
5252
5353
54#define FUNC_DEF(source) op(const source &src, const rgb_t *palbase)
54#define FUNC_DEF(source) op(const source &src, const rgb_t *palbase) const
5555#define FUNCTOR(name, x...) \
5656    template<typename _source, typename _dest> \
5757    struct name { _dest FUNC_DEF(_source) { x } };
r243235r243236
120120//  Copy and rotation
121121//============================================================
122122
123struct blit_base {
124
125   blit_base(int dest_bpp, bool is_rot, bool is_passthrough)
126   : m_dest_bpp(dest_bpp), m_is_rot(is_rot), m_is_passthrough(is_passthrough)
127   { }
128   virtual ~blit_base() { }
129
130   virtual void texop(const texture_info *texture, const render_texinfo *texsource) const = 0;
131   int m_dest_bpp;
132   bool m_is_rot;
133   bool m_is_passthrough;
134};
135
123136template<typename _src_type, typename _dest_type, typename _op, int _len_div>
124void texcopy(const texture_info *texture, const render_texinfo *texsource)
137struct blit_texcopy : public blit_base
125138{
126   ATTR_UNUSED const rgb_t *palbase = texsource->palette();
127   int x, y;
128    _op op;
129   /* loop over Y */
130   for (y = 0; y < texsource->height; y++) {
131      _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div);
132      _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
133      x = texsource->width / (_len_div);
134      while (x > 0) {
135         *dst++ = op.op(*src, palbase);
136         src++;
137         x--;
138      }
139   }
140}
139   blit_texcopy() : blit_base(sizeof(_dest_type) / _len_div, false, false) { }
140    void texop(const texture_info *texture, const render_texinfo *texsource) const
141    {
142       ATTR_UNUSED const rgb_t *palbase = texsource->palette();
143       int x, y;
144       /* loop over Y */
145       for (y = 0; y < texsource->height; y++) {
146          _src_type *src = (_src_type *)texsource->base + y * texsource->rowpixels / (_len_div);
147          _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
148          x = texsource->width / (_len_div);
149          while (x > 0) {
150             *dst++ = m_op.op(*src, palbase);
151             src++;
152             x--;
153          }
154       }
155    }
156private:
157    _op m_op;
158};
141159
142160#define TEXCOPYA(a, b, c, d) \
143inline void texcopy_ ## a(const texture_info *texture, const render_texinfo *texsource) \
144{ return texcopy<b, c, op_ ## a <b, c>, d>(texture, texsource); }
161      const struct blit_texcopy<b, c, op_ ## a <b, c>, d> texcopy_ ## a;
145162
146163template<typename _src_type, typename _dest_type, typename _op>
147void texcopy_rot(const texture_info *texture, const render_texinfo *texsource)
164struct blit_texrot : public blit_base
148165{
149    ATTR_UNUSED const rgb_t *palbase = texsource->palette();
150    int x, y;
151    const quad_setup_data *setup = &texture->m_setup;
152    int dudx = setup->dudx;
153    int dvdx = setup->dvdx;
154    _op op;
155    /* loop over Y */
156    for (y = 0; y < setup->rotheight; y++) {
157        INT32 curu = setup->startu + y * setup->dudy;
158        INT32 curv = setup->startv + y * setup->dvdy;
159        _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
160        x = setup->rotwidth;
161        while (x>0) {
162            _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16);
163            *dst++ = op.op(*src, palbase);
164            curu += dudx;
165            curv += dvdx;
166            x--;
167        }
168    }
169}
166   blit_texrot() : blit_base(sizeof(_dest_type), true, false) { }
167   void texop(const texture_info *texture, const render_texinfo *texsource) const
168   {
169      ATTR_UNUSED const rgb_t *palbase = texsource->palette();
170      int x, y;
171      const quad_setup_data *setup = &texture->m_setup;
172      int dudx = setup->dudx;
173      int dvdx = setup->dvdx;
174      /* loop over Y */
175      for (y = 0; y < setup->rotheight; y++) {
176         INT32 curu = setup->startu + y * setup->dudy;
177         INT32 curv = setup->startv + y * setup->dvdy;
178         _dest_type *dst = (_dest_type *)((UINT8 *)texture->m_pixels + y * texture->m_pitch);
179         x = setup->rotwidth;
180         while (x>0) {
181            _src_type *src = (_src_type *) texsource->base + (curv >> 16) * texsource->rowpixels + (curu >> 16);
182            *dst++ = m_op.op(*src, palbase);
183            curu += dudx;
184            curv += dvdx;
185            x--;
186         }
187      }
188   }
189private:
190    _op m_op;
191};
170192
171193#define TEXROTA(a, b, c) \
172inline void texcopy_rot_ ## a(const texture_info *texture, const render_texinfo *texsource) \
173{ return texcopy_rot<b, c, op_ ## a <b, c> >(texture, texsource); }
194      const struct blit_texrot<b, c, op_ ## a <b, c> > texcopy_rot_ ## a;
174195
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};
204
205#define TEXCOPYP(a, b, c) \
206      const struct blit_texpass<b, c> texcopy_ ## a;
207
208
175209TEXCOPYA(rgb32_argb32,  UINT32, UINT32, 1)
210TEXCOPYP(rgb32_rgb32,   UINT32, UINT32)
211
176212TEXCOPYA(rgb32pal_argb32,  UINT32, UINT32, 1)
177213TEXCOPYA(pal16_argb32,  UINT16, UINT32, 1)
178214TEXCOPYA(pal16a_argb32,  UINT16, UINT32, 1)
r243235r243236
183219TEXCOPYA(rgb15_argb1555,  UINT16, UINT16, 1)
184220TEXCOPYA(rgb15pal_argb1555,  UINT16, UINT16, 1)
185221
222TEXCOPYP(argb32_argb32,  UINT32, UINT32)
186223TEXCOPYA(argb32_rgb32, UINT32, UINT32, 1)
187224TEXCOPYA(pal16a_rgb32,  UINT16, UINT32, 1)
188225
189226TEXCOPYA(yuv16_argb32, UINT32, UINT64, 2)
190227TEXCOPYA(yuv16pal_argb32, UINT32, UINT64, 2)
191228
192//TEXCOPYA(yuv16_uyvy, UINT16, UINT16, OP_YUV16_UYVY)
229TEXCOPYP(yuv16_uyvy, UINT16, UINT16)
230TEXCOPYP(rgb15_rgb555, UINT16, UINT16)
193231
194232TEXCOPYA(yuv16pal_uyvy, UINT16, UINT16, 1)
195233
trunk/src/osd/sdl/draw13.c
r243235r243236
2424#include "osdsdl.h"
2525#include "window.h"
2626
27
2728//============================================================
2829//  DEBUGGING
2930//============================================================
r243235r243236
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
r243235r243236
134114    const HashT hash() const { return m_hash; }
135115    const UINT32 flags() const { return m_flags; }
136116    // FIXME:
137    const bool is_pixels_owned() const { // do we own / allocated it ?
138        return false && ((m_sdl_access == SDL_TEXTUREACCESS_STATIC)
139                && (m_copyinfo->func != NULL)) ;
140    }
117    const bool is_pixels_owned() const;
141118
142119private:
143120    Uint32              m_sdl_access;
r243235r243236
147124    UINT32              m_flags;              // rendering flags
148125
149126    SDL_Texture *       m_texture_id;
150    int                 m_is_rotated;
127    bool                m_is_rotated;
151128
152129    int                 m_format;             // texture format
153130    SDL_BlendMode       m_sdl_blendmode;
r243235r243236
155132    texture_info *      m_next;               // next texture in the list
156133};
157134
135//============================================================
136//  TEXCOPY FUNCS
137//============================================================
138
139#include "blit13.h"
140
158141/* sdl_info is the information about SDL for the current screen */
159struct sdl_info
142struct sdl_info13
160143{
161    sdl_info()
144    sdl_info13()
162145    : m_blittimer(0), m_renderer(NULL),
163146      m_hofs(0), m_vofs(0),
164147      m_resize_pending(0), m_resize_width(0), m_resize_height(0),
r243235r243236
192175   SDL_DisplayMode m_original_mode;
193176};
194177
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
195194//============================================================
196195//  PROTOTYPES
197196//============================================================
r243235r243236
210209static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
211210
212211//============================================================
213//  TEXCOPY FUNCS
214//============================================================
215
216#include "blit13.h"
217
218//============================================================
219212//  STATIC VARIABLES
220213//============================================================
221214
r243235r243236
223216#define BM_ALL (-1)
224217//( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD)
225218
226#define texcopy_NULL NULL
227#define ENTRY(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, 0}
228#define ENTRY_BM(a,b,c,d,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0}
229#define ENTRY_LR(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1}
219#define ENTRY(a,b,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, 0}
220#define ENTRY_BM(a,b,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0}
221#define ENTRY_LR(a,b,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, &texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1}
230222
231
232223static copy_info_t blit_info_default[] =
233224{
234225   /* no rotation */
235   ENTRY(ARGB32,           ARGB8888,   4, 0, NULL),
236   ENTRY_LR(ARGB32,        RGB888,     4, 0, argb32_rgb32),
226   ENTRY(ARGB32,            ARGB8888,   argb32_argb32),
227   ENTRY_LR(ARGB32,        RGB888,     argb32_rgb32),
237228   /* Entry primarily for directfb */
238   ENTRY_BM(ARGB32,        RGB888,     4, 0, argb32_rgb32, SDL_BLENDMODE_ADD),
239   ENTRY_BM(ARGB32,        RGB888,     4, 0, argb32_rgb32, SDL_BLENDMODE_MOD),
240   ENTRY_BM(ARGB32,        RGB888,     4, 0, argb32_rgb32, SDL_BLENDMODE_NONE),
229   ENTRY_BM(ARGB32,        RGB888,     argb32_rgb32, SDL_BLENDMODE_ADD),
230   ENTRY_BM(ARGB32,        RGB888,     argb32_rgb32, SDL_BLENDMODE_MOD),
231   ENTRY_BM(ARGB32,        RGB888,     argb32_rgb32, SDL_BLENDMODE_NONE),
241232
242   ENTRY(RGB32,            ARGB8888,   4, 0, rgb32_argb32),
243   ENTRY(RGB32,            RGB888,     4, 0, NULL),
233   ENTRY(RGB32,            ARGB8888,   rgb32_argb32),
234   ENTRY(RGB32,             RGB888,     rgb32_rgb32),
244235
245   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 0, rgb32pal_argb32),
246   ENTRY(RGB32_PALETTED,   RGB888,     4, 0, rgb32pal_argb32),
236   ENTRY(RGB32_PALETTED,   ARGB8888,   rgb32pal_argb32),
237   ENTRY(RGB32_PALETTED,   RGB888,     rgb32pal_argb32),
247238
248   ENTRY(YUY16,            UYVY,       2, 0, NULL /* yuv16_uyvy*/),
249   ENTRY(YUY16,            YUY2,       2, 0, yuv16_yuy2),
250   ENTRY(YUY16,            YVYU,       2, 0, yuv16_yvyu),
251   ENTRY(YUY16,            ARGB8888,   4, 0, yuv16_argb32),
252   ENTRY(YUY16,            RGB888,     4, 0, yuv16_argb32),
239   ENTRY(YUY16,             UYVY,       yuv16_uyvy),
240   ENTRY(YUY16,            YUY2,       yuv16_yuy2),
241   ENTRY(YUY16,            YVYU,       yuv16_yvyu),
242   ENTRY(YUY16,            ARGB8888,   yuv16_argb32),
243   ENTRY(YUY16,            RGB888,     yuv16_argb32),
253244
254   ENTRY(YUY16_PALETTED,   UYVY,       2, 0, yuv16pal_uyvy),
255   ENTRY(YUY16_PALETTED,   YUY2,       2, 0, yuv16pal_yuy2),
256   ENTRY(YUY16_PALETTED,   YVYU,       2, 0, yuv16pal_yvyu),
257   ENTRY(YUY16_PALETTED,   ARGB8888,   4, 0, yuv16pal_argb32),
258   ENTRY(YUY16_PALETTED,   RGB888,     4, 0, yuv16pal_argb32),
245   ENTRY(YUY16_PALETTED,   UYVY,       yuv16pal_uyvy),
246   ENTRY(YUY16_PALETTED,   YUY2,       yuv16pal_yuy2),
247   ENTRY(YUY16_PALETTED,   YVYU,       yuv16pal_yvyu),
248   ENTRY(YUY16_PALETTED,   ARGB8888,   yuv16pal_argb32),
249   ENTRY(YUY16_PALETTED,   RGB888,     yuv16pal_argb32),
259250
260   ENTRY(PALETTE16,        ARGB8888,   4, 0, pal16_argb32),
261   ENTRY(PALETTE16,        RGB888,     4, 0, pal16_argb32),
251   ENTRY(PALETTE16,        ARGB8888,   pal16_argb32),
252   ENTRY(PALETTE16,        RGB888,     pal16_argb32),
262253
263   ENTRY(RGB15,            RGB555,     2, 0, NULL /* rgb15_argb1555 */),
264   ENTRY(RGB15,            ARGB1555,   2, 0, rgb15_argb1555),
265   ENTRY(RGB15,            ARGB8888,   4, 0, rgb15_argb32),
266   ENTRY(RGB15,            RGB888,     4, 0, rgb15_argb32),
254   ENTRY(RGB15,             RGB555,     rgb15_rgb555),
255   ENTRY(RGB15,            ARGB1555,   rgb15_argb1555),
256   ENTRY(RGB15,            ARGB8888,   rgb15_argb32),
257   ENTRY(RGB15,            RGB888,     rgb15_argb32),
267258
268   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 0, rgb15pal_argb32),
269   ENTRY(RGB15_PALETTED,   RGB888,     4, 0, rgb15pal_argb32),
259   ENTRY(RGB15_PALETTED,   ARGB8888,   rgb15pal_argb32),
260   ENTRY(RGB15_PALETTED,   RGB888,     rgb15pal_argb32),
270261
271   ENTRY(PALETTE16A,       ARGB8888,   4, 0, pal16a_argb32),
272   ENTRY(PALETTE16A,       RGB888,     4, 0, pal16a_rgb32),
262   ENTRY(PALETTE16A,       ARGB8888,   pal16a_argb32),
263   ENTRY(PALETTE16A,       RGB888,     pal16a_rgb32),
273264
274265   /* rotation */
275   ENTRY(ARGB32,           ARGB8888,   4, 1, rot_argb32_argb32),
276   ENTRY_LR(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32),
266   ENTRY(ARGB32,           ARGB8888,   rot_argb32_argb32),
267   ENTRY_LR(ARGB32,        RGB888,     rot_argb32_rgb32),
277268   /* Entry primarily for directfb */
278   ENTRY_BM(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD),
279   ENTRY_BM(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD),
280   ENTRY_BM(ARGB32,        RGB888,     4, 1, rot_argb32_rgb32, SDL_BLENDMODE_NONE),
269   ENTRY_BM(ARGB32,        RGB888,     rot_argb32_rgb32, SDL_BLENDMODE_ADD),
270   ENTRY_BM(ARGB32,        RGB888,     rot_argb32_rgb32, SDL_BLENDMODE_MOD),
271   ENTRY_BM(ARGB32,        RGB888,     rot_argb32_rgb32, SDL_BLENDMODE_NONE),
281272
282   ENTRY(RGB32,            ARGB8888,   4, 1, rot_rgb32_argb32),
283   ENTRY(RGB32,            RGB888,     4, 1, rot_argb32_argb32),
273   ENTRY(RGB32,            ARGB8888,   rot_rgb32_argb32),
274   ENTRY(RGB32,            RGB888,     rot_argb32_argb32),
284275
285   ENTRY(RGB32_PALETTED,   ARGB8888,   4, 1, rot_rgb32pal_argb32),
286   ENTRY(RGB32_PALETTED,   RGB888,     4, 1, rot_rgb32pal_argb32),
276   ENTRY(RGB32_PALETTED,   ARGB8888,   rot_rgb32pal_argb32),
277   ENTRY(RGB32_PALETTED,   RGB888,     rot_rgb32pal_argb32),
287278
288   ENTRY(YUY16,            ARGB8888,   4, 1, rot_yuv16_argb32rot),
289   ENTRY(YUY16,            RGB888,     4, 1, rot_yuv16_argb32rot),
279   ENTRY(YUY16,            ARGB8888,   rot_yuv16_argb32rot),
280   ENTRY(YUY16,            RGB888,     rot_yuv16_argb32rot),
290281
291   ENTRY(YUY16_PALETTED,   ARGB8888,   4, 1, rot_yuv16pal_argb32rot),
292   ENTRY(YUY16_PALETTED,   RGB888,     4, 1, rot_yuv16pal_argb32rot),
282   ENTRY(YUY16_PALETTED,   ARGB8888,   rot_yuv16pal_argb32rot),
283   ENTRY(YUY16_PALETTED,   RGB888,     rot_yuv16pal_argb32rot),
293284
294   ENTRY(PALETTE16,        ARGB8888,   4, 1, rot_pal16_argb32),
295   ENTRY(PALETTE16,        RGB888,     4, 1, rot_pal16_argb32),
285   ENTRY(PALETTE16,        ARGB8888,   rot_pal16_argb32),
286   ENTRY(PALETTE16,        RGB888,     rot_pal16_argb32),
296287
297   ENTRY(RGB15,            RGB555,     2, 1, rot_rgb15_argb1555),
298   ENTRY(RGB15,            ARGB1555,   2, 1, rot_rgb15_argb1555),
299   ENTRY(RGB15,            ARGB8888,   4, 1, rot_rgb15_argb32),
300   ENTRY(RGB15,            RGB888,     4, 1, rot_rgb15_argb32),
288   ENTRY(RGB15,            RGB555,     rot_rgb15_argb1555),
289   ENTRY(RGB15,            ARGB1555,   rot_rgb15_argb1555),
290   ENTRY(RGB15,            ARGB8888,   rot_rgb15_argb32),
291   ENTRY(RGB15,            RGB888,     rot_rgb15_argb32),
301292
302   ENTRY(RGB15_PALETTED,   ARGB8888,   4, 1, rot_rgb15pal_argb32),
303   ENTRY(RGB15_PALETTED,   RGB888,     4, 1, rot_rgb15pal_argb32),
293   ENTRY(RGB15_PALETTED,   ARGB8888,   rot_rgb15pal_argb32),
294   ENTRY(RGB15_PALETTED,   RGB888,     rot_rgb15pal_argb32),
304295
305   ENTRY(PALETTE16A,       ARGB8888,   4, 1, rot_pal16a_argb32),
306   ENTRY(PALETTE16A,       RGB888,     4, 1, rot_pal16a_rgb32),
296   ENTRY(PALETTE16A,       ARGB8888,   rot_pal16a_argb32),
297   ENTRY(PALETTE16A,       RGB888,     rot_pal16a_rgb32),
307298
308299{ -1 },
309300};
r243235r243236
396387   SDL_RenderCopy(m_renderer,  m_texture_id, NULL, &target_rect);
397388}
398389
399void 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)
400391{
401392   SDL_Rect target_rect;
402393
r243235r243236
550541      {
551542         if (bi->pixel_count)
552543            osd_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname,
553                  bi->rotate ? "rot" : "norot", bi->bm_mask, bi->samples,
544                  bi->blitter->m_is_rot ? "rot" : "norot", bi->bm_mask, bi->samples,
554545                  (int) bi->perf);
555546         freeme = bi;
556547         bi = bi->next;
r243235r243236
582573static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
583574{
584575   // allocate memory for our structures
585   sdl_info *sdl = global_alloc(sdl_info);
576   sdl_info13 *sdl = global_alloc(sdl_info13);
586577
587578   /* FIXME: On Ubuntu and potentially other Linux OS you should use
588579    * to disable panning. This has to be done before every invocation of mame.
r243235r243236
598589   UINT32 extra_flags = (window->fullscreen() ?
599590         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
600591
592#if defined(SDLMAME_WIN32)
593   SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
594#endif
601595   // create the SDL window
602596   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
603597         width, height, extra_flags);
r243235r243236
612606      mode.h = height;
613607      if (window->refresh)
614608         mode.refresh_rate = window->refresh;
609#if 0
615610      if (window->depth)
616611      {
617612         switch (window->depth)
r243235r243236
632627            osd_printf_warning("Ignoring depth %d\n", window->depth);
633628         }
634629      }
630#endif
631
635632      SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
636633#ifndef SDLMAME_WIN32
637634      /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
r243235r243236
642639#endif
643640   }
644641   else
645      SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
646
642   {
643      //SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
644   }
647645   // create renderer
648646
649647   if (video_config.waitvsync)
r243235r243236
657655   }
658656
659657   //SDL_SelectRenderer(window->sdl_window);
660
661658   SDL_ShowWindow(window->sdl_window);
662659   //SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
663660   SDL_RaiseWindow(window->sdl_window);
661
664662   SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
665663
666664   sdl->m_blittimer = 3;
r243235r243236
676674
677675static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
678676{
679   sdl_info *sdl = (sdl_info *) window->dxdata;
677   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
680678
681679   sdl->m_resize_pending = 1;
682680   sdl->m_resize_height = height;
r243235r243236
695693
696694static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
697695{
698   sdl_info *sdl = (sdl_info *) window->dxdata;
696   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
699697
700698   *xt = x - sdl->m_hofs;
701699   *yt = y - sdl->m_vofs;
r243235r243236
721719
722720static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
723721{
724   sdl_info *sdl = (sdl_info *) window->dxdata;
722   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
725723   render_primitive *prim;
726724   texture_info *texture=NULL;
727725   float vofs, hofs;
r243235r243236
835833
836834static void drawsdl2_window_clear(sdl_window_info *window)
837835{
838   sdl_info *sdl = (sdl_info *) window->dxdata;
836   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
839837
840838   sdl->m_blittimer = 2;
841839}
r243235r243236
847845
848846static void drawsdl2_window_destroy(sdl_window_info *window)
849847{
850   sdl_info *sdl = (sdl_info *) window->dxdata;
848   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
851849
852850   // skip if nothing
853851   if (sdl == NULL)
r243235r243236
886884
887885   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
888886   {
889      if ((m_is_rotated == bi->rotate)
887      if ((m_is_rotated == bi->blitter->m_is_rot)
890888            && (m_sdl_blendmode == bi->bm_mask))
891889      {
892890         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
r243235r243236
907905   /* try last resort handlers */
908906   for (bi = blit_info[m_format]; bi != NULL; bi = bi->next)
909907   {
910      if ((m_is_rotated == bi->rotate)
908      if ((m_is_rotated == bi->blitter->m_is_rot)
911909         && (m_sdl_blendmode == bi->bm_mask))
912910         if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
913911            return bi;
r243235r243236
916914   return NULL;
917915}
918916
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
919924//============================================================
920925//  texture_info::matches
921926//============================================================
r243235r243236
945950   m_flags = flags;
946951   m_texinfo = texsource;
947952   m_texinfo.seqid = -1; // force set data
948   m_is_rotated = FALSE;
953   m_is_rotated = false;
949954   m_setup = setup;
950955   m_sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags));
951956   m_pitch = 0;
r243235r243236
974979
975980   if (setup.rotwidth != m_texinfo.width || setup.rotheight != m_texinfo.height
976981         || setup.dudx < 0 || setup.dvdy < 0)
977      m_is_rotated = TRUE;
982      m_is_rotated = true;
978983   else
979      m_is_rotated = FALSE;
984      m_is_rotated = false;
980985
981986   //m_sdl_access = SDL_TEXTUREACCESS_STATIC;
982987   m_sdl_access = SDL_TEXTUREACCESS_STREAMING;
r243235r243236
9981003
9991004   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
10001005   {
1001      if (m_copyinfo->func != NULL)
1002         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->dst_bpp);
1006      if (m_copyinfo->blitter->m_is_passthrough)
1007         m_pixels = NULL;
10031008      else
1004         m_pixels = NULL;
1009         m_pixels = malloc(m_setup.rotwidth * m_setup.rotheight * m_copyinfo->blitter->m_dest_bpp);
10051010   }
10061011   m_last_access = osd_ticks();
10071012
r243235r243236
10231028   m_copyinfo->time -= osd_ticks();
10241029   if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
10251030   {
1026      if ( m_copyinfo->func )
1031      if ( m_copyinfo->blitter->m_is_passthrough )
10271032      {
1028         m_pitch = m_setup.rotwidth * m_copyinfo->dst_bpp;
1029         m_copyinfo->func(this, &texsource);
1033         m_pixels = texsource.base;
1034         m_pitch = m_texinfo.rowpixels * m_copyinfo->blitter->m_dest_bpp;
10301035      }
10311036      else
10321037      {
1033         m_pixels = texsource.base;
1034         m_pitch = m_texinfo.rowpixels * m_copyinfo->dst_bpp;
1038         m_pitch = m_setup.rotwidth * m_copyinfo->blitter->m_dest_bpp;
1039         m_copyinfo->blitter->texop(this, &texsource);
10351040      }
10361041      SDL_UpdateTexture(m_texture_id, NULL, m_pixels, m_pitch);
10371042   }
10381043   else
10391044   {
10401045      SDL_LockTexture(m_texture_id, NULL, (void **) &m_pixels, &m_pitch);
1041      if ( m_copyinfo->func )
1042         m_copyinfo->func(this, &texsource);
1043      else
1046      if ( m_copyinfo->blitter->m_is_passthrough )
10441047      {
10451048         UINT8 *src = (UINT8 *) texsource.base;
10461049         UINT8 *dst = (UINT8 *) m_pixels;
1047         int spitch = texsource.rowpixels * m_copyinfo->dst_bpp;
1048         int num = texsource.width * m_copyinfo->dst_bpp;
1050         int spitch = texsource.rowpixels * m_copyinfo->blitter->m_dest_bpp;
1051         int num = texsource.width * m_copyinfo->blitter->m_dest_bpp;
10491052         int h = texsource.height;
10501053         while (h--) {
10511054            memcpy(dst, src, num);
r243235r243236
10531056            dst += m_pitch;
10541057         }
10551058      }
1059      else
1060         m_copyinfo->blitter->texop(this, &texsource);
10561061      SDL_UnlockTexture(m_texture_id);
10571062   }
10581063   m_copyinfo->time += osd_ticks();
r243235r243236
11131118//  texture_find
11141119//============================================================
11151120
1116texture_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)
11171122{
11181123   HashT texhash = texture_compute_hash(prim.texture, prim.flags);
11191124   texture_info *texture;
r243235r243236
11501155//  texture_update
11511156//============================================================
11521157
1153texture_info * sdl_info::texture_update(const render_primitive &prim)
1158texture_info * sdl_info13::texture_update(const render_primitive &prim)
11541159{
11551160   quad_setup_data setup;
11561161   texture_info *texture;
r243235r243236
11841189
11851190static void drawsdl2_destroy_all_textures(sdl_window_info *window)
11861191{
1187   sdl_info *sdl = (sdl_info *) window->dxdata;
1192   sdl_info13 *sdl = (sdl_info13 *) window->dxdata;
11881193
11891194   if (sdl == NULL)
11901195      return;
trunk/src/osd/sdl/sdlmain.c
r243235r243236
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


Previous 199869 Revisions Next


© 1997-2024 The MAME Team