1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Code refactor: make methods of TxUtil static.

This commit is contained in:
Sergey Lipskiy 2016-12-15 17:48:35 +07:00
parent e8522e7034
commit 8c42c31865
8 changed files with 16 additions and 30 deletions

View File

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

View File

@ -41,7 +41,6 @@ protected:
tx_wstring _ident;
tx_wstring _path;
dispInfoFuncExt _callback;
TxUtil *_txUtil;
struct TXCACHE {
int size;
GHQTexInfo info;

View File

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

View File

@ -48,7 +48,6 @@ private:
TxQuantize *_txQuantize;
TxTexCache *_txTexCache;
TxHiResCache *_txHiResCache;
TxUtil *_txUtil;
TxImage *_txImage;
boolean _initialized;
void clear();

View File

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

View File

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

View File

@ -30,7 +30,6 @@
class TxQuantize
{
private:
TxUtil *_txUtil;
int _numcore;
/* fast optimized... well, sort of. */

View File

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