Let the tile data pack cache images so we aren't reloading them for various individual tiles within the image. Also, a couple minor efficiency improvements elsewhere.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@949 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -36,7 +36,10 @@ import nochump.util.zip.ZipFile;
|
|||||||
|
|
||||||
import com.threerings.media.image.PngRecolorUtil;
|
import com.threerings.media.image.PngRecolorUtil;
|
||||||
import com.threerings.util.DataPack;
|
import com.threerings.util.DataPack;
|
||||||
|
import com.threerings.util.Map;
|
||||||
|
import com.threerings.util.Maps;
|
||||||
import com.threerings.util.MultiLoader;
|
import com.threerings.util.MultiLoader;
|
||||||
|
import com.threerings.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like a normal data pack, but we don't deal with any data, and all our filenames are a direct
|
* Like a normal data pack, but we don't deal with any data, and all our filenames are a direct
|
||||||
@@ -86,7 +89,17 @@ public class TileDataPack extends DataPack
|
|||||||
|
|
||||||
public function getTileSetImage (path :String, zations :Array, callback :Function) :void
|
public function getTileSetImage (path :String, zations :Array, callback :Function) :void
|
||||||
{
|
{
|
||||||
MultiLoader.getContents(PngRecolorUtil.recolorPNG(getFile(path), zations), callback);
|
var key :String = zations == null ? path : path + ":" + StringUtil.toString(zations);
|
||||||
|
|
||||||
|
if (_cache.containsKey(key)) {
|
||||||
|
callback(_cache.get(key));
|
||||||
|
} else {
|
||||||
|
MultiLoader.getContents(PngRecolorUtil.recolorPNG(getFile(path), zations),
|
||||||
|
function(result :Bitmap) :void {
|
||||||
|
_cache.put(key, result);
|
||||||
|
callback(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTileImage (path :String, bounds :Rectangle, zations :Array,
|
public function getTileImage (path :String, bounds :Rectangle, zations :Array,
|
||||||
@@ -99,5 +112,8 @@ public class TileDataPack extends DataPack
|
|||||||
callback(new Bitmap(data));
|
callback(new Bitmap(data));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Cache of images loaded from this data pack. */
|
||||||
|
protected var _cache :Map = Maps.newMapOf(String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public /* abstract */ class TileSet
|
|||||||
// if it's not in the active set, it's not in memory; so load it
|
// if it's not in the active set, it's not in memory; so load it
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
tile = createTile();
|
tile = createTile();
|
||||||
tile.key = new Tile_Key(this, tileIndex, zations);
|
tile.key = key;
|
||||||
initTile(tile, tileIndex, zations);
|
initTile(tile, tileIndex, zations);
|
||||||
_atiles.put(tile.key, tile);
|
_atiles.put(tile.key, tile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,8 +272,6 @@ public class MisoScenePanel extends Sprite
|
|||||||
_objScene.layoutRenderer = new ClassFactory(PrioritizedSceneLayoutRenderer);
|
_objScene.layoutRenderer = new ClassFactory(PrioritizedSceneLayoutRenderer);
|
||||||
|
|
||||||
refreshBaseBlockScenes();
|
refreshBaseBlockScenes();
|
||||||
|
|
||||||
_isoView.addScene(_objScene);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ public class SceneBlock
|
|||||||
var y :int = getBlockY(_key);
|
var y :int = getBlockY(_key);
|
||||||
|
|
||||||
_baseScene = new IsoScene();
|
_baseScene = new IsoScene();
|
||||||
|
_baseScene.layoutEnabled = false;
|
||||||
for (var ii :int = x; ii < x + BLOCK_SIZE; ii++) {
|
for (var ii :int = x; ii < x + BLOCK_SIZE; ii++) {
|
||||||
for (var jj :int = y; jj < y + BLOCK_SIZE; jj++) {
|
for (var jj :int = y; jj < y + BLOCK_SIZE; jj++) {
|
||||||
var tileId :int = model.getBaseTileId(ii, jj);
|
var tileId :int = model.getBaseTileId(ii, jj);
|
||||||
|
|||||||
Reference in New Issue
Block a user