- replaced MIN/MAX in common code.

This commit is contained in:
Christoph Oelckers 2021-10-30 10:46:17 +02:00
commit eb69bbcae0
63 changed files with 200 additions and 236 deletions

View file

@ -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; }
};

View file

@ -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);
}
}
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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;
}