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).

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
  • Out of interest can you elaborate on what exactly you're trying to do with this? Is it some kind of annotation of another application? – Tom Duckering Dec 21 '09 at 11:55
  • I have one 'master' application and *n* browser plugins that have drawable areas. Ideally i'd like to avoid exchanging image data through an additional buffer in shared memory. – Georg Fritzsche Dec 21 '09 at 11:57
  • possible duplicate of [Mac OS X: Can one process render to another process's window?](http://stackoverflow.com/questions/583202/mac-os-x-can-one-process-render-to-another-processs-window) – Georg Fritzsche Feb 15 '12 at 05:03

1 Answers1

2

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?

Community
  • 1
  • 1
Thomas Zoechling
  • 34,177
  • 3
  • 81
  • 112
  • 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 Dec 21 '09 at 12:15
  • 1
    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. – Thomas Zoechling Dec 21 '09 at 12:38
  • 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 Dec 21 '09 at 14:00
  • Well, i wasn't more successful... so i'm accepting your answer. – Georg Fritzsche Mar 11 '10 at 20:17