Pass the dirty rectangle for a dirty item to its paint() method so

that we can join multiple dirty rectangles for an item into a single
larger item but still rely on the dirty item to know how to paint
itself.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@515 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-10-22 18:14:57 +00:00
parent 7d667778b1
commit 841f732174
@@ -1,5 +1,5 @@
// //
// $Id: DirtyItemList.java,v 1.3 2001/10/19 23:26:31 shaper Exp $ // $Id: DirtyItemList.java,v 1.4 2001/10/22 18:14:57 shaper Exp $
package com.threerings.media.sprite; package com.threerings.media.sprite;
@@ -64,13 +64,15 @@ public class DirtyItemList extends ArrayList
/** /**
* Paints the dirty item to the given graphics context. Only * Paints the dirty item to the given graphics context. Only
* the dirty rectangle of the item is question is actually * the portion of the item that falls within the given dirty
* drawn. * rectangle is actually drawn.
*/ */
public void paint (Graphics2D gfx) public void paint (Graphics2D gfx, Rectangle clip)
{ {
Shape oclip = gfx.getClip();
// clip the draw region to the dirty portion of the item // clip the draw region to the dirty portion of the item
gfx.setClip(dirtyRect); gfx.clip(clip);
// paint the item // paint the item
if (obj instanceof Sprite) { if (obj instanceof Sprite) {
@@ -78,6 +80,14 @@ public class DirtyItemList extends ArrayList
} else { } else {
((ObjectTile)obj).paint(gfx, bounds); ((ObjectTile)obj).paint(gfx, bounds);
} }
// restore original clipping region
gfx.setClip(oclip);
}
public String toString ()
{
return "[obj=" + obj + ", x=" + x + ", y=" + y + "]";
} }
} }
} }