views:

167

answers:

1

Is it possible to draw in other processes windows on MacOSX using Cocoa or other libraries?
If yes, are there any samples? Alternatively a quick summary of what i'd have to do?
(I need to support at least OSX 10.5)

Shared memory is of course a possible solution, but i'd prefer direct drawing to avoid synchronization overhead and code duplication (the use-case consists of one producer and n clients).

+2  A: 

This is a duplicate of Mac OS X: Can one process render to another process’s window?
Short answer: If you only need to support >=10.6, you could probably use the IOSurface API.
Details about that in this post: Need help with IOSurface & OpenGL for max os x snow leopard application

If you can provide more details about what you try to achieve, there might be some other solutions. (e.g. Compositing the things you intend to render onto an image from CGWindowListCreateImage)

Edit:
To me it seems that the easiest way to accomplish what you want is to use some sort of shared memory.
You could map the data to visualize into memory with mmap and share the drawing code between your applications.

Edit2: I just saw that you want to avoid shared memory. But why?

weichsel
Thanks for that. What i get out of it though is *it might work with NSWindowSharingReadWrite but i don't know how* - maybe someone figured it out in the mean-time?
Georg Fritzsche
Regarding the details: i have one master application with some video streams and multiple instances of a browser plugin that show the video streams in their drawing area.
Georg Fritzsche
I recently also investigated the sharing state (but for reading, not for writing) - I coulnd't find anything useful.If you are more successful, please post your results back here.
weichsel
Regarding shared memory, mainly 2 reasons: a) i don't want the overhead of synchronisation etc. b) i want to keep the drawing code out of the clients if possible. What if i'd e.g. decode directly in or into a video buffer?
Georg Fritzsche
Well, i wasn't more successful... so i'm accepting your answer.
Georg Fritzsche