diff options
Diffstat (limited to 'src/osd/mac')
-rw-r--r-- | src/osd/mac/macmain.cpp | 17 | ||||
-rw-r--r-- | src/osd/mac/osdmac.h | 14 | ||||
-rw-r--r-- | src/osd/mac/video.cpp | 160 | ||||
-rw-r--r-- | src/osd/mac/window.cpp | 204 | ||||
-rw-r--r-- | src/osd/mac/window.h | 57 | ||||
-rw-r--r-- | src/osd/mac/windowcontroller.mm | 2 |
6 files changed, 107 insertions, 347 deletions
diff --git a/src/osd/mac/macmain.cpp b/src/osd/mac/macmain.cpp index 40bcd7d1882..a778046c159 100644 --- a/src/osd/mac/macmain.cpp +++ b/src/osd/mac/macmain.cpp @@ -17,8 +17,10 @@ #include <unistd.h> // MAME headers +#include "corestr.h" #include "osdepend.h" #include "emu.h" +#include "main.h" #include "emuopts.h" #include "strconv.h" @@ -41,12 +43,11 @@ //============================================================ const options_entry mac_options::s_option_entries[] = -{ - { MACOPTION_INIPATH, INI_PATH, OPTION_STRING, "path to ini files" }, + { + {MACOPTION_INIPATH, INI_PATH, core_options::option_type::STRING, "path to ini files"}, - // End of list - { nullptr } -}; + // End of list + {nullptr}}; //============================================================ // mac_options @@ -58,7 +59,7 @@ mac_options::mac_options() std::string ini_path(INI_PATH); add_entries(mac_options::s_option_entries); strreplace(ini_path,"APP_NAME", emulator_info::get_appname_lower()); - set_default_value(MACOPTION_INIPATH, ini_path.c_str()); + set_default_value(MACOPTION_INIPATH, std::move(ini_path)); } //============================================================ @@ -146,7 +147,6 @@ static void defines_verbose(void) osd_printf_verbose("\n"); osd_printf_verbose("Build defines 1: "); MACRO_VERBOSE(LSB_FIRST); - MACRO_VERBOSE(PTR64); MACRO_VERBOSE(MAME_NOASM); MACRO_VERBOSE(MAME_DEBUG); MACRO_VERBOSE(BIGENDIAN); @@ -192,8 +192,6 @@ static void osd_mac_info(void) void mac_osd_interface::video_register() { - video_options_add("opengl", nullptr); - video_options_add("bgfx", nullptr); } //============================================================ @@ -231,6 +229,7 @@ void mac_osd_interface::init(running_machine &machine) int bench = options().bench(); if (bench > 0) { + options().set_value(OPTION_SLEEP, false, OPTION_PRIORITY_MAXIMUM); options().set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); options().set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM); options().set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); diff --git a/src/osd/mac/osdmac.h b/src/osd/mac/osdmac.h index 1ed9e6b8a5b..081c5757c17 100644 --- a/src/osd/mac/osdmac.h +++ b/src/osd/mac/osdmac.h @@ -44,11 +44,13 @@ public: // general overridables virtual void init(running_machine &machine) override; virtual void update(bool skip_redraw) override; + virtual void input_update(bool relative_reset) override; + virtual void check_osd_inputs() override; // input overridables - virtual void customize_input_type_list(simple_list<input_type_entry> &typelist) override; + virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override; - virtual void video_register() override; + virtual void video_register(); virtual bool video_init() override; virtual bool window_init() override; @@ -56,18 +58,16 @@ public: virtual void video_exit() override; virtual void window_exit() override; + virtual void process_events() override; + virtual bool has_focus() const override; + // sdl specific - void poll_inputs(running_machine &machine); void release_keys(); bool should_hide_mouse(); void process_events_buf(); virtual mac_options &options() override { return m_options; } -protected: - virtual void build_slider_list() override; - virtual void update_slider_list() override; - private: virtual void osd_exit() override; diff --git a/src/osd/mac/video.cpp b/src/osd/mac/video.cpp index 638e7a949b3..d441b5f07f3 100644 --- a/src/osd/mac/video.cpp +++ b/src/osd/mac/video.cpp @@ -21,6 +21,9 @@ #include "window.h" #include "osdmac.h" #include "modules/lib/osdlib.h" +#include "modules/monitor/monitor_module.h" + +extern void MacPollInputs(); // in windowcontroller.mm //============================================================ // CONSTANTS @@ -41,9 +44,6 @@ osd_video_config video_config; //============================================================ // PROTOTYPES //============================================================ - -static void check_osd_inputs(running_machine &machine); - static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error); @@ -73,10 +73,12 @@ bool mac_osd_interface::video_init() get_resolution(options().resolution(), options().resolution(index), &conf, true); // create window ... - std::shared_ptr<mac_window_info> win = std::make_shared<mac_window_info>(machine(), index, m_monitor_module->pick_monitor(reinterpret_cast<osd_options &>(options()), index), &conf); + auto win = std::make_unique<mac_window_info>(machine(), *m_render, index, m_monitor_module->pick_monitor(reinterpret_cast<osd_options &>(options()), index), &conf); if (win->window_init()) return false; + + s_window_list.emplace_back(std::move(win)); } return true; @@ -103,64 +105,60 @@ void mac_osd_interface::update(bool skip_redraw) if (!skip_redraw) { // profiler_mark(PROFILER_BLIT); - for (auto window : osd_common_t::s_window_list) + for (auto const &window : osd_common_t::window_list()) window->update(); // profiler_mark(PROFILER_END); } - // poll the joystick values here - downcast<mac_osd_interface&>(machine().osd()).poll_inputs(machine()); - - check_osd_inputs(machine()); // if we're running, disable some parts of the debugger if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) debugger_update(); } //============================================================ -// check_osd_inputs +// input_update //============================================================ -static void check_osd_inputs(running_machine &machine) +void mac_osd_interface::input_update(bool relative_reset) { - // check for toggling fullscreen mode - if (machine.ui_input().pressed(IPT_OSD_1)) - { - for (auto curwin : osd_common_t::s_window_list) - std::static_pointer_cast<mac_window_info>(curwin)->toggle_full_screen(); - } + // poll the joystick values here + process_events_buf(); + MacPollInputs(); + poll_input_modules(relative_reset); +} - auto window = osd_common_t::s_window_list.front(); - if (machine.ui_input().pressed(IPT_OSD_2)) - { - //FIXME: on a per window basis - video_config.fullstretch = !video_config.fullstretch; - window->target()->set_scale_mode(video_config.fullstretch? SCALE_FRACTIONAL : SCALE_INTEGER); - machine.ui().popup_time(1, "Uneven stretch %s", video_config.fullstretch? "enabled":"disabled"); - } +//============================================================ +// check_osd_inputs +//============================================================ - if (machine.ui_input().pressed(IPT_OSD_4)) +void mac_osd_interface::check_osd_inputs() +{ + // check for toggling fullscreen mode (don't do this in debug mode) + if (machine().ui_input().pressed(IPT_OSD_1) && !(machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)) { - //FIXME: on a per window basis - video_config.keepaspect = !video_config.keepaspect; - window->target()->set_keepaspect(video_config.keepaspect); - machine.ui().popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled"); + // destroy the renderers first so that the render module can bounce if it depends on having a window handle + for (auto it = window_list().rbegin(); window_list().rend() != it; ++it) + (*it)->renderer_reset(); + for (auto const &curwin : window_list()) + dynamic_cast<mac_window_info &>(*curwin).toggle_full_screen(); } + auto const &window = window_list().front(); + //FIXME: on a per window basis - if (machine.ui_input().pressed(IPT_OSD_5)) + if (machine().ui_input().pressed(IPT_OSD_5)) { video_config.filter = !video_config.filter; - machine.ui().popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled"); + machine().ui().popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled"); } - if (machine.ui_input().pressed(IPT_OSD_6)) - std::static_pointer_cast<mac_window_info>(window)->modify_prescale(-1); + if (machine().ui_input().pressed(IPT_OSD_6)) + dynamic_cast<mac_window_info &>(*window).modify_prescale(-1); - if (machine.ui_input().pressed(IPT_OSD_7)) - std::static_pointer_cast<mac_window_info>(window)->modify_prescale(1); + if (machine().ui_input().pressed(IPT_OSD_7)) + dynamic_cast<mac_window_info &>(*window).modify_prescale(1); - if (machine.ui_input().pressed(IPT_OSD_8)) + if (machine().ui_input().pressed(IPT_OSD_8)) window->renderer().record(); } @@ -170,51 +168,16 @@ static void check_osd_inputs(running_machine &machine) void mac_osd_interface::extract_video_config() { - const char *stemp; - // global options: extract the data video_config.windowed = options().window(); video_config.prescale = options().prescale(); video_config.filter = options().filter(); - video_config.keepaspect = options().keep_aspect(); video_config.numscreens = options().numscreens(); - video_config.fullstretch = options().uneven_stretch(); // if we are in debug mode, never go full screen if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) video_config.windowed = true; - // default to working video please - video_config.novideo = 0; - - // d3d options: extract the data - stemp = options().video(); - if (strcmp(stemp, "auto") == 0) - { - stemp = "opengl"; - } - - if (strcmp(stemp, OSDOPTVAL_NONE) == 0) - { - video_config.mode = VIDEO_MODE_SOFT; - video_config.novideo = 1; - - if (!emulator_info::standalone() && options().seconds_to_run() == 0) - osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n"); - } - - else if (strcmp(stemp, MACOPTVAL_OPENGL) == 0) - video_config.mode = VIDEO_MODE_OPENGL; - else if (strcmp(stemp, MACOPTVAL_BGFX) == 0) - { - video_config.mode = VIDEO_MODE_BGFX; - } - else - { - osd_printf_warning("Invalid video value %s; reverting to OpenGL\n", stemp); - video_config.mode = VIDEO_MODE_OPENGL; - } - video_config.switchres = options().switch_res(); video_config.waitvsync = options().wait_vsync(); video_config.syncrefresh = options().sync_refresh(); @@ -224,63 +187,12 @@ void mac_osd_interface::extract_video_config() video_config.syncrefresh = 0; } - if (video_config.prescale < 1 || video_config.prescale > 3) + if (video_config.prescale < 1 || video_config.prescale > 8) { osd_printf_warning("Invalid prescale option, reverting to '1'\n"); video_config.prescale = 1; } - // default to working video please - video_config.forcepow2texture = options().gl_force_pow2_texture(); - video_config.allowtexturerect = !(options().gl_no_texture_rect()); - video_config.vbo = options().gl_vbo(); - video_config.pbo = options().gl_pbo(); - video_config.glsl = options().gl_glsl(); - if ( video_config.glsl ) - { - int i; - video_config.glsl_filter = options().glsl_filter(); - video_config.glsl_shader_mamebm_num=0; - for(i=0; i<GLSL_SHADER_MAX; i++) - { - stemp = options().shader_mame(i); - if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0) - { - video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1); - strcpy(video_config.glsl_shader_mamebm[i], stemp); - video_config.glsl_shader_mamebm_num++; - } else { - video_config.glsl_shader_mamebm[i] = nullptr; - } - } - video_config.glsl_shader_scrn_num=0; - for(i=0; i<GLSL_SHADER_MAX; i++) - { - stemp = options().shader_screen(i); - if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0) - { - video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1); - strcpy(video_config.glsl_shader_scrn[i], stemp); - video_config.glsl_shader_scrn_num++; - } else { - video_config.glsl_shader_scrn[i] = nullptr; - } - } - } else { - int i; - video_config.glsl_filter = 0; - video_config.glsl_shader_mamebm_num=0; - for(i=0; i<GLSL_SHADER_MAX; i++) - { - video_config.glsl_shader_mamebm[i] = nullptr; - } - video_config.glsl_shader_scrn_num=0; - for(i=0; i<GLSL_SHADER_MAX; i++) - { - video_config.glsl_shader_scrn[i] = nullptr; - } - } - // misc options: sanity check values // global options: sanity check values diff --git a/src/osd/mac/window.cpp b/src/osd/mac/window.cpp index 3993b3502d2..161bc8b677b 100644 --- a/src/osd/mac/window.cpp +++ b/src/osd/mac/window.cpp @@ -9,7 +9,7 @@ //============================================================ // standard C headers -#include <math.h> +#include <cmath> #ifndef _MSC_VER #include <unistd.h> #endif @@ -20,14 +20,13 @@ #include "emu.h" #include "emuopts.h" #include "render.h" +#include "screen.h" #include "ui/uimain.h" // OSD headers #include "window.h" #include "osdmac.h" -#include "modules/render/drawbgfx.h" -#include "modules/render/drawogl.h" #include "modules/monitor/monitor_common.h" //============================================================ @@ -68,48 +67,22 @@ bool mac_osd_interface::window_init() { osd_printf_verbose("Enter macwindow_init\n"); - // initialize the drawers - - switch (video_config.mode) - { - case VIDEO_MODE_BGFX: - renderer_bgfx::init(machine()); - break; - case VIDEO_MODE_OPENGL: - renderer_ogl::init(machine()); - break; - } - // set up the window list osd_printf_verbose("Leave macwindow_init\n"); return true; } -void mac_osd_interface::update_slider_list() +void mac_osd_interface::process_events() { - for (auto window : osd_common_t::s_window_list) - { - // check if any window has dirty sliders - if (window->renderer().sliders_dirty()) - { - build_slider_list(); - return; - } - } } -void mac_osd_interface::build_slider_list() +bool mac_osd_interface::has_focus() const { - m_sliders.clear(); - - for (auto window : osd_common_t::s_window_list) - { - std::vector<ui::menu_item> window_sliders = window->renderer().get_slider_list(); - m_sliders.insert(m_sliders.end(), window_sliders.begin(), window_sliders.end()); - } + return true; } + //============================================================ // macwindow_exit // (main thread) @@ -122,23 +95,11 @@ void mac_osd_interface::window_exit() // free all the windows while (!osd_common_t::s_window_list.empty()) { - auto window = osd_common_t::s_window_list.front(); - - // Part of destroy removes the window from the list + auto window = std::move(osd_common_t::s_window_list.back()); + s_window_list.pop_back(); window->destroy(); } - switch(video_config.mode) - { - case VIDEO_MODE_BGFX: - renderer_bgfx::exit(); - break; - case VIDEO_MODE_OPENGL: - renderer_ogl::exit(); - break; - default: - break; - } osd_printf_verbose("Leave macwindow_exit\n"); } @@ -217,8 +178,6 @@ void mac_window_info::toggle_full_screen() m_windowed_dim = get_size(); } - // reset UI to main menu - machine().ui().menu_reset(); // kill off the drawers renderer_reset(); if (fullscreen() && video_config.switchres) @@ -229,7 +188,7 @@ void mac_window_info::toggle_full_screen() downcast<mac_osd_interface &>(machine().osd()).release_keys(); - set_renderer(osd_renderer::make_for_type(video_config.mode, shared_from_this())); + renderer_create(); // toggle the window mode set_fullscreen(!fullscreen()); @@ -241,7 +200,7 @@ void mac_window_info::modify_prescale(int dir) { int new_prescale = prescale(); - if (dir > 0 && prescale() < 3) + if (dir > 0 && prescale() < 8) new_prescale = prescale() + 1; if (dir < 0 && prescale() > 1) new_prescale = prescale() - 1; @@ -261,8 +220,8 @@ void mac_window_info::modify_prescale(int dir) notify_changed(); m_prescale = new_prescale; } - machine().ui().popup_time(1, "Prescale %d", prescale()); } + machine().ui().popup_time(1, "Prescale %d", prescale()); } //============================================================ @@ -307,25 +266,11 @@ int mac_window_info::window_init() // set the initial maximized state // FIXME: Does not belong here - mac_options &options = downcast<mac_options &>(m_machine.options()); - m_startmaximized = options.maximize(); + m_startmaximized = downcast<mac_options &>(machine().options()).maximize(); - // add us to the list - osd_common_t::s_window_list.push_back(std::static_pointer_cast<mac_window_info>(shared_from_this())); + create_target(); - set_renderer(osd_renderer::make_for_type(video_config.mode, static_cast<osd_window*>(this)->shared_from_this())); - - // load the layout - m_target = m_machine.render().target_alloc(); - - // set the specific view - set_starting_view(m_index, options.view(), options.view(m_index)); - - // make the window title - if (video_config.numscreens == 1) - sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name); - else - sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().type.fullname(), m_machine.system().name, m_index); + renderer_create(); result = complete_create(); @@ -360,18 +305,6 @@ void mac_window_info::complete_destroy() downcast<mac_osd_interface &>(machine().osd()).release_keys(); } -void mac_window_info::destroy() -{ - // remove us from the list - osd_common_t::s_window_list.remove(std::static_pointer_cast<mac_window_info>(shared_from_this())); - - // free the textures etc - complete_destroy(); - - // free the render target, after the textures! - machine().render().target_free(m_target); -} - //============================================================ // pick_best_mode @@ -386,7 +319,7 @@ osd_dim mac_window_info::pick_best_mode() osd_dim ret(0,0); #if 0 // determine the minimum width/height for the selected target - m_target->compute_minimum_size(minimum_width, minimum_height); + target()->compute_minimum_size(minimum_width, minimum_height); // use those as the target for now target_width = minimum_width * std::max(1, prescale()); @@ -399,7 +332,7 @@ osd_dim mac_window_info::pick_best_mode() } // FIXME: this should be provided by monitor ! - num = SDL_GetNumDisplayModes(m_monitor->oshandle()); + num = SDL_GetNumDisplayModes(monitor()->oshandle()); if (num == 0) { @@ -411,7 +344,7 @@ osd_dim mac_window_info::pick_best_mode() for (i = 0; i < num; ++i) { SDL_DisplayMode mode; - SDL_GetDisplayMode(m_monitor->oshandle(), i, &mode); + SDL_GetDisplayMode(monitor()->oshandle(), i, &mode); // compute initial score based on difference between target and current size_score = 1.0f / (1.0f + abs((int32_t)mode.w - target_width) + abs((int32_t)mode.h - target_height)); @@ -462,12 +395,12 @@ void mac_window_info::update() update_cursor_state(); // if we're visible and running and not in the middle of a resize, draw - if (m_target != nullptr) + if (target() != nullptr) { int tempwidth, tempheight; // see if the games video mode has changed - m_target->compute_minimum_size(tempwidth, tempheight); + target()->compute_minimum_size(tempwidth, tempheight); if (osd_dim(tempwidth, tempheight) != m_minimum_dim) { m_minimum_dim = osd_dim(tempwidth, tempheight); @@ -499,13 +432,10 @@ void mac_window_info::update() // and redraw now - // Some configurations require events to be polled in the worker thread - downcast< mac_osd_interface& >(machine().osd()).process_events_buf(); - // Check whether window has vector screens { - const screen_device *screen = screen_device_iterator(machine().root_device()).byindex(m_index); + const screen_device *screen = screen_device_enumerator(machine().root_device()).byindex(index()); if ((screen != nullptr) && (screen->screen_type() == SCREEN_TYPE_VECTOR)) renderer().set_flags(osd_renderer::FLAG_HAS_VECTOR_SCREEN); else @@ -535,31 +465,10 @@ void mac_window_info::update() //============================================================ -// set_starting_view -// (main thread) -//============================================================ - -void mac_window_info::set_starting_view(int index, const char *defview, const char *view) -{ - int viewindex; - - // choose non-auto over auto - if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0) - view = defview; - - // query the video system to help us pick a view - viewindex = target()->configured_view(view, index, video_config.numscreens); - - // set the view - target()->set_view(viewindex); -} - - -//============================================================ // complete_create //============================================================ -extern void *CreateMAMEWindow(char *title, int x, int y, int w, int h, bool isFullscreen); +extern void *CreateMAMEWindow(const char *title, int x, int y, int w, int h, bool isFullscreen); extern void *GetOSWindow(void *wincontroller); int mac_window_info::complete_create() @@ -582,9 +491,13 @@ int mac_window_info::complete_create() temp = m_windowed_dim; } else if (m_startmaximized) - temp = get_max_bounds(video_config.keepaspect ); + { + temp = get_max_bounds(keepaspect()); + } else - temp = get_min_bounds(video_config.keepaspect ); + { + temp = get_min_bounds(keepaspect()); + } // create the window ..... osd_printf_verbose("Enter mac_window_info::complete_create\n"); @@ -592,7 +505,7 @@ int mac_window_info::complete_create() // get monitor work area for centering osd_rect work = monitor()->usuable_position_size(); - auto window = CreateMAMEWindow(m_title, + auto window = CreateMAMEWindow(title().c_str(), work.left() + (work.width() - temp.width()) / 2, work.top() + (work.height() - temp.height()) / 2, temp.width(), temp.height(), fullscreen()); @@ -605,24 +518,6 @@ int mac_window_info::complete_create() set_platform_window(window); - // set main window - if (m_index > 0) - { - for (auto w : osd_common_t::s_window_list) - { - if (w->m_index == 0) - { - set_main_window(std::dynamic_pointer_cast<osd_window>(w)); - break; - } - } - } - else - { - // We must be the main window - set_main_window(shared_from_this()); - } - // update monitor resolution after mode change to ensure proper pixel aspect monitor()->refresh(); if (fullscreen() && video_config.switchres) @@ -712,14 +607,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad int32_t viswidth, visheight; int32_t adjwidth, adjheight; float pixel_aspect; - std::shared_ptr<osd_monitor_info> monitor = m_monitor; // do not constrain aspect ratio for integer scaled views - if (m_target->scale_mode() != SCALE_FRACTIONAL) + if (target()->scale_mode() != SCALE_FRACTIONAL) return rect; // get the pixel aspect ratio for the target monitor - pixel_aspect = monitor->pixel_aspect(); + pixel_aspect = monitor()->pixel_aspect(); // determine the proposed width/height propwidth = rect.width() - extrawidth; @@ -731,21 +625,21 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad { case WMSZ_BOTTOM: case WMSZ_TOP: - m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight); + target()->compute_visible_area(10000, propheight, pixel_aspect, target()->orientation(), propwidth, propheight); break; case WMSZ_LEFT: case WMSZ_RIGHT: - m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight); + target()->compute_visible_area(propwidth, 10000, pixel_aspect, target()->orientation(), propwidth, propheight); break; default: - m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight); + target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), propwidth, propheight); break; } // get the minimum width/height for the current layout - m_target->compute_minimum_size(minwidth, minheight); + target()->compute_minimum_size(minwidth, minheight); // clamp against the absolute minimum propwidth = std::max(propwidth, MIN_WINDOW_DIM); @@ -758,13 +652,13 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad // clamp against the maximum (fit on one screen for full screen mode) if (m_fullscreen) { - maxwidth = monitor->position_size().width() - extrawidth; - maxheight = monitor->position_size().height() - extraheight; + maxwidth = monitor()->position_size().width() - extrawidth; + maxheight = monitor()->position_size().height() - extraheight; } else { - maxwidth = monitor->usuable_position_size().width() - extrawidth; - maxheight = monitor->usuable_position_size().height() - extraheight; + maxwidth = monitor()->usuable_position_size().width() - extrawidth; + maxheight = monitor()->usuable_position_size().height() - extraheight; // further clamp to the maximum width/height in the window if (m_win_config.width != 0) @@ -778,7 +672,7 @@ osd_rect mac_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad propheight = std::min(propheight, maxheight); // compute the visible area based on the proposed rectangle - m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight); + target()->compute_visible_area(propwidth, propheight, pixel_aspect, target()->orientation(), viswidth, visheight); // compute the adjustments we need to make adjwidth = (viswidth + extrawidth) - rect.width(); @@ -826,7 +720,7 @@ osd_dim mac_window_info::get_min_bounds(int constrain) //assert(GetCurrentThreadId() == window_threadid); // get the minimum target size - m_target->compute_minimum_size(minwidth, minheight); + target()->compute_minimum_size(minwidth, minheight); // expand to our minimum dimensions if (minwidth < MIN_WINDOW_DIM) @@ -839,7 +733,7 @@ osd_dim mac_window_info::get_min_bounds(int constrain) minheight += wnd_extra_height(); // if we want it constrained, figure out which one is larger - if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL) + if (constrain && target()->scale_mode() == SCALE_FRACTIONAL) { // first constrain with no height limit osd_rect test1(0,0,minwidth,10000); @@ -892,8 +786,8 @@ osd_dim mac_window_info::get_max_bounds(int constrain) //assert(GetCurrentThreadId() == window_threadid); // compute the maximum client area - // m_monitor->refresh(); - osd_rect maximum = m_monitor->usuable_position_size(); + // monitor()->refresh(); + osd_rect maximum = monitor()->usuable_position_size(); // clamp to the window's max int tempw = maximum.width(); @@ -914,7 +808,7 @@ osd_dim mac_window_info::get_max_bounds(int constrain) maximum = maximum.resize(tempw, temph); // constrain to fit - if (constrain && m_target->scale_mode() == SCALE_FRACTIONAL) + if (constrain && target()->scale_mode() == SCALE_FRACTIONAL) maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT); // remove extra window stuff @@ -929,25 +823,19 @@ osd_dim mac_window_info::get_max_bounds(int constrain) mac_window_info::mac_window_info( running_machine &a_machine, + render_module &renderprovider, int index, std::shared_ptr<osd_monitor_info> a_monitor, const osd_window_config *config) - : osd_window_t(*config) - , m_next(nullptr) + : osd_window_t(a_machine, renderprovider, index, a_monitor, *config) , m_startmaximized(0) // Following three are used by input code to defer resizes , m_minimum_dim(0, 0) , m_windowed_dim(0, 0) , m_rendered_event(0, 1) - , m_target(nullptr) - , m_machine(a_machine) - , m_monitor(a_monitor) - , m_fullscreen(0) , m_mouse_captured(false) , m_mouse_hidden(false) { - m_index = index; - //FIXME: these should be per_window in config-> or even better a bit set m_fullscreen = !video_config.windowed; m_prescale = video_config.prescale; diff --git a/src/osd/mac/window.h b/src/osd/mac/window.h index 24e749a425b..fce0b5f54bf 100644 --- a/src/osd/mac/window.h +++ b/src/osd/mac/window.h @@ -8,11 +8,13 @@ // //============================================================ -#ifndef __MACWINDOW__ -#define __MACWINDOW__ +#ifndef MAME_OSD_MAC_WINDOW_H +#define MAME_OSD_MAC_WINDOW_H + +#pragma once #include "osdmac.h" -#include "video.h" +#include "osdsync.h" #include "modules/osdwindow.h" @@ -28,12 +30,12 @@ class render_target; typedef uintptr_t HashT; -#define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid) +#define OSDWORK_CALLBACK(name) void *name(void *param, int threadid) class mac_window_info : public osd_window_t<void *> { public: - mac_window_info(running_machine &a_machine, int index, std::shared_ptr<osd_monitor_info> a_monitor, + mac_window_info(running_machine &a_machine, render_module &renderprovider, int index, std::shared_ptr<osd_monitor_info> a_monitor, const osd_window_config *config); ~mac_window_info(); @@ -44,7 +46,7 @@ public: void toggle_full_screen(); void modify_prescale(int dir); void resize(int32_t width, int32_t height); - void destroy() override; + void complete_destroy() override; void capture_pointer() override; void release_pointer() override; @@ -57,20 +59,8 @@ public: int xy_to_render_target(int x, int y, int *xt, int *yt); - running_machine &machine() const override { return m_machine; } - osd_monitor_info *monitor() const override { return m_monitor.get(); } - int fullscreen() const override { return m_fullscreen; } - - render_target *target() override { return m_target; } - - int prescale() const { return m_prescale; } - - // Pointer to next window - mac_window_info * m_next; - private: // window handle and info - char m_title[256]; int m_startmaximized; // dimensions @@ -79,18 +69,15 @@ private: // rendering info osd_event m_rendered_event; - render_target * m_target; //int m_extra_flags; // returns 0 on success, else 1 int complete_create(); - void complete_destroy(); private: int wnd_extra_width(); int wnd_extra_height(); - void set_starting_view(int index, const char *defview, const char *view); osd_rect constrain_to_aspect_ratio(const osd_rect &rect, int adjustment); osd_dim get_min_bounds(int constrain); osd_dim get_max_bounds(int constrain); @@ -98,37 +85,11 @@ private: osd_dim pick_best_mode(); void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; } - // Pointer to machine - running_machine & m_machine; - // monitor info - std::shared_ptr<osd_monitor_info> m_monitor; - int m_fullscreen; bool m_mouse_captured; bool m_mouse_hidden; void measure_fps(int update); }; -struct osd_draw_callbacks -{ - osd_renderer *(*create)(osd_window *window); -}; - -//============================================================ -// PROTOTYPES -//============================================================ - -//============================================================ -// PROTOTYPES - drawogl.c -//============================================================ - -int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks); - -//============================================================ -// PROTOTYPES - drawbgfx.c -//============================================================ - -int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks); - -#endif /* __MACWINDOW__ */ +#endif // MAME_OSD_MAC_WINDOW_H diff --git a/src/osd/mac/windowcontroller.mm b/src/osd/mac/windowcontroller.mm index dd49d559b0b..3a4b046d662 100644 --- a/src/osd/mac/windowcontroller.mm +++ b/src/osd/mac/windowcontroller.mm @@ -109,7 +109,7 @@ void *GetOSWindow(void *wincontroller) return [wc getWindow]; } -void *CreateMAMEWindow(char *title, int x, int y, int w, int h, bool isFullscreen) +void *CreateMAMEWindow(const char *title, int x, int y, int w, int h, bool isFullscreen) { NSRect bounds = NSMakeRect(x, y, w, h); NSUInteger style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask; |