diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index 30f453e6..5b89786f 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -36,15 +36,11 @@ TxCache::~TxCache() { /* free memory, clean up, etc */ clear(); - - delete _txUtil; } TxCache::TxCache(int options, int cachesize, const wchar_t *path, const wchar_t *ident, dispInfoFuncExt callback) { - _txUtil = new TxUtil(); - _options = options; _cacheSize = cachesize; _callback = callback; @@ -85,7 +81,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) uint32 format = info->format; if (!dataSize) { - dataSize = _txUtil->sizeofTx(info->width, info->height, info->format); + dataSize = TxUtil::sizeofTx(info->width, info->height, info->format); if (!dataSize) return 0; diff --git a/src/GLideNHQ/TxCache.h b/src/GLideNHQ/TxCache.h index 922d1443..afff8ebd 100644 --- a/src/GLideNHQ/TxCache.h +++ b/src/GLideNHQ/TxCache.h @@ -41,7 +41,6 @@ protected: tx_wstring _ident; tx_wstring _path; dispInfoFuncExt _callback; - TxUtil *_txUtil; struct TXCACHE { int size; GHQTexInfo info; diff --git a/src/GLideNHQ/TxFilter.cpp b/src/GLideNHQ/TxFilter.cpp index d98720d2..d5cb2c56 100644 --- a/src/GLideNHQ/TxFilter.cpp +++ b/src/GLideNHQ/TxFilter.cpp @@ -49,7 +49,6 @@ void TxFilter::clear() /* clear other stuff */ delete _txImage; delete _txQuantize; - delete _txUtil; } TxFilter::~TxFilter() @@ -60,7 +59,7 @@ TxFilter::~TxFilter() TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, int cachesize, const wchar_t * path, const wchar_t * texPackPath, const wchar_t * ident, dispInfoFuncExt callback) : - _tex1(nullptr), _tex2(nullptr), _txQuantize(nullptr), _txTexCache(nullptr), _txHiResCache(nullptr), _txUtil(nullptr), _txImage(nullptr) + _tex1(nullptr), _tex2(nullptr), _txQuantize(nullptr), _txTexCache(nullptr), _txHiResCache(nullptr), _txImage(nullptr) { /* HACKALERT: the emulator misbehaves and sometimes forgets to shutdown */ if ((ident && wcscmp(ident, wst("DEFAULT")) != 0 && _ident.compare(ident) == 0) && @@ -90,10 +89,9 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, _txImage = new TxImage(); _txQuantize = new TxQuantize(); - _txUtil = new TxUtil(); /* get number of CPU cores. */ - _numcore = _txUtil->getNumberofProcessors(); + _numcore = TxUtil::getNumberofProcessors(); _initialized = 0; @@ -161,7 +159,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint /* calculate checksum of source texture */ if (!g64crc) - g64crc = (uint64)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat)); + g64crc = (uint64)(TxUtil::checksumTx(texture, srcwidth, srcheight, srcformat)); DBG_INFO(80, wst("filter: crc:%08X %08X %d x %d gfmt:%x\n"), (uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff), srcwidth, srcheight, srcformat); @@ -561,7 +559,7 @@ uint64 TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) { if (_options & (HIRESTEXTURES_MASK|DUMP_TEX)) - return _txUtil->checksum64(src, width, height, size, rowStride, palette); + return TxUtil::checksum64(src, width, height, size, rowStride, palette); return 0; } diff --git a/src/GLideNHQ/TxFilter.h b/src/GLideNHQ/TxFilter.h index 22b0b9ef..a4396ae1 100644 --- a/src/GLideNHQ/TxFilter.h +++ b/src/GLideNHQ/TxFilter.h @@ -48,7 +48,6 @@ private: TxQuantize *_txQuantize; TxTexCache *_txTexCache; TxHiResCache *_txHiResCache; - TxUtil *_txUtil; TxImage *_txImage; boolean _initialized; void clear(); diff --git a/src/GLideNHQ/TxHiResCache.cpp b/src/GLideNHQ/TxHiResCache.cpp index 0c3c4ffe..4e789185 100644 --- a/src/GLideNHQ/TxHiResCache.cpp +++ b/src/GLideNHQ/TxHiResCache.cpp @@ -672,7 +672,7 @@ TxHiResCache::loadHiResTextures(const wchar_t * dir_path, boolean replace) /* quantize */ { - tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); + tmptex = (uint8 *)malloc(TxUtil::sizeofTx(width, height, destformat)); if (tmptex) { switch (destformat) { case GL_RGBA8: diff --git a/src/GLideNHQ/TxQuantize.cpp b/src/GLideNHQ/TxQuantize.cpp index a5975b90..475bcc3c 100644 --- a/src/GLideNHQ/TxQuantize.cpp +++ b/src/GLideNHQ/TxQuantize.cpp @@ -35,16 +35,13 @@ TxQuantize::TxQuantize() { - _txUtil = new TxUtil(); - /* get number of CPU cores. */ - _numcore = _txUtil->getNumberofProcessors(); + _numcore = TxUtil::getNumberofProcessors(); } TxQuantize::~TxQuantize() { - delete _txUtil; } void diff --git a/src/GLideNHQ/TxQuantize.h b/src/GLideNHQ/TxQuantize.h index 2b09515a..66f2f655 100644 --- a/src/GLideNHQ/TxQuantize.h +++ b/src/GLideNHQ/TxQuantize.h @@ -30,7 +30,6 @@ class TxQuantize { private: - TxUtil *_txUtil; int _numcore; /* fast optimized... well, sort of. */ diff --git a/src/GLideNHQ/TxUtil.h b/src/GLideNHQ/TxUtil.h index a1b338d8..02a92bfd 100644 --- a/src/GLideNHQ/TxUtil.h +++ b/src/GLideNHQ/TxUtil.h @@ -35,22 +35,20 @@ class TxUtil { private: - uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride); - boolean RiceCRC32_CI4(const uint8* src, int width, int height, int rowStride, + static uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride); + static boolean RiceCRC32_CI4(const uint8* src, int width, int height, int rowStride, uint32* crc32, uint32* cimax); - boolean RiceCRC32_CI8(const uint8* src, int width, int height, int rowStride, + static boolean RiceCRC32_CI8(const uint8* src, int width, int height, int rowStride, uint32* crc32, uint32* cimax); public: - TxUtil() { } - ~TxUtil() { } - int sizeofTx(int width, int height, uint16 format); - uint32 checksumTx(uint8 *data, int width, int height, uint16 format); + static int sizeofTx(int width, int height, uint16 format); + static uint32 checksumTx(uint8 *data, int width, int height, uint16 format); #if 0 /* unused */ - uint32 chkAlpha(uint32* src, int width, int height); + static uint32 chkAlpha(uint32* src, int width, int height); #endif - uint32 checksum(uint8 *src, int width, int height, int size, int rowStride); - uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); - int getNumberofProcessors(); + static uint32 checksum(uint8 *src, int width, int height, int size, int rowStride); + static uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); + static int getNumberofProcessors(); }; class TxMemBuf