void sdl_window_info::notify_changed() { worker_param wp; if (SDL_ThreadID() == main_threadid) { execute_async_wait(¬ify_changed_wt, worker_param(this)); } else execute_sync(¬ify_changed_wt, worker_param(this)); }
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 (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()); } } if (video_config.waitvsync && video_config.syncrefresh) event_wait_ticks = osd_ticks_per_second(); // block at most a second else event_wait_ticks = 0; if (osd_event_wait(m_rendered_event, event_wait_ticks)) { // ensure the target bounds are up-to-date, and then get the primitives render_primitive_list &primlist = *m_renderer->get_primitives(); // and redraw now execute_async(&draw_video_contents_wt, worker_param(this, primlist)); } } }
void sdl_window_info::window_changeres(running_machine &machine) { #if (SDLMAME_SDL2) if (this->fullscreen() && video_config.switchres) { execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(this)); SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO); execute_async_wait(&complete_create_wt, worker_param(this)); } #else if (this->fullscreen() && video_config.switchres) this->window_resize(window->minwidth, window->minheight); #endif }
void sdl_window_info::destroy() { sdl_window_info **prevptr; ASSERT_MAIN_THREAD(); if (multithreading_enabled) { sdlwindow_sync(); } //osd_event_wait(window->rendered_event, osd_ticks_per_second()*10); // remove us from the list for (prevptr = &sdl_window_list; *prevptr != NULL; prevptr = &(*prevptr)->m_next) if (*prevptr == this) { *prevptr = this->m_next; break; } // free the textures etc execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(this)); // free the render target, after the textures! this->machine().render().target_free(m_target); // free the event osd_event_free(m_rendered_event); // free the lock osd_lock_free(this->m_render_lock); }
void sdl_window_info::modify_prescale(int dir) { worker_param wp = worker_param(this); int new_prescale = prescale(); if (dir > 0 && prescale() < 3) new_prescale = prescale() + 1; if (dir < 0 && prescale() > 1) new_prescale = prescale() - 1; if (new_prescale != prescale()) { if (m_fullscreen && video_config.switchres) { execute_async_wait(&sdlwindow_video_window_destroy_wt, wp); m_prescale = new_prescale; execute_async_wait(&complete_create_wt, wp); } else { notify_changed(); m_prescale = new_prescale; } machine().ui().popup_time(1, "Prescale %d", prescale()); } }
void sdl_window_info::resize(INT32 width, INT32 height) { ASSERT_MAIN_THREAD(); osd_dim cd = get_size(); if (width != cd.width() || height != cd.height()) execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height)); }
void sdl_window_info::toggle_full_screen() { ASSERT_MAIN_THREAD(); execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(this)); }
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); } } } }