Previous 199869 Revisions Next

r34097 Monday 29th December, 2014 at 01:00:57 UTC by Couriersud
Changed sdl_window_info to be closer to C++:
- Made some members private
- moved static functions into sdl_window_info
- extended work_param struct with constructors for better readability
[src/osd/sdl]draw13.c drawogl.c drawsdl.c input.c sdl.mak video.c window.c window.h

trunk/src/osd/sdl/draw13.c
r242608r242609
551551
552552   window->dxdata = sdl;
553553
554   sdl->extra_flags = (window->fullscreen ?
554   sdl->extra_flags = (window->fullscreen() ?
555555         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
556556
557557   // create the SDL window
558   window->sdl_window = SDL_CreateWindow(window->title, window->monitor->monitor_x, 0,
558   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
559559         width, height, sdl->extra_flags);
560560
561   if (window->fullscreen && video_config.switchres)
561   if (window->fullscreen() && video_config.switchres)
562562   {
563563      SDL_DisplayMode mode;
564      SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
564      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
565565      mode.w = width;
566566      mode.h = height;
567567      if (window->refresh)
r242608r242609
665665
666666static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window)
667667{
668   if ((!window->fullscreen) || (video_config.switchres))
668   if ((!window->fullscreen()) || (video_config.switchres))
669669   {
670      sdlwindow_blit_surface_size(window, window->width, window->height);
670      window->blit_surface_size(window->width, window->height);
671671   }
672672   else
673673   {
674      sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
674      window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
675675   }
676   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
676   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
677677   return window->target->get_primitives();
678678}
679679
r242608r242609
721721   {
722722      int ch, cw;
723723
724      if ((window->fullscreen) && (!video_config.switchres))
724      if ((window->fullscreen()) && (!video_config.switchres))
725725      {
726         ch = window->monitor->center_height;
727         cw = window->monitor->center_width;
726         ch = window->monitor()->center_height;
727         cw = window->monitor()->center_width;
728728      }
729729      else
730730      {
trunk/src/osd/sdl/drawogl.c
r242608r242609
493493   window->dxdata = sdl;
494494
495495#if (SDLMAME_SDL2)
496   sdl->extra_flags = (window->fullscreen ?
496   sdl->extra_flags = (window->fullscreen() ?
497497         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
498498   sdl->extra_flags |= SDL_WINDOW_OPENGL;
499499
r242608r242609
510510   //load_gl_lib(window->machine());
511511
512512   // create the SDL window
513   window->sdl_window = SDL_CreateWindow(window->title, window->monitor->monitor_x, 0,
513   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
514514         width, height, sdl->extra_flags);
515515
516516   if  (!window->sdl_window )
r242608r242609
519519      return 1;
520520   }
521521
522   if (window->fullscreen && video_config.switchres)
522   if (window->fullscreen() && video_config.switchres)
523523   {
524524      SDL_DisplayMode mode;
525      SDL_GetCurrentDisplayMode(window->monitor->handle, &mode);
525      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
526526      mode.w = width;
527527      mode.h = height;
528528      if (window->refresh)
r242608r242609
547547   SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0);
548548
549549#else
550   sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
550   sdl->extra_flags = (window->fullscreen() ?  SDL_FULLSCREEN : SDL_RESIZABLE);
551551   sdl->extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF;
552552
553553   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
r242608r242609
794794
795795static render_primitive_list &drawogl_window_get_primitives(sdl_window_info *window)
796796{
797   if ((!window->fullscreen) || (video_config.switchres))
797   if ((!window->fullscreen()) || (video_config.switchres))
798798   {
799      sdlwindow_blit_surface_size(window, window->width, window->height);
799      window->blit_surface_size(window->width, window->height);
800800   }
801801   else
802802   {
803      sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
803      window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
804804   }
805   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
805   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
806806   return window->target->get_primitives();
807807}
808808
r242608r242609
11431143      screen_device_iterator myiter(window->machine().root_device());
11441144      for (screen = myiter.first(); screen != NULL; screen = myiter.next())
11451145      {
1146         if (window->index == 0)
1146         if (window->index() == 0)
11471147         {
11481148            if ((screen->width() != window->screen_width) || (screen->height() != window->screen_height))
11491149            {
r242608r242609
11801180   screen_device_iterator iter(window->machine().root_device());
11811181   for (screen = iter.first(); screen != NULL; screen = iter.next())
11821182   {
1183      if (scrnum == window->index)
1183      if (scrnum == window->index())
11841184      {
11851185         is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
11861186         break;
r242608r242609
12711271   {
12721272      int ch, cw;
12731273
1274      if ((window->fullscreen) && (!video_config.switchres))
1274      if ((window->fullscreen()) && (!video_config.switchres))
12751275      {
1276         ch = window->monitor->center_height;
1277         cw = window->monitor->center_width;
1276         ch = window->monitor()->center_height;
1277         cw = window->monitor()->center_width;
12781278      }
12791279      else
12801280      {
trunk/src/osd/sdl/drawsdl.c
r242608r242609
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   {
r242608r242609
402402
403403   SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
404404
405   sdl->extra_flags = (window->fullscreen ?
405   sdl->extra_flags = (window->fullscreen() ?
406406         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
407407         | SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
408408
409409   window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
410410         width, height, sdl->extra_flags);
411411
412   if (window->fullscreen && video_config.switchres)
412   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)
r242608r242609
424424
425425   SDL_ShowWindow(window->sdl_window);
426426
427   SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen);
427   SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen());
428428   SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
429429   SDL_RaiseWindow(window->sdl_window);
430430
431431   /* FIXME: Bug in SDL 1.3 */
432   if (window->fullscreen)
432   if (window->fullscreen())
433433      SDL_SetWindowGrab(window->sdl_window, SDL_TRUE);
434434
435435   // create a texture
r242608r242609
468468
469469   setup_texture(window, width, height);
470470#else
471   sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
471   sdl->extra_flags = (window->fullscreen() ?  SDL_FULLSCREEN : SDL_RESIZABLE);
472472
473473   sdl->extra_flags |= sm->extra_flags;
474474
r242608r242609
623623   sdl_info *sdl = (sdl_info *) window->dxdata;
624624   const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
625625
626   if ((!window->fullscreen) || (video_config.switchres))
626   if ((!window->fullscreen()) || (video_config.switchres))
627627   {
628      sdlwindow_blit_surface_size(window, window->width, window->height);
628      window->blit_surface_size(window->width, window->height);
629629   }
630630   else
631631   {
632      sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
632      window->blit_surface_size(window->monitor()->center_width, window->monitor()->center_height);
633633   }
634634
635635   if (!sm->is_scale)
636      window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
636      window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
637637   else
638638      window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
639639
r242608r242609
747747   // figure out what coordinate system to use for centering - in window mode it's always the
748748   // SDL surface size.  in fullscreen the surface covers all monitors, so center according to
749749   // the first one only
750   if ((window->fullscreen) && (!video_config.switchres))
750   if ((window->fullscreen()) && (!video_config.switchres))
751751   {
752      ch = window->monitor->center_height;
753      cw = window->monitor->center_width;
752      ch = window->monitor()->center_height;
753      cw = window->monitor()->center_width;
754754   }
755755   else
756756   {
trunk/src/osd/sdl/input.c
r242608r242609
15661566      {
15671567         if (w->resize_width && w->resize_height && ((now - w->last_resize) > osd_ticks_per_second() / 10))
15681568         {
1569            sdlwindow_resize(w, w->resize_width, w->resize_height);
1569            w->window_resize(w->resize_width, w->resize_height);
15701570            w->resize_width = 0;
15711571            w->resize_height = 0;
15721572         }
r242608r242609
19411941         machine.schedule_exit();
19421942         break;
19431943      case SDL_VIDEORESIZE:
1944         sdlwindow_resize(sdl_window_list, event.resize.w, event.resize.h);
1944          sdl_window_list->window_resize(event.resize.w, event.resize.h);
19451945         break;
19461946#else
19471947      case SDL_TEXTINPUT:
r242608r242609
19731973            app_has_mouse_focus = 0;
19741974            break;
19751975         case SDL_WINDOWEVENT_MOVED:
1976            sdlwindow_clear(window);
1976            window->window_clear();
19771977            focus_window = window;
19781978            break;
19791979         case SDL_WINDOWEVENT_RESIZED:
r242608r242609
19861986            else
19871987            {
19881988               if (event.window.data1 != window->width || event.window.data2 != window->height)
1989                  sdlwindow_resize(window, event.window.data1, event.window.data2);
1989                  window->window_resize(event.window.data1, event.window.data2);
19901990            }
19911991            focus_window = window;
19921992            break;
trunk/src/osd/sdl/sdl.mak
r242608r242609
7777# change for custom OS X installations
7878SDL_FRAMEWORK_PATH = /Library/Frameworks/
7979
80# SDL_LIBVER = sdl
81
8082###########################################################################
8183##################   END USER-CONFIGURABLE OPTIONS   ######################
8284###########################################################################
trunk/src/osd/sdl/video.c
r242608r242609
326326   {
327327//      profiler_mark(PROFILER_BLIT);
328328      for (window = sdl_window_list; window != NULL; window = window->next)
329         sdlwindow_video_window_update(machine(), window);
329         window->video_window_update(machine());
330330//      profiler_mark(PROFILER_END);
331331   }
332332
r242608r242609
568568
569569      while (curwin != (sdl_window_info *)NULL)
570570      {
571         sdlwindow_toggle_full_screen(machine, curwin);
571         curwin->toggle_full_screen(machine);
572572         curwin = curwin->next;
573573      }
574574   }
r242608r242609
597597   #endif
598598
599599   if (ui_input_pressed(machine, IPT_OSD_6))
600      sdlwindow_modify_prescale(machine, window, -1);
600      window->modify_prescale(machine, -1);
601601
602602   if (ui_input_pressed(machine, IPT_OSD_7))
603      sdlwindow_modify_prescale(machine, window, 1);
603      window->modify_prescale(machine, 1);
604604}
605605
606606//============================================================
trunk/src/osd/sdl/window.c
r242608r242609
101101static sdl_draw_info draw;
102102
103103struct worker_param {
104    worker_param()
105    : m_window(NULL), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0)
106    {
107    }
108    worker_param(running_machine &amachine, sdl_window_info *awindow)
109    : m_window(awindow), m_list(NULL), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0)
110    {
111    }
112    worker_param(running_machine &amachine, sdl_window_info *awindow, render_primitive_list *alist)
113    : m_window(awindow), m_list(alist), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0)
114    {
115    }
116    worker_param(sdl_window_info *awindow, int anew_width, int anew_height)
117    : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height)
118    {
119    }
120    worker_param(sdl_window_info *awindow)
121    : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0)
122    {
123    }
104124   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
105   sdl_window_info *window;
106   render_primitive_list *list;
125   sdl_window_info *window() const { assert(m_window != NULL); return m_window; }
126    render_primitive_list *list() const { return m_list; }
127   int new_width() const { return m_resize_new_width; }
128    int new_height() const { return m_resize_new_height; }
129    // FIXME: only needed for window set-up which returns an error.
130    void set_window(sdl_window_info *window) { m_window = window; }
131private:
132   sdl_window_info *m_window;
133   render_primitive_list *m_list;
107134   running_machine *m_machine;
108   int resize_new_width;
109   int resize_new_height;
135   int m_resize_new_width;
136   int m_resize_new_height;
110137};
111138
112139
r242608r242609
114141//  PROTOTYPES
115142//============================================================
116143
117static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window);
118144static OSDWORK_CALLBACK( draw_video_contents_wt );
119145static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt );
120146static OSDWORK_CALLBACK( sdlwindow_resize_wt );
r242608r242609
122148static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window);
123149static void sdlwindow_sync(void);
124150
125static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
126static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain);
127
128151static void *complete_create_wt(void *param, int threadid);
129152static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view);
130153
131154//============================================================
132//  clear the worker_param structure, inline - faster than memset
133//============================================================
134
135INLINE void clear_worker_param(worker_param *wp)
136{
137   wp->window=NULL;
138   wp->list=NULL;
139   wp->m_machine=NULL;
140   wp->resize_new_width=0;
141   wp->resize_new_height=0;
142}
143
144
145//============================================================
146155//  execute_async
147156//============================================================
148157
149158
150INLINE void execute_async(osd_work_callback callback, worker_param *wp)
159INLINE void execute_async(osd_work_callback callback, const worker_param &wp)
151160{
152   worker_param *wp_temp = NULL;
161   worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
162   *wp_temp = wp;
153163
154   if (wp)
155   {
156      wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
157      *wp_temp = *wp;
158   }
159164   if (multithreading_enabled)
160165   {
161166      osd_work_item_queue(work_queue, callback, (void *) wp_temp, WORK_ITEM_FLAG_AUTO_RELEASE);
r242608r242609
163168      callback((void *) wp_temp, 0);
164169}
165170
171INLINE void execute_sync(osd_work_callback callback, const worker_param &wp)
172{
173    worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param));
174    *wp_temp = wp;
166175
176    callback((void *) wp_temp, 0);
177}
178
179
167180//============================================================
168181//  execute_async_wait
169182//============================================================
170183
171INLINE void execute_async_wait(osd_work_callback callback, worker_param *wp)
184INLINE void execute_async_wait(osd_work_callback callback, const worker_param &wp)
172185{
173186   execute_async(callback, wp);
174187   sdlwindow_sync();
r242608r242609
294307
295308void sdl_osd_interface::window_exit()
296309{
310    worker_param wp_dummy;
311
297312   ASSERT_MAIN_THREAD();
298313
299314   osd_printf_verbose("Enter sdlwindow_exit\n");
r242608r242609
303318   {
304319      sdl_window_info *temp = sdl_window_list;
305320      sdl_window_list = temp->next;
306      sdlwindow_video_window_destroy(machine(), temp);
321      temp->video_window_destroy(machine());
322       // free the window itself
323       global_free(temp);
307324   }
308325
309326   // if we're multithreaded, clean up the window thread
r242608r242609
315332   // kill the drawers
316333   (*draw.exit)();
317334
318   execute_async_wait(&sdlwindow_exit_wt, NULL);
335   execute_async_wait(&sdlwindow_exit_wt, wp_dummy);
319336
320337   if (multithreading_enabled)
321338   {
r242608r242609
338355   return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1;
339356}
340357
341void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height)
358void sdl_window_info::blit_surface_size(int window_width, int window_height)
342359{
343360   INT32 newwidth, newheight;
344361   int xscale = 1, yscale = 1;
r242608r242609
347364   INT32 target_height = window_height;
348365
349366   // start with the minimum size
350   window->target->compute_minimum_size(newwidth, newheight);
367   target->compute_minimum_size(newwidth, newheight);
351368
352369   // compute the appropriate visible area if we're trying to keepaspect
353370   if (video_config.keepaspect)
354371   {
355372      // make sure the monitor is up-to-date
356      sdlvideo_monitor_refresh(window->monitor);
357      window->target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(window->monitor), window->target->orientation(), target_width, target_height);
373      sdlvideo_monitor_refresh(m_monitor);
374      target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(m_monitor), target->orientation(), target_width, target_height);
358375      desired_aspect = (float)target_width / (float)target_height;
359376   }
360377
r242608r242609
406423   }
407424
408425   //FIXME: really necessary to distinguish for yuv_modes ?
409   if (window->target->zoom_to_screen()
426   if (target->zoom_to_screen()
410427      && (video_config.scale_mode == VIDEO_SCALE_MODE_NONE ))
411428      newwidth = window_width;
412429
413   if ((window->blitwidth != newwidth) || (window->blitheight != newheight))
414      sdlwindow_clear(window);
430   if ((blitwidth != newwidth) || (blitheight != newheight))
431      window_clear();
415432
416   window->blitwidth = newwidth;
417   window->blitheight = newheight;
433   blitwidth = newwidth;
434   blitheight = newheight;
418435}
419436
420437
r242608r242609
426443static OSDWORK_CALLBACK( sdlwindow_resize_wt )
427444{
428445   worker_param *      wp = (worker_param *) param;
429   sdl_window_info *   window = wp->window;
446   sdl_window_info *   window = wp->window();
430447
431448   ASSERT_WINDOW_THREAD();
432449
433450   window->destroy_all_textures(window);
434   window->resize(window, wp->resize_new_width, wp->resize_new_height);
451   window->resize(window, wp->new_width(), wp->new_height());
435452
436   sdlwindow_blit_surface_size(window, wp->resize_new_width, wp->resize_new_height);
453   window->blit_surface_size(wp->new_width(), wp->new_height());
437454
438   sdlwindow_clear(window);
455   window->window_clear();
439456
440457   osd_free(wp);
441458   return NULL;
442459}
443460
444void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height)
461void sdl_window_info::window_resize(INT32 width, INT32 height)
445462{
446   worker_param wp;
447
448463   ASSERT_MAIN_THREAD();
449464
450   if (width == window->width && height == window->height)
465   if (width == this->width && height == this->height)
451466      return;
452467
453   clear_worker_param(&wp);
454   wp.resize_new_width = width;
455   wp.resize_new_height = height;
456   wp.window = window;
457
458   execute_async_wait(&sdlwindow_resize_wt, &wp);
468   execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height));
459469}
460470
461471
r242608r242609
467477static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt )
468478{
469479   worker_param *wp = (worker_param *) param;
470   sdl_window_info *window = wp->window;
480   sdl_window_info *window = wp->window();
471481
472482   ASSERT_WINDOW_THREAD();
473483
r242608r242609
476486   return NULL;
477487}
478488
479void sdlwindow_clear(sdl_window_info *window)
489void sdl_window_info::window_clear()
480490{
481   worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param));
491   worker_param wp;
482492
483   clear_worker_param(wp);
484   wp->window = window;
485
486493   if (SDL_ThreadID() == main_threadid)
487494   {
488      execute_async_wait(&sdlwindow_clear_surface_wt, wp);
489      osd_free(wp);
495      execute_async_wait(&sdlwindow_clear_surface_wt, worker_param(this));
490496   }
491497   else
492      sdlwindow_clear_surface_wt( (void *) wp, 0);
498       execute_sync(&sdlwindow_clear_surface_wt, worker_param(this));
493499}
494500
495501
r242608r242609
501507static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
502508{
503509   worker_param *wp = (worker_param *) param;
504   sdl_window_info *window = wp->window;
510   sdl_window_info *window = wp->window();
505511
506512   ASSERT_WINDOW_THREAD();
507513
r242608r242609
510516      return NULL;
511517
512518   // If we are going fullscreen (leaving windowed) remember our windowed size
513   if (!window->fullscreen)
519   if (!window->fullscreen())
514520   {
515521      window->windowed_width = window->width;
516522      window->windowed_height = window->height;
r242608r242609
520526   sdlinput_release_keys(wp->machine());
521527
522528   // toggle the window mode
523   window->fullscreen = !window->fullscreen;
529   window->set_fullscreen(!window->fullscreen());
524530
525531   complete_create_wt(param, 0);
526532
527533   return NULL;
528534}
529535
530void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window)
536void sdl_window_info::toggle_full_screen(running_machine &machine)
531537{
532   worker_param wp;
533
534538   ASSERT_MAIN_THREAD();
535539
536   clear_worker_param(&wp);
537   wp.window = window;
538   wp.m_machine = &machine;
539
540   execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp);
540   execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this));
541541}
542542
543543static OSDWORK_CALLBACK( destroy_all_textures_wt )
544544{
545545   worker_param *wp = (worker_param *) param;
546546
547   sdl_window_info *window = wp->window;
547   sdl_window_info *window = wp->window();
548548
549549   window->destroy_all_textures(window);
550550
r242608r242609
552552   return NULL;
553553}
554554
555void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir)
555void sdl_window_info::modify_prescale(running_machine &machine, int dir)
556556{
557   worker_param wp;
558   int new_prescale = window->prescale;
557   worker_param wp = worker_param(machine, this);
558   int new_prescale = prescale;
559559
560   clear_worker_param(&wp);
560   if (dir > 0 && prescale < 3)
561      new_prescale = prescale + 1;
562   if (dir < 0 && prescale > 1)
563      new_prescale = prescale - 1;
561564
562   wp.window = window;
563   wp.m_machine = &machine;
564
565   if (dir > 0 && window->prescale < 3)
566      new_prescale = window->prescale + 1;
567   if (dir < 0 && window->prescale > 1)
568      new_prescale = window->prescale - 1;
569
570   if (new_prescale != window->prescale)
565   if (new_prescale != prescale)
571566   {
572      if (window->fullscreen && video_config.switchres)
567      if (m_fullscreen && video_config.switchres)
573568      {
574         execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
569         execute_async_wait(&sdlwindow_video_window_destroy_wt, wp);
575570
576         window->prescale = new_prescale;
571         prescale = new_prescale;
577572
578         execute_async_wait(&complete_create_wt, &wp);
573         execute_async_wait(&complete_create_wt, wp);
579574
580575      }
581576      else
582577      {
583         execute_async_wait(destroy_all_textures_wt, &wp);
584         window->prescale = new_prescale;
578         execute_async_wait(destroy_all_textures_wt, wp);
579         prescale = new_prescale;
585580      }
586      machine.ui().popup_time(1, "Prescale %d", window->prescale);
581      machine.ui().popup_time(1, "Prescale %d", prescale);
587582   }
588583}
589584
r242608r242609
611606   {
612607      //FIXME: SDL1.3: really broken: the whole SDL code
613608      //       will only work correct with relative mouse movements ...
614      if (!window->fullscreen && !sdlinput_should_hide_mouse(machine))
609      if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine))
615610      {
616611         SDL_ShowCursor(SDL_ENABLE);
617612         if (SDL_GetWindowGrab(window->sdl_window ))
r242608r242609
633628   // the possibility of losing control
634629   if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED))
635630   {
636      if ( window->fullscreen || sdlinput_should_hide_mouse(machine) )
631      if ( window->fullscreen() || sdlinput_should_hide_mouse(machine) )
637632      {
638633         SDL_ShowCursor(SDL_DISABLE);
639634         if (!SDL_WM_GrabInput(SDL_GRAB_QUERY))
r242608r242609
659654    worker_param *      wp = (worker_param *) param;
660655    //sdl_window_info *   window = wp->window;
661656
662    sdlwindow_update_cursor_state(*wp->m_machine, wp->window);
657    sdlwindow_update_cursor_state(wp->machine(), wp->window());
663658
664659    return NULL;
665660}
r242608r242609
678673
679674   ASSERT_MAIN_THREAD();
680675
681   clear_worker_param(wp);
682
683676   // allocate a new window object
684   window = global_alloc_clear(sdl_window_info);
685   window->maxwidth = config->width;
686   window->maxheight = config->height;
687   window->depth = config->depth;
688   window->refresh = config->refresh;
689   window->monitor = monitor;
690   window->m_machine = &machine;
691   window->index = index;
677   window = global_alloc(sdl_window_info(&machine, monitor, index, config));
692678
693   //FIXME: these should be per_window in config-> or even better a bit set
694   window->fullscreen = !video_config.windowed;
695   window->prescale = video_config.prescale;
696
697679   // set the initial maximized state
698680   // FIXME: Does not belong here
699681   sdl_options &options = downcast<sdl_options &>(machine.options());
700682   window->startmaximized = options.maximize();
701683
702   if (!window->fullscreen)
703   {
704      window->windowed_width = config->width;
705      window->windowed_height = config->height;
706   }
707
708684   // add us to the list
709685   *last_window_ptr = window;
710686   last_window_ptr = &window->next;
r242608r242609
726702   else
727703      sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
728704
729   wp->window = window;
705   wp->set_window(window);
730706
707   // FIXME: pass error back in a different way
731708   if (multithreading_enabled)
732709   {
733710      osd_work_item *wi;
r242608r242609
747724   return 0;
748725
749726error:
750   sdlwindow_video_window_destroy(machine, window);
727   window->video_window_destroy(machine);
728    // free the window itself
729    global_free(window);
751730   return 1;
752731}
753732
r242608r242609
760739static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt )
761740{
762741   worker_param *      wp = (worker_param *) param;
763   sdl_window_info *   window = wp->window;
742   sdl_window_info *   window = wp->window();
764743
765744   ASSERT_WINDOW_THREAD();
766745
r242608r242609
775754   return NULL;
776755}
777756
778static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window)
757void sdl_window_info::video_window_destroy(running_machine &machine)
779758{
780759   sdl_window_info **prevptr;
781   worker_param wp;
782760
783761   ASSERT_MAIN_THREAD();
784762   if (multithreading_enabled)
r242608r242609
790768
791769   // remove us from the list
792770   for (prevptr = &sdl_window_list; *prevptr != NULL; prevptr = &(*prevptr)->next)
793      if (*prevptr == window)
771      if (*prevptr == this)
794772      {
795         *prevptr = window->next;
773         *prevptr = this->next;
796774         break;
797775      }
798776
799777   // free the textures etc
800   clear_worker_param(&wp);
801   wp.window = window;
802   wp.m_machine = &machine;
803   execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
778   execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this));
804779
805780   // free the render target, after the textures!
806   window->machine().render().target_free(window->target);
781   this->machine().render().target_free(target);
807782
808783   // free the event
809   osd_event_free(window->rendered_event);
784   osd_event_free(rendered_event);
810785
811   // free the window itself
812   global_free(window);
813786}
814787
815788
r242608r242609
818791//============================================================
819792
820793#if SDLMAME_SDL2
821static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
794void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
822795{
823796   int minimum_width, minimum_height, target_width, target_height;
824797   int i;
r242608r242609
826799   float size_score, best_score = 0.0f;
827800
828801   // determine the minimum width/height for the selected target
829   window->target->compute_minimum_size(minimum_width, minimum_height);
802   target->compute_minimum_size(minimum_width, minimum_height);
830803
831804   // use those as the target for now
832   target_width = minimum_width * MAX(1, window->prescale);
833   target_height = minimum_height * MAX(1, window->prescale);
805   target_width = minimum_width * MAX(1, prescale);
806   target_height = minimum_height * MAX(1, prescale);
834807
835808   // if we're not stretching, allow some slop on the minimum since we can handle it
836809   {
r242608r242609
838811      minimum_height -= 4;
839812   }
840813
841   num = SDL_GetNumDisplayModes(window->monitor->handle);
814   num = SDL_GetNumDisplayModes(m_monitor->handle);
842815
843816   if (num == 0)
844817   {
r242608r242609
850823      for (i = 0; i < num; ++i)
851824      {
852825         SDL_DisplayMode mode;
853         SDL_GetDisplayMode(window->monitor->handle, i, &mode);
826         SDL_GetDisplayMode(m_monitor->handle, i, &mode);
854827
855828         // compute initial score based on difference between target and current
856829         size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height));
r242608r242609
864837            size_score *= 0.1f;
865838
866839         // if we're looking for a particular mode, that's a winner
867         if (mode.w == window->maxwidth && mode.h == window->maxheight)
840         if (mode.w == m_maxwidth && mode.h == m_maxheight)
868841            size_score = 2.0f;
869842
870843         // refresh adds some points
871         if (window->refresh)
872            size_score *= 1.0f / (1.0f + fabsf(window->refresh - mode.refresh_rate) / 10.0f);
844         if (refresh)
845            size_score *= 1.0f / (1.0f + fabsf(refresh - mode.refresh_rate) / 10.0f);
873846
874847         osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score);
875848
r242608r242609
885858   }
886859}
887860#else
888static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
861void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
889862{
890863   int minimum_width, minimum_height, target_width, target_height;
891864   int i;
r242608r242609
893866   SDL_Rect **modes;
894867
895868   // determine the minimum width/height for the selected target
896   window->target->compute_minimum_size(minimum_width, minimum_height);
869   target->compute_minimum_size(minimum_width, minimum_height);
897870
898871   // use those as the target for now
899   target_width = minimum_width * MAX(1, window->prescale);
900   target_height = minimum_height * MAX(1, window->prescale);
872   target_width = minimum_width * MAX(1, prescale);
873   target_height = minimum_height * MAX(1, prescale);
901874
902875   // if we're not stretching, allow some slop on the minimum since we can handle it
903876   {
r242608r242609
913886    */
914887   modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
915888#else
916   modes = window->monitor->modes;
889   modes = window->m_monitor->modes;
917890#endif
918891
919892   if (modes == (SDL_Rect **)0)
r242608r242609
923896   }
924897   else if (modes == (SDL_Rect **)-1)  // all modes are possible
925898   {
926      *fswidth = window->maxwidth;
927      *fsheight = window->maxheight;
899      *fswidth = m_maxwidth;
900      *fsheight = m_maxheight;
928901   }
929902   else
930903   {
r242608r242609
942915            size_score *= 0.1f;
943916
944917         // if we're looking for a particular mode, that's a winner
945         if (modes[i]->w == window->maxwidth && modes[i]->h == window->maxheight)
918         if (modes[i]->w == m_maxwidth && modes[i]->h == m_maxheight)
946919            size_score = 2.0f;
947920
948921         osd_printf_verbose("%4dx%4d -> %f\n", (int)modes[i]->w, (int)modes[i]->h, size_score);
r242608r242609
965938//  (main thread)
966939//============================================================
967940
968void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window)
941void sdl_window_info::video_window_update(running_machine &machine)
969942{
970943   osd_ticks_t     event_wait_ticks;
971944   ASSERT_MAIN_THREAD();
r242608r242609
973946   // adjust the cursor state
974947   //sdlwindow_update_cursor_state(machine, window);
975948
976    {
977        worker_param wp;
949    execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this));
978950
979        clear_worker_param(&wp);
980        wp.window = window;
981        wp.m_machine = &machine;
982
983        execute_async(&sdlwindow_update_cursor_state_wt, &wp);
984    }
985
986951   // if we're visible and running and not in the middle of a resize, draw
987   if (window->target != NULL)
952   if (target != NULL)
988953   {
989954      int tempwidth, tempheight;
990955
991956      // see if the games video mode has changed
992      window->target->compute_minimum_size(tempwidth, tempheight);
993      if (tempwidth != window->minwidth || tempheight != window->minheight)
957      target->compute_minimum_size(tempwidth, tempheight);
958      if (tempwidth != m_minwidth || tempheight != m_minheight)
994959      {
995         window->minwidth = tempwidth;
996         window->minheight = tempheight;
960         m_minwidth = tempwidth;
961         m_minheight = tempheight;
997962
998         if (!window->fullscreen)
963         if (!this->m_fullscreen)
999964         {
1000            sdlwindow_blit_surface_size(window, window->width, window->height);
1001            sdlwindow_resize(window, window->blitwidth, window->blitheight);
965            blit_surface_size(width, height);
966            window_resize(blitwidth, blitheight);
1002967         }
1003968         else if (video_config.switchres)
1004969         {
1005            pick_best_mode(window, &tempwidth, &tempheight);
1006            sdlwindow_resize(window, tempwidth, tempheight);
970            this->pick_best_mode(&tempwidth, &tempheight);
971            window_resize(tempwidth, tempheight);
1007972         }
1008973      }
1009974
r242608r242609
1012977      else
1013978         event_wait_ticks = 0;
1014979
1015      if (osd_event_wait(window->rendered_event, event_wait_ticks))
980      if (osd_event_wait(rendered_event, event_wait_ticks))
1016981      {
1017         worker_param wp;
1018         render_primitive_list *primlist;
982            // ensure the target bounds are up-to-date, and then get the primitives
983         render_primitive_list *primlist = &get_primitives(this);
1019984
1020         clear_worker_param(&wp);
1021
1022         // ensure the target bounds are up-to-date, and then get the primitives
1023         primlist = &window->get_primitives(window);
1024
1025985         // and redraw now
1026986
1027         wp.list = primlist;
1028         wp.window = window;
1029         wp.m_machine = &machine;
1030
1031         execute_async(&draw_video_contents_wt, &wp);
987         execute_async(&draw_video_contents_wt, worker_param(machine, this, primlist));
1032988      }
1033989   }
1034990}
r242608r242609
10661022static OSDWORK_CALLBACK( complete_create_wt )
10671023{
10681024   worker_param *      wp = (worker_param *) param;
1069   sdl_window_info *   window = wp->window;
1025   sdl_window_info *   window = wp->window();
10701026
10711027   int tempwidth, tempheight;
10721028   static int result[2] = {0,1};
r242608r242609
10741030   ASSERT_WINDOW_THREAD();
10751031   osd_free(wp);
10761032
1077   if (window->fullscreen)
1033   if (window->fullscreen())
10781034   {
10791035      // default to the current mode exactly
1080      tempwidth = window->monitor->monitor_width;
1081      tempheight = window->monitor->monitor_height;
1036      tempwidth = window->monitor()->monitor_width;
1037      tempheight = window->monitor()->monitor_height;
10821038
10831039      // if we're allowed to switch resolutions, override with something better
10841040      if (video_config.switchres)
1085         pick_best_mode(window, &tempwidth, &tempheight);
1041          window->pick_best_mode(&tempwidth, &tempheight);
10861042   }
10871043   else if (window->windowed_width)
10881044   {
r242608r242609
10951051      if (window->startmaximized)
10961052      {
10971053         tempwidth = tempheight = 0;
1098         get_max_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
1054         window->get_max_bounds(&tempwidth, &tempheight, video_config.keepaspect );
10991055      }
11001056      else
11011057      {
r242608r242609
11031059            instead of letting sdlwindow_blit_surface_size() resize it
11041060            this stops the window from "flashing" from the wrong aspect
11051061            size to the right one at startup. */
1106         tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640;
1107         tempheight = (window->maxheight != 0) ? window->maxheight : 480;
1062         tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640;
1063         tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480;
11081064
1109         get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect );
1065         window->get_min_bounds(&tempwidth, &tempheight, video_config.keepaspect );
11101066      }
11111067   }
11121068
r242608r242609
11741130   UINT32  dc =        0;
11751131   int     update =    1;
11761132   worker_param *wp = (worker_param *) param;
1177   sdl_window_info *window = wp->window;
1133   sdl_window_info *window = wp->window();
11781134
11791135   ASSERT_REDRAW_THREAD();
11801136
11811137   // Some configurations require events to be polled in the worker thread
11821138   sdlinput_process_events_buf(wp->machine());
11831139
1184   window->primlist = wp->list;
1140   window->primlist = wp->list();
11851141
11861142   // if no bitmap, just fill
11871143   if (window->primlist == NULL)
r242608r242609
12091165//  (window thread)
12101166//============================================================
12111167
1212static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width, int *window_height, int adjustment)
1168void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment)
12131169{
12141170   INT32 extrawidth = 0;
12151171   INT32 extraheight = 0;
r242608r242609
12201176   float pixel_aspect;
12211177
12221178   // make sure the monitor is up-to-date
1223   sdlvideo_monitor_refresh(window->monitor);
1179   sdlvideo_monitor_refresh(m_monitor);
12241180
12251181   // get the pixel aspect ratio for the target monitor
1226   pixel_aspect = sdlvideo_monitor_get_aspect(window->monitor);
1182   pixel_aspect = sdlvideo_monitor_get_aspect(m_monitor);
12271183
12281184   // determine the proposed width/height
12291185   propwidth = *window_width - extrawidth;
r242608r242609
12351191   {
12361192      case WMSZ_BOTTOM:
12371193      case WMSZ_TOP:
1238         window->target->compute_visible_area(10000, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight);
1194         target->compute_visible_area(10000, propheight, pixel_aspect, target->orientation(), propwidth, propheight);
12391195         break;
12401196
12411197      case WMSZ_LEFT:
12421198      case WMSZ_RIGHT:
1243         window->target->compute_visible_area(propwidth, 10000, pixel_aspect, window->target->orientation(), propwidth, propheight);
1199         target->compute_visible_area(propwidth, 10000, pixel_aspect, target->orientation(), propwidth, propheight);
12441200         break;
12451201
12461202      default:
1247         window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight);
1203         target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), propwidth, propheight);
12481204         break;
12491205   }
12501206
12511207   // get the minimum width/height for the current layout
1252   window->target->compute_minimum_size(minwidth, minheight);
1208   target->compute_minimum_size(minwidth, minheight);
12531209
12541210   // clamp against the absolute minimum
12551211   propwidth = MAX(propwidth, MIN_WINDOW_DIM);
r242608r242609
12601216   propheight = MAX(propheight, minheight);
12611217
12621218   // clamp against the maximum (fit on one screen for full screen mode)
1263   if (window->fullscreen)
1219   if (this->m_fullscreen)
12641220   {
1265      maxwidth = window->monitor->center_width - extrawidth;
1266      maxheight = window->monitor->center_height - extraheight;
1221      maxwidth = m_monitor->center_width - extrawidth;
1222      maxheight = m_monitor->center_height - extraheight;
12671223   }
12681224   else
12691225   {
1270      maxwidth = window->monitor->center_width - extrawidth;
1271      maxheight = window->monitor->center_height - extraheight;
1226      maxwidth = m_monitor->center_width - extrawidth;
1227      maxheight = m_monitor->center_height - extraheight;
12721228
12731229      // further clamp to the maximum width/height in the window
1274      if (window->maxwidth != 0)
1275         maxwidth = MIN(maxwidth, window->maxwidth + extrawidth);
1276      if (window->maxheight != 0)
1277         maxheight = MIN(maxheight, window->maxheight + extraheight);
1230      if (this->m_maxwidth != 0)
1231         maxwidth = MIN(maxwidth, this->m_maxwidth + extrawidth);
1232      if (this->m_maxheight != 0)
1233         maxheight = MIN(maxheight, this->m_maxheight + extraheight);
12781234   }
12791235
12801236   // clamp to the maximum
r242608r242609
12821238   propheight = MIN(propheight, maxheight);
12831239
12841240   // compute the visible area based on the proposed rectangle
1285   window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), viswidth, visheight);
1241   target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), viswidth, visheight);
12861242
12871243   *window_width = viswidth;
12881244   *window_height = visheight;
r242608r242609
12941250//  (window thread)
12951251//============================================================
12961252
1297static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain)
1253void sdl_window_info::get_min_bounds(int *window_width, int *window_height, int constrain)
12981254{
12991255   INT32 minwidth, minheight;
13001256
13011257   // get the minimum target size
1302   window->target->compute_minimum_size(minwidth, minheight);
1258   this->target->compute_minimum_size(minwidth, minheight);
13031259
13041260   // expand to our minimum dimensions
13051261   if (minwidth < MIN_WINDOW_DIM)
r242608r242609
13151271
13161272      // first constrain with no height limit
13171273      test1w = minwidth; test1h = 10000;
1318      constrain_to_aspect_ratio(window, &test1w, &test1h, WMSZ_BOTTOMRIGHT);
1274      this->constrain_to_aspect_ratio(&test1w, &test1h, WMSZ_BOTTOMRIGHT);
13191275
13201276      // then constrain with no width limit
13211277      test2w = 10000; test2h = minheight;
1322      constrain_to_aspect_ratio(window, &test2w, &test2h, WMSZ_BOTTOMRIGHT);
1278      this->constrain_to_aspect_ratio(&test2w, &test2h, WMSZ_BOTTOMRIGHT);
13231279
13241280      // pick the larger
13251281      if ( test1w > test2w )
r242608r242609
13441300//  (window thread)
13451301//============================================================
13461302
1347static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain)
1303void sdl_window_info::get_max_bounds(int *window_width, int *window_height, int constrain)
13481304{
13491305   INT32 maxwidth, maxheight;
13501306
13511307   // compute the maximum client area
1352   maxwidth = window->monitor->center_width;
1353   maxheight = window->monitor->center_height;
1308   maxwidth = m_monitor->center_width;
1309   maxheight = m_monitor->center_height;
13541310
13551311   // clamp to the window's max
1356   if (window->maxwidth != 0)
1312   if (this->m_maxwidth != 0)
13571313   {
1358      int temp = window->maxwidth + WINDOW_DECORATION_WIDTH;
1314      int temp = this->m_maxwidth + WINDOW_DECORATION_WIDTH;
13591315      if (temp < maxwidth)
13601316         maxwidth = temp;
13611317   }
1362   if (window->maxheight != 0)
1318   if (this->m_maxheight != 0)
13631319   {
1364      int temp = window->maxheight + WINDOW_DECORATION_HEIGHT;
1320      int temp = this->m_maxheight + WINDOW_DECORATION_HEIGHT;
13651321      if (temp < maxheight)
13661322         maxheight = temp;
13671323   }
13681324
13691325   // constrain to fit
13701326   if (constrain)
1371      constrain_to_aspect_ratio(window, &maxwidth, &maxheight, WMSZ_BOTTOMRIGHT);
1327      this->constrain_to_aspect_ratio(&maxwidth, &maxheight, WMSZ_BOTTOMRIGHT);
13721328   //else
13731329   {
13741330      maxwidth -= WINDOW_DECORATION_WIDTH;
trunk/src/osd/sdl/window.h
r242608r242609
3434
3535struct sdl_window_info
3636{
37   // Pointer to next window
37
38    sdl_window_info(running_machine *a_machine, sdl_monitor_info *a_monitor,
39            int index, const sdl_window_config *config)
40    : next(NULL), m_minwidth(0), m_minheight(0),
41      startmaximized(0),
42      rendered_event(0), target(0), primlist(NULL), dxdata(NULL),
43      width(0), height(0), blitwidth(0), blitheight(0),
44      start_viewscreen(0),
45#if (SDLMAME_SDL2)
46      sdl_window(NULL),
47      resize_width(0),
48      resize_height(0),
49      last_resize(0),
50#else
51      screen_width(0), screen_height(0),
52#endif
53      m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0)
54    {
55        m_maxwidth = config->width;
56        m_maxheight = config->height;
57        depth = config->depth;
58        refresh = config->refresh;
59        m_index = index;
60
61        //FIXME: these should be per_window in config-> or even better a bit set
62        m_fullscreen = !video_config.windowed;
63        prescale = video_config.prescale;
64
65        if (!m_fullscreen)
66        {
67            windowed_width = config->width;
68            windowed_height = config->height;
69        }
70    }
71
72    void video_window_update(running_machine &machine);
73    void blit_surface_size(int window_width, int window_height);
74    void toggle_full_screen(running_machine &machine);
75    void modify_prescale(running_machine &machine, int dir);
76    void window_resize(INT32 width, INT32 height);
77    void window_clear();
78
79    void video_window_destroy(running_machine &machine);
80    void pick_best_mode(int *fswidth, int *fsheight);
81    void get_min_bounds(int *window_width, int *window_height, int constrain);
82    void get_max_bounds(int *window_width, int *window_height, int constrain);
83
84    // Pointer to next window
3885   sdl_window_info *   next;
3986
40   // Pointer to machine
4187   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
42   running_machine *   m_machine;
88   sdl_monitor_info *monitor() const { return m_monitor; }
89    int fullscreen() const { return m_fullscreen; }
90    int index() const { return m_index; }
4391
92    void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; }
93
4494   // Draw Callbacks
4595   int (*create)(sdl_window_info *window, int width, int height);
4696   void (*resize)(sdl_window_info *window, int width, int height);
r242608r242609
54104   // window handle and info
55105   char                title[256];
56106
57   // monitor info
58   sdl_monitor_info *  monitor;
59   int                 fullscreen;
60   int         index;
61
62107   // diverse flags
63   int                 minwidth, minheight;
64   int                 maxwidth, maxheight;
108   int                 m_minwidth, m_minheight;
109   int                 m_maxwidth, m_maxheight;
65110   int                 depth;
66111   int                 refresh;
67112   int                 windowed_width;
r242608r242609
100145   int                 screen_width;
101146   int                 screen_height;
102147#endif
148
149private:
150   void constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment);
151
152    // Pointer to machine
153    running_machine *   m_machine;
154    // monitor info
155    sdl_monitor_info *  m_monitor;
156    int                 m_fullscreen;
157    int                 m_index;
158
103159};
104160
105161struct sdl_draw_info
r242608r242609
121177
122178// creation/deletion of windows
123179int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
124void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window);
125void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height);
126void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window);
127void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir);
128void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height);
129void sdlwindow_clear(sdl_window_info *window);
130180
131
132181//============================================================
133182// PROTOTYPES - drawsdl.c
134183//============================================================


Previous 199869 Revisions Next


© 1997-2024 The MAME Team