Factored some duplicated code into a shared method that can be used to easily

and efficiently dirty old and new bounds when our bounds change.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@88 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Michael Bayne
2006-12-05 06:51:41 +00:00
parent 8286ef88c4
commit 7850123988
3 changed files with 43 additions and 32 deletions
@@ -154,8 +154,8 @@ public abstract class Sprite extends AbstractMedia
return; // no-op
}
// start with our current bounds
Rectangle dirty = new Rectangle(_bounds);
// make a note of our current bounds
Rectangle obounds = new Rectangle(_bounds);
// move ourselves
_ox = x;
@@ -165,19 +165,8 @@ public abstract class Sprite extends AbstractMedia
// of our current bounds
updateRenderOrigin();
// grow the dirty rectangle to incorporate our new bounds and pass
// the dirty region to our region manager
if (_mgr != null) {
// if our new bounds intersect our old bounds, grow a single
// dirty rectangle to incorporate them both
if (_bounds.intersects(dirty)) {
dirty.add(_bounds);
} else {
// otherwise invalidate our new bounds separately
_mgr.getRegionManager().invalidateRegion(_bounds);
}
_mgr.getRegionManager().addDirtyRegion(dirty);
}
// this method will invalidate our old and new bounds efficiently
invalidateAfterChange(obounds);
}
// documentation inherited