Previous 199869 Revisions Next

r34729 Thursday 29th January, 2015 at 22:25:46 UTC by Couriersud
Merge branch 'master' of https://github.com/mamedev/mame.git
[src/osd/sdl]draw13.c drawogl.c drawsdl.c osdsdl.h video.c video.h window.c

trunk/src/osd/sdl/draw13.c
r243240r243241
593593   SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
594594#endif
595595   // create the SDL window
596   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
596   window->sdl_window = SDL_CreateWindow(window->title,
597         window->monitor()->position_size().x, window->monitor()->position_size().y,
597598         width, height, extra_flags);
598599
599600   if (window->fullscreen() && video_config.switchres)
r243240r243241
710711
711712static void drawsdl2_set_target_bounds(sdl_window_info *window)
712713{
713   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
714   window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
714715}
715716
716717//============================================================
r243240r243241
761762
762763      if ((window->fullscreen()) && (!video_config.switchres))
763764      {
764         ch = window->monitor()->center_height;
765         cw = window->monitor()->center_width;
765         ch = window->monitor()->center_height();
766         cw = window->monitor()->center_width();
766767      }
767768      else
768769      {
trunk/src/osd/sdl/drawogl.c
r243240r243241
558558   //load_gl_lib(window->machine());
559559
560560   // create the SDL window
561   window->sdl_window = SDL_CreateWindow(window->title, window->monitor()->monitor_x, 0,
561   window->sdl_window = SDL_CreateWindow(window->title,
562         window->monitor()->position_size().x, window->monitor()->position_size().y,
562563         width, height, sdl->extra_flags);
563564
564565   if  (!window->sdl_window )
r243240r243241
570571   if (window->fullscreen() && video_config.switchres)
571572   {
572573      SDL_DisplayMode mode;
573      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
574      SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
574575      mode.w = width;
575576      mode.h = height;
576577      if (window->refresh)
r243240r243241
842843
843844static void drawogl_set_target_bounds(sdl_window_info *window)
844845{
845   window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor()));
846   window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
846847}
847848
848849//============================================================
r243240r243241
13121313
13131314      if ((window->fullscreen()) && (!video_config.switchres))
13141315      {
1315         ch = window->monitor()->center_height;
1316         cw = window->monitor()->center_width;
1316         ch = window->monitor()->center_height();
1317         cw = window->monitor()->center_width();
13171318      }
13181319      else
13191320      {
trunk/src/osd/sdl/drawsdl.c
r243240r243241
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   {
r243240r243241
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)
r243240r243241
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, sdlvideo_monitor_get_aspect(window->monitor()));
626      window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect());
627627   else
628628      window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
629629}
r243240r243241
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
r243240r243241
66#include "watchdog.h"
77#include "clifront.h"
88#include "modules/lib/osdobj_common.h"
9#include "video.h"
109#include "modules/osdmodule.h"
1110#include "modules/font/font_module.h"
1211
r243240r243241
215214private:
216215   virtual void osd_exit();
217216
218   void extract_window_config(int index, sdl_window_config *conf);
219
220217   // FIXME: remove machine usage
221218   void extract_video_config(running_machine &machine);
222219
trunk/src/osd/sdl/video.c
r243240r243241
6969#endif
7070#endif
7171
72sdl_monitor_info *sdl_monitor_info::primary_monitor = NULL;
73sdl_monitor_info *sdl_monitor_info::list = NULL;
74
7275//============================================================
7376//  LOCAL VARIABLES
7477//============================================================
7578
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
8683static void check_osd_inputs(running_machine &machine);
8784
8885static float get_aspect(const char *defdata, const char *data, int report_error);
r243240r243241
10198   extract_video_config(machine());
10299
103100   // set up monitors first
104   init_monitors();
101   sdl_monitor_info::init();
105102
106103   // we need the beam width in a float, contrary to what the core does.
107104   video_config.beamwidth = options().beam();
r243240r243241
115112   {
116113      sdl_window_config conf;
117114      memset(&conf, 0, sizeof(conf));
118      extract_window_config(index, &conf);
119      if (sdlwindow_video_window_create(machine(), index, pick_monitor(options(), index), &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))
120117         return false;
121118   }
122119
r243240r243241
131128void sdl_osd_interface::video_exit()
132129{
133130   window_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
131   sdl_monitor_info::exit();
143132}
144133
145134
r243240r243241
147136//  sdlvideo_monitor_refresh
148137//============================================================
149138
150void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
139void sdl_monitor_info::refresh()
151140{
152141   #if (SDLMAME_SDL2)
153142   SDL_DisplayMode dmode;
154143
155144   #if defined(SDLMAME_WIN32)
156   SDL_GetDesktopDisplayMode(monitor->handle, &dmode);
145   SDL_GetDesktopDisplayMode(m_handle, &dmode);
157146   #else
158   SDL_GetCurrentDisplayMode(monitor->handle, &dmode);
147   SDL_GetCurrentDisplayMode(m_handle, &dmode);
159148   #endif
160   monitor->monitor_width = dmode.w;
161   monitor->monitor_height = dmode.h;
162   monitor->center_width = dmode.w;
163   monitor->center_height = dmode.h;
149   SDL_GetDisplayBounds(m_handle, &m_dimensions);
150   m_center_width = m_dimensions.w;
151   m_center_height = m_dimensions.h;
164152
165153   // FIXME: Use SDL_GetDisplayBounds(monitor->handle, &tt) to update monitor_x
166154   // SDL_Rect tt;
r243240r243241
169157   MONITORINFOEX info;
170158   info.cbSize = sizeof(info);
171159   GetMonitorInfo((HMONITOR)monitor->handle, (LPMONITORINFO)&info);
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;
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;
174163   char *temp = utf8_from_wstring(info.szDevice);
175164   strcpy(monitor->monitor_device, temp);
176165   osd_free(temp);
r243240r243241
285274//  sdlvideo_monitor_get_aspect
286275//============================================================
287276
288float sdlvideo_monitor_get_aspect(sdl_monitor_info *monitor)
277float sdl_monitor_info::aspect()
289278{
290279   // refresh the monitor information and compute the aspect
280   refresh();
281   // FIXME: returning 0 looks odd, video_config is bad
291282   if (video_config.keepaspect)
292283   {
293      sdlvideo_monitor_refresh(monitor);
294      return monitor->aspect / ((float)monitor->monitor_width / (float)monitor->monitor_height);
284      return m_aspect / ((float)m_dimensions.w / (float)m_dimensions.h);
295285   }
296286   return 0.0f;
297287}
298288
299289
300290
301//============================================================
302//  sdlvideo_monitor_from_handle
303//============================================================
304291
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
317292//============================================================
318293//  update
319294//============================================================
r243240r243241
431406//  init_monitors
432407//============================================================
433408
434static void init_monitors(void)
409void sdl_monitor_info::init()
435410{
436411   sdl_monitor_info **tailptr;
437412
438413   // make a list of monitors
439   sdl_monitor_list = NULL;
440   tailptr = &sdl_monitor_list;
414   sdl_monitor_info::list = NULL;
415   tailptr = &sdl_monitor_info::list;
441416
442417   #if (SDLMAME_SDL2)
443418   {
r243240r243241
452427
453428         // allocate a new monitor info
454429         monitor = global_alloc_clear(sdl_monitor_info);
430         monitor->m_handle = i;
455431
456         snprintf(monitor->monitor_device, sizeof(monitor->monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
432         snprintf(monitor->m_monitor_device, sizeof(monitor->m_monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
457433
458434         SDL_GetDesktopDisplayMode(i, &dmode);
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;
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
466439         // guess the aspect ratio assuming square pixels
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);
440         monitor->m_aspect = (float)(dmode.w) / (float)(dmode.h);
469441
442         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_monitor_device, dmode.w, dmode.h);
443
470444         monx += dmode.w;
471445
472446         // save the primary monitor handle
r243240r243241
486460   #endif
487461}
488462
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}
489473
474
490475//============================================================
491476//  pick_monitor
492477//============================================================
493478
494479#if (SDLMAME_SDL2) || defined(SDLMAME_WIN32)
495static sdl_monitor_info *pick_monitor(sdl_options &options, int index)
480sdl_monitor_info *sdl_monitor_info::pick_monitor(sdl_options &options, int index)
496481{
497482   sdl_monitor_info *monitor;
498483   const char *scrname, *scrname2;
r243240r243241
513498   // look for a match in the name first
514499   if (scrname != NULL)
515500   {
516      for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next)
501      for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next)
517502      {
518503         moncount++;
519         if (strcmp(scrname, monitor->monitor_device) == 0)
504         if (strcmp(scrname, monitor->device()) == 0)
520505            goto finishit;
521506      }
522507   }
523508
524509   // didn't find it; alternate monitors until we hit the jackpot
525510   index %= moncount;
526   for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next)
511   for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next)
527512      if (index-- == 0)
528513         goto finishit;
529514
r243240r243241
533518finishit:
534519   if (aspect != 0)
535520   {
536      monitor->aspect = aspect;
521      monitor->set_aspect(aspect);
537522   }
538523   return monitor;
539524}
r243240r243241
609594}
610595
611596//============================================================
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//============================================================
622597//  extract_video_config
623598//============================================================
624599
trunk/src/osd/sdl/video.h
r243240r243241
1212#ifndef __SDLVIDEO__
1313#define __SDLVIDEO__
1414
15#include "osdsdl.h"
16
1517//============================================================
1618//  CONSTANTS
1719//============================================================
r243240r243241
5658   int                 height;
5759};
5860
59struct sdl_monitor_info
61class sdl_monitor_info
6062{
63public:
6164   sdl_monitor_info  * next;                   // pointer to next monitor in list
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)
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
7496};
7597
7698
r243240r243241
137159
138160extern sdl_video_config video_config;
139161
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
148162#endif
trunk/src/osd/sdl/window.c
r243240r243241
407407   if (video_config.keepaspect)
408408   {
409409      // make sure the monitor is up-to-date
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);
410      target->compute_visible_area(target_width, target_height, m_monitor->aspect(), target->orientation(), target_width, target_height);
412411      desired_aspect = (float)target_width / (float)target_height;
413412   }
414413
r243240r243241
849848      minimum_height -= 4;
850849   }
851850
852   num = SDL_GetNumDisplayModes(m_monitor->handle);
851   num = SDL_GetNumDisplayModes(m_monitor->handle());
853852
854853   if (num == 0)
855854   {
r243240r243241
861860      for (i = 0; i < num; ++i)
862861      {
863862         SDL_DisplayMode mode;
864         SDL_GetDisplayMode(m_monitor->handle, i, &mode);
863         SDL_GetDisplayMode(m_monitor->handle(), i, &mode);
865864
866865         // compute initial score based on difference between target and current
867866         size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height));
r243240r243241
10241023         }
10251024         else
10261025         {
1027            blit_surface_size(monitor()->center_width, monitor()->center_height);
1026            blit_surface_size(monitor()->center_width(), monitor()->center_height());
10281027         }
10291028
10301029         // ensure the target bounds are up-to-date, and then get the primitives
r243240r243241
10831082   if (window->fullscreen())
10841083   {
10851084      // default to the current mode exactly
1086      tempwidth = window->monitor()->monitor_width;
1087      tempheight = window->monitor()->monitor_height;
1085      tempwidth = window->monitor()->position_size().w;
1086      tempheight = window->monitor()->position_size().h;
10881087
10891088      // if we're allowed to switch resolutions, override with something better
10901089      if (video_config.switchres)
r243240r243241
12251224   INT32 viswidth, visheight;
12261225   float pixel_aspect;
12271226
1228   // make sure the monitor is up-to-date
1229   sdlvideo_monitor_refresh(m_monitor);
1230
12311227   // get the pixel aspect ratio for the target monitor
1232   pixel_aspect = sdlvideo_monitor_get_aspect(m_monitor);
1228   pixel_aspect = m_monitor->aspect();
12331229
12341230   // determine the proposed width/height
12351231   propwidth = *window_width - extrawidth;
r243240r243241
12681264   // clamp against the maximum (fit on one screen for full screen mode)
12691265   if (this->m_fullscreen)
12701266   {
1271      maxwidth = m_monitor->center_width - extrawidth;
1272      maxheight = m_monitor->center_height - extraheight;
1267      maxwidth = m_monitor->center_width() - extrawidth;
1268      maxheight = m_monitor->center_height() - extraheight;
12731269   }
12741270   else
12751271   {
1276      maxwidth = m_monitor->center_width - extrawidth;
1277      maxheight = m_monitor->center_height - extraheight;
1272      maxwidth = m_monitor->center_width() - extrawidth;
1273      maxheight = m_monitor->center_height() - extraheight;
12781274
12791275      // further clamp to the maximum width/height in the window
12801276      if (this->m_maxwidth != 0)
r243240r243241
13551351   INT32 maxwidth, maxheight;
13561352
13571353   // compute the maximum client area
1358   maxwidth = m_monitor->center_width;
1359   maxheight = m_monitor->center_height;
1354   maxwidth = m_monitor->center_width();
1355   maxheight = m_monitor->center_height();
13601356
13611357   // clamp to the window's max
13621358   if (this->m_maxwidth != 0)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team