Allow image preparation to be turned off on a run by run basis

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@552 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2008-06-24 23:44:50 +00:00
parent 25d74475d9
commit 550c360df6
2 changed files with 18 additions and 6 deletions
@@ -44,6 +44,15 @@ public class ClientImageManager extends ImageManager
_runCacheSize = cacheKilobytes;
}
/**
* Sets if images should be recreated in the graphics context's preferred format before
* rendering. This must be called before the ImageManager is created.
*/
public static void setPrepareImages (boolean prepareImages)
{
_runPrepareImages = prepareImages;
}
public ClientImageManager (ResourceManager rmgr, OptimalImageCreator icreator)
{
super(rmgr, icreator);
@@ -75,7 +84,7 @@ public class ClientImageManager extends ImageManager
src = getImage(key, zations);
bounds = new Rectangle(0, 0, src.getWidth(), src.getHeight());
} else if (!_prepareImages.getValue()) {
} else if (!_runPrepareImages) {
src = getImage(key, zations);
percentageOfDataBuffer =
(bounds.width * bounds.height)/(float)(src.getHeight() * src.getWidth());
@@ -84,7 +93,7 @@ public class ClientImageManager extends ImageManager
if (_runBlank.getValue()) {
return new BlankMirage(bounds.width, bounds.height);
} else if (_prepareImages.getValue()) {
} else if (_runPrepareImages) {
return new CachedVolatileMirage(this, key, bounds, zations);
} else {
return new BufferedMirage(src, percentageOfDataBuffer);
@@ -107,6 +116,11 @@ public class ClientImageManager extends ImageManager
"Cause image manager to optimize all images for display.",
"narya.media.image.prep_images", MediaPrefs.config, true);
/**
* If images should be prepared for the graphics context in this run.
*/
protected static boolean _runPrepareImages = _prepareImages.getValue();
/** A debug toggle for running entirely without rendering images. */
protected static RuntimeAdjust.BooleanAdjust _runBlank = new RuntimeAdjust.BooleanAdjust(
"Cause image manager to return blank images.",
@@ -446,8 +446,7 @@ public class ImageUtil
} else {
// otherwise composite them by rendering them with an alpha
// rule
BufferedImage target = isrc.createImage(
wid, hei, Transparency.TRANSLUCENT);
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.drawImage(mask, 0, 0, null);
@@ -484,8 +483,7 @@ public class ImageUtil
// But it's something to consider)
// composite them by rendering them with an alpha rule
BufferedImage target = isrc.createImage(
wid, hei, Transparency.TRANSLUCENT);
BufferedImage target = isrc.createImage(wid, hei, Transparency.TRANSLUCENT);
Graphics2D g2 = target.createGraphics();
try {
g2.setColor(Color.BLACK); // whatever, really