mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- replaced MIN/MAX in common code.
This commit is contained in:
parent
07a181090b
commit
eb69bbcae0
63 changed files with 200 additions and 236 deletions
|
@ -455,7 +455,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
|
|||
// Note that this only works for unflipped and unrotated full textures.
|
||||
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
||||
{
|
||||
double wi = std::min(parms.windowright, parms.texwidth);
|
||||
double wi = min(parms.windowright, parms.texwidth);
|
||||
x += parms.windowleft * xscale;
|
||||
w -= (parms.texwidth - wi + parms.windowleft) * xscale;
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ int GetUIScale(F2DDrawer *drawer, int altval)
|
|||
// block scales that result in something larger than the current screen.
|
||||
int vmax = drawer->GetHeight() / 200;
|
||||
int hmax = drawer->GetWidth() / 320;
|
||||
int max = MAX(vmax, hmax);
|
||||
return MAX(1,MIN(scaleval, max));
|
||||
int max = std::max(vmax, hmax);
|
||||
return std::max(1,min(scaleval, max));
|
||||
}
|
||||
|
||||
// The new console font is twice as high, so the scaling calculation must factor that in.
|
||||
|
@ -172,8 +172,8 @@ int GetConScale(F2DDrawer* drawer, int altval)
|
|||
// block scales that result in something larger than the current screen.
|
||||
int vmax = drawer->GetHeight() / 400;
|
||||
int hmax = drawer->GetWidth() / 640;
|
||||
int max = MAX(vmax, hmax);
|
||||
return MAX(1, MIN(scaleval, max));
|
||||
int max = std::max(vmax, hmax);
|
||||
return std::max(1, min(scaleval, max));
|
||||
}
|
||||
|
||||
|
||||
|
@ -357,7 +357,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect)
|
|||
if (numret > 1) ret[1].SetInt(y);
|
||||
if (numret > 2) ret[2].SetInt(w);
|
||||
if (numret > 3) ret[3].SetInt(h);
|
||||
return MIN(numret, 4);
|
||||
return min(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -460,7 +460,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetFullscreenRect)
|
|||
if (numret >= 2) ret[1].SetFloat(rect.top);
|
||||
if (numret >= 3) ret[2].SetFloat(rect.width);
|
||||
if (numret >= 4) ret[3].SetFloat(rect.height);
|
||||
return MIN(numret, 4);
|
||||
return min(numret, 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -905,7 +905,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
|
|||
break;
|
||||
|
||||
case DTA_Alpha:
|
||||
parms->Alpha = (float)(MIN<double>(1., ListGetDouble(tags)));
|
||||
parms->Alpha = (float)(min<double>(1., ListGetDouble(tags)));
|
||||
break;
|
||||
|
||||
case DTA_AlphaChannel:
|
||||
|
@ -1090,7 +1090,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
|
|||
break;
|
||||
|
||||
case DTA_ShadowAlpha:
|
||||
//parms->shadowAlpha = (float)MIN(1., ListGetDouble(tags));
|
||||
//parms->shadowAlpha = (float)min(1., ListGetDouble(tags));
|
||||
break;
|
||||
|
||||
case DTA_ShadowColor:
|
||||
|
@ -1286,10 +1286,10 @@ static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height,
|
|||
{
|
||||
case 1:
|
||||
default:
|
||||
myratio = MIN(64.0f / 27.0f, myratio);
|
||||
myratio = min(64.0f / 27.0f, myratio);
|
||||
break;
|
||||
case 0:
|
||||
myratio = MIN(16.0f / 9.0f, myratio);
|
||||
myratio = min(16.0f / 9.0f, myratio);
|
||||
case -1:
|
||||
break;
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords)
|
|||
VirtualToRealCoords(twod, x, y, w, h, vw, vh, vbottom, handleaspect);
|
||||
if (numret >= 1) ret[0].SetVector2(DVector2(x, y));
|
||||
if (numret >= 2) ret[1].SetVector2(DVector2(w, h));
|
||||
return MIN(numret, 2);
|
||||
return min(numret, 2);
|
||||
}
|
||||
|
||||
void VirtualToRealCoordsInt(F2DDrawer *drawer, int &x, int &y, int &w, int &h,
|
||||
|
@ -1594,7 +1594,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame)
|
|||
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2)
|
||||
{
|
||||
if (designheight < 240 && realheight >= 480) designheight = 240;
|
||||
*cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight);
|
||||
*cleanx = *cleany = min(realwidth / designwidth, realheight / designheight);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -579,7 +579,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
// Make sure one source is capable of stereo output with the rest doing
|
||||
// mono, without running out of voices
|
||||
attribs.Push(ALC_MONO_SOURCES);
|
||||
attribs.Push(std::max<ALCint>(snd_channels, 2) - 1);
|
||||
attribs.Push(max<ALCint>(snd_channels, 2) - 1);
|
||||
attribs.Push(ALC_STEREO_SOURCES);
|
||||
attribs.Push(1);
|
||||
if(ALC.SOFT_HRTF)
|
||||
|
@ -681,7 +681,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
// At least Apple's OpenAL implementation returns zeroes,
|
||||
// although it can generate reasonable number of sources.
|
||||
|
||||
const int numChannels = std::max<int>(snd_channels, 2);
|
||||
const int numChannels = max<int>(snd_channels, 2);
|
||||
int numSources = numMono + numStereo;
|
||||
|
||||
if (0 == numSources)
|
||||
|
@ -689,7 +689,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
numSources = numChannels;
|
||||
}
|
||||
|
||||
Sources.Resize(std::min<int>(numChannels, numSources));
|
||||
Sources.Resize(min<int>(numChannels, numSources));
|
||||
for(unsigned i = 0;i < Sources.Size();i++)
|
||||
{
|
||||
alGenSources(1, &Sources[i]);
|
||||
|
@ -1346,7 +1346,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
|||
float gain = GetRolloff(rolloff, dist * distscale);
|
||||
// Don't let the ref distance go to 0, or else distance attenuation is
|
||||
// lost with the inverse distance model.
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_MAX_DISTANCE, std::numeric_limits<float>::max());
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 1.f);
|
||||
}
|
||||
|
@ -1466,9 +1466,9 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch)
|
|||
|
||||
ALuint source = GET_PTRID(chan->SysChannel);
|
||||
if (WasInWater && !(chan->ChanFlags & CHANF_UI))
|
||||
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)*PITCH_MULT);
|
||||
alSourcef(source, AL_PITCH, max(pitch, 0.0001f)*PITCH_MULT);
|
||||
else
|
||||
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f));
|
||||
alSourcef(source, AL_PITCH, max(pitch, 0.0001f));
|
||||
}
|
||||
|
||||
void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
|
||||
|
@ -1622,7 +1622,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
|
|||
{
|
||||
float dist = sqrtf(dist_sqr);
|
||||
float gain = GetRolloff(&chan->Rolloff, dist * chan->DistanceScale);
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
|
||||
}
|
||||
|
||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
|
|
|
@ -407,7 +407,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
|
|||
sfx = &S_sfx[sound_id];
|
||||
|
||||
// Scale volume according to SNDINFO data.
|
||||
volume = std::min(volume * sfx->Volume, 1.f);
|
||||
volume = min(volume * sfx->Volume, 1.f);
|
||||
if (volume <= 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -847,7 +847,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
|
|||
|
||||
CalcPosVel(chan, &chanorigin, NULL);
|
||||
// scale the limit distance with the attenuation. An attenuation of 0 means the limit distance is infinite and all sounds within the level are inside the limit.
|
||||
float attn = std::min(chan->DistanceScale, attenuation);
|
||||
float attn = min(chan->DistanceScale, attenuation);
|
||||
if (attn <= 0 || (chanorigin - pos).LengthSquared() <= limit_range / attn)
|
||||
{
|
||||
count++;
|
||||
|
@ -1074,8 +1074,8 @@ void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int chann
|
|||
void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
|
||||
{
|
||||
assert(chan != nullptr);
|
||||
GSnd->ChannelPitch(chan, std::max(0.0001f, pitch));
|
||||
chan->Pitch = std::max(1, int(float(DEFAULT_PITCH) * pitch));
|
||||
GSnd->ChannelPitch(chan, max(0.0001f, pitch));
|
||||
chan->Pitch = max(1, int(float(DEFAULT_PITCH) * pitch));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -144,7 +144,7 @@ void FCommandBuffer::MakeStartPosGood()
|
|||
{ // The cursor is in front of the visible part of the line
|
||||
n = CursorPosCells;
|
||||
}
|
||||
StartPosCells = std::max(0, n);
|
||||
StartPosCells = max(0, n);
|
||||
bool overflow;
|
||||
StartPos = CharsForCells(StartPosCells, &overflow);
|
||||
if (overflow)
|
||||
|
|
|
@ -856,7 +856,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
|
|||
{ // Scroll console buffer down
|
||||
if (ev->subtype == EV_GUI_WheelDown)
|
||||
{
|
||||
RowAdjust = std::max (0, RowAdjust - 3);
|
||||
RowAdjust = max (0, RowAdjust - 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1092,7 +1092,7 @@ void C_SearchForPullins(FExecList *exec, const char *file, FCommandLine &argv)
|
|||
|
||||
lastSlash1 = strrchr(file, '/');
|
||||
lastSlash2 = strrchr(file, '\\');
|
||||
lastSlash = MAX(lastSlash1, lastSlash2);
|
||||
lastSlash = max(lastSlash1, lastSlash2);
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
|
|
|
@ -273,7 +273,7 @@ bool C_TabCompleteList ()
|
|||
}
|
||||
}
|
||||
nummatches++;
|
||||
maxwidth = std::max (maxwidth, strlen (TabCommands[i].TabName.GetChars()));
|
||||
maxwidth = max (maxwidth, strlen (TabCommands[i].TabName.GetChars()));
|
||||
}
|
||||
}
|
||||
if (nummatches > 1)
|
||||
|
|
|
@ -565,9 +565,9 @@ bool FRemapTable::AddDesaturation(int start, int end, double r1, double g1, doub
|
|||
GPalette.BaseColors[c].g * 143 +
|
||||
GPalette.BaseColors[c].b * 37) / 256.0;
|
||||
|
||||
PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)),
|
||||
MIN(255, int(g1 + intensity*g2)),
|
||||
MIN(255, int(b1 + intensity*b2)));
|
||||
PalEntry pe = PalEntry( min(255, int(r1 + intensity*r2)),
|
||||
min(255, int(g1 + intensity*g2)),
|
||||
min(255, int(b1 + intensity*b2)));
|
||||
|
||||
int cc = GPalette.Remap[c];
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ int FRFFLump::FillCache()
|
|||
|
||||
if (Flags & LUMPF_COMPRESSED)
|
||||
{
|
||||
int cryptlen = MIN<int> (LumpSize, 256);
|
||||
int cryptlen = min<int> (LumpSize, 256);
|
||||
uint8_t *data = (uint8_t *)Cache;
|
||||
|
||||
for (int i = 0; i < cryptlen; ++i)
|
||||
|
|
|
@ -124,7 +124,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin)
|
|||
uint32_t uPosFound=0;
|
||||
|
||||
FileSize = (uint32_t)fin.GetLength();
|
||||
uMaxBack = MIN<uint32_t>(0xffff, FileSize);
|
||||
uMaxBack = min<uint32_t>(0xffff, FileSize);
|
||||
|
||||
uBackRead = 4;
|
||||
while (uBackRead < uMaxBack)
|
||||
|
@ -137,7 +137,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin)
|
|||
uBackRead += BUFREADCOMMENT;
|
||||
uReadPos = FileSize - uBackRead;
|
||||
|
||||
uReadSize = MIN<uint32_t>((BUFREADCOMMENT + 4), (FileSize - uReadPos));
|
||||
uReadSize = min<uint32_t>((BUFREADCOMMENT + 4), (FileSize - uReadPos));
|
||||
|
||||
if (fin.Seek(uReadPos, FileReader::SeekSet) != 0) break;
|
||||
|
||||
|
|
|
@ -936,7 +936,7 @@ int FFont::StringWidth(const uint8_t *string, int spacing) const
|
|||
}
|
||||
}
|
||||
|
||||
return std::max(maxw, w);
|
||||
return max(maxw, w);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -348,7 +348,7 @@ static size_t SingleStep()
|
|||
State = GCS_Finalize;
|
||||
}
|
||||
//assert(old >= AllocBytes);
|
||||
Estimate -= MAX<size_t>(0, old - AllocBytes);
|
||||
Estimate -= max<size_t>(0, old - AllocBytes);
|
||||
return (GCSWEEPMAX - finalize_count) * GCSWEEPCOST + finalize_count * GCFINALIZECOST;
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ CCMD(gc)
|
|||
}
|
||||
else
|
||||
{
|
||||
GC::Pause = MAX(1,atoi(argv[2]));
|
||||
GC::Pause = max(1,atoi(argv[2]));
|
||||
}
|
||||
}
|
||||
else if (stricmp(argv[1], "stepmul") == 0)
|
||||
|
@ -636,7 +636,7 @@ CCMD(gc)
|
|||
}
|
||||
else
|
||||
{
|
||||
GC::StepMul = MAX(100, atoi(argv[2]));
|
||||
GC::StepMul = max(100, atoi(argv[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent)
|
|||
break;
|
||||
}
|
||||
|
||||
event.data1 = MIN(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8));
|
||||
event.data1 = min(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8));
|
||||
|
||||
D_PostEvent(&event);
|
||||
}
|
||||
|
|
|
@ -969,7 +969,7 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
|||
else
|
||||
{
|
||||
const bool result = *count >= extensionCount;
|
||||
*count = std::min(*count, extensionCount);
|
||||
*count = min(*count, extensionCount);
|
||||
|
||||
for (unsigned int i = 0; i < *count; ++i)
|
||||
{
|
||||
|
|
|
@ -510,7 +510,7 @@ void FConsoleWindow::NetProgress(const int count)
|
|||
if (m_netMaxPos > 1)
|
||||
{
|
||||
[m_netCountText setStringValue:[NSString stringWithFormat:@"%d / %d", m_netCurPos, m_netMaxPos]];
|
||||
[m_netProgressBar setDoubleValue:MIN(m_netCurPos, m_netMaxPos)];
|
||||
[m_netProgressBar setDoubleValue:min(m_netCurPos, m_netMaxPos)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ static inline char *strlwr(char *str)
|
|||
}
|
||||
|
||||
inline int I_GetNumaNodeCount() { return 1; }
|
||||
inline int I_GetNumaNodeThreadCount(int numaNode) { return std::max<int>(std::thread::hardware_concurrency(), 1); }
|
||||
inline int I_GetNumaNodeThreadCount(int numaNode) { return max<int>(std::thread::hardware_concurrency(), 1); }
|
||||
inline void I_SetThreadNumaNode(std::thread &thread, int numaNode) { }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -778,7 +778,7 @@ static HCURSOR CreateAlphaCursor(FBitmap &source, int leftofs, int topofs)
|
|||
// Find closest integer scale factor for the monitor DPI
|
||||
HDC screenDC = GetDC(0);
|
||||
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
|
||||
int scale = std::max((dpi + 96 / 2 - 1) / 96, 1);
|
||||
int scale = max((dpi + 96 / 2 - 1) / 96, 1);
|
||||
ReleaseDC(0, screenDC);
|
||||
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
|
|
|
@ -351,7 +351,7 @@ void FBasicStartupScreen :: NetProgress(int count)
|
|||
|
||||
mysnprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos);
|
||||
SetDlgItemTextA (NetStartPane, IDC_NETSTARTCOUNT, buf);
|
||||
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, std::min(NetCurPos, NetMaxPos), 0);
|
||||
SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, min(NetCurPos, NetMaxPos), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@ void FStrifeStartupScreen::DrawStuff(int old_laser, int new_laser)
|
|||
ST_LASERSPACE_X + new_laser, ST_LASERSPACE_Y, ST_LASER_WIDTH, ST_LASER_HEIGHT);
|
||||
|
||||
// The bot jumps up and down like crazy.
|
||||
y = std::max(0, (new_laser >> 1) % 5 - 2);
|
||||
y = max(0, (new_laser >> 1) % 5 - 2);
|
||||
if (y > 0)
|
||||
{
|
||||
ST_Util_ClearBlock(bitmap_info, 0xF0, ST_BOT_X, ST_BOT_Y, ST_BOT_WIDTH, y);
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
void EnableDrawBuffers(int count, bool apply = false) override
|
||||
{
|
||||
count = std::min(count, 3);
|
||||
count = min(count, 3);
|
||||
if (mNumDrawBuffers != count)
|
||||
{
|
||||
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
|
|
|
@ -263,7 +263,7 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
|
|||
|
||||
// If we have 4.2, always use it because it adds important new syntax.
|
||||
if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420;
|
||||
int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
|
||||
int shaderVersion = min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
|
||||
patchedCode.AppendFormat("#version %d\n", shaderVersion);
|
||||
|
||||
// TODO: Find some way to add extension requirements to the patching
|
||||
|
|
|
@ -122,7 +122,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
{
|
||||
static bool first=true;
|
||||
|
||||
mPipelineNbr = gl_pipeline_depth == 0? std::min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS);
|
||||
mPipelineNbr = gl_pipeline_depth == 0? min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS);
|
||||
mPipelineType = 1;
|
||||
|
||||
InitGLES();
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
void EnableDrawBuffers(int count, bool apply = false) override
|
||||
{
|
||||
/*
|
||||
count = std::min(count, 3);
|
||||
count = min(count, 3);
|
||||
if (mNumDrawBuffers != count)
|
||||
{
|
||||
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
|
|
|
@ -98,7 +98,7 @@ std::pair<PalEntry, PalEntry>& R_GetSkyCapColor(FGameTexture* tex)
|
|||
const uint32_t* buffer = (const uint32_t*)bitmap.GetPixels();
|
||||
if (buffer)
|
||||
{
|
||||
sky.Colors.first = averageColor((uint32_t*)buffer, w * MIN(30, h), 0);
|
||||
sky.Colors.first = averageColor((uint32_t*)buffer, w * min(30, h), 0);
|
||||
if (h > 30)
|
||||
{
|
||||
sky.Colors.second = averageColor(((uint32_t*)buffer) + (h - 30) * w, w * 30, 0);
|
||||
|
|
|
@ -326,9 +326,9 @@ void PPLensDistort::Render(PPRenderState *renderstate)
|
|||
// Scale factor to keep sampling within the input texture
|
||||
float r2 = aspect * aspect * 0.25f + 0.25f;
|
||||
float sqrt_r2 = sqrt(r2);
|
||||
float f0 = 1.0f + MAX(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f);
|
||||
float f2 = 1.0f + MAX(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f);
|
||||
float f = MAX(f0, f2);
|
||||
float f0 = 1.0f + max(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f);
|
||||
float f2 = 1.0f + max(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f);
|
||||
float f = max(f0, f2);
|
||||
float scale = 1.0f / f;
|
||||
|
||||
LensUniforms uniforms;
|
||||
|
@ -498,8 +498,8 @@ void PPCameraExposure::Render(PPRenderState *renderstate, int sceneWidth, int sc
|
|||
|
||||
void PPCameraExposure::UpdateTextures(int width, int height)
|
||||
{
|
||||
int firstwidth = MAX(width / 2, 1);
|
||||
int firstheight = MAX(height / 2, 1);
|
||||
int firstwidth = max(width / 2, 1);
|
||||
int firstheight = max(height / 2, 1);
|
||||
|
||||
if (ExposureLevels.size() > 0 && ExposureLevels[0].Viewport.width == firstwidth && ExposureLevels[0].Viewport.height == firstheight)
|
||||
{
|
||||
|
@ -511,8 +511,8 @@ void PPCameraExposure::UpdateTextures(int width, int height)
|
|||
int i = 0;
|
||||
do
|
||||
{
|
||||
width = MAX(width / 2, 1);
|
||||
height = MAX(height / 2, 1);
|
||||
width = max(width / 2, 1);
|
||||
height = max(height / 2, 1);
|
||||
|
||||
PPExposureLevel blevel;
|
||||
blevel.Viewport.left = 0;
|
||||
|
@ -746,7 +746,7 @@ void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneW
|
|||
LinearDepthUniforms linearUniforms;
|
||||
linearUniforms.SampleIndex = 0;
|
||||
linearUniforms.LinearizeDepthA = 1.0f / screen->GetZFar() - 1.0f / screen->GetZNear();
|
||||
linearUniforms.LinearizeDepthB = MAX(1.0f / screen->GetZNear(), 1.e-8f);
|
||||
linearUniforms.LinearizeDepthB = max(1.0f / screen->GetZNear(), 1.e-8f);
|
||||
linearUniforms.InverseDepthRangeA = 1.0f;
|
||||
linearUniforms.InverseDepthRangeB = 0.0f;
|
||||
linearUniforms.Scale = sceneScale;
|
||||
|
|
|
@ -219,8 +219,8 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(
|
|||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = std::min(tex->GetWidth(), image->GetWidth());
|
||||
bounds.height = std::min(tex->GetHeight(), image->GetHeight());
|
||||
bounds.width = min(tex->GetWidth(), image->GetWidth());
|
||||
bounds.height = min(tex->GetHeight(), image->GetHeight());
|
||||
|
||||
renderFunc(bounds);
|
||||
|
||||
|
|
|
@ -100,10 +100,10 @@ void PolyTriangleThreadData::SetScissor(int x, int y, int w, int h)
|
|||
|
||||
void PolyTriangleThreadData::UpdateClip()
|
||||
{
|
||||
clip.left = MAX(MAX(viewport_x, scissor.left), 0);
|
||||
clip.top = MAX(MAX(viewport_y, scissor.top), 0);
|
||||
clip.right = MIN(MIN(viewport_x + viewport_width, scissor.right), dest_width);
|
||||
clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height);
|
||||
clip.left = max(max(viewport_x, scissor.left), 0);
|
||||
clip.top = max(max(viewport_y, scissor.top), 0);
|
||||
clip.right = min(min(viewport_x + viewport_width, scissor.right), dest_width);
|
||||
clip.bottom = min(min(viewport_y + viewport_height, scissor.bottom), dest_height);
|
||||
}
|
||||
|
||||
void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPushConstants &constants)
|
||||
|
@ -206,11 +206,11 @@ void PolyTriangleThreadData::SetStencil(int stencilRef, int op)
|
|||
StencilTestValue = stencilRef;
|
||||
if (op == SOP_Increment)
|
||||
{
|
||||
StencilWriteValue = MIN(stencilRef + 1, (int)255);
|
||||
StencilWriteValue = min(stencilRef + 1, (int)255);
|
||||
}
|
||||
else if (op == SOP_Decrement)
|
||||
{
|
||||
StencilWriteValue = MAX(stencilRef - 1, (int)0);
|
||||
StencilWriteValue = max(stencilRef - 1, (int)0);
|
||||
}
|
||||
else // SOP_Keep
|
||||
{
|
||||
|
@ -453,8 +453,8 @@ void PolyTriangleThreadData::DrawShadedLine(const ShadedTriVertex *const* vert)
|
|||
{
|
||||
float clipdistance1 = clipdistance[0 * numclipdistances + p];
|
||||
float clipdistance2 = clipdistance[1 * numclipdistances + p];
|
||||
if (clipdistance1 < 0.0f) t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1);
|
||||
if (clipdistance2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2);
|
||||
if (clipdistance1 < 0.0f) t1 = max(-clipdistance1 / (clipdistance2 - clipdistance1), t1);
|
||||
if (clipdistance2 < 0.0f) t2 = min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2);
|
||||
if (t1 >= t2)
|
||||
return;
|
||||
}
|
||||
|
@ -792,8 +792,8 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts)
|
|||
// Clip halfspace
|
||||
if ((clipdistance1 >= 0.0f || clipdistance2 >= 0.0f) && outputverts + 1 < max_additional_vertices)
|
||||
{
|
||||
float t1 = (clipdistance1 < 0.0f) ? MAX(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f) : 0.0f;
|
||||
float t2 = (clipdistance2 < 0.0f) ? MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f;
|
||||
float t1 = (clipdistance1 < 0.0f) ? max(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f) : 0.0f;
|
||||
float t2 = (clipdistance2 < 0.0f) ? min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f;
|
||||
|
||||
// add t1 vertex
|
||||
for (int k = 0; k < 3; k++)
|
||||
|
|
|
@ -85,16 +85,16 @@ public:
|
|||
|
||||
int skipped_by_thread(int first_line)
|
||||
{
|
||||
int clip_first_line = MAX(first_line, numa_start_y);
|
||||
int clip_first_line = max(first_line, numa_start_y);
|
||||
int core_skip = (num_cores - (clip_first_line - core) % num_cores) % num_cores;
|
||||
return clip_first_line + core_skip - first_line;
|
||||
}
|
||||
|
||||
int count_for_thread(int first_line, int count)
|
||||
{
|
||||
count = MIN(count, numa_end_y - first_line);
|
||||
count = min(count, numa_end_y - first_line);
|
||||
int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores;
|
||||
return MAX(c, 0);
|
||||
return max(c, 0);
|
||||
}
|
||||
|
||||
struct Scanline
|
||||
|
|
|
@ -336,10 +336,10 @@ void BlendColorAdd_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thread
|
|||
uint32_t srcscale = APART(src);
|
||||
srcscale += srcscale >> 7;
|
||||
|
||||
uint32_t a = MIN<int32_t>((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = MIN<int32_t>((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = MIN<int32_t>((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = MIN<int32_t>((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255);
|
||||
uint32_t a = min<int32_t>((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = min<int32_t>((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = min<int32_t>((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = min<int32_t>((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
@ -382,10 +382,10 @@ void BlendColorAdd_SrcCol_One(int y, int x0, int x1, PolyTriangleThreadData* thr
|
|||
srcscale_g += srcscale_g >> 7;
|
||||
srcscale_b += srcscale_b >> 7;
|
||||
|
||||
uint32_t a = MIN<int32_t>((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = MIN<int32_t>((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = MIN<int32_t>((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = MIN<int32_t>((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255);
|
||||
uint32_t a = min<int32_t>((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255);
|
||||
uint32_t r = min<int32_t>((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255);
|
||||
uint32_t g = min<int32_t>((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255);
|
||||
uint32_t b = min<int32_t>((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
@ -514,10 +514,10 @@ void BlendColorRevSub_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thr
|
|||
uint32_t srcscale = APART(src);
|
||||
srcscale += srcscale >> 7;
|
||||
|
||||
uint32_t a = MAX<int32_t>(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t r = MAX<int32_t>(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t g = MAX<int32_t>(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t b = MAX<int32_t>(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t a = max<int32_t>(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t r = max<int32_t>(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t g = max<int32_t>(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0);
|
||||
uint32_t b = max<int32_t>(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0);
|
||||
|
||||
line[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
|
||||
// L = light-pos
|
||||
// dist = sqrt(dot(L, L))
|
||||
// distance_attenuation = 1 - MIN(dist * (1/radius), 1)
|
||||
// distance_attenuation = 1 - min(dist * (1/radius), 1)
|
||||
__m128 Lx = _mm_sub_ps(lightposX, _mm_loadu_ps(&worldposX[x]));
|
||||
__m128 Ly = _mm_sub_ps(lightposY, _mm_loadu_ps(&worldposY[x]));
|
||||
__m128 Lz = _mm_sub_ps(lightposZ, _mm_loadu_ps(&worldposZ[x]));
|
||||
|
@ -179,7 +179,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
|
||||
// L = light-pos
|
||||
// dist = sqrt(dot(L, L))
|
||||
// distance_attenuation = 1 - MIN(dist * (1/radius), 1)
|
||||
// distance_attenuation = 1 - min(dist * (1/radius), 1)
|
||||
float Lx = lightposX - worldposX[x];
|
||||
float Ly = lightposY - worldposY[x];
|
||||
float Lz = lightposZ - worldposZ[x];
|
||||
|
@ -191,7 +191,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2)));
|
||||
#endif
|
||||
float dist = dist2 * rcp_dist;
|
||||
float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f);
|
||||
float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f);
|
||||
|
||||
// The simple light type
|
||||
float simple_attenuation = distance_attenuation;
|
||||
|
@ -202,7 +202,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
Ly *= rcp_dist;
|
||||
Lz *= rcp_dist;
|
||||
float dotNL = worldnormalX * Lx + worldnormalY * Ly + worldnormalZ * Lz;
|
||||
float point_attenuation = MAX(dotNL, 0.0f) * distance_attenuation;
|
||||
float point_attenuation = max(dotNL, 0.0f) * distance_attenuation;
|
||||
|
||||
uint32_t attenuation = (uint32_t)(is_attenuated ? (int32_t)point_attenuation : (int32_t)simple_attenuation);
|
||||
|
||||
|
@ -211,9 +211,9 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
lit_b += (BPART(light_color) * attenuation) >> 8;
|
||||
}
|
||||
|
||||
lit_r = MIN<uint32_t>(lit_r, 255);
|
||||
lit_g = MIN<uint32_t>(lit_g, 255);
|
||||
lit_b = MIN<uint32_t>(lit_b, 255);
|
||||
lit_r = min<uint32_t>(lit_r, 255);
|
||||
lit_g = min<uint32_t>(lit_g, 255);
|
||||
lit_b = min<uint32_t>(lit_b, 255);
|
||||
lightarray[x] = MAKEARGB(lit_a, lit_r, lit_g, lit_b);
|
||||
|
||||
// Palette version:
|
||||
|
@ -255,7 +255,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t* lightarray = thread->scanline.lightarray;
|
||||
for (int x = x0; x < x1; x++)
|
||||
{
|
||||
uint32_t l = MIN(lightpos >> 8, 256);
|
||||
uint32_t l = min(lightpos >> 8, 256);
|
||||
|
||||
uint32_t r = vColorR[x];
|
||||
uint32_t g = vColorG[x];
|
||||
|
@ -273,9 +273,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
@ -287,7 +287,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t* lightarray = thread->scanline.lightarray;
|
||||
for (int x = x0; x < x1; x++)
|
||||
{
|
||||
uint32_t l = MIN((FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8, 256);
|
||||
uint32_t l = min((FRACUNIT - clamp<fixed_t>(shade - min(maxvis, lightpos), 0, maxlight)) >> 8, 256);
|
||||
uint32_t r = vColorR[x];
|
||||
uint32_t g = vColorG[x];
|
||||
uint32_t b = vColorB[x];
|
||||
|
@ -304,9 +304,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
@ -327,7 +327,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
uint32_t g = thread->scanline.vColorG[x];
|
||||
uint32_t b = thread->scanline.vColorB[x];
|
||||
|
||||
float fogdist = MAX(16.0f, w[x]);
|
||||
float fogdist = max(16.0f, w[x]);
|
||||
float fogfactor = std::exp2(constants->uFogDensity * fogdist);
|
||||
|
||||
// brightening around the player for light mode 2:
|
||||
|
@ -365,9 +365,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar
|
|||
g += (uint32_t)(constants->uDynLightColor.Y * 255.0f);
|
||||
b += (uint32_t)(constants->uDynLightColor.Z * 255.0f);
|
||||
|
||||
r = MIN<uint32_t>(r, 255);
|
||||
g = MIN<uint32_t>(g, 255);
|
||||
b = MIN<uint32_t>(b, 255);
|
||||
r = min<uint32_t>(r, 255);
|
||||
g = min<uint32_t>(g, 255);
|
||||
b = min<uint32_t>(b, 255);
|
||||
}
|
||||
|
||||
lightarray[x] = MAKEARGB(a, r, g, b);
|
||||
|
|
|
@ -291,9 +291,9 @@ static void FuncNormal_AddColor(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN(r + RPART(texel), (uint32_t)255),
|
||||
MIN(g + GPART(texel), (uint32_t)255),
|
||||
MIN(b + BPART(texel), (uint32_t)255));
|
||||
min(r + RPART(texel), (uint32_t)255),
|
||||
min(g + GPART(texel), (uint32_t)255),
|
||||
min(b + BPART(texel), (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,9 +309,9 @@ static void FuncNormal_AddObjectColor(int x0, int x1, PolyTriangleThreadData* th
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
min((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
min((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
min((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,9 +331,9 @@ static void FuncNormal_AddObjectColor2(int x0, int x1, PolyTriangleThreadData* t
|
|||
uint32_t texel = fragcolor[x];
|
||||
fragcolor[x] = MAKEARGB(
|
||||
APART(texel),
|
||||
MIN((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
MIN((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
min((r * RPART(texel)) >> 8, (uint32_t)255),
|
||||
min((g * GPART(texel)) >> 8, (uint32_t)255),
|
||||
min((b * BPART(texel)) >> 8, (uint32_t)255));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ static void GetLightColor(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
mulG += mulG >> 7;
|
||||
mulB += mulB >> 7;
|
||||
|
||||
float fogdist = MAX(16.0f, w[x]);
|
||||
float fogdist = max(16.0f, w[x]);
|
||||
float fogfactor = std::exp2(uFogDensity * fogdist);
|
||||
|
||||
uint32_t a = (APART(fg) * mulA + 127) >> 8;
|
||||
|
@ -512,7 +512,7 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
float fogfactor = 0.0f;
|
||||
if (constants->uFogEnabled != 0)
|
||||
{
|
||||
fogdist = MAX(16.0f, w[x]);
|
||||
fogdist = max(16.0f, w[x]);
|
||||
fogfactor = std::exp2(constants->uFogDensity * fogdist);
|
||||
}
|
||||
frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a);*/
|
||||
|
@ -594,9 +594,9 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread)
|
|||
b = (BPART(fragcolor[x]) * b + 127) >> 8;
|
||||
|
||||
// frag.rgb = frag.rgb + uFogColor.rgb;
|
||||
r = MIN(r + fogR, (uint32_t)255);
|
||||
g = MIN(g + fogG, (uint32_t)255);
|
||||
b = MIN(b + fogB, (uint32_t)255);
|
||||
r = min(r + fogR, (uint32_t)255);
|
||||
g = min(g + fogG, (uint32_t)255);
|
||||
b = min(b + fogB, (uint32_t)255);
|
||||
|
||||
fragcolor[x] = MAKEARGB(a, r, g, b);
|
||||
}
|
||||
|
|
|
@ -207,17 +207,17 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat
|
|||
SortVertices(args, sortedVertices);
|
||||
|
||||
int clipleft = thread->clip.left;
|
||||
int cliptop = MAX(thread->clip.top, thread->numa_start_y);
|
||||
int cliptop = max(thread->clip.top, thread->numa_start_y);
|
||||
int clipright = thread->clip.right;
|
||||
int clipbottom = MIN(thread->clip.bottom, thread->numa_end_y);
|
||||
int clipbottom = min(thread->clip.bottom, thread->numa_end_y);
|
||||
|
||||
int topY = (int)(sortedVertices[0]->y + 0.5f);
|
||||
int midY = (int)(sortedVertices[1]->y + 0.5f);
|
||||
int bottomY = (int)(sortedVertices[2]->y + 0.5f);
|
||||
|
||||
topY = MAX(topY, cliptop);
|
||||
midY = MIN(midY, clipbottom);
|
||||
bottomY = MIN(bottomY, clipbottom);
|
||||
topY = max(topY, cliptop);
|
||||
midY = min(midY, clipbottom);
|
||||
bottomY = min(bottomY, clipbottom);
|
||||
|
||||
if (topY >= bottomY)
|
||||
return;
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
// The number of lines to skip to reach the first line to be rendered by this thread
|
||||
int skipped_by_thread(int first_line)
|
||||
{
|
||||
int clip_first_line = MAX(first_line, numa_start_y);
|
||||
int clip_first_line = max(first_line, numa_start_y);
|
||||
int core_skip = (num_cores - (clip_first_line - core) % num_cores) % num_cores;
|
||||
return clip_first_line + core_skip - first_line;
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ public:
|
|||
// The number of lines to be rendered by this thread
|
||||
int count_for_thread(int first_line, int count)
|
||||
{
|
||||
count = MIN(count, numa_end_y - first_line);
|
||||
count = min(count, numa_end_y - first_line);
|
||||
int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores;
|
||||
return MAX(c, 0);
|
||||
return max(c, 0);
|
||||
}
|
||||
|
||||
// Calculate the dest address for the first line to be rendered by this thread
|
||||
|
|
|
@ -193,7 +193,7 @@ int ViewportScaledWidth(int width, int height)
|
|||
width = ((float)width/height > ActiveRatio(width, height)) ? (int)(height * ActiveRatio(width, height)) : width;
|
||||
height = ((float)width/height < ActiveRatio(width, height)) ? (int)(width / ActiveRatio(width, height)) : height;
|
||||
}
|
||||
return (int)std::max((int32_t)min_width, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledWidth(width, height)));
|
||||
return (int)max((int32_t)min_width, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledWidth(width, height)));
|
||||
}
|
||||
|
||||
int ViewportScaledHeight(int width, int height)
|
||||
|
@ -205,7 +205,7 @@ int ViewportScaledHeight(int width, int height)
|
|||
height = ((float)width/height < ActiveRatio(width, height)) ? (int)(width / ActiveRatio(width, height)) : height;
|
||||
width = ((float)width/height > ActiveRatio(width, height)) ? (int)(height * ActiveRatio(width, height)) : width;
|
||||
}
|
||||
return (int)std::max((int32_t)min_height, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledHeight(width, height)));
|
||||
return (int)max((int32_t)min_height, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledHeight(width, height)));
|
||||
}
|
||||
|
||||
float ViewportPixelAspect()
|
||||
|
|
|
@ -186,7 +186,7 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds)
|
|||
int screenWidth = GetWidth();
|
||||
int screenHeight = GetHeight();
|
||||
float scaleX, scaleY;
|
||||
scaleX = std::min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect()));
|
||||
scaleX = min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect()));
|
||||
scaleY = scaleX * ViewportPixelAspect();
|
||||
mOutputLetterbox.width = (int)round(screenWidth * scaleX);
|
||||
mOutputLetterbox.height = (int)round(screenHeight * scaleY);
|
||||
|
|
|
@ -252,7 +252,7 @@ void DCanvas::Resize(int width, int height, bool optimizepitch)
|
|||
}
|
||||
else
|
||||
{
|
||||
Pitch = width + MAX(0, CPU.DataL1LineSize - 8);
|
||||
Pitch = width + max(0, CPU.DataL1LineSize - 8);
|
||||
}
|
||||
}
|
||||
int bytes_per_pixel = Bgra ? 4 : 1;
|
||||
|
@ -275,7 +275,7 @@ void V_UpdateModeSize (int width, int height)
|
|||
|
||||
// This reference size is being used so that on 800x450 (small 16:9) a scale of 2 gets used.
|
||||
|
||||
CleanXfac = std::max(std::min(screen->GetWidth() / 400, screen->GetHeight() / 240), 1);
|
||||
CleanXfac = max(min(screen->GetWidth() / 400, screen->GetHeight() / 240), 1);
|
||||
if (CleanXfac >= 4) CleanXfac--; // Otherwise we do not have enough space for the episode/skill menus in some languages.
|
||||
CleanYfac = CleanXfac;
|
||||
CleanWidth = screen->GetWidth() / CleanXfac;
|
||||
|
@ -292,7 +292,7 @@ void V_UpdateModeSize (int width, int height)
|
|||
else if (w < 1920) factor = 2;
|
||||
else factor = int(factor * 0.7);
|
||||
|
||||
CleanYfac_1 = CleanXfac_1 = factor;// MAX(1, int(factor * 0.7));
|
||||
CleanYfac_1 = CleanXfac_1 = factor;// max(1, int(factor * 0.7));
|
||||
CleanWidth_1 = width / CleanXfac_1;
|
||||
CleanHeight_1 = height / CleanYfac_1;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ void VkRenderState::ApplyRenderPass(int dt)
|
|||
pipelineKey.ColorMask = mColorMask;
|
||||
pipelineKey.CullMode = mCullMode;
|
||||
pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->NumLayers() : 0;
|
||||
pipelineKey.NumTextureLayers = std::max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it
|
||||
pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it
|
||||
if (mSpecialEffect > EFF_NONE)
|
||||
{
|
||||
pipelineKey.SpecialEffect = mSpecialEffect;
|
||||
|
|
|
@ -73,7 +73,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
|
|||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
|
||||
size_t bufsize = std::max(size, (size_t)16); // For supporting zero byte buffers
|
||||
size_t bufsize = max(size, (size_t)16); // For supporting zero byte buffers
|
||||
|
||||
// If SetData is called multiple times we have to keep the old buffers alive as there might still be draw commands referencing them
|
||||
if (mBuffer)
|
||||
|
@ -153,7 +153,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
|
|||
|
||||
void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
|
||||
{
|
||||
size = std::max(size, (size_t)16); // For supporting zero byte buffers
|
||||
size = max(size, (size_t)16); // For supporting zero byte buffers
|
||||
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
if (mStaging)
|
||||
|
@ -174,7 +174,7 @@ void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
|
|||
|
||||
void VKBuffer::Resize(size_t newsize)
|
||||
{
|
||||
newsize = std::max(newsize, (size_t)16); // For supporting zero byte buffers
|
||||
newsize = max(newsize, (size_t)16); // For supporting zero byte buffers
|
||||
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
|
||||
|
@ -222,7 +222,7 @@ void VKBuffer::Unmap()
|
|||
|
||||
void *VKBuffer::Lock(unsigned int size)
|
||||
{
|
||||
size = std::max(size, (unsigned int)16); // For supporting zero byte buffers
|
||||
size = max(size, (unsigned int)16); // For supporting zero byte buffers
|
||||
|
||||
if (!mBuffer)
|
||||
{
|
||||
|
|
|
@ -571,7 +571,7 @@ inline BufferBuilder::BufferBuilder()
|
|||
|
||||
inline void BufferBuilder::setSize(size_t size)
|
||||
{
|
||||
bufferInfo.size = std::max(size, (size_t)16);
|
||||
bufferInfo.size = max(size, (size_t)16);
|
||||
}
|
||||
|
||||
inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocFlags)
|
||||
|
|
|
@ -309,7 +309,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish, bool uploadOnly)
|
|||
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());
|
||||
}
|
||||
|
||||
int numWaitFences = MIN(mNextSubmit, (int)maxConcurrentSubmitCount);
|
||||
int numWaitFences = min(mNextSubmit, (int)maxConcurrentSubmitCount);
|
||||
|
||||
if (numWaitFences > 0)
|
||||
{
|
||||
|
@ -345,8 +345,8 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<voi
|
|||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = std::min(tex->GetWidth(), image->Image->width);
|
||||
bounds.height = std::min(tex->GetHeight(), image->Image->height);
|
||||
bounds.width = min(tex->GetWidth(), image->Image->width);
|
||||
bounds.height = min(tex->GetHeight(), image->Image->height);
|
||||
|
||||
renderFunc(bounds);
|
||||
|
||||
|
@ -628,7 +628,7 @@ void VulkanFrameBuffer::UpdateGpuStats()
|
|||
if (q.endIndex <= q.startIndex)
|
||||
continue;
|
||||
|
||||
int64_t timeElapsed = std::max(static_cast<int64_t>(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0);
|
||||
int64_t timeElapsed = max(static_cast<int64_t>(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0);
|
||||
double timeNS = timeElapsed * timestampPeriod;
|
||||
|
||||
FString out;
|
||||
|
|
|
@ -161,8 +161,8 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
|
|||
VkSurfaceCapabilitiesKHR surfaceCapabilities = GetSurfaceCapabilities();
|
||||
|
||||
actualExtent = { static_cast<uint32_t>(width), static_cast<uint32_t>(height) };
|
||||
actualExtent.width = std::max(surfaceCapabilities.minImageExtent.width, std::min(surfaceCapabilities.maxImageExtent.width, actualExtent.width));
|
||||
actualExtent.height = std::max(surfaceCapabilities.minImageExtent.height, std::min(surfaceCapabilities.maxImageExtent.height, actualExtent.height));
|
||||
actualExtent.width = max(surfaceCapabilities.minImageExtent.width, min(surfaceCapabilities.maxImageExtent.width, actualExtent.width));
|
||||
actualExtent.height = max(surfaceCapabilities.minImageExtent.height, min(surfaceCapabilities.maxImageExtent.height, actualExtent.height));
|
||||
if (actualExtent.width == 0 || actualExtent.height == 0)
|
||||
{
|
||||
swapChain = VK_NULL_HANDLE;
|
||||
|
@ -176,9 +176,9 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
|
|||
// When vsync is on we only want two images. This creates a slight performance penalty in exchange for reduced input latency (less mouse lag).
|
||||
// When vsync is off we want three images as it allows us to generate new images even during the vertical blanking period where one entry is being used by the presentation engine.
|
||||
if (swapChainPresentMode == VK_PRESENT_MODE_MAILBOX_KHR || swapChainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR)
|
||||
imageCount = std::min(imageCount, (uint32_t)3);
|
||||
imageCount = min(imageCount, (uint32_t)3);
|
||||
else
|
||||
imageCount = std::min(imageCount, (uint32_t)2);
|
||||
imageCount = min(imageCount, (uint32_t)2);
|
||||
|
||||
VkSwapchainCreateInfoKHR swapChainCreateInfo = {};
|
||||
swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
|
|
|
@ -218,8 +218,8 @@ int VkHardwareTexture::GetMipLevels(int w, int h)
|
|||
int levels = 1;
|
||||
while (w > 1 || h > 1)
|
||||
{
|
||||
w = std::max(w >> 1, 1);
|
||||
h = std::max(h >> 1, 1);
|
||||
w = max(w >> 1, 1);
|
||||
h = max(h >> 1, 1);
|
||||
levels++;
|
||||
}
|
||||
return levels;
|
||||
|
@ -391,7 +391,7 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
|
|||
int numLayers = NumLayers();
|
||||
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(std::max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS));
|
||||
auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS));
|
||||
|
||||
descriptor->SetDebugName("VkHardwareTexture.mDescriptorSets");
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ void VkTextureImage::GenerateMipmaps(VulkanCommandBuffer *cmdbuffer)
|
|||
barrier0.execute(cmdbuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
|
||||
Layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
|
||||
int nextWidth = std::max(mipWidth >> 1, 1);
|
||||
int nextHeight = std::max(mipHeight >> 1, 1);
|
||||
int nextWidth = max(mipWidth >> 1, 1);
|
||||
int nextHeight = max(mipHeight >> 1, 1);
|
||||
|
||||
VkImageBlit blit = {};
|
||||
blit.srcOffsets[0] = { 0, 0, 0 };
|
||||
|
|
|
@ -8896,7 +8896,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build)
|
|||
ArgList.ShrinkToFit();
|
||||
|
||||
if (!staticcall) emitters.SetVirtualReg(selfemit.RegNum);
|
||||
int resultcount = vmfunc->Proto->ReturnTypes.Size() == 0 ? 0 : std::max(AssignCount, 1);
|
||||
int resultcount = vmfunc->Proto->ReturnTypes.Size() == 0 ? 0 : max(AssignCount, 1);
|
||||
|
||||
assert((unsigned)resultcount <= vmfunc->Proto->ReturnTypes.Size());
|
||||
for (int i = 0; i < resultcount; i++)
|
||||
|
|
|
@ -345,7 +345,7 @@ PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned
|
|||
// its fields.
|
||||
if (Align != nullptr)
|
||||
{
|
||||
*Align = MAX(*Align, type->Align);
|
||||
*Align = max(*Align, type->Align);
|
||||
}
|
||||
|
||||
if (AddSymbol(field) == nullptr)
|
||||
|
|
|
@ -1702,7 +1702,7 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const
|
|||
{
|
||||
bool readsomething = false;
|
||||
unsigned count = ar.ArraySize();
|
||||
unsigned loop = std::min(count, ElementCount);
|
||||
unsigned loop = min(count, ElementCount);
|
||||
uint8_t *addrb = (uint8_t *)addr;
|
||||
for(unsigned i=0;i<loop;i++)
|
||||
{
|
||||
|
|
|
@ -677,7 +677,7 @@ static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const
|
|||
void DumpFunction(FILE *dump, VMScriptFunction *sfunc, const char *label, int labellen)
|
||||
{
|
||||
const char *marks = "=======================================================";
|
||||
fprintf(dump, "\n%.*s %s %.*s", MAX(3, 38 - labellen / 2), marks, label, MAX(3, 38 - labellen / 2), marks);
|
||||
fprintf(dump, "\n%.*s %s %.*s", max(3, 38 - labellen / 2), marks, label, max(3, 38 - labellen / 2), marks);
|
||||
fprintf(dump, "\nInteger regs: %-3d Float regs: %-3d Address regs: %-3d String regs: %-3d\nStack size: %d\n",
|
||||
sfunc->NumRegD, sfunc->NumRegF, sfunc->NumRegA, sfunc->NumRegS, sfunc->MaxParam);
|
||||
VMDumpConstants(dump, sfunc);
|
||||
|
|
|
@ -80,7 +80,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, StatusbarToRealCoords, StatusbarTo
|
|||
if (numret > 1) ret[1].SetFloat(y);
|
||||
if (numret > 2) ret[2].SetFloat(w);
|
||||
if (numret > 3) ret[3].SetFloat(h);
|
||||
return MIN(4, numret);
|
||||
return min(4, numret);
|
||||
}
|
||||
|
||||
void SBar_DrawTexture(DStatusBarCore* self, int texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth)
|
||||
|
@ -228,7 +228,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, TransformRect, SBar_TransformRect)
|
|||
if (numret > 1) ret[1].SetFloat(y);
|
||||
if (numret > 2) ret[2].SetFloat(w);
|
||||
if (numret > 3) ret[3].SetFloat(h);
|
||||
return MIN(4, numret);
|
||||
return min(4, numret);
|
||||
}
|
||||
|
||||
static void SBar_Fill(DStatusBarCore* self, int color, double x, double y, double w, double h, int flags)
|
||||
|
@ -437,7 +437,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize)
|
|||
x = GetTextureSize(texid, &y);
|
||||
if (numret > 0) ret[0].SetInt(x);
|
||||
if (numret > 1) ret[1].SetInt(y);
|
||||
return MIN(numret, 2);
|
||||
return min(numret, 2);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -941,7 +941,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand)
|
|||
self->GetKeysForCommand(cmd.GetChars(), &k1, &k2);
|
||||
if (numret > 0) ret[0].SetInt(k1);
|
||||
if (numret > 1) ret[1].SetInt(k2);
|
||||
return MIN(numret, 2);
|
||||
return min(numret, 2);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FKeyBindings, GetAllKeysForCommand)
|
||||
|
|
|
@ -56,7 +56,7 @@ static void *AllocJitMemory(size_t size)
|
|||
}
|
||||
else
|
||||
{
|
||||
const size_t bytesToAllocate = std::max(size_t(1024 * 1024), size);
|
||||
const size_t bytesToAllocate = max(size_t(1024 * 1024), size);
|
||||
size_t allocatedSize = 0;
|
||||
void *p = OSUtils::allocVirtualMemory(bytesToAllocate, &allocatedSize, OSUtils::kVMWritable | OSUtils::kVMExecutable);
|
||||
if (!p)
|
||||
|
@ -803,7 +803,7 @@ static int CaptureStackTrace(int max_frames, void **out_frames)
|
|||
|
||||
#elif defined(WIN32)
|
||||
// JIT isn't supported here, so just do nothing.
|
||||
return 0;//return RtlCaptureStackBackTrace(0, MIN(max_frames, 32), out_frames, nullptr);
|
||||
return 0;//return RtlCaptureStackBackTrace(0, min(max_frames, 32), out_frames, nullptr);
|
||||
#else
|
||||
return backtrace(out_frames, max_frames);
|
||||
#endif
|
||||
|
|
|
@ -746,7 +746,7 @@ ADD_STAT(VM)
|
|||
for (auto d : VMCycles)
|
||||
{
|
||||
added += d.TimeMS();
|
||||
peak = MAX<double>(peak, d.TimeMS());
|
||||
peak = max<double>(peak, d.TimeMS());
|
||||
}
|
||||
for (auto d : VMCalls) addedc += d;
|
||||
memmove(&VMCycles[1], &VMCycles[0], 9 * sizeof(cycle_t));
|
||||
|
|
|
@ -293,11 +293,11 @@ static void ST_CalcCleanFacs(int designwidth, int designheight, int realwidth, i
|
|||
}
|
||||
// Use whichever pair of cwidth/cheight or width/height that produces less difference
|
||||
// between CleanXfac and CleanYfac.
|
||||
cx1 = MAX(cwidth / designwidth, 1);
|
||||
cy1 = MAX(cheight / designheight, 1);
|
||||
cx2 = MAX(realwidth / designwidth, 1);
|
||||
cy2 = MAX(realheight / designheight, 1);
|
||||
if (abs(cx1 - cy1) <= abs(cx2 - cy2) || MAX(cx1, cx2) >= 4)
|
||||
cx1 = max(cwidth / designwidth, 1);
|
||||
cy1 = max(cheight / designheight, 1);
|
||||
cx2 = max(realwidth / designwidth, 1);
|
||||
cy2 = max(realheight / designheight, 1);
|
||||
if (abs(cx1 - cy1) <= abs(cx2 - cy2) || max(cx1, cx2) >= 4)
|
||||
{ // e.g. 640x360 looks better with this.
|
||||
*cleanx = cx1;
|
||||
*cleany = cy1;
|
||||
|
@ -489,7 +489,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag
|
|||
if (boxwidth <= 0 || (boxheight > 0 && scale2 < scale1))
|
||||
scale1 = scale2;
|
||||
}
|
||||
else scale1 = MIN(scale1, scale2);
|
||||
else scale1 = min(scale1, scale2);
|
||||
|
||||
boxwidth = texwidth * scale1;
|
||||
boxheight = texheight * scale1;
|
||||
|
|
|
@ -460,7 +460,7 @@ struct bCopyAlpha
|
|||
struct bOverlay
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = MAX(s,d); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = max(s,d); }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
|
@ -473,21 +473,21 @@ struct bBlend
|
|||
|
||||
struct bAdd
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MIN<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = min<int>((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
struct bSubtract
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
||||
struct bReverseSubtract
|
||||
{
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max<int>((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); }
|
||||
static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; }
|
||||
static __forceinline bool ProcessAlpha0() { return false; }
|
||||
};
|
||||
|
|
|
@ -113,7 +113,7 @@ TArray<uint8_t> FFontChar2::CreatePalettedPixels(int)
|
|||
if (runlen != 0)
|
||||
{
|
||||
uint8_t color = lump.ReadUInt8();
|
||||
color = MIN(color, max);
|
||||
color = min(color, max);
|
||||
*dest_p = color;
|
||||
dest_p += dest_adv;
|
||||
x--;
|
||||
|
@ -137,7 +137,7 @@ TArray<uint8_t> FFontChar2::CreatePalettedPixels(int)
|
|||
{
|
||||
uint8_t color = lump.ReadUInt8();
|
||||
setlen = (-code) + 1;
|
||||
setval = MIN(color, max);
|
||||
setval = min(color, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, int width, int height,
|
|||
break;
|
||||
|
||||
case MAKE_ID('P','L','T','E'):
|
||||
PaletteSize = MIN<int> (len / 3, 256);
|
||||
PaletteSize = min<int> (len / 3, 256);
|
||||
StartOfPalette = (uint32_t)lump.Tell();
|
||||
lump.Seek(len, FileReader::SeekCur);
|
||||
break;
|
||||
|
@ -762,7 +762,7 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans)
|
|||
lump->Seek (len, FileReader::SeekCur);
|
||||
else
|
||||
{
|
||||
PaletteSize = std::min<int> (len / 3, 256);
|
||||
PaletteSize = min<int> (len / 3, 256);
|
||||
for(int i = 0; i < PaletteSize; i++)
|
||||
{
|
||||
pe[i].r = lump->ReadUInt8();
|
||||
|
@ -794,4 +794,4 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans)
|
|||
bmp.CopyPixelDataRGB(0, 0, Pixels.Data(), Width, Height, 3, pixwidth, 0, CF_RGB);
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
}
|
|
@ -153,7 +153,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe
|
|||
{
|
||||
b&=~128;
|
||||
lump.Read(data, bytesperpixel);
|
||||
for (int i=MIN<int>(Size, (b+1)); i>0; i--)
|
||||
for (int i=min<int>(Size, (b+1)); i>0; i--)
|
||||
{
|
||||
buffer[0] = data[0];
|
||||
if (bytesperpixel>=2) buffer[1] = data[1];
|
||||
|
@ -164,7 +164,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe
|
|||
}
|
||||
else
|
||||
{
|
||||
lump.Read(buffer, MIN<int>(Size, (b+1))*bytesperpixel);
|
||||
lump.Read(buffer, min<int>(Size, (b+1))*bytesperpixel);
|
||||
buffer += (b+1)*bytesperpixel;
|
||||
}
|
||||
Size -= b+1;
|
||||
|
|
|
@ -67,8 +67,8 @@ static void ResampleBoxPrecalc(TArray<BoxPrecalc>& boxes, int oldDim)
|
|||
const int src_p = int(dst * scale_factor_1);
|
||||
|
||||
BoxPrecalc& precalc = boxes[dst];
|
||||
precalc.boxStart = clamp<int>(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1);
|
||||
precalc.boxEnd = clamp<int>(max<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
|
||||
precalc.boxStart = std::clamp<int>(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1);
|
||||
precalc.boxEnd = std::clamp<int>(std::max<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text)
|
|||
{
|
||||
struct { uint32_t len, id; char key[80]; } head;
|
||||
int len = (int)strlen (text);
|
||||
int keylen = std::min ((int)strlen (keyword), 79);
|
||||
int keylen = min ((int)strlen (keyword), 79);
|
||||
uint32_t crc;
|
||||
|
||||
head.len = BigLong(len + keylen + 1);
|
||||
|
@ -329,7 +329,7 @@ char *M_GetPNGText (PNGHandle *png, const char *keyword)
|
|||
if (strncmp (keyword, png->TextChunks[i], 80) == 0)
|
||||
{
|
||||
// Woo! A match was found!
|
||||
keylen = std::min<size_t> (80, strlen (keyword) + 1);
|
||||
keylen = min<size_t> (80, strlen (keyword) + 1);
|
||||
textlen = strlen (png->TextChunks[i] + keylen) + 1;
|
||||
char *str = new char[textlen];
|
||||
strcpy (str, png->TextChunks[i] + keylen);
|
||||
|
@ -351,7 +351,7 @@ bool M_GetPNGText (PNGHandle *png, const char *keyword, char *buffer, size_t buf
|
|||
if (strncmp (keyword, png->TextChunks[i], 80) == 0)
|
||||
{
|
||||
// Woo! A match was found!
|
||||
keylen = std::min<size_t> (80, strlen (keyword) + 1);
|
||||
keylen = min<size_t> (80, strlen (keyword) + 1);
|
||||
strncpy (buffer, png->TextChunks[i] + keylen, buffsize);
|
||||
return true;
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int p
|
|||
if (stream.avail_in == 0 && chunklen > 0)
|
||||
{
|
||||
stream.next_in = chunkbuffer;
|
||||
stream.avail_in = (uInt)file.Read (chunkbuffer, std::min<uint32_t>(chunklen,sizeof(chunkbuffer)));
|
||||
stream.avail_in = (uInt)file.Read (chunkbuffer, min<uint32_t>(chunklen,sizeof(chunkbuffer)));
|
||||
chunklen -= stream.avail_in;
|
||||
}
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
|||
FContentIdBuilder builder;
|
||||
builder.id = 0;
|
||||
builder.imageID = GetImage()->GetId();
|
||||
builder.translation = MAX(0, translation);
|
||||
builder.translation = max(0, translation);
|
||||
builder.expand = exx;
|
||||
result.mContentId = builder.id;
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ bool GetFileInfo(const char* pathname, size_t *size, time_t *time)
|
|||
bool res = _wstat64(wstr.c_str(), &info) == 0;
|
||||
#endif
|
||||
if (!res || (info.st_mode & S_IFDIR)) return false;
|
||||
if (size) *size = info.st_size;
|
||||
if (size) *size = (size_t)info.st_size;
|
||||
if (time) *time = info.st_mtime;
|
||||
return res;
|
||||
}
|
||||
|
@ -1060,7 +1060,7 @@ void md5Update(FileReader& file, MD5Context& md5, unsigned len)
|
|||
|
||||
while (len > 0)
|
||||
{
|
||||
t = std::min<unsigned>(len, sizeof(readbuf));
|
||||
t = min<unsigned>(len, sizeof(readbuf));
|
||||
len -= t;
|
||||
t = (long)file.Read(readbuf, t);
|
||||
md5.Update(readbuf, t);
|
||||
|
|
|
@ -509,7 +509,7 @@ class DecompressorLZSS : public DecompressorBase
|
|||
// Partial overlap: Copy in 2 or 3 chunks.
|
||||
do
|
||||
{
|
||||
unsigned int copy = std::min<unsigned int>(len, pos+1);
|
||||
unsigned int copy = min<unsigned int>(len, pos+1);
|
||||
memcpy(Stream.InternalBuffer, copyStart, copy);
|
||||
Stream.InternalBuffer += copy;
|
||||
Stream.InternalOut += copy;
|
||||
|
@ -575,7 +575,7 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
unsigned int copy = std::min<unsigned int>(Stream.InternalOut, AvailOut);
|
||||
unsigned int copy = min<unsigned int>(Stream.InternalOut, AvailOut);
|
||||
if(copy > 0)
|
||||
{
|
||||
memcpy(Out, Stream.WindowData, copy);
|
||||
|
|
|
@ -500,7 +500,7 @@ PalEntry averageColor(const uint32_t* data, int size, int maxout)
|
|||
g = g / size;
|
||||
b = b / size;
|
||||
|
||||
int maxv = MAX(MAX(r, g), b);
|
||||
int maxv = max(max(r, g), b);
|
||||
|
||||
if (maxv && maxout)
|
||||
{
|
||||
|
@ -802,9 +802,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f
|
|||
BaseColors[c].g * 143 +
|
||||
BaseColors[c].b * 37) / 256.0;
|
||||
|
||||
PalEntry pe = PalEntry(std::min(255, int(r1 + intensity * r2)),
|
||||
std::min(255, int(g1 + intensity * g2)),
|
||||
std::min(255, int(b1 + intensity * b2)));
|
||||
PalEntry pe = PalEntry(min(255, int(r1 + intensity * r2)),
|
||||
min(255, int(g1 + intensity * g2)),
|
||||
min(255, int(b1 + intensity * b2)));
|
||||
|
||||
cm->Colormap[c] = BestColor((uint32_t*)BaseColors, pe.r, pe.g, pe.b);
|
||||
}
|
||||
|
@ -813,9 +813,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f
|
|||
// This table is used by the texture composition code
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
cm->GrayscaleToColor[i] = PalEntry(std::min(255, int(r1 + i * r2)),
|
||||
std::min(255, int(g1 + i * g2)),
|
||||
std::min(255, int(b1 + i * b2)));
|
||||
cm->GrayscaleToColor[i] = PalEntry(min(255, int(r1 + i * r2)),
|
||||
min(255, int(g1 + i * g2)),
|
||||
min(255, int(b1 + i * b2)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -911,7 +911,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
|
|||
fr.Seek(len, FileReader::SeekCur);
|
||||
else
|
||||
{
|
||||
int PaletteSize = MIN<int>(len, 768);
|
||||
int PaletteSize = min<int>(len, 768);
|
||||
fr.Read(buffer, PaletteSize);
|
||||
return PaletteSize / 3;
|
||||
}
|
||||
|
@ -930,7 +930,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
|
|||
sc.MustGetString();
|
||||
sc.MustGetNumber(); // version - ignore
|
||||
sc.MustGetNumber();
|
||||
int colors = MIN(256, sc.Number) * 3;
|
||||
int colors = min(256, sc.Number) * 3;
|
||||
for (int i = 0; i < colors; i++)
|
||||
{
|
||||
sc.MustGetNumber();
|
||||
|
@ -944,7 +944,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
|
|||
}
|
||||
else
|
||||
{
|
||||
memcpy(buffer, lumpmem, MIN<size_t>(768, lump.GetSize()));
|
||||
memcpy(buffer, lumpmem, min<size_t>(768, lump.GetSize()));
|
||||
return 256;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,41 +93,5 @@ const ClassType *BinarySearch (const ClassType *first, int max,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// MIN
|
||||
//
|
||||
// Returns the minimum of a and b.
|
||||
//==========================================================================
|
||||
|
||||
#ifdef MIN
|
||||
#undef MIN
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
const T MIN (const T a, const T b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// MAX
|
||||
//
|
||||
// Returns the maximum of a and b.
|
||||
//==========================================================================
|
||||
|
||||
#ifdef MAX
|
||||
#undef MAX
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
const T MAX (const T a, const T b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
|
||||
#endif //__TEMPLATES_H__
|
||||
|
|
Loading…
Reference in a new issue