trunk/src/osd/sdl/window.h
| r243518 | r243519 | |
| 49 | 49 | : |
| 50 | 50 | #ifdef OSD_SDL |
| 51 | 51 | #else |
| 52 | | m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0), |
| 52 | m_hwnd(0), m_focus_hwnd(0), m_resize_state(0), |
| 53 | 53 | m_maxwidth(0), m_maxheight(0), |
| 54 | 54 | m_refresh(0), |
| 55 | 55 | #endif |
| r243518 | r243519 | |
| 64 | 64 | |
| 65 | 65 | int prescale() const { return m_prescale; }; |
| 66 | 66 | |
| 67 | float aspect() const { return monitor()->aspect(); } |
| 68 | |
| 67 | 69 | #ifdef OSD_SDL |
| 68 | 70 | virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0; |
| 69 | 71 | virtual sdl_monitor_info *monitor() const = 0; |
| r243518 | r243519 | |
| 74 | 76 | virtual SDL_Surface *sdl_surface() = 0; |
| 75 | 77 | #endif |
| 76 | 78 | #else |
| 79 | virtual win_monitor_info *monitor() const = 0; |
| 77 | 80 | virtual bool win_has_menu() = 0; |
| 81 | // FIXME: cann we replace winwindow_video_window_monitor(NULL) with monitor() ? |
| 78 | 82 | virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0; |
| 79 | 83 | |
| 80 | 84 | // window handle and info |
| r243518 | r243519 | |
| 83 | 87 | // During modularization, this should be passed in differently |
| 84 | 88 | HWND m_focus_hwnd; |
| 85 | 89 | |
| 86 | | // monitor info |
| 87 | | win_monitor_info * m_monitor; |
| 88 | 90 | int m_resize_state; |
| 89 | 91 | int m_maxwidth, m_maxheight; |
| 90 | 92 | int m_refresh; |
trunk/src/osd/windows/drawd3d.c
| r243518 | r243519 | |
| 247 | 247 | GetClientRectExceptMenu(window().m_hwnd, &client, window().fullscreen()); |
| 248 | 248 | if (rect_width(&client) > 0 && rect_height(&client) > 0) |
| 249 | 249 | { |
| 250 | | window().target()->set_bounds(rect_width(&client), rect_height(&client), window().m_monitor->get_aspect()); |
| 250 | window().target()->set_bounds(rect_width(&client), rect_height(&client), window().aspect()); |
| 251 | 251 | window().target()->set_max_update_rate((get_refresh() == 0) ? get_origmode().RefreshRate : get_refresh()); |
| 252 | 252 | } |
| 253 | 253 | return &window().target()->get_primitives(); |
| r243518 | r243519 | |
| 1220 | 1220 | // make sure it's a pixel format we can get behind |
| 1221 | 1221 | if (m_pixformat != D3DFMT_X1R5G5B5 && m_pixformat != D3DFMT_R5G6B5 && m_pixformat != D3DFMT_X8R8G8B8) |
| 1222 | 1222 | { |
| 1223 | | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1224 | | if (utf8_device != NULL) |
| 1225 | | { |
| 1226 | | osd_printf_error("Device %s currently in an unsupported mode\n", utf8_device); |
| 1227 | | osd_free(utf8_device); |
| 1228 | | } |
| 1223 | osd_printf_error("Device %s currently in an unsupported mode\n", window().monitor()->devicename()); |
| 1229 | 1224 | return 1; |
| 1230 | 1225 | } |
| 1231 | 1226 | } |
| r243518 | r243519 | |
| 1248 | 1243 | result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !window().fullscreen()); |
| 1249 | 1244 | if (result != D3D_OK) |
| 1250 | 1245 | { |
| 1251 | | char *utf8_device = utf8_from_tstring(window().m_monitor->info.szDevice); |
| 1252 | | if (utf8_device != NULL) |
| 1253 | | { |
| 1254 | | osd_printf_error("Proposed video mode not supported on device %s\n", utf8_device); |
| 1255 | | osd_free(utf8_device); |
| 1256 | | } |
| 1246 | osd_printf_error("Proposed video mode not supported on device %s\n", window().monitor()->devicename()); |
| 1257 | 1247 | return 1; |
| 1258 | 1248 | } |
| 1259 | 1249 | return 0; |
| r243518 | r243519 | |
| 1276 | 1266 | HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum); |
| 1277 | 1267 | |
| 1278 | 1268 | // if we match the proposed monitor, this is it |
| 1279 | | if (curmonitor == window().m_monitor->handle) |
| 1269 | if (curmonitor == window().monitor()->handle) |
| 1280 | 1270 | { |
| 1281 | 1271 | return adapternum; |
| 1282 | 1272 | } |
trunk/src/osd/windows/drawdd.c
| r243518 | r243519 | |
| 856 | 856 | if (video_config.keepaspect) |
| 857 | 857 | { |
| 858 | 858 | win_monitor_info *monitor = window().winwindow_video_window_monitor(NULL); |
| 859 | | window().target()->compute_visible_area(target_width, target_height, monitor->get_aspect(), window().target()->orientation(), target_width, target_height); |
| 859 | window().target()->compute_visible_area(target_width, target_height, monitor->aspect(), window().target()->orientation(), target_width, target_height); |
| 860 | 860 | desired_aspect = (float)target_width / (float)target_height; |
| 861 | 861 | } |
| 862 | 862 | |
| r243518 | r243519 | |
| 1000 | 1000 | else if (video_config.keepaspect) |
| 1001 | 1001 | { |
| 1002 | 1002 | // compute the appropriate visible area |
| 1003 | | window().target()->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window().target()->orientation(), dstwidth, dstheight); |
| 1003 | window().target()->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->aspect(), window().target()->orientation(), dstwidth, dstheight); |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | // center within |
| r243518 | r243519 | |
| 1082 | 1082 | HRESULT result; |
| 1083 | 1083 | |
| 1084 | 1084 | // choose the monitor number |
| 1085 | | get_adapter_for_monitor(window().m_monitor); |
| 1085 | get_adapter_for_monitor(window().monitor()); |
| 1086 | 1086 | |
| 1087 | 1087 | // create a temporary DirectDraw object |
| 1088 | 1088 | result = (*directdrawcreateex)(adapter_ptr, (LPVOID *)&ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); |
trunk/src/osd/windows/video.c
| r243518 | r243519 | |
| 112 | 112 | win_monitor_info::win_monitor_info() |
| 113 | 113 | : next(NULL), |
| 114 | 114 | handle(NULL), |
| 115 | | aspect(0.0f), |
| 115 | m_aspect(0.0f), |
| 116 | 116 | reqwidth(0), |
| 117 | | reqheight(0) |
| 117 | reqheight(0), |
| 118 | m_name(NULL) |
| 118 | 119 | { |
| 119 | 120 | } |
| 120 | 121 | |
| 121 | 122 | win_monitor_info::~win_monitor_info() |
| 122 | 123 | { |
| 124 | if (m_name != NULL) |
| 125 | osd_free(m_name); |
| 123 | 126 | } |
| 124 | 127 | |
| 125 | 128 | //============================================================ |
| r243518 | r243519 | |
| 134 | 137 | info.cbSize = sizeof(info); |
| 135 | 138 | result = GetMonitorInfo(handle, (LPMONITORINFO)&info); |
| 136 | 139 | assert(result); |
| 140 | if (m_name != NULL) |
| 141 | osd_free(m_name); |
| 142 | m_name = utf8_from_tstring(info.szDevice); |
| 137 | 143 | (void)result; // to silence gcc 4.6 |
| 138 | 144 | } |
| 139 | 145 | |
| r243518 | r243519 | |
| 143 | 149 | // winvideo_monitor_get_aspect |
| 144 | 150 | //============================================================ |
| 145 | 151 | |
| 146 | | float win_monitor_info::get_aspect() |
| 152 | float win_monitor_info::aspect() |
| 147 | 153 | { |
| 148 | 154 | // refresh the monitor information and compute the aspect |
| 149 | 155 | if (video_config.keepaspect) |
| r243518 | r243519 | |
| 152 | 158 | refresh(); |
| 153 | 159 | width = rect_width(&info.rcMonitor); |
| 154 | 160 | height = rect_height(&info.rcMonitor); |
| 155 | | return aspect / ((float)width / (float)height); |
| 161 | return m_aspect / ((float)width / (float)height); |
| 156 | 162 | } |
| 157 | 163 | return 0.0f; |
| 158 | 164 | } |
| r243518 | r243519 | |
| 219 | 225 | win_monitor_info *monitor; |
| 220 | 226 | for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next) |
| 221 | 227 | { |
| 222 | | char *utf8_device = utf8_from_tstring(monitor->info.szDevice); |
| 223 | | if (utf8_device != NULL) |
| 224 | | { |
| 225 | | osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, utf8_device, (monitor == primary_monitor) ? "(primary)" : ""); |
| 226 | | osd_free(utf8_device); |
| 227 | | } |
| 228 | osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : ""); |
| 228 | 229 | } |
| 229 | 230 | } |
| 230 | 231 | } |
| r243518 | r243519 | |
| 298 | 299 | if (scrname[0] != 0) |
| 299 | 300 | for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next) |
| 300 | 301 | { |
| 301 | | char *utf8_device; |
| 302 | 302 | int rc = 1; |
| 303 | 303 | |
| 304 | 304 | moncount++; |
| 305 | 305 | |
| 306 | | utf8_device = utf8_from_tstring(monitor->info.szDevice); |
| 307 | | if (utf8_device != NULL) |
| 308 | | { |
| 309 | | rc = strcmp(scrname, utf8_device); |
| 310 | | osd_free(utf8_device); |
| 311 | | } |
| 306 | rc = strcmp(scrname, monitor->devicename()); |
| 307 | |
| 312 | 308 | if (rc == 0) |
| 313 | 309 | goto finishit; |
| 314 | 310 | } |
trunk/src/osd/windows/video.h
| r243518 | r243519 | |
| 37 | 37 | virtual ~win_monitor_info(); |
| 38 | 38 | |
| 39 | 39 | void refresh(); |
| 40 | | float get_aspect(); |
| 41 | | void set_aspect(float a) { aspect = a; } |
| 40 | float aspect(); |
| 41 | void set_aspect(float a) { m_aspect = a; } |
| 42 | const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; } |
| 42 | 43 | |
| 43 | 44 | win_monitor_info * next; // pointer to next monitor in list |
| 44 | 45 | HMONITOR handle; // handle to the monitor |
| 45 | 46 | MONITORINFOEX info; // most recently retrieved info |
| 46 | 47 | private: |
| 47 | | float aspect; // computed/configured aspect ratio of the physical device |
| 48 | float m_aspect; // computed/configured aspect ratio of the physical device |
| 48 | 49 | int reqwidth; // requested width for this monitor |
| 49 | 50 | int reqheight; // requested height for this monitor |
| 51 | char * m_name; |
| 50 | 52 | }; |
| 51 | 53 | |
| 52 | 54 | |
| 53 | 55 | struct win_window_config |
| 54 | 56 | { |
| 55 | | float aspect; // decoded aspect ratio |
| 57 | float aspect; // decoded aspect ratio FIXME:Not used! |
| 56 | 58 | int width; // decoded width |
| 57 | 59 | int height; // decoded height |
| 58 | 60 | int refresh; // decoded refresh |
trunk/src/osd/windows/window.h
| r243518 | r243519 | |
| 48 | 48 | osd_window() |
| 49 | 49 | : |
| 50 | 50 | #ifdef OSD_SDL |
| 51 | | m_start_viewscreen(0), |
| 52 | 51 | #else |
| 53 | | m_hwnd(0), m_focus_hwnd(0), m_monitor(NULL), m_resize_state(0), |
| 52 | m_hwnd(0), m_focus_hwnd(0), m_resize_state(0), |
| 54 | 53 | m_maxwidth(0), m_maxheight(0), |
| 55 | 54 | m_refresh(0), |
| 56 | 55 | #endif |
| r243518 | r243519 | |
| 65 | 64 | |
| 66 | 65 | int prescale() const { return m_prescale; }; |
| 67 | 66 | |
| 67 | float aspect() const { return monitor()->aspect(); } |
| 68 | |
| 68 | 69 | #ifdef OSD_SDL |
| 69 | 70 | virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0; |
| 70 | 71 | virtual sdl_monitor_info *monitor() const = 0; |
| r243518 | r243519 | |
| 75 | 76 | virtual SDL_Surface *sdl_surface() = 0; |
| 76 | 77 | #endif |
| 77 | 78 | #else |
| 79 | virtual win_monitor_info *monitor() const = 0; |
| 78 | 80 | virtual bool win_has_menu() = 0; |
| 81 | // FIXME: cann we replace winwindow_video_window_monitor(NULL) with monitor() ? |
| 79 | 82 | virtual win_monitor_info *winwindow_video_window_monitor(const RECT *proposed) = 0; |
| 80 | 83 | |
| 81 | 84 | // window handle and info |
| r243518 | r243519 | |
| 84 | 87 | // During modularization, this should be passed in differently |
| 85 | 88 | HWND m_focus_hwnd; |
| 86 | 89 | |
| 87 | | // monitor info |
| 88 | | win_monitor_info * m_monitor; |
| 89 | 90 | int m_resize_state; |
| 90 | 91 | int m_maxwidth, m_maxheight; |
| 91 | 92 | int m_refresh; |
| r243518 | r243519 | |
| 168 | 169 | return GetMenu(m_hwnd) ? true : false; |
| 169 | 170 | } |
| 170 | 171 | |
| 172 | win_monitor_info *monitor() const { return m_monitor; } |
| 173 | |
| 171 | 174 | win_window_info * m_next; |
| 172 | 175 | volatile int m_init_state; |
| 173 | 176 | |
| r243518 | r243519 | |
| 179 | 182 | int m_ismaximized; |
| 180 | 183 | |
| 181 | 184 | // monitor info |
| 185 | win_monitor_info * m_monitor; |
| 182 | 186 | int m_fullscreen; |
| 183 | 187 | int m_fullscreen_safe; |
| 184 | 188 | float m_aspect; |