void winwindow_video_window_update(win_window_info *window) { int targetview, targetorient, targetlayerconfig; assert(GetCurrentThreadId() == main_threadid); mtlog_add("winwindow_video_window_update: begin"); // see if the target has changed significantly in window mode targetview = render_target_get_view(window->target); targetorient = render_target_get_orientation(window->target); targetlayerconfig = render_target_get_layer_config(window->target); if (targetview != window->targetview || targetorient != window->targetorient || targetlayerconfig != window->targetlayerconfig) { window->targetview = targetview; window->targetorient = targetorient; window->targetlayerconfig = targetlayerconfig; // in window mode, reminimize/maximize if (!window->fullscreen) { if (window->isminimized) SendMessage(window->hwnd, WM_USER_SET_MINSIZE, 0, 0); if (window->ismaximized) SendMessage(window->hwnd, WM_USER_SET_MAXSIZE, 0, 0); } } // if we're visible and running and not in the middle of a resize, draw if (window->hwnd != NULL && window->target != NULL) { int got_lock = TRUE; mtlog_add("winwindow_video_window_update: try lock"); // only block if we're throttled if (video_config.throttle || timeGetTime() - last_update_time > 250) osd_lock_acquire(window->render_lock); else got_lock = osd_lock_try(window->render_lock); // only render if we were able to get the lock if (got_lock) { const render_primitive_list *primlist; mtlog_add("winwindow_video_window_update: got lock"); // don't hold the lock; we just used it to see if rendering was still happening osd_lock_release(window->render_lock); // ensure the target bounds are up-to-date, and then get the primitives primlist = (*draw.window_get_primitives)(window); // post a redraw request with the primitive list as a parameter last_update_time = timeGetTime(); mtlog_add("winwindow_video_window_update: PostMessage start"); if (multithreading_enabled) PostMessage(window->hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist); else SendMessage(window->hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist); mtlog_add("winwindow_video_window_update: PostMessage end"); } } mtlog_add("winwindow_video_window_update: end"); }
void sdl_window_info::update() { osd_ticks_t event_wait_ticks; ASSERT_MAIN_THREAD(); // adjust the cursor state //sdlwindow_update_cursor_state(machine, window); execute_async(&update_cursor_state_wt, worker_param(this)); // if we're visible and running and not in the middle of a resize, draw if (m_target != NULL) { int tempwidth, tempheight; // see if the games video mode has changed m_target->compute_minimum_size(tempwidth, tempheight); if (video_config.switchres && m_fullscreen && machine().options().changeres() && machine().switchres.game.changeres) { switchres_resolution_change(this); return; } else if (osd_dim(tempwidth, tempheight) != m_minimum_dim) { m_minimum_dim = osd_dim(tempwidth, tempheight); if (!this->m_fullscreen) { //Don't resize window without user interaction; //window_resize(blitwidth, blitheight); } else if (video_config.switchres) { osd_dim tmp = this->pick_best_mode(); resize(tmp.width(), tmp.height()); } } int got_lock = false; got_lock = osd_lock_try(m_render_lock); // only render if we were able to get the lock if (got_lock) { // don't hold the lock; we just used it to see if rendering was still happening osd_lock_release(m_render_lock); // ensure the target bounds are up-to-date, and then get the primitives render_primitive_list &primlist = *m_renderer->get_primitives(); // and redraw now osd_event_reset(m_rendered_event); execute_async(&draw_video_contents_wt, worker_param(this, primlist)); if (video_config.waitvsync && machine().video().throttled()) { event_wait_ticks = osd_ticks_per_second(); // block at most a second osd_event_wait(m_rendered_event, event_wait_ticks); } } } }