diff --git a/src/emu/layout/horizont.lay b/src/emu/layout/horizont.lay index b141aedb065..908804832af 100644 --- a/src/emu/layout/horizont.lay +++ b/src/emu/layout/horizont.lay @@ -12,20 +12,6 @@ - - - - - - - - - - - - - - diff --git a/src/emu/layout/vertical.lay b/src/emu/layout/vertical.lay index b95e8799258..2d66df317f8 100644 --- a/src/emu/layout/vertical.lay +++ b/src/emu/layout/vertical.lay @@ -1,6 +1,5 @@ - @@ -13,20 +12,6 @@ - - - - - - - - - - - - - - diff --git a/src/emu/render.cpp b/src/emu/render.cpp index abe7ee87cc7..9b4782c2b85 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -933,6 +933,8 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI // aspect and scale options m_keepaspect = manager.machine().options().keep_aspect(); + m_int_scale_x = manager.machine().options().int_scale_x(); + m_int_scale_y = manager.machine().options().int_scale_y(); // determine the base orientation based on options if (!manager.machine().options().rotate()) @@ -1008,11 +1010,6 @@ void render_target::set_bounds(INT32 width, INT32 height, float pixel_aspect) m_bounds.x0 = m_bounds.y0 = 0; m_bounds.x1 = (float)width; m_bounds.y1 = (float)height; - m_pixel_aspect = pixel_aspect != 0.0? pixel_aspect : 1.0; - - // Check if our layout needs to be recomputed - if (m_curview != nullptr && m_curview->set_physical_size(width, height, m_pixel_aspect, m_orientation)) - m_curview->recompute(m_layerconfig); } @@ -1221,12 +1218,7 @@ void render_target::compute_minimum_size(INT32 &minwidth, INT32 &minheight) const rectangle &visarea = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? vectorvis : screen->visible_area(); // apply target orientation to the bounds - render_bounds bounds; - if (m_curview->bounds().scale_type == RENDER_SCALE_FRACTIONAL) - bounds = curitem->bounds(); - else - set_render_bounds_wh(&bounds, 0, 0, 1, 1); - + render_bounds bounds = curitem->bounds(); apply_orientation(bounds, m_orientation); normalize_bounds(bounds); diff --git a/src/emu/render.h b/src/emu/render.h index c968d2207dc..37abd2abd5e 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -173,8 +173,6 @@ struct render_bounds float y0; // topmost Y coordinate float x1; // rightmost X coordinate float y1; // bottommost Y coordinate - float aspect; // aspect ratio for this item - int scale_type; // type of scale for this item float width() const { return x1 - x0; } float height() const { return y1 - y0; } @@ -809,7 +807,6 @@ public: int m_orientation; // orientation of this item render_bounds m_bounds; // bounds of the item render_bounds m_rawbounds; // raw (original) bounds of the item - render_bounds m_scaledbounds; // raw bounds of the item after scale is applied render_color m_color; // color of the item }; @@ -825,7 +822,6 @@ public: const render_bounds &screen_bounds() const { return m_scrbounds; } const render_screen_list &screens() const { return m_screens; } bool layer_enabled(item_layer layer) const { return m_layenabled[layer]; } - int physical_width() const { return m_physical_width; } // bool has_art() const { return (m_backdrop_list.count() + m_overlay_list.count() + m_bezel_list.count() + m_cpanel_list.count() + m_marquee_list.count() != 0); } @@ -833,8 +829,6 @@ public: // operations void recompute(render_layer_config layerconfig); - bool set_physical_size(INT32 new_width, INT32 new_height, float new_pixel_aspect, int new_orientation); - void scale_bounds(render_bounds *dest, const render_bounds *src); // resolve tags, if any void resolve_tags(); @@ -845,13 +839,6 @@ private: std::string m_name; // name of the layout float m_aspect; // X/Y of the layout float m_scraspect; // X/Y of the screen areas - int m_physical_width; // render_target's width in pixels - int m_physical_height; // render_target's height in pixels - float m_pixel_aspect; // render_target's pixel aspect - int m_orientation; // render target's orientation - bool m_keepaspect; // constrain aspect ratio - int m_int_scale_x; // horizontal integer scale factor - int m_int_scale_y; // vertical integer scale factor render_screen_list m_screens; // list of active screens render_bounds m_bounds; // computed bounds of the view render_bounds m_scrbounds; // computed bounds of the screens within the view @@ -910,6 +897,7 @@ public: UINT32 width() const { return m_width; } UINT32 height() const { return m_height; } float pixel_aspect() const { return m_pixel_aspect; } + int scale_type() const { return m_scale_type; } float max_update_rate() const { return m_max_refresh; } int orientation() const { return m_orientation; } render_layer_config layer_config() const { return m_layerconfig; } @@ -1014,6 +1002,9 @@ private: render_bounds m_bounds; // bounds of the target bool m_keepaspect; // constrain aspect ratio float m_pixel_aspect; // aspect ratio of individual pixels + int m_scale_type; // type of scale to apply + int m_int_scale_x; // horizontal integer scale factor + int m_int_scale_y; // vertical integer scale factor float m_max_refresh; // maximum refresh rate, 0 or if none int m_orientation; // orientation render_layer_config m_layerconfig; // layer configuration diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index a2c5b15d576..a69ea831e44 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -99,14 +99,6 @@ enum -//************************************************************************** -// MACROS -//************************************************************************** - -#define FSWAP(var1, var2) do { float temp = var1; var1 = var2; var2 = temp; } while (0) - - - //************************************************************************** // GLOBAL VARIABLES //************************************************************************** @@ -313,11 +305,6 @@ void parse_bounds(running_machine &machine, xml_data_node *boundsnode, render_bo } // parse out the data - bounds.scale_type = xml_get_attribute_int_with_subst(machine, *boundsnode, "scaletype", 0); - int aspectx = xml_get_attribute_int_with_subst(machine, *boundsnode, "aspectx", 1); - int aspecty = xml_get_attribute_int_with_subst(machine, *boundsnode, "aspecty", 1); - bounds.aspect = (float)aspectx / (float)aspecty; - if (xml_get_attribute(boundsnode, "left") != nullptr) { // left/right/top/bottom format @@ -2145,13 +2132,7 @@ void layout_element::component::apply_skew(bitmap_argb32 &dest, int skewwidth) layout_view::layout_view(running_machine &machine, xml_data_node &viewnode, simple_list &elemlist) : m_next(nullptr), m_aspect(1.0f), - m_scraspect(1.0f), - m_physical_width(0), - m_physical_height(0), - m_orientation(0), - m_keepaspect(machine.options().keep_aspect()), - m_int_scale_x(machine.options().int_scale_x()), - m_int_scale_y(machine.options().int_scale_y()) + m_scraspect(1.0f) { // allocate a copy of the name m_name = xml_get_attribute_string_with_subst(machine, viewnode, "name", ""); @@ -2252,23 +2233,20 @@ void layout_view::recompute(render_layer_config layerconfig) if (m_layenabled[layer]) for (item *curitem = first_item(layer); curitem != nullptr; curitem = curitem->next()) { - // fist apply scale to item bounds if required - scale_bounds(&curitem->m_scaledbounds, &curitem->m_rawbounds); - // accumulate bounds if (first) - m_bounds = curitem->m_scaledbounds; + m_bounds = curitem->m_rawbounds; else - union_render_bounds(&m_bounds, &curitem->m_scaledbounds); + union_render_bounds(&m_bounds, &curitem->m_rawbounds); first = false; // accumulate screen bounds if (curitem->m_screen != nullptr) { if (scrfirst) - m_scrbounds = curitem->m_scaledbounds; + m_scrbounds = curitem->m_rawbounds; else - union_render_bounds(&m_scrbounds, &curitem->m_scaledbounds); + union_render_bounds(&m_scrbounds, &curitem->m_rawbounds); scrfirst = false; // accumulate the screens in use while we're scanning @@ -2279,7 +2257,7 @@ void layout_view::recompute(render_layer_config layerconfig) // if we have an explicit bounds, override it if (m_expbounds.x1 > m_expbounds.x0) - scale_bounds(&m_bounds, &m_expbounds); + m_bounds = m_expbounds; // if we're handling things normally, the target bounds are (0,0)-(1,1) render_bounds target_bounds; @@ -2316,127 +2294,14 @@ void layout_view::recompute(render_layer_config layerconfig) for (item_layer layer = ITEM_LAYER_FIRST; layer < ITEM_LAYER_MAX; ++layer) for (item *curitem = first_item(layer); curitem != nullptr; curitem = curitem->next()) { - curitem->m_bounds.x0 = target_bounds.x0 + (curitem->m_scaledbounds.x0 - xoffs) * xscale; - curitem->m_bounds.x1 = target_bounds.x0 + (curitem->m_scaledbounds.x1 - xoffs) * xscale; - curitem->m_bounds.y0 = target_bounds.y0 + (curitem->m_scaledbounds.y0 - yoffs) * yscale; - curitem->m_bounds.y1 = target_bounds.y0 + (curitem->m_scaledbounds.y1 - yoffs) * yscale; + curitem->m_bounds.x0 = target_bounds.x0 + (curitem->m_rawbounds.x0 - xoffs) * xscale; + curitem->m_bounds.x1 = target_bounds.x0 + (curitem->m_rawbounds.x1 - xoffs) * xscale; + curitem->m_bounds.y0 = target_bounds.y0 + (curitem->m_rawbounds.y0 - yoffs) * yscale; + curitem->m_bounds.y1 = target_bounds.y0 + (curitem->m_rawbounds.y1 - yoffs) * yscale; } } -//------------------------------------------------- -// set_physical_size - update our physical size -// information -//------------------------------------------------- - -bool layout_view::set_physical_size(INT32 new_width, INT32 new_height, float new_pixel_aspect, int new_orientation) -{ - if ((new_width != 0 && new_height != 0 && new_pixel_aspect != 0.0f) && - (new_width != m_physical_width || new_height != m_physical_height || new_pixel_aspect != m_pixel_aspect || new_orientation != m_orientation)) - { - // physical size has changed - m_physical_width = new_width; - m_physical_height = new_height; - m_pixel_aspect = new_pixel_aspect; - m_orientation = new_orientation; - return true; - } - // physical size was already up-to-date - return false; -} - - -//------------------------------------------------- -// scale_bounds - apply proper scale type -// to render_bounds -//------------------------------------------------- - -void layout_view::scale_bounds(render_bounds *dest, const render_bounds *src) -{ - // Start with the raw bounds from the layout file - if (src == nullptr || dest == nullptr) - return; - - *dest = *src; - - // Get the physical size and properties of the render target which owns us - int target_width = m_physical_width; - int target_height = m_physical_height; - float pixel_aspect = m_keepaspect? m_pixel_aspect: 1.0; - - if (target_width == 0 || target_height == 0) - return; - - // Apply orientation if required - if (m_orientation & ORIENTATION_SWAP_XY) - { - FSWAP(target_width, target_height); - pixel_aspect = 1.0 / pixel_aspect; - } - - // Now, based on the defined scale type for these bounds, apply different methods - switch (src->scale_type) - { - // Fractional: default for standard views (scaletype not defined), just preserve the raw bounds - case RENDER_SCALE_FRACTIONAL: - break; - - // Full stretch: bounds are scaled to whole size of the render target. Used by integer scaled views - // to define the bounds of the actual "view". - case RENDER_SCALE_STRETCH_FULL: - { - dest->x0 *= target_width * pixel_aspect; - dest->y0 *= target_height; - dest->x1 *= target_width * pixel_aspect; - dest->y1 *= target_height; - break; - } - - // Integer/Strecth-H: bounds are scaled by integer factors. For the Stretch-H case, integer scaling is - // only applied to the vertical axis. Used by integer scaled views, to define the bounds of the "screen". - case RENDER_SCALE_INTEGER: - case RENDER_SCALE_STRETCH_H: - { - float dest_width, dest_width_asp, dest_height, dest_height_asp, dest_aspect; - dest_width = dest_width_asp = (float)target_width; - dest_height = dest_height_asp = (float)target_height; - dest_aspect = dest_width / dest_height * pixel_aspect; - - // We need to work out which one is the horizontal axis, regardless of the monitor orientation - float x_scale, y_scale; - if (dest_aspect > 1.0) - { - // x-axis matches monitor's horizontal dimension - dest_width_asp *= m_keepaspect? src->aspect / dest_aspect : 1.0; - x_scale = src->scale_type == RENDER_SCALE_INTEGER? - MAX(1, render_round_nearest(dest_width_asp / src->width())) : dest_width_asp / src->width(); - y_scale = MAX(1, render_round_nearest(dest_height / src->height())); - } - else - { - // y-axis matches monitor's vertical dimension - dest_height_asp *= m_keepaspect? dest_aspect / src->aspect : 1.0; - y_scale = src->scale_type == RENDER_SCALE_INTEGER? - MAX(1, render_round_nearest(dest_height_asp / src->height())) : dest_height_asp / src->height(); - x_scale = MAX(1, render_round_nearest(dest_width / src->width())); - } - - // Check if we have user defined scale factors, if so use them instead - x_scale = m_int_scale_x? m_int_scale_x : x_scale; - y_scale = m_int_scale_y? m_int_scale_y : y_scale; - - // Finally, apply scale to bounds - float new_width = src->width() * x_scale; - float new_height = src->height() * y_scale; - float x_border = (dest_width - new_width) / 2; - float y_border = (dest_height - new_height) / 2; - set_render_bounds_wh(dest, x_border * pixel_aspect, y_border, new_width * pixel_aspect, new_height); - break; - } - } -} - - //----------------------------- // resolve_tags - resolve tags //----------------------------- diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index c2d86858bf9..199e428afc8 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -1192,7 +1192,7 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad osd_monitor_info *monitor = m_monitor; // do not constrain aspect ratio for integer scaled views - if (m_target->current_view()->bounds().scale_type != RENDER_SCALE_FRACTIONAL) + if (m_target->scale_type() != RENDER_SCALE_FRACTIONAL) return rect; // get the pixel aspect ratio for the target monitor @@ -1316,7 +1316,7 @@ osd_dim sdl_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->current_view()->bounds().scale_type == RENDER_SCALE_FRACTIONAL) + if (constrain && m_target->scale_type() == RENDER_SCALE_FRACTIONAL) { // first constrain with no height limit osd_rect test1(0,0,minwidth,10000); @@ -1380,7 +1380,7 @@ osd_dim sdl_window_info::get_max_bounds(int constrain) maximum = maximum.resize(tempw, temph); // constrain to fit - if (constrain && m_target->current_view()->bounds().scale_type == RENDER_SCALE_FRACTIONAL) + if (constrain && m_target->scale_type() == RENDER_SCALE_FRACTIONAL) maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT); // remove extra window stuff diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index c6fd834b17f..e0089d98585 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -1663,7 +1663,7 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad assert(GetCurrentThreadId() == window_threadid); // do not constrain aspect ratio for integer scaled views - if (m_target->current_view()->bounds().scale_type != RENDER_SCALE_FRACTIONAL) + if (m_target->scale_type() != RENDER_SCALE_FRACTIONAL) return rect; // get the pixel aspect ratio for the target monitor @@ -1787,7 +1787,7 @@ osd_dim win_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->current_view()->bounds().scale_type == RENDER_SCALE_FRACTIONAL) + if (constrain && m_target->scale_type() == RENDER_SCALE_FRACTIONAL) { // first constrain with no height limit osd_rect test1(0,0,minwidth,10000); @@ -1847,7 +1847,7 @@ osd_dim win_window_info::get_max_bounds(int constrain) maximum = maximum.resize(tempw, temph); // constrain to fit - if (constrain && m_target->current_view()->bounds().scale_type == RENDER_SCALE_FRACTIONAL) + if (constrain && m_target->scale_type() == RENDER_SCALE_FRACTIONAL) maximum = constrain_to_aspect_ratio(maximum, WMSZ_BOTTOMRIGHT); return maximum.dim();