branches/osd/src/osd/windows/video.c
| r31539 | r31540 | |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | win_monitor_info::win_monitor_info() |
| 113 | : next(NULL), |
| 114 | handle(NULL), |
| 115 | aspect(0.0f), |
| 116 | reqwidth(0), |
| 117 | reqheight(0) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | win_monitor_info::~win_monitor_info() |
| 122 | { |
| 123 | } |
| 124 | |
| 112 | 125 | //============================================================ |
| 113 | 126 | // winvideo_monitor_refresh |
| 114 | 127 | //============================================================ |
| 115 | 128 | |
| 116 | | void winvideo_monitor_refresh(win_monitor_info *monitor) |
| 129 | void win_monitor_info::refresh() |
| 117 | 130 | { |
| 118 | 131 | BOOL result; |
| 119 | 132 | |
| 120 | 133 | // 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); |
| 123 | 136 | assert(result); |
| 124 | 137 | (void)result; // to silence gcc 4.6 |
| 125 | 138 | } |
| r31539 | r31540 | |
| 130 | 143 | // winvideo_monitor_get_aspect |
| 131 | 144 | //============================================================ |
| 132 | 145 | |
| 133 | | float winvideo_monitor_get_aspect(win_monitor_info *monitor) |
| 146 | float win_monitor_info::get_aspect() |
| 134 | 147 | { |
| 135 | 148 | // refresh the monitor information and compute the aspect |
| 136 | 149 | if (video_config.keepaspect) |
| 137 | 150 | { |
| 138 | 151 | 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); |
| 143 | 156 | } |
| 144 | 157 | return 0.0f; |
| 145 | 158 | } |
| r31539 | r31540 | |
| 236 | 249 | (void)result; // to silence gcc 4.6 |
| 237 | 250 | |
| 238 | 251 | // allocate a new monitor info |
| 239 | | monitor = global_alloc_clear(win_monitor_info); |
| 252 | monitor = global_alloc(win_monitor_info); |
| 240 | 253 | |
| 241 | 254 | // copy in the data |
| 242 | 255 | monitor->handle = handle; |
| 243 | 256 | monitor->info = info; |
| 244 | 257 | |
| 245 | 258 | // 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)); |
| 247 | 260 | |
| 248 | 261 | // save the primary monitor handle |
| 249 | 262 | if (monitor->info.dwFlags & MONITORINFOF_PRIMARY) |
| r31539 | r31540 | |
| 311 | 324 | |
| 312 | 325 | finishit: |
| 313 | 326 | if (aspect != 0) |
| 314 | | monitor->aspect = aspect; |
| 327 | monitor->set_aspect(aspect); |
| 315 | 328 | return monitor; |
| 316 | 329 | } |
| 317 | 330 | |
branches/osd/src/osd/windows/window.c
| r31539 | r31540 | |
| 835 | 835 | monitor = window->monitor; |
| 836 | 836 | |
| 837 | 837 | // make sure we're up-to-date |
| 838 | | winvideo_monitor_refresh(monitor); |
| 838 | monitor->refresh(); |
| 839 | 839 | return monitor; |
| 840 | 840 | } |
| 841 | 841 | |
| r31539 | r31540 | |
| 1493 | 1493 | assert(GetCurrentThreadId() == window_threadid); |
| 1494 | 1494 | |
| 1495 | 1495 | // get the pixel aspect ratio for the target monitor |
| 1496 | | pixel_aspect = winvideo_monitor_get_aspect(monitor); |
| 1496 | pixel_aspect = monitor->get_aspect(); |
| 1497 | 1497 | |
| 1498 | 1498 | // determine the proposed width/height |
| 1499 | 1499 | propwidth = rect_width(rect) - extrawidth; |
| r31539 | r31540 | |
| 1665 | 1665 | assert(GetCurrentThreadId() == window_threadid); |
| 1666 | 1666 | |
| 1667 | 1667 | // compute the maximum client area |
| 1668 | | winvideo_monitor_refresh(window->monitor); |
| 1668 | window->monitor->refresh(); |
| 1669 | 1669 | maximum = window->monitor->info.rcWork; |
| 1670 | 1670 | |
| 1671 | 1671 | // clamp to the window's max |
branches/osd/src/osd/windows/video.h
| r31539 | r31540 | |
| 29 | 29 | // TYPE DEFINITIONS |
| 30 | 30 | //============================================================ |
| 31 | 31 | |
| 32 | | struct win_monitor_info |
| 32 | class win_monitor_info |
| 33 | 33 | { |
| 34 | public: |
| 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 | |
| 34 | 42 | win_monitor_info * next; // pointer to next monitor in list |
| 35 | 43 | HMONITOR handle; // handle to the monitor |
| 36 | | MONITORINFOEX info; // most recently retrieved info |
| 44 | MONITORINFOEX info; // most recently retrieved info |
| 45 | private: |
| 37 | 46 | float aspect; // computed/configured aspect ratio of the physical device |
| 38 | 47 | int reqwidth; // requested width for this monitor |
| 39 | 48 | int reqheight; // requested height for this monitor |
| r31539 | r31540 | |
| 81 | 90 | // GLOBAL VARIABLES |
| 82 | 91 | //============================================================ |
| 83 | 92 | |
| 84 | | extern win_monitor_info *win_monitor_list; |
| 85 | 93 | extern win_video_config video_config; |
| 86 | 94 | |
| 87 | 95 | |
| r31539 | r31540 | |
| 89 | 97 | // PROTOTYPES |
| 90 | 98 | //============================================================ |
| 91 | 99 | |
| 92 | | void winvideo_monitor_refresh(win_monitor_info *monitor); |
| 93 | | float winvideo_monitor_get_aspect(win_monitor_info *monitor); |
| 94 | 100 | win_monitor_info *winvideo_monitor_from_handle(HMONITOR monitor); |
| 95 | 101 | |
| 96 | 102 | #endif |
branches/osd/src/osd/windows/drawd3d.c
| r31539 | r31540 | |
| 272 | 272 | GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen); |
| 273 | 273 | if (rect_width(&client) > 0 && rect_height(&client) > 0) |
| 274 | 274 | { |
| 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()); |
| 276 | 276 | window->target->set_max_update_rate((d3d->get_refresh() == 0) ? d3d->get_origmode().RefreshRate : d3d->get_refresh()); |
| 277 | 277 | } |
| 278 | 278 | return &window->target->get_primitives(); |
branches/osd/src/osd/windows/drawdd.c
| r31539 | r31540 | |
| 842 | 842 | if (video_config.keepaspect) |
| 843 | 843 | { |
| 844 | 844 | 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); |
| 846 | 846 | desired_aspect = (float)target_width / (float)target_height; |
| 847 | 847 | } |
| 848 | 848 | |
| r31539 | r31540 | |
| 987 | 987 | else if (video_config.keepaspect) |
| 988 | 988 | { |
| 989 | 989 | // 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); |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | // center within |