Re: Coalesced updates = pain
Re: Coalesced updates = pain
- Subject: Re: Coalesced updates = pain
- From: John Stiles <email@hidden>
- Date: Fri, 22 Jul 2005 19:01:59 -0700
On Jul 22, 2005, at 6:47 PM, John Stiles wrote:
On Jul 22, 2005, at 5:36 PM, Corbin Dunn wrote:
Hmm, that didn't exist when I wrote the code back on OS X 10.2 :)
I guess I will use that technique on 10.3+ and use displayRect on
10.2.
Yes; it came about to address this very problem!
But it's not helping! :(
I can't use this. If any rectangles overlap, it breaks them up into
multiple little sub-rectangles which confuse my rendering code. I
can see what it's trying to accomplish, but my rendering code
doesn't work well with these arbitrary rectangles. I just want the
rectangles that I originally passed in.
I think I am going to try an alternate approach. Thanks for the
help, though. It got me thinking.
For the benefit of the list, my (pseudocode) solution was as follows.
It might not be ideal but it seems to work really well in practice.
- Add a member to my NSView subclass, "rectsToUpdate". It's an array
of the rectangles I want to draw.
- Call displayRect like this:
unionRect = aUnionOfAllTheRectsIn( myRectangleList );
// Call displayRect and include the update hint so it
doesn't update more than necessary.
rectsToUpdate = &myRectangleList;
[self displayRect:unionRect];
rectsToUpdate = NULL;
- Redo my drawRect to look like this:
- (void) drawRect:(NSRect)rect
{
if( rectsToUpdate != NULL )
{
// My animation code initiated the draw.
... draw each of the rectsToUpdate
}
else
{
// The system initiated the draw.
... draw the passed in rect
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden