From 841f732174aaa70cd6a8ccb6c23f0e034f6c74ed Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Mon, 22 Oct 2001 18:14:57 +0000 Subject: [PATCH] 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 --- .../media/sprite/DirtyItemList.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/media/sprite/DirtyItemList.java b/src/java/com/threerings/media/sprite/DirtyItemList.java index 074493fa2..13ebe54ca 100644 --- a/src/java/com/threerings/media/sprite/DirtyItemList.java +++ b/src/java/com/threerings/media/sprite/DirtyItemList.java @@ -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; @@ -64,13 +64,15 @@ public class DirtyItemList extends ArrayList /** * Paints the dirty item to the given graphics context. Only - * the dirty rectangle of the item is question is actually - * drawn. + * the portion of the item that falls within the given dirty + * 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 - gfx.setClip(dirtyRect); + gfx.clip(clip); // paint the item if (obj instanceof Sprite) { @@ -78,6 +80,14 @@ public class DirtyItemList extends ArrayList } else { ((ObjectTile)obj).paint(gfx, bounds); } + + // restore original clipping region + gfx.setClip(oclip); + } + + public String toString () + { + return "[obj=" + obj + ", x=" + x + ", y=" + y + "]"; } } }