Skip navigation.
 
mlRe: clearing (not erasing) when drawing from a thread
FROM : Murat Konar
DATE : Mon Nov 26 20:22:15 2007

Having thought this over, and reflecting on what is probably going on 
in the normal case of drawing, I have concluded that what I'm after 
is not generally possible.

Here's my reasoning; I'd be happy to be proved wrong, but here goes:

Loosely, when I'm drawing to a window from a thread, I am asking to 
have my image to be composited onto a bitmap that is shared by all 
views in the window.

In Cocoa's normal drawing, the entire view stack is re-composited, 
one view at a time. The effect of having my superviews composited 
onto the shared bitmap before I draw is that what ever I drew before 
has been effectively erased.

When drawing from a thread, I don't have the benefit of my superviews 
clearing out what I drew before, and calling  drawRect: on all my 
superviews is obviously not a solution.

The only alternative I can think of is to periodically grab an image 
of the composited view stack (minus my view) on the main thread, and 
feed it to my thread, then from my thread composite my stuff on top 
of the image then draw the result.

_murat


On Nov 26, 2007, at 7:58 AM, Matt Neuburg wrote:

> On Sun, 25 Nov 2007 15:57:10 -0800, m <<email_removed>> said:

>>            [tiffImage drawAtPoint:NSMakePoint(0, 0)
>> fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
>>
>> The problem is that successive frames of my image get composited on
>> top of each other

>
> Possibly this has something to do with what NSCompositeSourceOver 
> means. It
> might help to experiment with other options...
>

>> (my drawing will be placed over an arbitrary and possibly changing 
>> background)

>
> But you are still the one drawing that background, right? So if 
> necessary
> you *could* draw it again in the area where the image is to go, right?
>
> Just some things to think about - These are the sorts of 
> considerations that
> have led me to solutions of similar problems in the past... m.

Related mailsAuthorDate
mlclearing (not erasing) when drawing from a thread m Nov 26, 00:57
mlRe: clearing (not erasing) when drawing from a thread Alastair Houghton Nov 26, 11:32
mlRe: clearing (not erasing) when drawing from a thread Matt Neuburg Nov 26, 16:58
mlRe: clearing (not erasing) when drawing from a thread Murat Konar Nov 26, 20:22
mlRe: clearing (not erasing) when drawing from a thread Murat Konar Nov 26, 20:24