diff options
author | Lukas Rusak <lorusak@gmail.com> | 2023-04-13 09:00:06 -0700 |
---|---|---|
committer | Lukas Rusak <lorusak@gmail.com> | 2023-04-14 20:45:47 -0700 |
commit | 3e102ce67bdc3fa4c87ba902bc31fa6c3a918c9a (patch) | |
tree | e016d5346fc78eb0b2b9c6a14f06f7a29749184f | |
parent | 2084b0f60b4ca7c193c6b0ddc7e07dd56b42dec8 (diff) |
TexturePacker: DecoderManager: use as a proper class
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
3 files changed, 15 insertions, 17 deletions
diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.cpp b/tools/depends/native/TexturePacker/src/DecoderManager.cpp index 5d900d7bfe..9f0ae6746c 100644 --- a/tools/depends/native/TexturePacker/src/DecoderManager.cpp +++ b/tools/depends/native/TexturePacker/src/DecoderManager.cpp @@ -20,23 +20,20 @@ #include <cstdio> #include "DecoderManager.h" -bool DecoderManager::verbose; -std::vector<IDecoder *> DecoderManager::m_decoders; - // ADD new decoders here // include decoders #include "PNGDecoder.h" #include "JPGDecoder.h" #include "GIFDecoder.h" -void DecoderManager::InstantiateDecoders() +DecoderManager::DecoderManager() { m_decoders.push_back(new PNGDecoder()); m_decoders.push_back(new JPGDecoder()); m_decoders.push_back(new GIFDecoder()); } -void DecoderManager::FreeDecoders() +DecoderManager::~DecoderManager() { for (unsigned int i = 0; i < m_decoders.size(); i++) { diff --git a/tools/depends/native/TexturePacker/src/DecoderManager.h b/tools/depends/native/TexturePacker/src/DecoderManager.h index 8ef479ceb1..a4b1050fdd 100644 --- a/tools/depends/native/TexturePacker/src/DecoderManager.h +++ b/tools/depends/native/TexturePacker/src/DecoderManager.h @@ -25,12 +25,13 @@ class DecoderManager { public: - static void InstantiateDecoders(); - static void FreeDecoders(); - static bool IsSupportedGraphicsFile(char *strFileName); - static bool LoadFile(const std::string& filename, DecodedFrames& frames); - static bool verbose; + DecoderManager(); + ~DecoderManager(); + + bool IsSupportedGraphicsFile(char* strFileName); + bool LoadFile(const std::string& filename, DecodedFrames& frames); + bool verbose; private: - static std::vector<IDecoder *> m_decoders; + std::vector<IDecoder*> m_decoders; }; diff --git a/tools/depends/native/TexturePacker/src/TexturePacker.cpp b/tools/depends/native/TexturePacker/src/TexturePacker.cpp index 0d2b89508f..e61d6b8eb0 100644 --- a/tools/depends/native/TexturePacker/src/TexturePacker.cpp +++ b/tools/depends/native/TexturePacker/src/TexturePacker.cpp @@ -51,6 +51,8 @@ #define DIR_SEPARATOR '/' +static DecoderManager decoderManager; + const char *GetFormatString(unsigned int format) { switch (format) @@ -103,7 +105,7 @@ void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, CreateSkeletonHeaderImpl(xbtfWriter, fullPath + DIR_SEPARATOR + dp->d_name, tmpPath + dp->d_name); } - else if (DecoderManager::IsSupportedGraphicsFile(dp->d_name)) + else if (decoderManager.IsSupportedGraphicsFile(dp->d_name)) { std::string fileName = ""; if (relativePath.size() > 0) @@ -287,7 +289,7 @@ int createBundle(const std::string& InputDir, const std::string& OutputFile, dou output += ' '; DecodedFrames frames; - bool loaded = DecoderManager::LoadFile(fullPath, frames); + bool loaded = decoderManager.LoadFile(fullPath, frames); if (!loaded) { @@ -384,7 +386,7 @@ int main(int argc, char* argv[]) } else if (!strcmp(args[i], "-verbose")) { - DecoderManager::verbose = true; + decoderManager.verbose = true; } else if (!platform_stricmp(args[i], "-output") || !platform_stricmp(args[i], "-o")) { @@ -411,8 +413,6 @@ int main(int argc, char* argv[]) if (pos != InputDir.length() - 1) InputDir += DIR_SEPARATOR; - double maxMSE = 1.5; // HQ only please - DecoderManager::InstantiateDecoders(); + double maxMSE = 1.5; // HQ only please createBundle(InputDir, OutputFilename, maxMSE, flags, dupecheck); - DecoderManager::FreeDecoders(); } |