From 49b0eef393f4d321928fb0b6093d58a7637cf1da Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 2 May 2014 22:47:04 -0400 Subject: [PATCH] Remove the min/max functions in CommonFuncs. The algorithm header has the same functions. --- Source/Core/AudioCommon/stdafx.h | 1 + Source/Core/Common/CommonFuncs.h | 9 ------- Source/Core/Common/Hash.cpp | 14 +++++----- Source/Core/Common/SysConf.h | 3 ++- Source/Core/Common/stdafx.h | 4 ++- .../Core/FifoPlayer/FifoRecordAnalyzer.cpp | 6 +++-- Source/Core/Core/HW/SI.cpp | 4 ++- .../IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp | 4 ++- Source/Core/Core/IPC_HLE/WII_Socket.cpp | 4 ++- Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp | 4 ++- Source/Core/Core/PowerPC/JitArmIL/IR_Arm.cpp | 4 ++- Source/Core/Core/stdafx.h | 3 ++- Source/Core/DiscIO/CompressedBlob.cpp | 4 +-- Source/Core/DiscIO/FileSystemGCWii.cpp | 2 +- Source/Core/DiscIO/stdafx.h | 3 ++- Source/Core/DolphinWX/stdafx.h | 5 ++-- Source/Core/InputCommon/stdafx.h | 1 + Source/Core/VideoBackends/D3D/stdafx.h | 4 ++- Source/Core/VideoBackends/OGL/stdafx.h | 4 ++- .../VideoBackends/Software/Rasterizer.cpp | 25 ++++++++--------- .../VideoBackends/Software/SWRenderer.cpp | 14 +++++----- .../VideoBackends/Software/TextureSampler.cpp | 5 ++-- .../VideoBackends/Software/TransformUnit.cpp | 27 ++++++++++--------- Source/Core/VideoBackends/Software/stdafx.h | 4 ++- Source/Core/VideoCommon/TextureCacheBase.cpp | 4 ++- .../VideoCommon/TextureDecoder_Generic.cpp | 24 +++++------------ .../Core/VideoCommon/TextureDecoder_x64.cpp | 5 ++-- Source/Core/VideoCommon/stdafx.h | 3 ++- Source/UnitTests/Common/CommonFuncsTest.cpp | 9 ------- 29 files changed, 104 insertions(+), 99 deletions(-) diff --git a/Source/Core/AudioCommon/stdafx.h b/Source/Core/AudioCommon/stdafx.h index e28b312ed0..37663533a9 100644 --- a/Source/Core/AudioCommon/stdafx.h +++ b/Source/Core/AudioCommon/stdafx.h @@ -12,6 +12,7 @@ #endif */ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions #include #include diff --git a/Source/Core/Common/CommonFuncs.h b/Source/Core/Common/CommonFuncs.h index e2ee8936a1..a4a5d8baa6 100644 --- a/Source/Core/Common/CommonFuncs.h +++ b/Source/Core/Common/CommonFuncs.h @@ -158,15 +158,6 @@ extern "C" { #endif // M_IX86 #endif // WIN32 ndef -// Dolphin's min and max functions -#undef min -#undef max - -template -inline T min(const T& a, const T& b) {return a > b ? b : a;} -template -inline T max(const T& a, const T& b) {return a > b ? a : b;} - // Generic function to get last error message. // Call directly after the command or use the error num. // This function might change the error code. diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp index f7ed8f308f..e346dba796 100644 --- a/Source/Core/Common/Hash.cpp +++ b/Source/Core/Common/Hash.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. - +#include #include "Common/Hash.h" #if _M_SSE >= 0x402 #include "Common/CPUDetect.h" @@ -155,7 +155,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples) const u8 * data = (const u8*)src; const int nblocks = len / 16; u32 Step = (len / 8); - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; @@ -233,7 +233,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; while (data < end) @@ -265,7 +265,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; while (data < end) @@ -308,7 +308,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) u32 Step = (len/4); const u32 *data = (const u32 *)src; const u32 *end = data + Step; - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; while (data < end) @@ -380,7 +380,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples) u32 out[2]; const int nblocks = len / 8; u32 Step = (len / 4); - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; @@ -456,7 +456,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if (samples == 0) samples = max(Step, 1u); + if (samples == 0) samples = std::max(Step, 1u); Step = Step / samples; if (Step < 1) Step = 1; while (data < end) diff --git a/Source/Core/Common/SysConf.h b/Source/Core/Common/SysConf.h index 0edd1bbd4a..bbdc998c21 100644 --- a/Source/Core/Common/SysConf.h +++ b/Source/Core/Common/SysConf.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -58,7 +59,7 @@ struct SSysConfEntry { if (buffer) { - memcpy(data, buffer, min(bufferSize, dataLength)); + memcpy(data, buffer, std::min(bufferSize, dataLength)); return true; } return false; diff --git a/Source/Core/Common/stdafx.h b/Source/Core/Common/stdafx.h index 832a942e21..3142ff68d2 100644 --- a/Source/Core/Common/stdafx.h +++ b/Source/Core/Common/stdafx.h @@ -9,11 +9,13 @@ #define _WIN32_WINNT 0x501 #endif #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif */ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions + /* #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 diff --git a/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp index 1e50ff3a77..4d4ebd3420 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Core/Core.h" #include "Core/FifoPlayer/FifoAnalyzer.h" #include "Core/FifoPlayer/FifoRecordAnalyzer.h" @@ -289,8 +291,8 @@ void FifoRecordAnalyzer::WriteTexMapMemory(int texMap, u32 &writtenTexMaps) width >>= 1; height >>= 1; - width = max(width, fmtWidth); - height = max(height, fmtHeight); + width = std::max(width, fmtWidth); + height = std::max(height, fmtHeight); u32 size = (width * height * fmtDepth) >> 1; textureSize += size; diff --git a/Source/Core/Core/HW/SI.cpp b/Source/Core/Core/HW/SI.cpp index 4005440a71..8cfa27d14a 100644 --- a/Source/Core/Core/HW/SI.cpp +++ b/Source/Core/Core/HW/SI.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/ChunkFile.h" #include "Common/Common.h" @@ -544,7 +546,7 @@ int GetTicksToNextSIPoll() else if (!g_Poll.Y) return SystemTimers::GetTicksPerSecond() / 60; - return min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X); + return std::min(VideoInterface::GetTicksPerFrame() / g_Poll.Y, VideoInterface::GetTicksPerLine() * g_Poll.X); } } // end of namespace SerialInterface diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp index fc72e86bb1..bd02d7ba21 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/FileUtil.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h" #include "Core/IPC_HLE/WII_Socket.h" @@ -174,7 +176,7 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress) ssl_set_authmode(&ssl->ctx, SSL_VERIFY_NONE); ssl_set_renegotiation(&ssl->ctx, SSL_RENEGOTIATION_ENABLED); - memcpy(ssl->hostname, hostname, min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN)); + memcpy(ssl->hostname, hostname, std::min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN)); ssl->hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0'; ssl_set_hostname(&ssl->ctx, ssl->hostname); diff --git a/Source/Core/Core/IPC_HLE/WII_Socket.cpp b/Source/Core/Core/IPC_HLE/WII_Socket.cpp index 4a526b20a0..a7b810be91 100644 --- a/Source/Core/Core/IPC_HLE/WII_Socket.cpp +++ b/Source/Core/Core/IPC_HLE/WII_Socket.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "Core/IPC_HLE/WII_IPC_HLE.h" @@ -589,7 +591,7 @@ void WiiSockMan::Update() FD_SET(sock.fd, &read_fds); FD_SET(sock.fd, &write_fds); FD_SET(sock.fd, &except_fds); - nfds = max(nfds, sock.fd+1); + nfds = std::max(nfds, sock.fd+1); } else { diff --git a/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp b/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp index 72a1afdd62..b007095761 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp @@ -24,6 +24,8 @@ The register allocation is linear scan allocation. #pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned #endif +#include + #include "Common/CPUDetect.h" #include "Common/MathUtil.h" #include "Core/HW/ProcessorInterface.h" @@ -76,7 +78,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) { unsigned& info = R.IInfo[Op - R.FirstI]; if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1); if (info < 2) info++; - R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I); + R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I); } static unsigned regReadUse(RegInfo& R, InstLoc I) { diff --git a/Source/Core/Core/PowerPC/JitArmIL/IR_Arm.cpp b/Source/Core/Core/PowerPC/JitArmIL/IR_Arm.cpp index da601d26f5..7847c6f953 100644 --- a/Source/Core/Core/PowerPC/JitArmIL/IR_Arm.cpp +++ b/Source/Core/Core/PowerPC/JitArmIL/IR_Arm.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/ArmEmitter.h" #include "Core/Core.h" #include "Core/CoreTiming.h" @@ -50,7 +52,7 @@ static void regMarkUse(RegInfo& R, InstLoc I, InstLoc Op, unsigned OpNum) { unsigned& info = R.IInfo[Op - R.FirstI]; if (info == 0) R.IInfo[I - R.FirstI] |= 1 << (OpNum + 1); if (info < 2) info++; - R.lastUsed[Op - R.FirstI] = max(R.lastUsed[Op - R.FirstI], I); + R.lastUsed[Op - R.FirstI] = std::max(R.lastUsed[Op - R.FirstI], I); } static void regClearInst(RegInfo& RI, InstLoc I) { for (int i = 0; i < RegAllocSize; i++) diff --git a/Source/Core/Core/stdafx.h b/Source/Core/Core/stdafx.h index 167fccc549..735aea396a 100644 --- a/Source/Core/Core/stdafx.h +++ b/Source/Core/Core/stdafx.h @@ -6,9 +6,10 @@ #define _WIN32_WINNT 0x501 #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions #include diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index 98b19f328d..553388b902 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -193,7 +193,7 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u u64 position = 0; int num_compressed = 0; int num_stored = 0; - int progress_monitor = max(1, header.num_blocks / 1000); + int progress_monitor = std::max(1, header.num_blocks / 1000); for (u32 i = 0; i < header.num_blocks; i++) { @@ -299,7 +299,7 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile, const CompressedBlobHeader &header = reader->GetHeader(); u8* buffer = new u8[header.block_size]; - int progress_monitor = max(1, header.num_blocks / 100); + int progress_monitor = std::max(1, header.num_blocks / 100); for (u64 i = 0; i < header.num_blocks; i++) { diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index cdd830c6f6..a264eb0ffb 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -104,7 +104,7 @@ bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath, const std::stri while (remainingSize) { // Limit read size to 128 MB - size_t readSize = (size_t)min(remainingSize, (u64)0x08000000); + size_t readSize = std::min(remainingSize, (u64)0x08000000); std::vector buffer(readSize); diff --git a/Source/Core/DiscIO/stdafx.h b/Source/Core/DiscIO/stdafx.h index 03a92c3b49..19ed0290e7 100644 --- a/Source/Core/DiscIO/stdafx.h +++ b/Source/Core/DiscIO/stdafx.h @@ -8,7 +8,8 @@ #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE diff --git a/Source/Core/DolphinWX/stdafx.h b/Source/Core/DolphinWX/stdafx.h index 8adaf25e66..9253fc3e09 100644 --- a/Source/Core/DolphinWX/stdafx.h +++ b/Source/Core/DolphinWX/stdafx.h @@ -12,8 +12,9 @@ #define _WIN32_IE 0x0500 #define _RICHEDIT_VER 0x0100 -#define WIN32_LEAN_AND_MEAN -#include // wxWidgets +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions +#include // wxWidgets #if _M_X86_32 diff --git a/Source/Core/InputCommon/stdafx.h b/Source/Core/InputCommon/stdafx.h index 613c8995a2..cd18106bfc 100644 --- a/Source/Core/InputCommon/stdafx.h +++ b/Source/Core/InputCommon/stdafx.h @@ -10,5 +10,6 @@ #endif */ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions #include diff --git a/Source/Core/VideoBackends/D3D/stdafx.h b/Source/Core/VideoBackends/D3D/stdafx.h index 81bb44dc19..d245b07645 100644 --- a/Source/Core/VideoBackends/D3D/stdafx.h +++ b/Source/Core/VideoBackends/D3D/stdafx.h @@ -5,8 +5,10 @@ #pragma once #define _WIN32_WINNT 0x501 #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif +#define NOMINMAX // Don't include windows min/max definitions + #include #include diff --git a/Source/Core/VideoBackends/OGL/stdafx.h b/Source/Core/VideoBackends/OGL/stdafx.h index 81bb44dc19..d245b07645 100644 --- a/Source/Core/VideoBackends/OGL/stdafx.h +++ b/Source/Core/VideoBackends/OGL/stdafx.h @@ -5,8 +5,10 @@ #pragma once #define _WIN32_WINNT 0x501 #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif +#define NOMINMAX // Don't include windows min/max definitions + #include #include diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index 67f80047cc..915757f766 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -2,8 +2,9 @@ // Licensed under GPLv2 // Refer to the license.txt file included. -#include "Common/Common.h" +#include +#include "Common/Common.h" #include "VideoBackends/Software/BPMemLoader.h" #include "VideoBackends/Software/EfbInterface.h" #include "VideoBackends/Software/HwRasterizer.h" @@ -231,12 +232,12 @@ inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord) float *uv1 = rasterBlock.Pixel[1][0].Uv[texcoord]; float *uv2 = rasterBlock.Pixel[0][1].Uv[texcoord]; - sDelta = max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0])); - tDelta = max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1])); + sDelta = std::max(fabsf(uv0[0] - uv1[0]), fabsf(uv0[0] - uv2[0])); + tDelta = std::max(fabsf(uv0[1] - uv1[1]), fabsf(uv0[1] - uv2[1])); } // get LOD in s28.4 - lod = FixedLog2(max(sDelta, tDelta)); + lod = FixedLog2(std::max(sDelta, tDelta)); // bias is s2.5 int bias = tm0.lod_bias; @@ -349,16 +350,16 @@ void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVer const s32 FDY31 = DY31 << 4; // Bounding rectangle - s32 minx = (min(min(X1, X2), X3) + 0xF) >> 4; - s32 maxx = (max(max(X1, X2), X3) + 0xF) >> 4; - s32 miny = (min(min(Y1, Y2), Y3) + 0xF) >> 4; - s32 maxy = (max(max(Y1, Y2), Y3) + 0xF) >> 4; + s32 minx = (std::min(std::min(X1, X2), X3) + 0xF) >> 4; + s32 maxx = (std::max(std::max(X1, X2), X3) + 0xF) >> 4; + s32 miny = (std::min(std::min(Y1, Y2), Y3) + 0xF) >> 4; + s32 maxy = (std::max(std::max(Y1, Y2), Y3) + 0xF) >> 4; // scissor - minx = max(minx, scissorLeft); - maxx = min(maxx, scissorRight); - miny = max(miny, scissorTop); - maxy = min(maxy, scissorBottom); + minx = std::max(minx, scissorLeft); + maxx = std::min(maxx, scissorRight); + miny = std::max(miny, scissorTop); + maxy = std::min(maxy, scissorBottom); if (minx >= maxx || miny >= maxy) return; diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index e78aae5e4c..ea26a94139 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/Common.h" #include "Core/Core.h" #include "VideoBackends/OGL/GLUtil.h" @@ -180,14 +182,14 @@ void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed *xfb, u32 fbWidt // We do the inverse BT.601 conversion for YCbCr to RGB // http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 + 1.596f * V)); - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 - 0.392f * U - 0.813f * V)); - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y1 + 2.017f * U )); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y1 + 1.596f * V)); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y1 - 0.392f * U - 0.813f * V)); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y1 + 2.017f * U )); TexturePointer[offset++] = 255; - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 + 1.596f * V)); - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 - 0.392f * U - 0.813f * V)); - TexturePointer[offset++] = (u8)min(255.0f, max(0.0f, 1.164f * Y2 + 2.017f * U )); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y2 + 1.596f * V)); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y2 - 0.392f * U - 0.813f * V)); + TexturePointer[offset++] = std::min(255.0f, std::max(0.0f, 1.164f * Y2 + 2.017f * U )); TexturePointer[offset++] = 255; } xfb += fbWidth; diff --git a/Source/Core/VideoBackends/Software/TextureSampler.cpp b/Source/Core/VideoBackends/Software/TextureSampler.cpp index b77248ff9d..d5a7f891b9 100644 --- a/Source/Core/VideoBackends/Software/TextureSampler.cpp +++ b/Source/Core/VideoBackends/Software/TextureSampler.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include "Core/HW/Memmap.h" @@ -142,8 +143,8 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample) while (mip) { - mipWidth = max(mipWidth, fmtWidth); - mipHeight = max(mipHeight, fmtHeight); + mipWidth = std::max(mipWidth, fmtWidth); + mipHeight = std::max(mipHeight, fmtHeight); u32 size = (mipWidth * mipHeight * fmtDepth) >> 1; imageSrc += size; diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp index dee4abe51e..2c4c495087 100644 --- a/Source/Core/VideoBackends/Software/TransformUnit.cpp +++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include "Common/Common.h" @@ -229,7 +230,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann case LIGHTDIF_CLAMP: { Vec3 ldir = (light->pos - pos).normalized(); - float diffuse = max(0.0f, ldir * normal); + float diffuse = std::max(0.0f, ldir * normal); AddScaledIntegerColor(light->color, diffuse, lightCol); } break; @@ -247,21 +248,21 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann float dist2 = ldir.length2(); float dist = sqrtf(dist2); ldir = ldir / dist; - attn = max(0.0f, ldir * light->dir); + attn = std::max(0.0f, ldir * light->dir); float cosAtt = light->cosatt.x + (light->cosatt.y * attn) + (light->cosatt.z * attn * attn); float distAtt = light->distatt.x + (light->distatt.y * dist) + (light->distatt.z * dist2); - attn = SafeDivide(max(0.0f, cosAtt), distAtt); + attn = SafeDivide(std::max(0.0f, cosAtt), distAtt); } else if (chan.attnfunc == 1) // specular { // donko - what is going on here? 655.36 is a guess but seems about right. - attn = (light->pos * normal) > -655.36 ? max(0.0f, (light->dir * normal)) : 0; + attn = (light->pos * normal) > -655.36 ? std::max(0.0f, (light->dir * normal)) : 0; ldir.set(1.0f, attn, attn * attn); - float cosAtt = max(0.0f, light->cosatt * ldir); + float cosAtt = std::max(0.0f, light->cosatt * ldir); float distAtt = light->distatt * ldir; - attn = SafeDivide(max(0.0f, cosAtt), distAtt); + attn = SafeDivide(std::max(0.0f, cosAtt), distAtt); } else { @@ -283,7 +284,7 @@ void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann case LIGHTDIF_CLAMP: { - float difAttn = max(0.0f, ldir * normal); + float difAttn = std::max(0.0f, ldir * normal); AddScaledIntegerColor(light->color, attn * difAttn, lightCol); } break; @@ -314,7 +315,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann case LIGHTDIF_CLAMP: { Vec3 ldir = (light->pos - pos).normalized(); - float diffuse = max(0.0f, ldir * normal); + float diffuse = std::max(0.0f, ldir * normal); lightCol += light->color[0] * diffuse; } break; @@ -331,21 +332,21 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann float dist2 = ldir.length2(); float dist = sqrtf(dist2); ldir = ldir / dist; - attn = max(0.0f, ldir * light->dir); + attn = std::max(0.0f, ldir * light->dir); float cosAtt = light->cosatt.x + (light->cosatt.y * attn) + (light->cosatt.z * attn * attn); float distAtt = light->distatt.x + (light->distatt.y * dist) + (light->distatt.z * dist2); - attn = SafeDivide(max(0.0f, cosAtt), distAtt); + attn = SafeDivide(std::max(0.0f, cosAtt), distAtt); } else /* if (chan.attnfunc == 1) */ // specular { // donko - what is going on here? 655.36 is a guess but seems about right. - attn = (light->pos * normal) > -655.36 ? max(0.0f, (light->dir * normal)) : 0; + attn = (light->pos * normal) > -655.36 ? std::max(0.0f, (light->dir * normal)) : 0; ldir.set(1.0f, attn, attn * attn); float cosAtt = light->cosatt * ldir; float distAtt = light->distatt * ldir; - attn = SafeDivide(max(0.0f, cosAtt), distAtt); + attn = SafeDivide(std::max(0.0f, cosAtt), distAtt); } switch (chan.diffusefunc) @@ -362,7 +363,7 @@ void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const LitChann case LIGHTDIF_CLAMP: { - float difAttn = max(0.0f, ldir * normal); + float difAttn = std::max(0.0f, ldir * normal); lightCol += light->color[0] * attn * difAttn; } break; diff --git a/Source/Core/VideoBackends/Software/stdafx.h b/Source/Core/VideoBackends/Software/stdafx.h index 9d8868e8a9..76dce7c64f 100644 --- a/Source/Core/VideoBackends/Software/stdafx.h +++ b/Source/Core/VideoBackends/Software/stdafx.h @@ -5,9 +5,11 @@ #pragma once #define _WIN32_WINNT 0x501 #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif +#define NOMINMAX // Don't include windows min/max definitions + #include #include diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 6742ac21c5..33ac8e604b 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/FileUtil.h" #include "Common/MemoryUtil.h" @@ -386,7 +388,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage, // D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there - while (g_ActiveConfig.backend_info.bUseMinimalMipCount && max(expandedWidth, expandedHeight) >> maxlevel == 0) + while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(expandedWidth, expandedHeight) >> maxlevel == 0) --maxlevel; TCacheEntryBase *entry = textures[texID]; diff --git a/Source/Core/VideoCommon/TextureDecoder_Generic.cpp b/Source/Core/VideoCommon/TextureDecoder_Generic.cpp index 95ead9c174..30edd16360 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Generic.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Generic.cpp @@ -1,20 +1,8 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. +#include #include #include "Common/Common.h" @@ -1055,8 +1043,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE)) return retval; - int w = min(width, 40); - int h = min(height, 10); + int w = std::min(width, 40); + int h = std::min(height, 10); int xoff = (width - w) >> 1; int yoff = (height - h) >> 1; diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp index ae11374538..efe116d39a 100644 --- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include "Common/Common.h" @@ -2037,8 +2038,8 @@ PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, in if ((!TexFmt_Overlay_Enable) || (retval == PC_TEX_FMT_NONE)) return retval; - int w = min(width, 40); - int h = min(height, 10); + int w = std::min(width, 40); + int h = std::min(height, 10); int xoff = (width - w) >> 1; int yoff = (height - h) >> 1; diff --git a/Source/Core/VideoCommon/stdafx.h b/Source/Core/VideoCommon/stdafx.h index 167fccc549..735aea396a 100644 --- a/Source/Core/VideoCommon/stdafx.h +++ b/Source/Core/VideoCommon/stdafx.h @@ -6,9 +6,10 @@ #define _WIN32_WINNT 0x501 #ifndef _WIN32_IE -#define _WIN32_IE 0x0500 // Default value is 0x0400 +#define _WIN32_IE 0x0500 // Default value is 0x0400 #endif #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX // Don't include windows min/max definitions #include diff --git a/Source/UnitTests/Common/CommonFuncsTest.cpp b/Source/UnitTests/Common/CommonFuncsTest.cpp index 285b5f253e..5fced4c5aa 100644 --- a/Source/UnitTests/Common/CommonFuncsTest.cpp +++ b/Source/UnitTests/Common/CommonFuncsTest.cpp @@ -28,15 +28,6 @@ TEST(CommonFuncs, CrashMacro) EXPECT_DEATH({ Crash(); }, ""); } -TEST(CommonFuncs, MinMax) -{ - EXPECT_EQ(4, min(4, 5)); - EXPECT_EQ(-1, min(-1, 1)); - - EXPECT_EQ(5, max(4, 5)); - EXPECT_EQ(1, max(-1, 1)); -} - TEST(CommonFuncs, Swap) { EXPECT_EQ(0xf0, Common::swap8(0xf0));