From 4b29f806df51147a1c2bb81c2d63215a7a762adc Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 18 Jun 2002 22:19:56 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/tile/Tile.java | 25 ++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/java/com/threerings/media/tile/Tile.java b/src/java/com/threerings/media/tile/Tile.java index 6a854c81b..635f7bc54 100644 --- a/src/java/com/threerings/media/tile/Tile.java +++ b/src/java/com/threerings/media/tile/Tile.java @@ -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; }