Allow tile set bundles to be created uncompressed - this probably will go hand-in-hand with the keepRawPngs parameter, but I can imagine the two being used separately so I won't overload the single parameter.

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@958 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mike Thomas
2010-07-16 00:13:44 +00:00
parent a462e54e46
commit 665ed38c30
2 changed files with 22 additions and 6 deletions
@@ -132,17 +132,18 @@ public class TileSetBundler
public TileSetBundler (File configFile) public TileSetBundler (File configFile)
throws IOException throws IOException
{ {
this(configFile, false); this(configFile, false, false);
} }
/** /**
* Constructs a tileset bundler with the specified bundler config * Constructs a tileset bundler with the specified bundler config
* file and whether to keep pngs as-is or if not, re-encode them. * file and whether to keep pngs as-is or if not, re-encode them.
*/ */
public TileSetBundler (File configFile, boolean keepRawPngs) public TileSetBundler (File configFile, boolean keepRawPngs, boolean uncompressed)
throws IOException throws IOException
{ {
_keepRawPngs = keepRawPngs; _keepRawPngs = keepRawPngs;
_uncompressed = uncompressed;
// we parse our configuration with a digester // we parse our configuration with a digester
Digester digester = new Digester(); Digester digester = new Digester();
@@ -352,7 +353,7 @@ public class TileSetBundler
File target, TileSetBundle bundle, ImageProvider improv, String imageBase, long newestMod) File target, TileSetBundle bundle, ImageProvider improv, String imageBase, long newestMod)
throws IOException throws IOException
{ {
return createBundleJar(target, bundle, improv, imageBase, _keepRawPngs); return createBundleJar(target, bundle, improv, imageBase, _keepRawPngs, _uncompressed);
} }
/** /**
@@ -367,14 +368,14 @@ public class TileSetBundler
*/ */
public static boolean createBundleJar ( public static boolean createBundleJar (
File target, TileSetBundle bundle, ImageProvider improv, String imageBase, File target, TileSetBundle bundle, ImageProvider improv, String imageBase,
boolean keepOriginalPngs) boolean keepOriginalPngs, boolean uncompressed)
throws IOException throws IOException
{ {
// now we have to create the actual bundle file // now we have to create the actual bundle file
FileOutputStream fout = new FileOutputStream(target); FileOutputStream fout = new FileOutputStream(target);
Manifest manifest = new Manifest(); Manifest manifest = new Manifest();
JarOutputStream jar = new JarOutputStream(fout, manifest); JarOutputStream jar = new JarOutputStream(fout, manifest);
jar.setLevel(Deflater.BEST_COMPRESSION); jar.setLevel(uncompressed ? Deflater.NO_COMPRESSION : Deflater.BEST_COMPRESSION);
try { try {
// write all of the image files to the bundle, converting the // write all of the image files to the bundle, converting the
@@ -516,4 +517,7 @@ public class TileSetBundler
/** Whether we should keep pngs as-is rather than re-encoding. */ /** Whether we should keep pngs as-is rather than re-encoding. */
protected boolean _keepRawPngs; protected boolean _keepRawPngs;
/** Normally we compress the jar, but if we want to leave them uncompressed, we set this. */
protected boolean _uncompressed;
} }
@@ -75,6 +75,15 @@ public class TileSetBundlerTask extends Task
_keepRawPngs = keep; _keepRawPngs = keep;
} }
/**
* Note whether we are supposed to leave the jar uncompressed rather than the normal process
* of zipping it at maximum compression.
*/
public void setUncompressed (boolean uncompressed)
{
_uncompressed = uncompressed;
}
/** /**
* Performs the actual work of the task. * Performs the actual work of the task.
*/ */
@@ -146,7 +155,7 @@ public class TileSetBundlerTask extends Task
protected TileSetBundler createBundler () protected TileSetBundler createBundler ()
throws IOException throws IOException
{ {
return new TileSetBundler(_config, _keepRawPngs); return new TileSetBundler(_config, _keepRawPngs, _uncompressed);
} }
/** /**
@@ -173,4 +182,7 @@ public class TileSetBundlerTask extends Task
/** Whether we should keep raw pngs rather than reencoding them in the bundle. */ /** Whether we should keep raw pngs rather than reencoding them in the bundle. */
protected boolean _keepRawPngs; protected boolean _keepRawPngs;
/** Whether we should keep the bundle jars uncompressed rather than zipped. */
protected boolean _uncompressed;
} }