diff options
author | 2016-07-31 11:50:20 +0200 | |
---|---|---|
committer | 2016-07-31 14:41:02 +0200 | |
commit | 9667c6a8cce1829a7321dde67bd0287c73234386 (patch) | |
tree | f3665957d557cb18728a40e75f7d9f2341aaff1d /src/osd | |
parent | 69ac4affc86caac51ff9720083ed128dabdb932f (diff) |
std::min and std:max instead of MIN and MAX, also some more macros converted to inline functions (nw)
Diffstat (limited to 'src/osd')
37 files changed, 172 insertions, 131 deletions
diff --git a/src/osd/modules/debugger/debugwin.cpp b/src/osd/modules/debugger/debugwin.cpp index 973aec1f570..c66a54e6d30 100644 --- a/src/osd/modules/debugger/debugwin.cpp +++ b/src/osd/modules/debugger/debugwin.cpp @@ -20,6 +20,8 @@ #include "win/memorywininfo.h" #include "win/pointswininfo.h" #include "win/uimetrics.h" +#undef min +#undef max #include "emu.h" #include "debugger.h" diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm index 35eb2d57c68..1d4155b6678 100644 --- a/src/osd/modules/debugger/osx/debugconsole.mm +++ b/src/osd/modules/debugger/osx/debugconsole.mm @@ -156,19 +156,19 @@ consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height; adjustment.width = regSize.width - regCurrent.width; adjustment.height = regSize.height - regCurrent.height; - adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); + adjustment.width += std::max(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); windowFrame.size.width += adjustment.width; windowFrame.size.height += adjustment.height; // not used - better to go for fixed height - windowFrame.size.height = MIN(512.0, available.size.height); - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); + windowFrame.size.height = std::min(512.0, available.size.height); + windowFrame.size.width = std::min(windowFrame.size.width, available.size.width); windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; windowFrame.origin.y = available.origin.y; [window setFrame:windowFrame display:YES]; NSRect lhsFrame = [regScroll frame]; NSRect rhsFrame = [dasmSplit frame]; - adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); + adjustment.width = std::min(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width; rhsFrame.size.width += lhsFrame.size.width - adjustment.width; lhsFrame.size.width = adjustment.width; diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm index 8f0c404cf93..409bbeadceb 100644 --- a/src/osd/modules/debugger/osx/debugview.mm +++ b/src/osd/modules/debugger/osx/debugview.mm @@ -172,7 +172,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) // this gets all the lines that are at least partially visible debug_view_xy origin(0, 0), size(totalWidth, totalHeight); [self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y]; - size.y = MIN(size.y, totalHeight - origin.y); + size.y = std::min(size.y, totalHeight - origin.y); // tell the underlying view how much real estate is available view->set_visible_size(size); @@ -205,8 +205,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) fontHeight * totalHeight); if (wholeLineScroll) content.height += (fontHeight * 2) - 1; - [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)), - ceil(MAX(clip.height, content.height)))]; + [self setFrameSize:NSMakeSize(ceil(std::max(clip.width, content.width)), + ceil(std::max(clip.height, content.height)))]; [self recomputeVisible]; } @@ -282,8 +282,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) fontHeight * newSize.y); if (wholeLineScroll) content.height += (fontHeight * 2) - 1; - [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)), - ceil(MAX(clip.height, content.height)))]; + [self setFrameSize:NSMakeSize(ceil(std::max(clip.width, content.width)), + ceil(std::max(clip.height, content.height)))]; } totalWidth = newSize.x; totalHeight = newSize.y; @@ -583,7 +583,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) if (wholeLineScroll) { CGFloat const clamp = [self bounds].size.height - fontHeight - proposedVisibleRect.size.height; - proposedVisibleRect.origin.y = MIN(proposedVisibleRect.origin.y, MAX(clamp, 0)); + proposedVisibleRect.origin.y = std::min(proposedVisibleRect.origin.y, std::max(clamp, 0)); proposedVisibleRect.origin.y -= fmod(proposedVisibleRect.origin.y, fontHeight); } return proposedVisibleRect; @@ -600,8 +600,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) INT32 row, clip; [self convertBounds:dirtyRect toFirstAffectedLine:&row count:&clip]; clip += row; - row = MAX(row, origin.y); - clip = MIN(clip, origin.y + size.y); + row = std::max(row, origin.y); + clip = std::min(clip, origin.y + size.y); // this gets the text for the whole visible area debug_view_char const *data = view->viewdata(); @@ -668,7 +668,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) inTextContainer:textContainer]; if (start == 0) box.origin.x = 0; - box.size.width = MAX([self bounds].size.width - box.origin.x, 0); + box.size.width = std::max([self bounds].size.width - box.origin.x, 0); [[self backgroundForAttribute:attr] set]; [NSBezierPath fillRect:NSMakeRect(box.origin.x, row * fontHeight, diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm index ceb41e1de79..a4cd46df631 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.mm +++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm @@ -341,16 +341,16 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD // limit the size to the minimum size NSSize const minimum = [window minSize]; - windowFrame.size.width = MAX(windowFrame.size.width, minimum.width); - windowFrame.size.height = MAX(windowFrame.size.height, minimum.height); + windowFrame.size.width = std::max(windowFrame.size.width, minimum.width); + windowFrame.size.height = std::max(windowFrame.size.height, minimum.height); // limit the size to the main screen size NSRect const available = [[NSScreen mainScreen] visibleFrame]; - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); - windowFrame.size.height = MIN(windowFrame.size.height, available.size.height); + windowFrame.size.width = std::min(windowFrame.size.width, available.size.width); + windowFrame.size.height = std::min(windowFrame.size.height, available.size.height); // arbitrary additional height limit - windowFrame.size.height = MIN(windowFrame.size.height, 320); + windowFrame.size.height = std::min(windowFrame.size.height, 320); // place it in the bottom right corner and apply windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; diff --git a/src/osd/modules/debugger/osx/deviceinfoviewer.mm b/src/osd/modules/debugger/osx/deviceinfoviewer.mm index bbc2ac7d0f5..29b4186ccf9 100644 --- a/src/osd/modules/debugger/osx/deviceinfoviewer.mm +++ b/src/osd/modules/debugger/osx/deviceinfoviewer.mm @@ -40,7 +40,7 @@ - (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize { NSSize const newBoundsSize = [[self superview] bounds].size; - [self setFrameSize:NSMakeSize(MAX(newBoundsSize.width, minWidth), [self frame].size.height)]; + [self setFrameSize:NSMakeSize(std::max(newBoundsSize.width, minWidth), [self frame].size.height)]; } @end @@ -97,9 +97,9 @@ - (void)addLabel:(NSString *)l withWidth:(CGFloat)w andField:(NSString *)f toView:(NSView *)v { NSTextField *const label = [self makeLabel:l]; NSTextField *const field = [self makeField:f]; - CGFloat const height = MAX([label frame].size.height, [field frame].size.height); + CGFloat const height = std::max([label frame].size.height, [field frame].size.height); NSSize space = [v bounds].size; - space.width = MAX(space.width, [field frame].size.width + w + 52); + space.width = std::max(space.width, [field frame].size.width + w + 52); space.height += height + 8; [label setFrame:NSMakeRect(25, space.height - height - 20, w, height)]; [field setFrame:NSMakeRect(w + 27, space.height - height - 20, space.width - w - 52, height)]; @@ -115,7 +115,7 @@ NSTextField *const field = [self makeField:f]; [field setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; NSSize space = [b frame].size; - space.width = MAX(space.width, [field frame].size.width + 32); + space.width = std::max(space.width, [field frame].size.width + 32); space.height += [field frame].size.height + 8; [field setFrame:NSMakeRect(15, 14, space.width - 32, [field frame].size.height)]; [b setFrameSize:space]; @@ -126,7 +126,7 @@ - (void)addBox:(NSBox *)b toView:(NSView *)v { NSSize space = [v frame].size; - space.width = MAX(space.width, [b frame].size.width + 34); + space.width = std::max(space.width, [b frame].size.width + 34); space.height += [b frame].size.height + 4; [b setFrameOrigin:NSMakePoint(17, space.height - [b frame].size.height - 16)]; [v setFrameSize:space]; diff --git a/src/osd/modules/debugger/osx/disassemblyview.mm b/src/osd/modules/debugger/osx/disassemblyview.mm index 212f8194cd6..4e99e38ddce 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.mm +++ b/src/osd/modules/debugger/osx/disassemblyview.mm @@ -47,8 +47,8 @@ { view->set_source(*source); debug_view_xy const current = view->total_size(); - max.x = MAX(max.x, current.x); - max.y = MAX(max.y, current.y); + max.x = std::max(max.x, current.x); + max.y = std::max(max.y, current.y); } view->set_source(*source); return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])), diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm index f57d62cfaf4..50fe4eae2ef 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.mm +++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm @@ -55,7 +55,7 @@ // adjust sizes to make it fit nicely expressionFrame = [expressionField frame]; - expressionFrame.size.height = MAX(expressionFrame.size.height, [subviewButton frame].size.height); + expressionFrame.size.height = std::max(expressionFrame.size.height, [subviewButton frame].size.height); expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; [expressionField setFrame:expressionFrame]; expressionFrame.origin.x = expressionFrame.size.width; diff --git a/src/osd/modules/debugger/osx/errorlogviewer.mm b/src/osd/modules/debugger/osx/errorlogviewer.mm index 0548ff9351f..087694ca81b 100644 --- a/src/osd/modules/debugger/osx/errorlogviewer.mm +++ b/src/osd/modules/debugger/osx/errorlogviewer.mm @@ -44,7 +44,7 @@ borderType:[logScroll borderType]]; // this thing starts with no content, so its prefered height may be very small - desired.height = MAX(desired.height, 240); + desired.height = std::max(desired.height, 240); [self cascadeWindowWithDesiredSize:desired forView:logScroll]; } diff --git a/src/osd/modules/debugger/osx/memoryview.mm b/src/osd/modules/debugger/osx/memoryview.mm index aac06f3e63a..5a843c6e38f 100644 --- a/src/osd/modules/debugger/osx/memoryview.mm +++ b/src/osd/modules/debugger/osx/memoryview.mm @@ -69,8 +69,8 @@ { view->set_source(*source); debug_view_xy const current = view->total_size(); - max.x = MAX(max.x, current.x); - max.y = MAX(max.y, current.y); + max.x = std::max(max.x, current.x); + max.y = std::max(max.y, current.y); } view->set_source(*source); return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])), diff --git a/src/osd/modules/debugger/osx/memoryviewer.mm b/src/osd/modules/debugger/osx/memoryviewer.mm index 9b027e11368..bd7d1941067 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.mm +++ b/src/osd/modules/debugger/osx/memoryviewer.mm @@ -53,7 +53,7 @@ // adjust sizes to make it fit nicely expressionFrame = [expressionField frame]; - expressionFrame.size.height = MAX(expressionFrame.size.height, [subviewButton frame].size.height); + expressionFrame.size.height = std::max(expressionFrame.size.height, [subviewButton frame].size.height); expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; [expressionField setFrame:expressionFrame]; expressionFrame.origin.x = expressionFrame.size.width; diff --git a/src/osd/modules/debugger/osx/pointsviewer.mm b/src/osd/modules/debugger/osx/pointsviewer.mm index c9301eb2894..d99f072a95c 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.mm +++ b/src/osd/modules/debugger/osx/pointsviewer.mm @@ -119,8 +119,8 @@ hasHorizontalScroller:YES hasVerticalScroller:YES borderType:[watchScroll borderType]]; - NSSize const desired = NSMakeSize(MAX(breakDesired.width, watchDesired.width), - MAX(breakDesired.height, watchDesired.height)); + NSSize const desired = NSMakeSize(std::max(breakDesired.width, watchDesired.width), + std::max(breakDesired.height, watchDesired.height)); [self cascadeWindowWithDesiredSize:desired forView:tabs]; // don't forget the result diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp index f1d66abee42..3b5c9d88cb3 100644 --- a/src/osd/modules/debugger/qt/debuggerview.cpp +++ b/src/osd/modules/debugger/qt/debuggerview.cpp @@ -49,7 +49,7 @@ void DebuggerView::paintEvent(QPaintEvent* event) // Tell the MAME debug view how much real estate is available QFontMetrics actualFont = fontMetrics(); const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.lineSpacing()); + const int fontHeight = std::max(1, actualFont.lineSpacing()); m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); @@ -240,7 +240,7 @@ void DebuggerView::mousePressEvent(QMouseEvent* event) { QFontMetrics actualFont = fontMetrics(); const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.height()); + const int fontHeight = std::max(1, actualFont.height()); debug_view_xy topLeft = m_view->visible_position(); debug_view_xy clickViewPosition; diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index 8709c8d5aa2..7b55db34a20 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -328,7 +328,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event) { QFontMetrics actualFont = fontMetrics(); const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.height()); + const int fontHeight = std::max(1, actualFont.height()); debug_view_xy topLeft = view()->visible_position(); debug_view_xy clickViewPosition; diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp index 735f59a2fbb..6c4e5b0a2e1 100644 --- a/src/osd/modules/debugger/win/consolewininfo.cpp +++ b/src/osd/modules/debugger/win/consolewininfo.cpp @@ -60,13 +60,13 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) : set_minwidth(bounds.right - bounds.left); bounds.top = bounds.left = 0; - bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + MAX(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH; + bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + std::max(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH; AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX); set_maxwidth(bounds.right - bounds.left); // position the window at the bottom-right - int const bestwidth = MIN(maxwidth(), work_bounds.right - work_bounds.left); - int const bestheight = MIN(500, work_bounds.bottom - work_bounds.top); + int const bestwidth = std::min(int(maxwidth()), int(work_bounds.right - work_bounds.left)); + int const bestheight = std::min(500, int(work_bounds.bottom - work_bounds.top)); SetWindowPos(window(), HWND_TOP, work_bounds.right - bestwidth, work_bounds.bottom - bestheight, bestwidth, bestheight, diff --git a/src/osd/modules/debugger/win/debugviewinfo.cpp b/src/osd/modules/debugger/win/debugviewinfo.cpp index 2104e09246e..d23a666adf8 100644 --- a/src/osd/modules/debugger/win/debugviewinfo.cpp +++ b/src/osd/modules/debugger/win/debugviewinfo.cpp @@ -475,9 +475,9 @@ void debugview_info::update() // if we hid the scrollbars, make sure we reset the top/left corners if (topleft.y + visiblesize.y > totalsize.y) - topleft.y = MAX(totalsize.y - visiblesize.y, 0); + topleft.y = std::max(totalsize.y - visiblesize.y, 0); if (topleft.x + visiblesize.x > totalsize.x) - topleft.x = MAX(totalsize.x - visiblesize.x, 0); + topleft.x = std::max(totalsize.x - visiblesize.x, 0); // fill out the scroll info struct for the vertical scrollbar scrollinfo.cbSize = sizeof(scrollinfo); diff --git a/src/osd/modules/debugger/win/debugwin.h b/src/osd/modules/debugger/win/debugwin.h index bedf2b36d43..0e3bcd25131 100644 --- a/src/osd/modules/debugger/win/debugwin.h +++ b/src/osd/modules/debugger/win/debugwin.h @@ -18,6 +18,8 @@ #ifdef _MSC_VER #include <zmouse.h> #endif +#undef min +#undef max #include "emu.h" diff --git a/src/osd/modules/diagnostics/diagnostics_win32.cpp b/src/osd/modules/diagnostics/diagnostics_win32.cpp index b3e9d8320e0..8179e333187 100644 --- a/src/osd/modules/diagnostics/diagnostics_win32.cpp +++ b/src/osd/modules/diagnostics/diagnostics_win32.cpp @@ -22,6 +22,9 @@ #include <memory> #include <vector> +#undef min +#undef max +#include <algorithm> #include "modules/lib/osdlib.h" @@ -709,7 +712,7 @@ int CLIB_DECL sampling_profiler::compare_address(const void *item1, const void * { const FPTR *entry1 = reinterpret_cast<const FPTR *>(item1); const FPTR *entry2 = reinterpret_cast<const FPTR *>(item2); - int mincount = MIN(entry1[0], entry2[0]); + int mincount = std::min(entry1[0], entry2[0]); // sort in order of: bucket, caller, caller's caller, etc. for (int index = 1; index <= mincount; index++) diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index eedfd1450c3..741376ecb81 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -18,6 +18,9 @@ #include <mutex> #include <queue> #include <string> +#undef min +#undef max +#include <algorithm> //============================================================ @@ -614,14 +617,14 @@ inline static INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawma if (raw >= center) { INT32 result = (INT64)(raw - center) * (INT64)INPUT_ABSOLUTE_MAX / (INT64)(rawmax - center); - return MIN(result, INPUT_ABSOLUTE_MAX); + return std::min(result, INPUT_ABSOLUTE_MAX); } // below center else { INT32 result = -((INT64)(center - raw) * (INT64)-INPUT_ABSOLUTE_MIN / (INT64)(center - rawmin)); - return MAX(result, INPUT_ABSOLUTE_MIN); + return std::max(result, INPUT_ABSOLUTE_MIN); } } diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index 0db6695565d..0ef0fc2d095 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -22,7 +22,10 @@ #undef WINNT #include <dinput.h> #undef interface +#undef min +#undef max +#include <algorithm> #include <mutex> #include <thread> @@ -387,8 +390,8 @@ public: } // cap the number of axes and buttons based on the format - devinfo->dinput.caps.dwAxes = MIN(devinfo->dinput.caps.dwAxes, 3); - devinfo->dinput.caps.dwButtons = MIN(devinfo->dinput.caps.dwButtons, (devinfo->dinput.format == &c_dfDIMouse) ? 4 : 8); + devinfo->dinput.caps.dwAxes = std::min(devinfo->dinput.caps.dwAxes, DWORD(3)); + devinfo->dinput.caps.dwButtons = std::min(devinfo->dinput.caps.dwButtons, DWORD((devinfo->dinput.format == &c_dfDIMouse) ? 4 : 8)); // populate the axes for (axisnum = 0; axisnum < devinfo->dinput.caps.dwAxes; axisnum++) @@ -479,9 +482,9 @@ int dinput_joystick_device::configure() osd_printf_warning("DirectInput: Unable to reset saturation for joystick %d (%s)\n", devindex, name()); // cap the number of axes, POVs, and buttons based on the format - dinput.caps.dwAxes = MIN(dinput.caps.dwAxes, 8); - dinput.caps.dwPOVs = MIN(dinput.caps.dwPOVs, 4); - dinput.caps.dwButtons = MIN(dinput.caps.dwButtons, 128); + dinput.caps.dwAxes = std::min(dinput.caps.dwAxes, DWORD(8)); + dinput.caps.dwPOVs = std::min(dinput.caps.dwPOVs, DWORD(4)); + dinput.caps.dwButtons = std::min(dinput.caps.dwButtons, DWORD(128)); // populate the axes for (axisnum = axiscount = 0; axiscount < dinput.caps.dwAxes && axisnum < 8; axisnum++) diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index 3c617ef191a..739ae4496f3 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -16,6 +16,8 @@ #include <windows.h> #include <tchar.h> #undef interface +#undef min +#undef max #include <mutex> #include <functional> diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 24234969eef..dc9b95b3f28 100644 --- a/src/osd/modules/input/input_win32.cpp +++ b/src/osd/modules/input/input_win32.cpp @@ -15,6 +15,8 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> #undef interface +#undef min +#undef max // MAME headers #include "emu.h" diff --git a/src/osd/modules/input/input_winhybrid.cpp b/src/osd/modules/input/input_winhybrid.cpp index a7453d59cf8..80a1280c511 100644 --- a/src/osd/modules/input/input_winhybrid.cpp +++ b/src/osd/modules/input/input_winhybrid.cpp @@ -25,6 +25,8 @@ #include <dinput.h> #undef interface +#undef min +#undef max // MAME headers #include "emu.h" diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp index 0b2427b7f1c..e64b166c287 100644 --- a/src/osd/modules/input/input_xinput.cpp +++ b/src/osd/modules/input/input_xinput.cpp @@ -19,6 +19,8 @@ #include <xinput.h> #undef interface +#undef min +#undef max // MAME headers #include "emu.h" diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h index 7abc76469ed..3fa62babfbf 100644 --- a/src/osd/modules/osdwindow.h +++ b/src/osd/modules/osdwindow.h @@ -21,6 +21,8 @@ #include <windowsx.h> #include <mmsystem.h> #endif +#undef min +#undef max #ifdef OSD_SDL // forward declaration diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp index 2116322f19a..444d3c05348 100644 --- a/src/osd/modules/render/bgfx/chainmanager.cpp +++ b/src/osd/modules/render/bgfx/chainmanager.cpp @@ -20,7 +20,8 @@ #include <bx/readerwriter.h> #include <bx/crtimpl.h> - +#undef min +#undef max #include "bgfxutil.h" #include "chainmanager.h" diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index 241f4b2a7f6..560bffa1379 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -25,7 +25,9 @@ #include "strconv.h" #include "d3dhlsl.h" #include "../frontend/mame/ui/slider.h" - +#undef min +#undef max +#include <algorithm> //============================================================ // PROTOTYPES @@ -1047,9 +1049,9 @@ rgb_t shaders::apply_color_convolution(rgb_t color) b = chroma[2] * saturation + luma; return rgb_t( - MAX(0, MIN(255, static_cast<int>(r * 255.0f))), - MAX(0, MIN(255, static_cast<int>(g * 255.0f))), - MAX(0, MIN(255, static_cast<int>(b * 255.0f)))); + std::max(0, std::min(255, static_cast<int>(r * 255.0f))), + std::max(0, std::min(255, static_cast<int>(g * 255.0f))), + std::max(0, std::min(255, static_cast<int>(b * 255.0f)))); } int shaders::color_convolution_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum) diff --git a/src/osd/modules/render/draw13.cpp b/src/osd/modules/render/draw13.cpp index 24bf22c3b27..50faacb1ca7 100644 --- a/src/osd/modules/render/draw13.cpp +++ b/src/osd/modules/render/draw13.cpp @@ -282,7 +282,7 @@ void renderer_sdl2::render_quad(texture_info *texture, const render_primitive &p texture->render_quad(prim, x, y); copyinfo->time += osd_ticks(); - copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); + copyinfo->pixel_count += std::max(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height())); if (m_last_blit_pixels) { copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels; diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp index 102abf35413..7668cb6660f 100644 --- a/src/osd/modules/render/drawd3d.cpp +++ b/src/osd/modules/render/drawd3d.cpp @@ -19,7 +19,9 @@ #include "window.h" #include "drawd3d.h" #include "modules/render/d3d/d3dhlsl.h" - +#undef min +#undef max +#include <algorithm> //============================================================ // TYPE DEFINITIONS @@ -1993,7 +1995,7 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t D3DFORMAT format; DWORD usage = m_texture_manager->is_dynamic_supported() ? D3DUSAGE_DYNAMIC : 0; D3DPOOL pool = m_texture_manager->is_dynamic_supported() ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; - int maxdim = MAX(m_renderer->get_presentation()->BackBufferWidth, m_renderer->get_presentation()->BackBufferHeight); + int maxdim = std::max(m_renderer->get_presentation()->BackBufferWidth, m_renderer->get_presentation()->BackBufferHeight); // pick the format if (PRIMFLAG_GET_TEXFORMAT(flags) == TEXFORMAT_YUY16) diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index 88ce712a396..1f03939de45 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -81,7 +81,7 @@ private: EFFECT_COUNT_MAX = 10 }; - UINT32 clamped_latency() const { return MAX(MIN(m_audio_latency, LATENCY_MAX), LATENCY_MIN); } + UINT32 clamped_latency() const { return std::max(std::min(m_audio_latency, LATENCY_MAX), LATENCY_MIN); } UINT32 buffer_avail() const { return ((m_writepos >= m_playpos) ? m_buffer_size : 0) + m_playpos - m_writepos; } UINT32 buffer_used() const { return ((m_playpos > m_writepos) ? m_buffer_size : 0) + m_writepos - m_playpos; } @@ -228,7 +228,7 @@ int sound_coreaudio::init(const osd_options &options) // Allocate buffer m_headroom = m_sample_bytes * (clamped_latency() * sample_rate() / 40); - m_buffer_size = m_sample_bytes * MAX(sample_rate() * (clamped_latency() + 3) / 40, 256); + m_buffer_size = m_sample_bytes * std::max(sample_rate() * (clamped_latency() + 3) / 40, 256); m_buffer = global_alloc_array_clear<INT8>(m_buffer_size); if (!m_buffer) { @@ -306,7 +306,7 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, INT16 const *buffer return; } - UINT32 const chunk = MIN(m_buffer_size - m_writepos, bytes_this_frame); + UINT32 const chunk = std::min(m_buffer_size - m_writepos, bytes_this_frame); memcpy(m_buffer + m_writepos, (INT8 *)buffer, chunk); m_writepos += chunk; if (m_writepos >= m_buffer_size) @@ -324,7 +324,7 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, INT16 const *buffer void sound_coreaudio::set_mastervolume(int attenuation) { - int const clamped_attenuation = MAX(MIN(attenuation, 0), -32); + int const clamped_attenuation = std::max(std::min(attenuation, 0), -32); m_scale = (-32 == clamped_attenuation) ? 0 : (INT32)(pow(10.0, clamped_attenuation / 20.0) * 128); } @@ -996,7 +996,7 @@ OSStatus sound_coreaudio::render( return noErr; } - UINT32 const chunk = MIN(m_buffer_size - m_playpos, number_bytes); + UINT32 const chunk = std::min(m_buffer_size - m_playpos, number_bytes); copy_scaled((INT8 *)data->mBuffers[0].mData, m_buffer + m_playpos, chunk); m_playpos += chunk; if (m_playpos >= m_buffer_size) diff --git a/src/osd/modules/sound/direct_sound.cpp b/src/osd/modules/sound/direct_sound.cpp index 04d29866876..b677889de6b 100644 --- a/src/osd/modules/sound/direct_sound.cpp +++ b/src/osd/modules/sound/direct_sound.cpp @@ -20,6 +20,8 @@ #undef WINNT #include <dsound.h> #undef interface +#undef min +#undef max // MAME headers #include "emu.h" @@ -34,6 +36,7 @@ #include "winmain.h" #include "window.h" #endif +#include <algorithm> //============================================================ // DEBUGGING @@ -163,7 +166,7 @@ private: assert(m_bytes1); assert((m_locked1 + m_locked2) >= bytes); - memcpy(m_bytes1, data, MIN(m_locked1, bytes)); + memcpy(m_bytes1, data, std::min(m_locked1, bytes)); if (m_locked1 < bytes) { assert(m_bytes2); @@ -359,7 +362,7 @@ void sound_direct_sound::update_audio_stream( void sound_direct_sound::set_mastervolume(int attenuation) { // clamp the attenuation to 0-32 range - attenuation = MAX(MIN(attenuation, 0), -32); + attenuation = std::max(std::min(attenuation, 0), -32); // set the master volume if (m_stream_buffer) @@ -429,7 +432,7 @@ HRESULT sound_direct_sound::dsound_init() // compute the buffer size based on the output sample rate DWORD stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * m_audio_latency / 10; - stream_buffer_size = MAX(1024, (stream_buffer_size / 1024) * 1024); + stream_buffer_size = std::max(DWORD(1024), (stream_buffer_size / 1024) * 1024); LOG(("stream_buffer_size = %u\n", (unsigned)stream_buffer_size)); diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index efab053ef6e..6bd73917c66 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -331,7 +331,7 @@ void sound_sdl::update_audio_stream(bool is_throttled, const INT16 *buffer, int void sound_sdl::set_mastervolume(int _attenuation) { // clamp the attenuation to 0-32 range - attenuation = MAX(MIN(_attenuation, 0), -32); + attenuation = std::max(std::min(_attenuation, 0), -32); if (stream_in_initialized) { @@ -445,7 +445,7 @@ int sound_sdl::init(const osd_options &options) sdl_xfer_samples = obtained.samples; // pin audio latency - audio_latency = MAX(MIN(m_audio_latency, MAX_AUDIO_LATENCY), 1); + audio_latency = std::max(std::min(m_audio_latency, MAX_AUDIO_LATENCY), 1); // compute the buffer sizes stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30; diff --git a/src/osd/modules/sound/xaudio2_sound.cpp b/src/osd/modules/sound/xaudio2_sound.cpp index bb45626a6c6..c4923a9571c 100644 --- a/src/osd/modules/sound/xaudio2_sound.cpp +++ b/src/osd/modules/sound/xaudio2_sound.cpp @@ -20,13 +20,16 @@ // XAudio2 include #include <xaudio2.h> +#undef interface +#undef min +#undef max + // stdlib includes #include <mutex> #include <thread> #include <queue> #include <chrono> - -#undef interface +#include <algorithm> // MAME headers #include "emu.h" @@ -397,7 +400,7 @@ void sound_xaudio2::update_audio_stream( while (bytes_left > 0) { - UINT32 chunk = MIN(m_buffer_size, bytes_left); + UINT32 chunk = std::min(UINT32(m_buffer_size), bytes_left); // Roll the buffer if needed if (m_writepos + chunk >= m_buffer_size) @@ -429,7 +432,7 @@ void sound_xaudio2::set_mastervolume(int attenuation) HRESULT result; // clamp the attenuation to 0-32 range - attenuation = MAX(MIN(attenuation, 0), -32); + attenuation = std::max(std::min(attenuation, 0), -32); // Ranges from 1.0 to XAUDIO2_MAX_VOLUME_LEVEL indicate additional gain // Ranges from 0 to 1.0 indicate a reduced volume level @@ -498,7 +501,7 @@ void sound_xaudio2::create_buffers(const WAVEFORMATEX &format) m_buffer_count = (audio_latency_in_seconds * 1000.0f) / SUBMIT_FREQUENCY_TARGET_MS; // Now record the size of the individual buffers - m_buffer_size = MAX(1024, total_buffer_size / m_buffer_count); + m_buffer_size = std::max(DWORD(1024), total_buffer_size / m_buffer_count); // Make the buffer a multiple of the format size bytes (rounding up) UINT32 remainder = m_buffer_size % format.nBlockAlign; diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index c6c15d0df2a..b102ba3deaa 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -111,15 +111,6 @@ using unicode_char = std::uint32_t; FUNDAMENTAL MACROS ***************************************************************************/ -/* Standard MIN/MAX macros */ -#ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#endif -#ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#endif - - /* U64 and S64 are used to wrap long integer constants. */ #if defined(__GNUC__) || defined(_MSC_VER) #define U64(val) val##ULL @@ -131,9 +122,20 @@ using unicode_char = std::uint32_t; /* Concatenate/extract 32-bit halves of 64-bit values */ -#define CONCAT_64(hi,lo) (((UINT64)(hi) << 32) | (UINT32)(lo)) -#define EXTRACT_64HI(val) ((UINT32)((val) >> 32)) -#define EXTRACT_64LO(val) ((UINT32)(val)) +inline UINT64 concat_64(UINT32 hi, UINT32 lo) +{ + return (UINT64(hi) << 32) | UINT32(lo); +} + +inline UINT32 extract_64hi(UINT64 val) +{ + return UINT32(val >> 32); +} + +inline UINT32 extract_64lo(UINT64 val) +{ + return UINT32(val); +} // Highly useful template for compile-time knowledge of an array size template <typename T, size_t N> constexpr inline size_t ARRAY_LENGTH(T (&)[N]) { return N;} @@ -147,27 +149,29 @@ template <typename T, typename U, std::size_t N> struct equivalent_array<T, U[N] template <typename T, typename U> using equivalent_array_t = typename equivalent_array<T, U>::type; #define EQUIVALENT_ARRAY(a, T) equivalent_array_t<T, std::remove_reference_t<decltype(a)> > - /* Macros for normalizing data into big or little endian formats */ -#define FLIPENDIAN_INT16(x) (((((UINT16) (x)) >> 8) | ((x) << 8)) & 0xffff) -#define FLIPENDIAN_INT32(x) ((((UINT32) (x)) << 24) | (((UINT32) (x)) >> 24) | \ - (( ((UINT32) (x)) & 0x0000ff00) << 8) | (( ((UINT32) (x)) & 0x00ff0000) >> 8)) -#define FLIPENDIAN_INT64(x) \ - ( \ - (((((UINT64) (x)) >> 56) & ((UINT64) 0xFF)) << 0) | \ - (((((UINT64) (x)) >> 48) & ((UINT64) 0xFF)) << 8) | \ - (((((UINT64) (x)) >> 40) & ((UINT64) 0xFF)) << 16) | \ - (((((UINT64) (x)) >> 32) & ((UINT64) 0xFF)) << 24) | \ - (((((UINT64) (x)) >> 24) & ((UINT64) 0xFF)) << 32) | \ - (((((UINT64) (x)) >> 16) & ((UINT64) 0xFF)) << 40) | \ - (((((UINT64) (x)) >> 8) & ((UINT64) 0xFF)) << 48) | \ - (((((UINT64) (x)) >> 0) & ((UINT64) 0xFF)) << 56) \ - ) +inline UINT16 flipendian_int16( UINT16 val ) +{ + return (val << 8) | (val >> 8 ); +} + +inline UINT32 flipendian_int32( UINT32 val ) +{ + val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF ); + return (val << 16) | (val >> 16); +} + +inline UINT64 flipendian_int64( UINT64 val ) +{ + val = ((val << 8) & U64(0xFF00FF00FF00FF00) ) | ((val >> 8) & U64(0x00FF00FF00FF00FF) ); + val = ((val << 16) & U64(0xFFFF0000FFFF0000) ) | ((val >> 16) & U64(0x0000FFFF0000FFFF) ); + return (val << 32) | (val >> 32); +} #ifdef LSB_FIRST -#define BIG_ENDIANIZE_INT16(x) (FLIPENDIAN_INT16(x)) -#define BIG_ENDIANIZE_INT32(x) (FLIPENDIAN_INT32(x)) -#define BIG_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x)) +#define BIG_ENDIANIZE_INT16(x) (flipendian_int16(x)) +#define BIG_ENDIANIZE_INT32(x) (flipendian_int32(x)) +#define BIG_ENDIANIZE_INT64(x) (flipendian_int64(x)) #define LITTLE_ENDIANIZE_INT16(x) (x) #define LITTLE_ENDIANIZE_INT32(x) (x) #define LITTLE_ENDIANIZE_INT64(x) (x) @@ -175,9 +179,9 @@ template <typename T, typename U> using equivalent_array_t = typename equivalent #define BIG_ENDIANIZE_INT16(x) (x) #define BIG_ENDIANIZE_INT32(x) (x) #define BIG_ENDIANIZE_INT64(x) (x) -#define LITTLE_ENDIANIZE_INT16(x) (FLIPENDIAN_INT16(x)) -#define LITTLE_ENDIANIZE_INT32(x) (FLIPENDIAN_INT32(x)) -#define LITTLE_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x)) +#define LITTLE_ENDIANIZE_INT16(x) (flipendian_int16(x)) +#define LITTLE_ENDIANIZE_INT32(x) (flipendian_int32(x)) +#define LITTLE_ENDIANIZE_INT64(x) (flipendian_int64(x)) #endif /* LSB_FIRST */ #ifdef _MSC_VER diff --git a/src/osd/osdsync.cpp b/src/osd/osdsync.cpp index d32de87459c..a782d287e1d 100644 --- a/src/osd/osdsync.cpp +++ b/src/osd/osdsync.cpp @@ -21,7 +21,9 @@ #include <atomic> #include <thread> #include <vector> - +#undef min +#undef max +#include <algorithm> // MAME headers #include "osdcore.h" #include "osdsync.h" @@ -89,7 +91,7 @@ static void spin_while_not(const volatile _AtomType * volatile atom, const _Main int osd_get_num_processors(void) { // max out at 4 for now since scaling above that seems to do poorly - return MIN(std::thread::hardware_concurrency(), 4); + return std::min(std::thread::hardware_concurrency(), 4U); } //============================================================ @@ -272,7 +274,7 @@ osd_work_queue *osd_work_queue_alloc(int flags) threadnum = osdthreadnum; // clamp to the maximum - queue->threads = MIN(threadnum, WORK_MAX_THREADS); + queue->threads = std::min(threadnum, WORK_MAX_THREADS); // allocate memory for thread array (+1 to count the calling thread if WORK_QUEUE_FLAG_MULTI) if (flags & WORK_QUEUE_FLAG_MULTI) @@ -639,7 +641,7 @@ static int effective_num_processors(void) // osd_num_processors == 0 for 'auto' if (osd_num_processors > 0) { - return MIN(4 * physprocs, osd_num_processors); + return std::min(4 * physprocs, osd_num_processors); } else { @@ -649,7 +651,7 @@ static int effective_num_processors(void) // note that we permit more than the real number of processors for testing const char *procsoverride = osd_getenv(ENV_PROCESSORS); if (procsoverride != nullptr && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0) - return MIN(4 * physprocs, numprocs); + return std::min(4 * physprocs, numprocs); // otherwise, return the info from the system return physprocs; diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp index 0c54d4d9e5a..d655298fa8b 100644 --- a/src/osd/sdl/window.cpp +++ b/src/osd/sdl/window.cpp @@ -490,8 +490,8 @@ osd_dim sdl_window_info::pick_best_mode() m_target->compute_minimum_size(minimum_width, minimum_height); // use those as the target for now - target_width = minimum_width * MAX(1, prescale()); - target_height = minimum_height * MAX(1, prescale()); + target_width = minimum_width * std::max(1, prescale()); + target_height = minimum_height * std::max(1, prescale()); // if we're not stretching, allow some slop on the minimum since we can handle it { @@ -926,12 +926,12 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad m_target->compute_minimum_size(minwidth, minheight); // clamp against the absolute minimum - propwidth = MAX(propwidth, MIN_WINDOW_DIM); - propheight = MAX(propheight, MIN_WINDOW_DIM); + propwidth = std::max(propwidth, MIN_WINDOW_DIM); + propheight = std::max(propheight, MIN_WINDOW_DIM); // clamp against the minimum width and height - propwidth = MAX(propwidth, minwidth); - propheight = MAX(propheight, minheight); + propwidth = std::max(propwidth, minwidth); + propheight = std::max(propheight, minheight); // clamp against the maximum (fit on one screen for full screen mode) if (m_fullscreen) @@ -946,14 +946,14 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad // further clamp to the maximum width/height in the window if (m_win_config.width != 0) - maxwidth = MIN(maxwidth, m_win_config.width + extrawidth); + maxwidth = std::min(maxwidth, m_win_config.width + extrawidth); if (m_win_config.height != 0) - maxheight = MIN(maxheight, m_win_config.height + extraheight); + maxheight = std::min(maxheight, m_win_config.height + extraheight); } // clamp to the maximum - propwidth = MIN(propwidth, maxwidth); - propheight = MIN(propheight, maxheight); + propwidth = std::min(propwidth, maxwidth); + 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); diff --git a/src/osd/strconv.cpp b/src/osd/strconv.cpp index 49a70f52684..7ab8f2f401b 100644 --- a/src/osd/strconv.cpp +++ b/src/osd/strconv.cpp @@ -5,12 +5,13 @@ // strconv.cpp - Win32 string conversion // //============================================================ - #if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS) #define WIN32_LEAN_AND_MEAN #include <windows.h> #endif - +#undef min +#undef max +#include <algorithm> // MAMEOS headers #include "strconv.h" @@ -140,7 +141,7 @@ int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count) goto error; // The multibyte char can't be bigger than the max character size - count = MIN(count, cp.MaxCharSize); + count = std::min(count, size_t(cp.MaxCharSize)); if (MultiByteToWideChar(CP_ACP, 0, osdchar, static_cast<DWORD>(count), &wch, 1) == 0) goto error; diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index b1cc369c0af..12e578d4682 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -51,8 +51,8 @@ using namespace Windows::UI::Core; #define MAKE_DI_SCAN(scan, isextended) (scan & 0x7f) | (isextended ? 0x80 : 0x00) #define WINOSD(machine) downcast<windows_osd_interface*>(&machine.osd()) -// min(x, y) macro interferes with chrono time_point::min() #undef min +#undef max //============================================================ // PARAMETERS @@ -1464,12 +1464,12 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad m_target->compute_minimum_size(minwidth, minheight); // clamp against the absolute minimum - propwidth = MAX(propwidth, MIN_WINDOW_DIM); - propheight = MAX(propheight, MIN_WINDOW_DIM); + propwidth = std::max(propwidth, MIN_WINDOW_DIM); + propheight = std::max(propheight, MIN_WINDOW_DIM); // clamp against the minimum width and height - propwidth = MAX(propwidth, minwidth); - propheight = MAX(propheight, minheight); + propwidth = std::max(propwidth, minwidth); + propheight = std::max(propheight, minheight); // clamp against the maximum (fit on one screen for full screen mode) if (fullscreen()) @@ -1484,14 +1484,14 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad // further clamp to the maximum width/height in the window if (m_win_config.width != 0) - maxwidth = MIN(maxwidth, m_win_config.width + extrawidth); + maxwidth = std::min(maxwidth, m_win_config.width + extrawidth); if (m_win_config.height != 0) - maxheight = MIN(maxheight, m_win_config.height + extraheight); + maxheight = std::min(maxheight, m_win_config.height + extraheight); } // clamp to the maximum - propwidth = MIN(propwidth, maxwidth); - propheight = MIN(propheight, maxheight); + propwidth = std::min(propwidth, maxwidth); + 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); |