com.threerings.media
Class RegionManager

java.lang.Object
  extended by com.threerings.media.RegionManager

public class RegionManager
extends Object

Manages regions (rectangles) that are invalidated in the process of ticking animations and sprites and generally doing other display related business.


Field Summary
protected  List<Rectangle> _dirty
          A list of dirty rectangles.
 
Constructor Summary
RegionManager()
           
 
Method Summary
 void addDirtyRegion(Rectangle rect)
          Adds the supplied rectangle to the dirty regions.
 Rectangle[] getDirtyRegions()
          Merges all outstanding dirty regions into a single list of rectangles and returns that to the caller.
 boolean haveDirtyRegions()
          Returns true if dirty regions have been accumulated since the last call to getDirtyRegions().
 void invalidateRegion(int x, int y, int width, int height)
          Invalidates the specified region.
 void invalidateRegion(Rectangle rect)
          Invalidates the specified region (the supplied rectangle will be cloned as the region manager fiddles with the rectangles it uses internally).
protected  boolean isValidSize(int width, int height)
          Used to ensure our dirty regions are not invalid.
 List<Rectangle> peekDirtyRegions()
          Returns our unmerged list of dirty regions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dirty

protected List<Rectangle> _dirty
A list of dirty rectangles.

Constructor Detail

RegionManager

public RegionManager()
Method Detail

invalidateRegion

public void invalidateRegion(int x,
                             int y,
                             int width,
                             int height)
Invalidates the specified region.


invalidateRegion

public void invalidateRegion(Rectangle rect)
Invalidates the specified region (the supplied rectangle will be cloned as the region manager fiddles with the rectangles it uses internally).


addDirtyRegion

public void addDirtyRegion(Rectangle rect)
Adds the supplied rectangle to the dirty regions. Control of the rectangle is given to the region manager as it may choose to bend, fold or mutilate it later. If you don't want the region manager messing with your rectangle, use invalidateRegion(int, int, int, int).


isValidSize

protected final boolean isValidSize(int width,
                                    int height)
Used to ensure our dirty regions are not invalid.


haveDirtyRegions

public boolean haveDirtyRegions()
Returns true if dirty regions have been accumulated since the last call to getDirtyRegions().


peekDirtyRegions

public List<Rectangle> peekDirtyRegions()
Returns our unmerged list of dirty regions. Do not modify the returned list. It's just for peeking. Unlike getDirtyRegions(), this does not clear out the list of dirty regions and prepare for the next frame.


getDirtyRegions

public Rectangle[] getDirtyRegions()
Merges all outstanding dirty regions into a single list of rectangles and returns that to the caller. Internally, the list of accumulated dirty regions is cleared out and prepared for the next frame.