aboutsummaryrefslogtreecommitdiff
path: root/tools/depends/native/TexturePacker/src
diff options
context:
space:
mode:
authorStefan Saraev <stefan@saraev.ca>2016-02-07 21:42:37 +0200
committerStefan Saraev <stefan@saraev.ca>2016-02-13 15:38:52 +0200
commit8f787d5623dfeeb74fc462f01c303c3413e58189 (patch)
tree83f21e1dcf6f47ad29e8bb5693b4e1767e950c35 /tools/depends/native/TexturePacker/src
parent5c46079095c97b92185b26278ff640f33e7bf57c (diff)
[texturepacker] remove squish usage
Diffstat (limited to 'tools/depends/native/TexturePacker/src')
-rw-r--r--tools/depends/native/TexturePacker/src/TexturePacker.cpp72
1 files changed, 4 insertions, 68 deletions
diff --git a/tools/depends/native/TexturePacker/src/TexturePacker.cpp b/tools/depends/native/TexturePacker/src/TexturePacker.cpp
index 1179eea9a5..2835cdef69 100644
--- a/tools/depends/native/TexturePacker/src/TexturePacker.cpp
+++ b/tools/depends/native/TexturePacker/src/TexturePacker.cpp
@@ -39,7 +39,6 @@
#include "XBTFWriter.h"
#include "md5.h"
#include "cmdlineargs.h"
-#include "squish.h"
#ifdef TARGET_WINDOWS
#define strncasecmp _strnicmp
@@ -56,8 +55,6 @@
using namespace std;
#define FLAGS_USE_LZO 1
-#define FLAGS_ALLOW_YCOCG 2
-#define FLAGS_USE_DXT 4
#define DIR_SEPARATOR "/"
@@ -196,12 +193,6 @@ CXBTFFrame appendContent(CXBTFWriter &writer, int width, int height, unsigned ch
return frame;
}
-void CompressImage(const squish::u8 *brga, int width, int height, squish::u8 *compressed, unsigned int flags, double &colorMSE, double &alphaMSE)
-{
- squish::CompressImage(brga, width, height, compressed, flags | squish::kSourceBGRA);
- squish::ComputeMSE(brga, width, height, compressed, flags | squish::kSourceBGRA, colorMSE, alphaMSE);
-}
-
bool HasAlpha(unsigned char *argb, unsigned int width, unsigned int height)
{
unsigned char *p = argb + 3; // offset of alpha
@@ -219,63 +210,14 @@ CXBTFFrame createXBTFFrame(RGBAImage &image, CXBTFWriter& writer, double maxMSE,
int width, height;
unsigned int format = 0;
unsigned char* argb = (unsigned char*)image.pixels;
- unsigned int compressedSize = 0;
- unsigned char* compressed = NULL;
width = image.width;
height = image.height;
bool hasAlpha = HasAlpha(argb, width, height);
- if (flags & FLAGS_USE_DXT)
- {
- double colorMSE, alphaMSE;
- compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt5);
- compressed = new unsigned char[compressedSize];
- // first try DXT1, which is only 4bits/pixel
- CompressImage(argb, width, height, compressed, squish::kDxt1, colorMSE, alphaMSE);
- if (colorMSE < maxMSE && alphaMSE < maxMSE)
- { // success - use it
- compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt1);
- format = XB_FMT_DXT1;
- }
-
- if (!format)
- { // try DXT3 and DXT5 - use whichever is better (color is the same, but alpha will be different)
- CompressImage(argb, width, height, compressed, squish::kDxt3, colorMSE, alphaMSE);
- if (colorMSE < maxMSE)
- { // color is fine, test DXT5 as well
- double dxt5MSE;
- squish::u8* compressed2 = new squish::u8[squish::GetStorageRequirements(width, height, squish::kDxt5)];
- CompressImage(argb, width, height, compressed2, squish::kDxt5, colorMSE, dxt5MSE);
- if (alphaMSE < maxMSE && alphaMSE < dxt5MSE)
- { // DXT3 passes and is best
- compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt3);
- format = XB_FMT_DXT3;
- }
- else if (dxt5MSE < maxMSE)
- { // DXT5 passes
- compressedSize = squish::GetStorageRequirements(width, height, squish::kDxt5);
- memcpy(compressed, compressed2, compressedSize);
- format = XB_FMT_DXT5;
- }
- delete[] compressed2;
- }
- }
- }
-
CXBTFFrame frame;
- if (format)
- {
- frame = appendContent(writer, width, height, compressed, compressedSize, format, hasAlpha, flags);
- if (compressedSize)
- delete[] compressed;
- }
- else
- {
- // none of the compressed stuff works for us, so we use 32bit texture
- format = XB_FMT_A8R8G8B8;
- frame = appendContent(writer, width, height, argb, (width * height * 4), format, hasAlpha, flags);
- }
+ format = XB_FMT_A8R8G8B8;
+ frame = appendContent(writer, width, height, argb, (width * height * 4), format, hasAlpha, flags);
return frame;
}
@@ -288,7 +230,6 @@ void Usage()
puts(" -output <dir> Output directory/filename. Default: Textures.xpr");
puts(" -dupecheck Enable duplicate file detection. Reduces output file size. Default: off");
puts(" -disable_lzo Disable lz0 packing");
- puts(" -disable_dxt Disable DXT compression");
}
static bool checkDupe(struct MD5Context* ctx,
@@ -425,10 +366,9 @@ int main(int argc, char* argv[])
bool dupecheck = false;
CmdLineArgs args(argc, (const char**)argv);
- // setup some defaults, dxt with lzo post packing,
- flags = FLAGS_USE_DXT;
+ // setup some defaults, lzo packing,
#ifdef USE_LZO_PACKING
- flags |= FLAGS_USE_LZO;
+ flags = FLAGS_USE_LZO;
#endif
if (args.size() == 1)
@@ -465,10 +405,6 @@ int main(int argc, char* argv[])
while ((c = (char *)strchr(OutputFilename.c_str(), '\\')) != NULL) *c = '/';
#endif
}
- else if (!platform_stricmp(args[i], "-disable_dxt"))
- {
- flags &= ~FLAGS_USE_DXT;
- }
#ifdef USE_LZO_PACKING
else if (!platform_stricmp(args[i], "-disable_lzo"))
{