Added support for obtaining estimated memory usage of a tile; modified
tile cache to be based on memory usage rather than tile count. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2175 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Tile.java,v 1.26 2003/01/13 22:49:46 mdb Exp $
|
// $Id: Tile.java,v 1.27 2003/01/17 02:30:50 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -39,6 +39,14 @@ public class Tile implements Cloneable
|
|||||||
return _mirage.getHeight();
|
return _mirage.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the estimated memory usage of our underlying tile image.
|
||||||
|
*/
|
||||||
|
public long getEstimatedMemoryUsage ()
|
||||||
|
{
|
||||||
|
return _mirage.getEstimatedMemoryUsage();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the tile image at the specified position in the given
|
* Render the tile image at the specified position in the given
|
||||||
* graphics context.
|
* graphics context.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileSet.java,v 1.39 2003/01/15 02:36:18 mdb Exp $
|
// $Id: TileSet.java,v 1.40 2003/01/17 02:30:50 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -142,8 +142,12 @@ public abstract class TileSet
|
|||||||
// create our tile cache if necessary
|
// create our tile cache if necessary
|
||||||
if (_tiles == null) {
|
if (_tiles == null) {
|
||||||
int tcsize = _cacheSize.getValue();
|
int tcsize = _cacheSize.getValue();
|
||||||
Log.debug("Creating tile cache [size=" + tcsize + "].");
|
Log.debug("Creating tile cache [size=" + tcsize + "k].");
|
||||||
_tiles = new LRUHashMap(tcsize);
|
_tiles = new LRUHashMap(tcsize*1024, new LRUHashMap.ItemSizer() {
|
||||||
|
public int computeSize (Object value) {
|
||||||
|
return (int)((Tile)value).getEstimatedMemoryUsage();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch and cache the tile
|
// fetch and cache the tile
|
||||||
@@ -305,6 +309,7 @@ public abstract class TileSet
|
|||||||
* framework. */
|
* framework. */
|
||||||
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
||||||
new RuntimeAdjust.IntAdjust(
|
new RuntimeAdjust.IntAdjust(
|
||||||
"Size (in tiles) of the tile LRU cache [requires reboot]",
|
"Size (in kb of memory used) of the tile LRU cache " +
|
||||||
"narya.media.tile.cache_size", MediaPrefs.config, 500);
|
"[requires restart]", "narya.media.tile.cache_size",
|
||||||
|
MediaPrefs.config, 1024);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user