Re: clearing (not erasing) when drawing from a thread
Re: clearing (not erasing) when drawing from a thread
- Subject: Re: clearing (not erasing) when drawing from a thread
- From: Alastair Houghton <email@hidden>
- Date: Mon, 26 Nov 2007 10:32:41 +0000
On 25 Nov 2007, at 23:57, m wrote:
Apologies in advance if this has already been answered. While
questions similar to mine have been posted, I wasn't able to locate
actual working answers.
On Tiger, when repeatedly drawing to a view from a thread, how do I
"clear out" what I drew before? NSEraseRect() won't work as it
erases to white. NSRectFillUsingOperation() with [NSColor
clearColor] results in a black rect. Tricks like erasing to the
background color won't work for me as there is no "the" background
color (my drawing will be placed over an arbitrary and possibly
changing background).
AFAIK you'd have to force the underlying views to refresh that part of
the display. That would be bad, because it would result in their
drawing code running from a thread, and not all views will be thread-
safe.
Layer-backed views would offer one way out if you were on Leopard, I
think, because they're composited together rather than simply drawn in
order into the same buffer. If you're on Tiger, I think you're either
going to have to use a child window, or manually save the background,
and draw that as the first step in your code. But the latter won't
work if the background is animating, so if that's a possibility then
you probably want to use a child window.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden