It's not a perfect solution, but make it so we can call the tile trimming task and

not actually write out new image to a file if we don't need to. 

This cuts my tileset building from 42 seconds to 22 when no files have changed 
(as opposed to 4 when it was skipping it altogether, but winding up with a hosed 
tsbundles.dat), so it's at least a decent bit better.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@391 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2008-01-10 19:51:24 +00:00
parent 9458c0704a
commit 9733142d35
2 changed files with 22 additions and 17 deletions
@@ -87,25 +87,28 @@ public class DirectoryTileSetBundler extends TileSetBundler
try { try {
// create a trimmed object tileset, which will // create a trimmed object tileset, which will
// write the trimmed tileset image to the destination // write the trimmed tileset image to the destination output stream
// output stream
File outFile = new File(target, imagePath); File outFile = new File(target, imagePath);
FileOutputStream fout = null;
if (outFile.lastModified() > newestMod) { if (outFile.lastModified() > newestMod) {
// Our file's newer than the newest bundle mod - up to date. // Our file's newer than the newest bundle mod - up to date.
// So don't actually do anything
// FIXME: We can't just skip it, since we would've normally trimmed it, // TODO: Ideally, we'd like to skip re-trimming altogether, since that's
// so we need to get an appropriate TrimmedObjectTileSet added to our // expensive, but for the moment, we're at least doing half as much by
// bundle in place of this old ObjectTileSet. // not writing out the trimmed image.
//continue;
} } else {
// It's changed, so let's open the file & do all that jazz
outFile.getParentFile().mkdirs(); outFile.getParentFile().mkdirs();
FileOutputStream fout = new FileOutputStream(outFile); fout = new FileOutputStream(outFile);
}
TrimmedObjectTileSet tset = TrimmedObjectTileSet tset =
TrimmedObjectTileSet.trimObjectTileSet( TrimmedObjectTileSet.trimObjectTileSet((ObjectTileSet)set, fout, "png");
(ObjectTileSet)set, fout, "png");
tset.setImagePath(imagePath); tset.setImagePath(imagePath);
// replace the original set with the trimmed // replace the original set with the trimmed tileset in the tileset bundle
// tileset in the tileset bundle
bundle.addTileSet(tileSetId, tset); bundle.addTileSet(tileSetId, tset);
} catch (Exception e) { } catch (Exception e) {
@@ -151,6 +151,7 @@ public class TileSetTrimmer
xoff += tb.width; xoff += tb.width;
} }
if (destImage != null) {
// write out trimmed image // write out trimmed image
if (imgFormat == null || FastImageIO.FILE_SUFFIX.equals(imgFormat)) { if (imgFormat == null || FastImageIO.FILE_SUFFIX.equals(imgFormat)) {
FastImageIO.write(image, destImage); FastImageIO.write(image, destImage);
@@ -159,3 +160,4 @@ public class TileSetTrimmer
} }
} }
} }
}