branches/osd/src/osd/windows/window.c
| r31515 | r31516 | |
| 117 | 117 | // PROTOTYPES |
| 118 | 118 | //============================================================ |
| 119 | 119 | |
| 120 | | static void winwindow_exit(running_machine &machine); |
| 121 | 120 | static void winwindow_video_window_destroy(win_window_info *window); |
| 122 | 121 | static void draw_video_contents(win_window_info *window, HDC dc, int update); |
| 123 | 122 | |
| r31515 | r31516 | |
| 181 | 180 | |
| 182 | 181 | |
| 183 | 182 | //============================================================ |
| 184 | | // winwindow_init |
| 183 | // window_init |
| 185 | 184 | // (main thread) |
| 186 | 185 | //============================================================ |
| 187 | 186 | |
| 188 | | void winwindow_init(running_machine &machine) |
| 187 | bool windows_osd_interface::window_init() |
| 189 | 188 | { |
| 190 | 189 | size_t temp; |
| 191 | 190 | |
| 192 | 191 | // determine if we are using multithreading or not |
| 193 | | multithreading_enabled = downcast<windows_options &>(machine.options()).multithreading(); |
| 192 | multithreading_enabled = downcast<windows_options &>(machine().options()).multithreading(); |
| 194 | 193 | |
| 195 | 194 | // get the main thread ID before anything else |
| 196 | 195 | main_threadid = GetCurrentThreadId(); |
| 197 | 196 | |
| 198 | | // ensure we get called on the way out |
| 199 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(winwindow_exit), &machine)); |
| 200 | | |
| 201 | 197 | // set up window class and register it |
| 202 | 198 | create_window_class(); |
| 203 | 199 | |
| r31515 | r31516 | |
| 234 | 230 | // initialize the drawers |
| 235 | 231 | if (video_config.mode == VIDEO_MODE_D3D) |
| 236 | 232 | { |
| 237 | | if (drawd3d_init(machine, &draw)) |
| 233 | if (drawd3d_init(machine(), &draw)) |
| 238 | 234 | video_config.mode = VIDEO_MODE_GDI; |
| 239 | 235 | } |
| 240 | 236 | if (video_config.mode == VIDEO_MODE_DDRAW) |
| 241 | 237 | { |
| 242 | | if (drawdd_init(machine, &draw)) |
| 238 | if (drawdd_init(machine(), &draw)) |
| 243 | 239 | video_config.mode = VIDEO_MODE_GDI; |
| 244 | 240 | } |
| 245 | 241 | if (video_config.mode == VIDEO_MODE_GDI) |
| 246 | | drawgdi_init(machine, &draw); |
| 242 | drawgdi_init(machine(), &draw); |
| 247 | 243 | if (video_config.mode == VIDEO_MODE_NONE) |
| 248 | | drawnone_init(machine, &draw); |
| 244 | drawnone_init(machine(), &draw); |
| 249 | 245 | |
| 250 | 246 | // set up the window list |
| 251 | 247 | last_window_ptr = &win_window_list; |
| 248 | |
| 249 | return true; |
| 252 | 250 | } |
| 253 | 251 | |
| 254 | 252 | |
| r31515 | r31516 | |
| 258 | 256 | // (main thread) |
| 259 | 257 | //============================================================ |
| 260 | 258 | |
| 261 | | static void winwindow_exit(running_machine &machine) |
| 259 | void windows_osd_interface::window_exit() |
| 262 | 260 | { |
| 263 | 261 | assert(GetCurrentThreadId() == main_threadid); |
| 264 | 262 | |
branches/osd/src/osd/sdl/window.c
| r31515 | r31516 | |
| 114 | 114 | // PROTOTYPES |
| 115 | 115 | //============================================================ |
| 116 | 116 | |
| 117 | | static void sdlwindow_exit(running_machine &machine); |
| 118 | 117 | static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window); |
| 119 | 118 | static OSDWORK_CALLBACK( draw_video_contents_wt ); |
| 120 | 119 | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ); |
| r31515 | r31516 | |
| 202 | 201 | |
| 203 | 202 | |
| 204 | 203 | //============================================================ |
| 205 | | // win_init_window |
| 204 | // window_init |
| 206 | 205 | // (main thread) |
| 207 | 206 | //============================================================ |
| 208 | 207 | |
| 209 | | int sdlwindow_init(running_machine &machine) |
| 208 | bool sdl_osd_interface::window_init() |
| 210 | 209 | { |
| 211 | 210 | osd_printf_verbose("Enter sdlwindow_init\n"); |
| 212 | 211 | // determine if we are using multithreading or not |
| 213 | | multithreading_enabled = downcast<sdl_options &>(machine.options()).multithreading(); |
| 212 | multithreading_enabled = downcast<sdl_options &>(machine().options()).multithreading(); |
| 214 | 213 | |
| 215 | 214 | // get the main thread ID before anything else |
| 216 | 215 | main_threadid = SDL_ThreadID(); |
| 217 | 216 | |
| 218 | | // ensure we get called on the way out |
| 219 | | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdlwindow_exit), &machine)); |
| 220 | | |
| 221 | 217 | // if multithreading, create a thread to run the windows |
| 222 | 218 | if (multithreading_enabled) |
| 223 | 219 | { |
| 224 | 220 | // create a thread to run the windows from |
| 225 | 221 | work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO); |
| 226 | 222 | if (work_queue == NULL) |
| 227 | | return 1; |
| 223 | return false; |
| 228 | 224 | osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE); |
| 229 | 225 | } |
| 230 | 226 | else |
| r31515 | r31516 | |
| 238 | 234 | #if USE_OPENGL |
| 239 | 235 | if (video_config.mode == VIDEO_MODE_OPENGL) |
| 240 | 236 | { |
| 241 | | if (drawogl_init(machine, &draw)) |
| 237 | if (drawogl_init(machine(), &draw)) |
| 242 | 238 | video_config.mode = VIDEO_MODE_SOFT; |
| 243 | 239 | } |
| 244 | 240 | #endif |
| 245 | 241 | #if SDLMAME_SDL2 |
| 246 | 242 | if (video_config.mode == VIDEO_MODE_SDL13) |
| 247 | 243 | { |
| 248 | | if (draw13_init(machine, &draw)) |
| 244 | if (draw13_init(machine(), &draw)) |
| 249 | 245 | video_config.mode = VIDEO_MODE_SOFT; |
| 250 | 246 | } |
| 251 | 247 | #endif |
| 252 | 248 | if (video_config.mode == VIDEO_MODE_SOFT) |
| 253 | 249 | { |
| 254 | 250 | if (drawsdl_init(&draw)) |
| 255 | | return 1; |
| 251 | return false; |
| 256 | 252 | } |
| 257 | 253 | |
| 258 | 254 | // set up the window list |
| 259 | 255 | last_window_ptr = &sdl_window_list; |
| 260 | 256 | osd_printf_verbose("Leave sdlwindow_init\n"); |
| 261 | | return 0; |
| 257 | return true; |
| 262 | 258 | } |
| 263 | 259 | |
| 264 | 260 | |
| r31515 | r31516 | |
| 296 | 292 | } |
| 297 | 293 | |
| 298 | 294 | |
| 299 | | static void sdlwindow_exit(running_machine &machine) |
| 295 | void sdl_osd_interface::window_exit() |
| 300 | 296 | { |
| 301 | 297 | ASSERT_MAIN_THREAD(); |
| 302 | 298 | |
| r31515 | r31516 | |
| 307 | 303 | { |
| 308 | 304 | sdl_window_info *temp = sdl_window_list; |
| 309 | 305 | sdl_window_list = temp->next; |
| 310 | | sdlwindow_video_window_destroy(machine, temp); |
| 306 | sdlwindow_video_window_destroy(machine(), temp); |
| 311 | 307 | } |
| 312 | 308 | |
| 313 | 309 | // if we're multithreaded, clean up the window thread |