Previous 199869 Revisions Next

r31540 Thursday 7th August, 2014 at 07:40:02 UTC by Miodrag Milanović
(OSD BRANCH) win_monitor_info to class (nw)
[/branches/osd/src/osd/windows]drawd3d.c drawdd.c drawgdi.c drawnone.c video.c video.h window.c

branches/osd/src/osd/windows/video.c
r31539r31540
109109
110110
111111
112win_monitor_info::win_monitor_info()
113   : next(NULL),
114     handle(NULL),
115     aspect(0.0f),
116     reqwidth(0),
117     reqheight(0)
118{
119}
120
121win_monitor_info::~win_monitor_info()
122{
123}
124
112125//============================================================
113126//  winvideo_monitor_refresh
114127//============================================================
115128
116void winvideo_monitor_refresh(win_monitor_info *monitor)
129void win_monitor_info::refresh()
117130{
118131   BOOL result;
119132
120133   // fetch the latest info about the monitor
121   monitor->info.cbSize = sizeof(monitor->info);
122   result = GetMonitorInfo(monitor->handle, (LPMONITORINFO)&monitor->info);
134   info.cbSize = sizeof(info);
135   result = GetMonitorInfo(handle, (LPMONITORINFO)&info);
123136   assert(result);
124137   (void)result; // to silence gcc 4.6
125138}
r31539r31540
130143//  winvideo_monitor_get_aspect
131144//============================================================
132145
133float winvideo_monitor_get_aspect(win_monitor_info *monitor)
146float win_monitor_info::get_aspect()
134147{
135148   // refresh the monitor information and compute the aspect
136149   if (video_config.keepaspect)
137150   {
138151      int width, height;
139      winvideo_monitor_refresh(monitor);
140      width = rect_width(&monitor->info.rcMonitor);
141      height = rect_height(&monitor->info.rcMonitor);
142      return monitor->aspect / ((float)width / (float)height);
152      refresh();
153      width = rect_width(&info.rcMonitor);
154      height = rect_height(&info.rcMonitor);
155      return aspect / ((float)width / (float)height);
143156   }
144157   return 0.0f;
145158}
r31539r31540
236249   (void)result; // to silence gcc 4.6
237250
238251   // allocate a new monitor info
239   monitor = global_alloc_clear(win_monitor_info);
252   monitor = global_alloc(win_monitor_info);
240253
241254   // copy in the data
242255   monitor->handle = handle;
243256   monitor->info = info;
244257
245258   // guess the aspect ratio assuming square pixels
246   monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top);
259   monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top));
247260
248261   // save the primary monitor handle
249262   if (monitor->info.dwFlags & MONITORINFOF_PRIMARY)
r31539r31540
311324
312325finishit:
313326   if (aspect != 0)
314      monitor->aspect = aspect;
327      monitor->set_aspect(aspect);
315328   return monitor;
316329}
317330
branches/osd/src/osd/windows/window.c
r31539r31540
835835      monitor = window->monitor;
836836
837837   // make sure we're up-to-date
838   winvideo_monitor_refresh(monitor);
838   monitor->refresh();
839839   return monitor;
840840}
841841
r31539r31540
14931493   assert(GetCurrentThreadId() == window_threadid);
14941494
14951495   // get the pixel aspect ratio for the target monitor
1496   pixel_aspect = winvideo_monitor_get_aspect(monitor);
1496   pixel_aspect = monitor->get_aspect();
14971497
14981498   // determine the proposed width/height
14991499   propwidth = rect_width(rect) - extrawidth;
r31539r31540
16651665   assert(GetCurrentThreadId() == window_threadid);
16661666
16671667   // compute the maximum client area
1668   winvideo_monitor_refresh(window->monitor);
1668   window->monitor->refresh();
16691669   maximum = window->monitor->info.rcWork;
16701670
16711671   // clamp to the window's max
branches/osd/src/osd/windows/video.h
r31539r31540
2929//  TYPE DEFINITIONS
3030//============================================================
3131
32struct win_monitor_info
32class win_monitor_info
3333{
34public:
35   win_monitor_info();
36   virtual ~win_monitor_info();
37
38   void refresh();
39   float get_aspect();
40   void set_aspect(float a) { aspect = a; }
41   
3442   win_monitor_info  * next;                   // pointer to next monitor in list
3543   HMONITOR            handle;                 // handle to the monitor
36   MONITORINFOEX       info;                   // most recently retrieved info
44   MONITORINFOEX       info;                   // most recently retrieved info   
45private:   
3746   float               aspect;                 // computed/configured aspect ratio of the physical device
3847   int                 reqwidth;               // requested width for this monitor
3948   int                 reqheight;              // requested height for this monitor
r31539r31540
8190//  GLOBAL VARIABLES
8291//============================================================
8392
84extern win_monitor_info *win_monitor_list;
8593extern win_video_config video_config;
8694
8795
r31539r31540
8997//  PROTOTYPES
9098//============================================================
9199
92void winvideo_monitor_refresh(win_monitor_info *monitor);
93float winvideo_monitor_get_aspect(win_monitor_info *monitor);
94100win_monitor_info *winvideo_monitor_from_handle(HMONITOR monitor);
95101
96102#endif
branches/osd/src/osd/windows/drawd3d.c
r31539r31540
272272   GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen);
273273   if (rect_width(&client) > 0 && rect_height(&client) > 0)
274274   {
275      window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
275      window->target->set_bounds(rect_width(&client), rect_height(&client), window->monitor->get_aspect());
276276      window->target->set_max_update_rate((d3d->get_refresh() == 0) ? d3d->get_origmode().RefreshRate : d3d->get_refresh());
277277   }
278278   return &window->target->get_primitives();
branches/osd/src/osd/windows/drawnone.c
r31539r31540
8888{
8989   RECT client;
9090   GetClientRect(window->hwnd, &client);
91   window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
91   window->target->set_bounds(rect_width(&client), rect_height(&client), window->monitor->get_aspect());
9292   return &window->target->get_primitives();
9393}
9494
branches/osd/src/osd/windows/drawgdi.c
r31539r31540
129129{
130130   RECT client;
131131   GetClientRect(window->hwnd, &client);
132   window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
132   window->target->set_bounds(rect_width(&client), rect_height(&client), window->monitor->get_aspect());
133133   return &window->target->get_primitives();
134134}
135135
branches/osd/src/osd/windows/drawdd.c
r31539r31540
842842      if (video_config.keepaspect)
843843      {
844844         win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
845         window->target->compute_visible_area(target_width, target_height, winvideo_monitor_get_aspect(monitor), window->target->orientation(), target_width, target_height);
845         window->target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window->target->orientation(), target_width, target_height);
846846         desired_aspect = (float)target_width / (float)target_height;
847847      }
848848
r31539r31540
987987   else if (video_config.keepaspect)
988988   {
989989      // compute the appropriate visible area
990      window->target->compute_visible_area(rect_width(&outer), rect_height(&outer), winvideo_monitor_get_aspect(monitor), window->target->orientation(), dstwidth, dstheight);
990      window->target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window->target->orientation(), dstwidth, dstheight);
991991   }
992992
993993   // center within

Previous 199869 Revisions Next


© 1997-2024 The MAME Team