This is DirtPile.h in view mode; [Download] [Up]
// This object tracks the dirty rectangle of the frame buffer. // If two rects overlap, they are coalesced. If they don't // overlap, they are kept separate. This way, when a redraw // is done, we have two flushes that are small rather than one // large flush. (The large flush would draw *lots* of unnecessary // pixels!) // Many thanks to Sam Streeper for giving me the idea to create this object. // It is based mostly upon code snippets which he gave me, which were taken // the game BoinkOut. Thanks, Sam! #import <appkit/appkit.h> #define MAX_RECTS 1024 // should be more than enough, and it's easier than // making it dynamic. (Not that I couldn't.... :-) ) extern BOOL coalesce(NXRect *p1, NXRect *p2); @interface DirtPile:Object { int maxRects; // max number of rects in list int numRects; // number of rects in list NXRect rectList[MAX_RECTS]; // list of dirty rects } - init; // initialize the instance - addRegion:(float)x :(float)y :(float)w :(float)h; // add a dirty rect - addRegion:(NXRect *)rect; // add a dirty rect - fullRedraw:sender :buffer; // assumed to be a view - doRedraw:buffer; // flush dirty rects from buffer to screen @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.