mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-20 07:58:44 +00:00
Merge with develop
--HG-- branch : compatibility-develop
This commit is contained in:
commit
b78afa1c4d
9 changed files with 369 additions and 75 deletions
|
@ -236,6 +236,34 @@ private :
|
||||||
sint32 nDestWidth, sint32 nDestHeight);
|
sint32 nDestWidth, sint32 nDestHeight);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The grayscale resample function
|
||||||
|
* \param pSrc grayscale 8-bits array
|
||||||
|
* \param pDest grayscale 8-bits array for storing resampled texture
|
||||||
|
* \param nSrcWidth original width
|
||||||
|
* \param nSrcHeight original height
|
||||||
|
* \param nDestWidth width after resample
|
||||||
|
* \param nDestHeight height after resample
|
||||||
|
*/
|
||||||
|
void resamplePicture8 (const uint8 *pSrc, uint8 *pDest,
|
||||||
|
sint32 nSrcWidth, sint32 nSrcHeight,
|
||||||
|
sint32 nDestWidth, sint32 nDestHeight);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The FAST resample function : works only when reducing the size by two
|
||||||
|
* and when the image is square
|
||||||
|
* \param pSrc grayscale 8-bits array
|
||||||
|
* \param pDest grayscale 8-bits array for storing resampled texture
|
||||||
|
* \param nSrcWidth original width
|
||||||
|
* \param nSrcHeight original height
|
||||||
|
* \param nDestWidth width after resample
|
||||||
|
* \param nDestHeight height after resample
|
||||||
|
*/
|
||||||
|
void resamplePicture8Fast (const uint8 *pSrc, uint8 *pDest,
|
||||||
|
sint32 nSrcWidth, sint32 nSrcHeight,
|
||||||
|
sint32 nDestWidth, sint32 nDestHeight);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quadratic interpolator
|
* Quadratic interpolator
|
||||||
* \return the interpolation in (x,y) of the values (xy**)
|
* \return the interpolation in (x,y) of the values (xy**)
|
||||||
|
|
|
@ -43,11 +43,25 @@
|
||||||
// This way we know about _HAS_TR1 and _STLPORT_VERSION
|
// This way we know about _HAS_TR1 and _STLPORT_VERSION
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#if defined(HAVE_X86_64)
|
||||||
|
# define NL_CPU_INTEL
|
||||||
|
# define NL_CPU_X86_64
|
||||||
|
// x86_64 CPU always have SSE2 instructions
|
||||||
|
# ifndef NL_HAS_SSE2
|
||||||
|
# define NL_HAS_SSE2
|
||||||
|
# endif
|
||||||
|
#elif defined(HAVE_X86)
|
||||||
|
# define NL_CPU_INTEL
|
||||||
|
# define NL_CPU_X86
|
||||||
|
#endif
|
||||||
|
|
||||||
// Operating systems definition
|
// Operating systems definition
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define NL_OS_WINDOWS
|
# define NL_OS_WINDOWS
|
||||||
# define NL_LITTLE_ENDIAN
|
# define NL_LITTLE_ENDIAN
|
||||||
# define NL_CPU_INTEL
|
# ifndef NL_CPU_INTEL
|
||||||
|
# define NL_CPU_INTEL
|
||||||
|
# endif
|
||||||
# ifndef _WIN32_WINNT
|
# ifndef _WIN32_WINNT
|
||||||
# define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
|
# define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
|
||||||
# endif
|
# endif
|
||||||
|
@ -384,10 +398,13 @@ inline void aligned_free(void *ptr) { free(ptr); }
|
||||||
#define NL_DEFAULT_MEMORY_ALIGNMENT 16
|
#define NL_DEFAULT_MEMORY_ALIGNMENT 16
|
||||||
#define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT)
|
#define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT)
|
||||||
|
|
||||||
|
#ifndef NL_CPU_X86_64
|
||||||
|
// on x86_64, new and delete are already aligned on 16 bytes
|
||||||
extern void *operator new(size_t size) throw(std::bad_alloc);
|
extern void *operator new(size_t size) throw(std::bad_alloc);
|
||||||
extern void *operator new[](size_t size) throw(std::bad_alloc);
|
extern void *operator new[](size_t size) throw(std::bad_alloc);
|
||||||
extern void operator delete(void *p) throw();
|
extern void operator delete(void *p) throw();
|
||||||
extern void operator delete[](void *p) throw();
|
extern void operator delete[](void *p) throw();
|
||||||
|
#endif
|
||||||
|
|
||||||
#else /* NL_HAS_SSE2 */
|
#else /* NL_HAS_SSE2 */
|
||||||
|
|
||||||
|
|
|
@ -1785,7 +1785,7 @@ void CBitmap::releaseMipMaps()
|
||||||
\*-------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------*/
|
||||||
void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight)
|
void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight)
|
||||||
{
|
{
|
||||||
nlassert(PixelFormat == RGBA);
|
nlassert(PixelFormat == RGBA || PixelFormat == Luminance);
|
||||||
bool needRebuild = false;
|
bool needRebuild = false;
|
||||||
|
|
||||||
// Deleting mipmaps
|
// Deleting mipmaps
|
||||||
|
@ -1804,13 +1804,27 @@ void CBitmap::resample(sint32 nNewWidth, sint32 nNewHeight)
|
||||||
|
|
||||||
//logResample("Resample: 30");
|
//logResample("Resample: 30");
|
||||||
CObjectVector<uint8> pDestui;
|
CObjectVector<uint8> pDestui;
|
||||||
pDestui.resize(nNewWidth*nNewHeight*4);
|
|
||||||
//logResample("Resample: 40");
|
|
||||||
NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0];
|
|
||||||
//logResample("Resample: 50");
|
|
||||||
|
|
||||||
resamplePicture32 ((NLMISC::CRGBA*)&_Data[0][0], pDestRgba, _Width, _Height, nNewWidth, nNewHeight);
|
if (PixelFormat == RGBA)
|
||||||
//logResample("Resample: 60");
|
{
|
||||||
|
pDestui.resize(nNewWidth*nNewHeight*4);
|
||||||
|
//logResample("Resample: 40");
|
||||||
|
NLMISC::CRGBA *pDestRgba = (NLMISC::CRGBA*)&pDestui[0];
|
||||||
|
//logResample("Resample: 50");
|
||||||
|
|
||||||
|
resamplePicture32 ((NLMISC::CRGBA*)&_Data[0][0], pDestRgba, _Width, _Height, nNewWidth, nNewHeight);
|
||||||
|
//logResample("Resample: 60");
|
||||||
|
}
|
||||||
|
else if (PixelFormat == Luminance)
|
||||||
|
{
|
||||||
|
pDestui.resize(nNewWidth*nNewHeight);
|
||||||
|
//logResample("Resample: 40");
|
||||||
|
uint8 *pDestGray = &pDestui[0];
|
||||||
|
//logResample("Resample: 50");
|
||||||
|
|
||||||
|
resamplePicture8 (&_Data[0][0], pDestGray, _Width, _Height, nNewWidth, nNewHeight);
|
||||||
|
//logResample("Resample: 60");
|
||||||
|
}
|
||||||
|
|
||||||
NLMISC::contReset(_Data[0]); // free memory
|
NLMISC::contReset(_Data[0]); // free memory
|
||||||
//logResample("Resample: 70");
|
//logResample("Resample: 70");
|
||||||
|
@ -2126,6 +2140,230 @@ void CBitmap::resamplePicture32Fast (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------*\
|
||||||
|
resamplePicture32
|
||||||
|
\*-------------------------------------------------------------------*/
|
||||||
|
void CBitmap::resamplePicture8 (const uint8 *pSrc, uint8 *pDest,
|
||||||
|
sint32 nSrcWidth, sint32 nSrcHeight,
|
||||||
|
sint32 nDestWidth, sint32 nDestHeight)
|
||||||
|
{
|
||||||
|
//logResample("RP8: 0 pSrc=%p pDest=%p, Src=%d x %d Dest=%d x %d", pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight);
|
||||||
|
if ((nSrcWidth<=0)||(nSrcHeight<=0)||(nDestHeight<=0)||(nDestHeight<=0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If we're reducing it by 2, call the fast resample
|
||||||
|
if (((nSrcHeight / 2) == nDestHeight) && ((nSrcHeight % 2) == 0) &&
|
||||||
|
((nSrcWidth / 2) == nDestWidth) && ((nSrcWidth % 2) == 0))
|
||||||
|
{
|
||||||
|
resamplePicture8Fast(pSrc, pDest, nSrcWidth, nSrcHeight, nDestWidth, nDestHeight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bXMag=(nDestWidth>=nSrcWidth);
|
||||||
|
bool bYMag=(nDestHeight>=nSrcHeight);
|
||||||
|
bool bXEq=(nDestWidth==nSrcWidth);
|
||||||
|
bool bYEq=(nDestHeight==nSrcHeight);
|
||||||
|
std::vector<float> pIterm (nDestWidth*nSrcHeight);
|
||||||
|
|
||||||
|
if (bXMag)
|
||||||
|
{
|
||||||
|
float fXdelta=(float)(nSrcWidth)/(float)(nDestWidth);
|
||||||
|
float *pItermPtr=&*pIterm.begin();
|
||||||
|
sint32 nY;
|
||||||
|
for (nY=0; nY<nSrcHeight; nY++)
|
||||||
|
{
|
||||||
|
const uint8 *pSrcLine=pSrc;
|
||||||
|
float fX=0.f;
|
||||||
|
sint32 nX;
|
||||||
|
for (nX=0; nX<nDestWidth; nX++)
|
||||||
|
{
|
||||||
|
float fVirgule=fX-(float)floor(fX);
|
||||||
|
nlassert (fVirgule>=0.f);
|
||||||
|
float vColor;
|
||||||
|
if (fVirgule>=0.5f)
|
||||||
|
{
|
||||||
|
if (fX<(float)(nSrcWidth-1))
|
||||||
|
{
|
||||||
|
float vColor1 (pSrcLine[(sint32)floor(fX)]);
|
||||||
|
float vColor2 (pSrcLine[(sint32)floor(fX)+1]);
|
||||||
|
vColor=vColor1*(1.5f-fVirgule)+vColor2*(fVirgule-0.5f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vColor = float(pSrcLine[(sint32)floor(fX)]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fX>=1.f)
|
||||||
|
{
|
||||||
|
float vColor1 (pSrcLine[(sint32)floor(fX)]);
|
||||||
|
float vColor2 (pSrcLine[(sint32)floor(fX)-1]);
|
||||||
|
vColor = vColor1*(0.5f+fVirgule)+vColor2*(0.5f-fVirgule);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vColor = float (pSrcLine[(sint32)floor(fX)]);
|
||||||
|
}
|
||||||
|
*(pItermPtr++)=vColor;
|
||||||
|
fX+=fXdelta;
|
||||||
|
}
|
||||||
|
pSrc+=nSrcWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bXEq)
|
||||||
|
{
|
||||||
|
float *pItermPtr=&*pIterm.begin();
|
||||||
|
for (sint32 nY=0; nY<nSrcHeight; nY++)
|
||||||
|
{
|
||||||
|
const uint8 *pSrcLine=pSrc;
|
||||||
|
sint32 nX;
|
||||||
|
for (nX=0; nX<nDestWidth; nX++)
|
||||||
|
*(pItermPtr++) = float (pSrcLine[nX]);
|
||||||
|
pSrc+=nSrcWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double fXdelta=(double)(nSrcWidth)/(double)(nDestWidth);
|
||||||
|
nlassert (fXdelta>1.f);
|
||||||
|
float *pItermPtr=&*pIterm.begin();
|
||||||
|
sint32 nY;
|
||||||
|
for (nY=0; nY<nSrcHeight; nY++)
|
||||||
|
{
|
||||||
|
const uint8 *pSrcLine=pSrc;
|
||||||
|
double fX=0.f;
|
||||||
|
sint32 nX;
|
||||||
|
for (nX=0; nX<nDestWidth; nX++)
|
||||||
|
{
|
||||||
|
float vColor = 0.f;
|
||||||
|
double fFinal=fX+fXdelta;
|
||||||
|
while ((fX<fFinal)&&((sint32)fX!=nSrcWidth))
|
||||||
|
{
|
||||||
|
double fNext=(double)floor (fX)+1.f;
|
||||||
|
if (fNext>fFinal)
|
||||||
|
fNext=fFinal;
|
||||||
|
vColor+=((float)(fNext-fX))* float (pSrcLine[(sint32)floor(fX)]);
|
||||||
|
fX=fNext;
|
||||||
|
}
|
||||||
|
fX = fFinal; // ensure fX == fFinal
|
||||||
|
vColor/=(float)fXdelta;
|
||||||
|
*(pItermPtr++)=vColor;
|
||||||
|
}
|
||||||
|
pSrc+=nSrcWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bYMag)
|
||||||
|
{
|
||||||
|
double fYdelta=(double)(nSrcHeight)/(double)(nDestHeight);
|
||||||
|
sint32 nX;
|
||||||
|
for (nX=0; nX<nDestWidth; nX++)
|
||||||
|
{
|
||||||
|
double fY=0.f;
|
||||||
|
sint32 nY;
|
||||||
|
for (nY=0; nY<nDestHeight; nY++)
|
||||||
|
{
|
||||||
|
double fVirgule=fY-(double)floor(fY);
|
||||||
|
nlassert (fVirgule>=0.f);
|
||||||
|
float vColor;
|
||||||
|
if (fVirgule>=0.5f)
|
||||||
|
{
|
||||||
|
if (fY<(double)(nSrcHeight-1))
|
||||||
|
{
|
||||||
|
float vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX];
|
||||||
|
float vColor2=pIterm[(((sint32)floor(fY))+1)*nDestWidth+nX];
|
||||||
|
vColor=vColor1*(1.5f-(float)fVirgule)+vColor2*((float)fVirgule-0.5f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fY>=1.f)
|
||||||
|
{
|
||||||
|
float vColor1=pIterm[((sint32)floor(fY))*nDestWidth+nX];
|
||||||
|
float vColor2=pIterm[(((sint32)floor(fY))-1)*nDestWidth+nX];
|
||||||
|
vColor=vColor1*(0.5f+(float)fVirgule)+vColor2*(0.5f-(float)fVirgule);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vColor=pIterm[((sint32)floor(fY))*nDestWidth+nX];
|
||||||
|
}
|
||||||
|
pDest[nX+nY*nDestWidth]=vColor;
|
||||||
|
fY+=fYdelta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bYEq)
|
||||||
|
{
|
||||||
|
for (sint32 nX=0; nX<nDestWidth; nX++)
|
||||||
|
{
|
||||||
|
sint32 nY;
|
||||||
|
for (nY=0; nY<nDestHeight; nY++)
|
||||||
|
{
|
||||||
|
pDest[nX+nY*nDestWidth]=pIterm[nY*nDestWidth+nX];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double fYdelta=(double)(nSrcHeight)/(double)(nDestHeight);
|
||||||
|
nlassert (fYdelta>1.f);
|
||||||
|
sint32 nX;
|
||||||
|
for (nX=0; nX<nDestWidth; nX++)
|
||||||
|
{
|
||||||
|
double fY=0.f;
|
||||||
|
sint32 nY;
|
||||||
|
for (nY=0; nY<nDestHeight; nY++)
|
||||||
|
{
|
||||||
|
float vColor = 0.f;
|
||||||
|
double fFinal=fY+fYdelta;
|
||||||
|
while ((fY<fFinal)&&((sint32)fY!=nSrcHeight))
|
||||||
|
{
|
||||||
|
double fNext=(double)floor (fY)+1.f;
|
||||||
|
if (fNext>fFinal)
|
||||||
|
fNext=fFinal;
|
||||||
|
vColor+=((float)(fNext-fY))*pIterm[((sint32)floor(fY))*nDestWidth+nX];
|
||||||
|
fY=fNext;
|
||||||
|
}
|
||||||
|
vColor/=(float)fYdelta;
|
||||||
|
pDest[nX+nY*nDestWidth]=vColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------*\
|
||||||
|
resamplePicture8Fast
|
||||||
|
\*-------------------------------------------------------------------*/
|
||||||
|
void CBitmap::resamplePicture8Fast (const uint8 *pSrc, uint8 *pDest,
|
||||||
|
sint32 nSrcWidth, sint32 nSrcHeight,
|
||||||
|
sint32 nDestWidth, sint32 nDestHeight)
|
||||||
|
{
|
||||||
|
// the image is divided by two : 1 pixel in dest = 4 pixels in src
|
||||||
|
// the resulting pixel in dest is an average of the four pixels in src
|
||||||
|
|
||||||
|
nlassert(nSrcWidth % 2 == 0);
|
||||||
|
nlassert(nSrcHeight % 2 == 0);
|
||||||
|
nlassert(nSrcWidth / 2 == nDestWidth);
|
||||||
|
nlassert(nSrcHeight / 2 == nDestHeight);
|
||||||
|
|
||||||
|
sint32 x, y, twoX, twoSrcWidthByY;
|
||||||
|
|
||||||
|
for (y=0 ; y<nDestHeight ; y++)
|
||||||
|
{
|
||||||
|
twoSrcWidthByY = 2*nSrcWidth*y;
|
||||||
|
for (x=0 ; x<nDestWidth ; x++)
|
||||||
|
{
|
||||||
|
twoX = 2*x;
|
||||||
|
pDest[x+y*nDestWidth] = (
|
||||||
|
(uint)pSrc[twoX + twoSrcWidthByY ]+
|
||||||
|
(uint)pSrc[twoX + twoSrcWidthByY + nSrcWidth ]+
|
||||||
|
(uint)pSrc[twoX+1 + twoSrcWidthByY ]+
|
||||||
|
(uint)pSrc[twoX+1 + twoSrcWidthByY + nSrcWidth ]+1)>>2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------*\
|
||||||
readTGA
|
readTGA
|
||||||
|
|
|
@ -80,7 +80,7 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); }
|
||||||
#endif // !NL_COMP_MINGW
|
#endif // !NL_COMP_MINGW
|
||||||
|
|
||||||
|
|
||||||
#ifdef NL_HAS_SSE2
|
#if defined(NL_HAS_SSE2) && !defined(NL_CPU_X86_64)
|
||||||
|
|
||||||
void *operator new(size_t size) throw(std::bad_alloc)
|
void *operator new(size_t size) throw(std::bad_alloc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -322,8 +322,7 @@ int main(int argc, char* argv[])
|
||||||
NLMISC::CConfigFile::CVar &bitmap_extensions = cf.getVar ("bitmap_extensions");
|
NLMISC::CConfigFile::CVar &bitmap_extensions = cf.getVar ("bitmap_extensions");
|
||||||
for (uint k = 0; k < (uint) bitmap_extensions.size(); ++k)
|
for (uint k = 0; k < (uint) bitmap_extensions.size(); ++k)
|
||||||
{
|
{
|
||||||
std::string ext = "." + bitmap_extensions.asString(k);
|
std::string ext = "." + NLMISC::toLower(bitmap_extensions.asString(k));
|
||||||
ext = NLMISC::strupr(ext);
|
|
||||||
if (std::find(bi.BitmapExtensions.begin(), bi.BitmapExtensions.end(), ext) == bi.BitmapExtensions.end())
|
if (std::find(bi.BitmapExtensions.begin(), bi.BitmapExtensions.end(), ext) == bi.BitmapExtensions.end())
|
||||||
{
|
{
|
||||||
bi.BitmapExtensions.push_back(ext);
|
bi.BitmapExtensions.push_back(ext);
|
||||||
|
@ -481,7 +480,7 @@ static void BuildColoredVersions(const CBuildInfo &bi)
|
||||||
{
|
{
|
||||||
for (uint l = 0; l < bi.BitmapExtensions.size(); ++l)
|
for (uint l = 0; l < bi.BitmapExtensions.size(); ++l)
|
||||||
{
|
{
|
||||||
std::string fileExt = "." + NLMISC::strupr(NLMISC::CFile::getExtension(files[k]));
|
std::string fileExt = "." + NLMISC::toLower(NLMISC::CFile::getExtension(files[k]));
|
||||||
if (fileExt == bi.BitmapExtensions[l])
|
if (fileExt == bi.BitmapExtensions[l])
|
||||||
{
|
{
|
||||||
//nlwarning("Processing : %s ", files[k].c_str());
|
//nlwarning("Processing : %s ", files[k].c_str());
|
||||||
|
@ -530,7 +529,7 @@ static bool CheckIfNeedRebuildColoredVersionForOneBitmap(const CBuildInfo &bi, c
|
||||||
masks.clear();
|
masks.clear();
|
||||||
|
|
||||||
std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension);
|
std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension);
|
||||||
std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(fileNameWithExtension));
|
std::string fileExt = NLMISC::toLower(NLMISC::CFile::getExtension(fileNameWithExtension));
|
||||||
|
|
||||||
for (uint k = 0; k < bi.ColorMasks.size(); ++k)
|
for (uint k = 0; k < bi.ColorMasks.size(); ++k)
|
||||||
{
|
{
|
||||||
|
@ -759,7 +758,7 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
masks.clear();
|
masks.clear();
|
||||||
|
|
||||||
std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension);
|
std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(fileNameWithExtension);
|
||||||
std::string fileExt = NLMISC::strupr(NLMISC::CFile::getExtension(fileNameWithExtension));
|
std::string fileExt = NLMISC::toLower(NLMISC::CFile::getExtension(fileNameWithExtension));
|
||||||
|
|
||||||
uint k;
|
uint k;
|
||||||
for (k = 0; k < bi.ColorMasks.size(); ++k)
|
for (k = 0; k < bi.ColorMasks.size(); ++k)
|
||||||
|
@ -792,46 +791,54 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
throw NLMISC::Exception("Failed to load mask");
|
throw NLMISC::Exception("Failed to load mask");
|
||||||
}
|
}
|
||||||
|
|
||||||
// masks can be converted to grayscale files
|
// convert color mask to grayscale (red is the new gray value)
|
||||||
if (bi.OptimizeTextures > 0 && maskDepth > 8)
|
if (li.Mask.getPixelFormat() == CBitmap::RGBA)
|
||||||
{
|
{
|
||||||
if (!li.Mask.isGrayscale())
|
// display a warning if checks enabled
|
||||||
|
if (bi.OptimizeTextures > 0 && !li.Mask.isGrayscale())
|
||||||
{
|
{
|
||||||
nlwarning("Mask %s is using colors, results may by incorrect! Use OptimizeTextures = 2 to fix it.", maskFileName.c_str());
|
nlwarning("Mask %s is using colors, results may by incorrect! Use OptimizeTextures = 2 to fix it.", maskFileName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get a pointer on original data
|
||||||
|
uint32 size = li.Mask.getPixels().size();
|
||||||
|
uint32 *data = (uint32*)li.Mask.getPixels().getPtr();
|
||||||
|
uint32 *endData = (uint32*)((uint8*)data + size);
|
||||||
|
|
||||||
|
NLMISC::CRGBA *color = NULL;
|
||||||
|
|
||||||
|
// process all pixels
|
||||||
|
while(data < endData)
|
||||||
|
{
|
||||||
|
color = (NLMISC::CRGBA*)data;
|
||||||
|
|
||||||
|
// copy red value to green and blue,
|
||||||
|
// because only red is used for mask
|
||||||
|
color->B = color->G = color->R;
|
||||||
|
|
||||||
|
// make opaque
|
||||||
|
color->A = 255;
|
||||||
|
|
||||||
|
++data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert image to real grayscale
|
||||||
|
if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance)
|
||||||
|
{
|
||||||
|
li.Mask.convertToType(NLMISC::CBitmap::Luminance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// masks can be converted to grayscale files
|
||||||
|
if (bi.OptimizeTextures > 0 && maskDepth > 8)
|
||||||
|
{
|
||||||
if (bi.OptimizeTextures > 1)
|
if (bi.OptimizeTextures > 1)
|
||||||
{
|
{
|
||||||
// get a pointer on original data
|
|
||||||
uint32 size = li.Mask.getPixels().size();
|
|
||||||
uint32 *data = (uint32*)li.Mask.getPixels().getPtr();
|
|
||||||
uint32 *endData = (uint32*)((uint8*)data + size);
|
|
||||||
|
|
||||||
NLMISC::CRGBA *color = NULL;
|
|
||||||
|
|
||||||
// process all pixels
|
|
||||||
while(data < endData)
|
|
||||||
{
|
|
||||||
color = (NLMISC::CRGBA*)data;
|
|
||||||
|
|
||||||
// copy red value to green and blue,
|
|
||||||
// because only red is used for mask
|
|
||||||
color->B = color->G = color->R;
|
|
||||||
|
|
||||||
// make opaque
|
|
||||||
color->A = 255;
|
|
||||||
|
|
||||||
++data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert image to real grayscale
|
|
||||||
li.Mask.convertToType(NLMISC::CBitmap::Luminance);
|
|
||||||
|
|
||||||
NLMISC::COFile os;
|
NLMISC::COFile os;
|
||||||
|
|
||||||
if (os.open(maskFileName))
|
if (os.open(maskFileName))
|
||||||
{
|
{
|
||||||
std::string ext = CFile::getExtension(maskFileName);
|
std::string ext = NLMISC::toLower(CFile::getExtension(maskFileName));
|
||||||
|
|
||||||
nlwarning("Optimizing mask %s...", maskFileName.c_str());
|
nlwarning("Optimizing mask %s...", maskFileName.c_str());
|
||||||
|
|
||||||
|
@ -856,11 +863,6 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (li.Mask.PixelFormat != NLMISC::CBitmap::Luminance)
|
|
||||||
{
|
|
||||||
li.Mask.convertToType(NLMISC::CBitmap::Luminance);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// make sure the mask has the same size
|
/// make sure the mask has the same size
|
||||||
if (li.Mask.getWidth() != srcBitmap.getWidth()
|
if (li.Mask.getWidth() != srcBitmap.getWidth()
|
||||||
|| li.Mask.getHeight() != srcBitmap.getHeight())
|
|| li.Mask.getHeight() != srcBitmap.getHeight())
|
||||||
|
@ -937,7 +939,7 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
|
||||||
nlinfo("Writing %s", outputFileName.c_str());
|
nlinfo("Writing %s", outputFileName.c_str());
|
||||||
/// Save the result. We let propagate exceptions (if there's no more space disk it useless to continue...)
|
/// Save the result. We let propagate exceptions (if there's no more space disk it useless to continue...)
|
||||||
{
|
{
|
||||||
std::string fullOutputPath = bi.OutputPath + "/" + outputFileName + bi.OutputFormat;
|
std::string fullOutputPath = bi.OutputPath + outputFileName + bi.OutputFormat;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,11 +48,3 @@ NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report")
|
||||||
NL_ADD_RUNTIME_FLAGS(crash_report)
|
NL_ADD_RUNTIME_FLAGS(crash_report)
|
||||||
|
|
||||||
INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX})
|
INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX})
|
||||||
|
|
||||||
IF(WITH_RYZOM_CLIENT AND APPLE)
|
|
||||||
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET crash_report POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report" COMMENT "Signing crash_report executable...")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET crash_report POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/CrashReport)
|
|
||||||
ENDIF()
|
|
||||||
|
|
|
@ -79,8 +79,41 @@ IF(WITH_RYZOM_CLIENT)
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp ARGS -RpX ${RYZOM_DATA_DIR} ${RYZOM_RESOURCES_DIR})
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp ARGS -RpX ${RYZOM_DATA_DIR} ${RYZOM_RESOURCES_DIR})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF(TARGET crash_report)
|
||||||
|
ADD_DEPENDENCIES(ryzom_client crash_report)
|
||||||
|
|
||||||
|
# copy crash_report to bundle
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crash_report ${RYZOM_CONTENTS_DIR}/MacOS/CrashReport)
|
||||||
|
|
||||||
|
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/CrashReport" COMMENT "Signing CrashReport executable...")
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(TARGET ryzom_client_patcher)
|
||||||
|
ADD_DEPENDENCIES(ryzom_client ryzom_client_patcher)
|
||||||
|
|
||||||
|
# copy ryzom_client_patcher to bundle
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher ${RYZOM_CONTENTS_DIR}/MacOS/RyzomClientPatcher)
|
||||||
|
|
||||||
|
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/RyzomClientPatcher" COMMENT "Signing RyzomClientPatcher executable...")
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(TARGET ryzom_configuration_qt)
|
||||||
|
ADD_DEPENDENCIES(ryzom_client ryzom_configuration_qt)
|
||||||
|
|
||||||
|
# copy ryzom_configuration_qt to bundle
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt ${RYZOM_CONTENTS_DIR}/MacOS/RyzomConfiguration)
|
||||||
|
|
||||||
|
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_CONTENTS_DIR}/MacOS/RyzomConfiguration" COMMENT "Signing RyzomConfiguration executable...")
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_OUTPUT_DIR}" COMMENT "Signing bundle...")
|
ADD_CUSTOM_COMMAND(TARGET ryzom_client POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${RYZOM_OUTPUT_DIR}" COMMENT "Signing Ryzom bundle...")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(WITH_RYZOM_STEAM)
|
IF(WITH_RYZOM_STEAM)
|
||||||
|
|
|
@ -69,11 +69,3 @@ IF(WITH_PCH)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INSTALL(TARGETS ryzom_configuration_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client)
|
INSTALL(TARGETS ryzom_configuration_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client)
|
||||||
|
|
||||||
IF(WITH_RYZOM_CLIENT AND APPLE)
|
|
||||||
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_configuration_qt POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt" COMMENT "Signing ryzom_configuration_qt executable...")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_configuration_qt POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_configuration_qt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/RyzomConfiguration)
|
|
||||||
ENDIF()
|
|
||||||
|
|
|
@ -42,12 +42,4 @@ IF(WITH_PCH)
|
||||||
ADD_NATIVE_PRECOMPILED_HEADER(ryzom_client_patcher ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.h ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.cpp)
|
ADD_NATIVE_PRECOMPILED_HEADER(ryzom_client_patcher ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.h ${CMAKE_SOURCE_DIR}/ryzom/client/src/stdpch.cpp)
|
||||||
ENDIF(WITH_PCH)
|
ENDIF(WITH_PCH)
|
||||||
|
|
||||||
INSTALL(TARGETS ryzom_client_patcher RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client BUNDLE DESTINATION /Applications)
|
INSTALL(TARGETS ryzom_client_patcher RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client)
|
||||||
|
|
||||||
IF(WITH_RYZOM_CLIENT AND APPLE)
|
|
||||||
IF(CODESIGN_ALLOCATE AND APPLE_CERTIFICATE)
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_client_patcher POST_BUILD COMMAND CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE} codesign -fs "${APPLE_CERTIFICATE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher" COMMENT "Signing ryzom_client_patcher executable...")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ADD_CUSTOM_COMMAND(TARGET ryzom_client_patcher POST_BUILD COMMAND cp -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ryzom_client_patcher ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents/MacOS/RyzomClientPatcher)
|
|
||||||
ENDIF()
|
|
||||||
|
|
Loading…
Reference in a new issue