We've discovered that setting the clipping rectangle generates a crapload

of rectangle objects. Thus rendering hundreds of tiles each frame has an
"undesirable" impact on garbage collection. I think Walter and I were
seeing something like 400k per second of garbage. So we're back to
extracting a subimage, which we're pretty sure doesn't copy the image
data, but simply draws the cropped image data directly from the original
rasters without creating shitloads of garbage.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1474 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-18 22:19:56 +00:00
parent f84b6b1e26
commit 4b29f806df
+10 -15
View File
@@ -1,5 +1,5 @@
//
// $Id: Tile.java,v 1.19 2002/05/06 18:08:32 mdb Exp $
// $Id: Tile.java,v 1.20 2002/06/18 22:19:56 mdb Exp $
package com.threerings.media.tile;
@@ -30,6 +30,7 @@ public class Tile implements Cloneable
{
_image = image;
_bounds = bounds;
_subimage = getImage();
}
/**
@@ -54,20 +55,11 @@ public class Tile implements Cloneable
*/
public void paint (Graphics gfx, int x, int y)
{
Shape oclip = gfx.getClip();
gfx.clipRect(x, y, getWidth(), getHeight());
gfx.drawImage(_image, x - _bounds.x, y - _bounds.y, null);
gfx.setClip(oclip);
}
/**
* Render the tile image at the top-left corner of the given shape in
* the given graphics context.
*/
public void paint (Graphics gfx, Shape dest)
{
Rectangle bounds = dest.getBounds();
paint(gfx, bounds.x, bounds.y);
// Shape oclip = gfx.getClip();
// gfx.clipRect(x, y, getWidth(), getHeight());
// gfx.drawImage(_image, x - _bounds.x, y - _bounds.y, null);
// gfx.setClip(oclip);
gfx.drawImage(_subimage, x, y, null);
}
/**
@@ -135,6 +127,9 @@ public class Tile implements Cloneable
/** Our tileset image. */
protected Image _image;
/** Our cropped tileset image. */
protected Image _subimage;
/** The bounds of the tile image within the tileset image. */
protected Rectangle _bounds;
}