Add 'normalNx' texture scaling

This commit is contained in:
Rachael Alexanderson 2018-09-25 03:34:23 -04:00
parent c589f1bba7
commit b6bcc1b0f5
3 changed files with 51 additions and 2 deletions

View file

@ -47,7 +47,7 @@
CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self < 0 || self > 19)
if (self < 0 || self > 22)
{
self = 0;
}
@ -187,7 +187,6 @@ static void scale4x ( uint32_t* inputBuffer, uint32_t* outputBuffer, int inWidth
delete[] buffer2x;
}
static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32_t* , uint32_t* , int , int),
const int N,
unsigned char *inputBuffer,
@ -205,6 +204,44 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32_t* , uint3
return newBuffer;
}
static void normalNx ( uint32_t* inputBuffer, uint32_t* outputBuffer, int inWidth, int inHeight, int size )
{
const int width = size * inWidth;
const int height = size * inHeight;
for ( int i = 0; i < inWidth; ++i )
{
for ( int j = 0; j < inHeight; ++j )
{
const uint32_t E = inputBuffer[ i +inWidth*j ];
for ( int k = 0; k < size; k++ )
{
for ( int l = 0; l < size; l++ )
{
outputBuffer[size*i+k + width*(size*j+l)] = E;
}
}
}
}
}
static unsigned char *normalNxHelper( void (normalNxFunction) ( uint32_t* , uint32_t* , int , int, int),
const int N,
unsigned char *inputBuffer,
const int inWidth,
const int inHeight,
int &outWidth,
int &outHeight )
{
outWidth = N * inWidth;
outHeight = N *inHeight;
unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4];
normalNxFunction ( reinterpret_cast<uint32_t*> ( inputBuffer ), reinterpret_cast<uint32_t*> ( newBuffer ), inWidth, inHeight, N );
delete[] inputBuffer;
return newBuffer;
}
#ifdef HAVE_MMX
static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ),
const int N,
@ -396,6 +433,12 @@ unsigned char *FTexture::CreateUpsampledTextureBuffer (unsigned char *inputBuffe
case 18:
case 19:
return xbrzHelper(xbrz::scale, type - 13, inputBuffer, inWidth, inHeight, outWidth, outHeight);
case 20:
return normalNxHelper( &normalNx, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight );
case 21:
return normalNxHelper( &normalNx, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight );
case 22:
return normalNxHelper( &normalNx, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight );
}
}
return inputBuffer;

View file

@ -2872,6 +2872,9 @@ OPTVAL_ROUND = "Round";
OPTVAL_SCALE2X = "Scale2x";
OPTVAL_SCALE3X = "Scale3x";
OPTVAL_SCALE4X = "Scale4x";
OPTVAL_NORMAL2X = "Normal2x";
OPTVAL_NORMAL3X = "Normal3x";
OPTVAL_NORMAL4X = "Normal4x";
OPTVAL_HQ2X = "hq2x";
OPTVAL_HQ3X = "hq3x";
OPTVAL_HQ4X = "hq4x";

View file

@ -2165,6 +2165,9 @@ OptionValue "HqResizeModes"
15, "$OPTVAL_OLD_4XBRZ"
16, "$OPTVAL_OLD_5XBRZ"
17, "$OPTVAL_OLD_6XBRZ"
20, "$OPTVAL_NORMAL2X"
21, "$OPTVAL_NORMAL3X"
22, "$OPTVAL_NORMAL4X"
}
OptionValue "HqResizeModesNoMMX"