FROM : Murat Konar
DATE : Mon Nov 26 20:24:01 2007
Oops. That's what I get for reading messages in the wrong order. Yes,
I had already come to the conclusions you outlined.
_murat
On Nov 26, 2007, at 2:32 AM, Alastair Houghton wrote:
> 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.
>
DATE : Mon Nov 26 20:24:01 2007
Oops. That's what I get for reading messages in the wrong order. Yes,
I had already come to the conclusions you outlined.
_murat
On Nov 26, 2007, at 2:32 AM, Alastair Houghton wrote:
> 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.
>
| Related mails | Author | Date |
|---|---|---|
| m | Nov 26, 00:57 | |
| Alastair Houghton | Nov 26, 11:32 | |
| Matt Neuburg | Nov 26, 16:58 | |
| Murat Konar | Nov 26, 20:22 | |
| Murat Konar | Nov 26, 20:24 |






Cocoa mail archive

