Mac OS X: Can one process render to another process's window?

后端 未结 3 1824
难免孤独
难免孤独 2020-12-23 10:18

Greetings!

I\'m currently porting a web browser plugin from Win32 to MacOSX. One of the features of the plugin is that when the plugin is loaded, it spawns a separat

相关标签:
3条回答
  • 2020-12-23 10:58

    I was investigating a solution to this almost a year ago. I started a few threads on the apple mailing lists:

    http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg08056.html

    http://www.mail-archive.com/quartzcomposer-dev@lists.apple.com/msg01878.html

    http://lists.apple.com/archives/mac-opengl/2008/May/msg00099.html

    I had to revert to a solution which used CGWindowListCreateImage which took a screen grab of the opengl process window and convert it to a bitmap for display in the main process window. This is far from effeicient since pixel data is transfered from video ram to system ram.

    I also tried a floating window solution. The opengl process window floated above the main process window and respond to mouse movements from the main window. But I had issues with dragging lag and window z order.

    You would think NSWindowSharingReadWrite would do what you require, but doumentation/examples back then were practically non existent.

    But maybe things have changed in the last year. Keep me posted if you find anything new !

    Good luck

    JC

    0 讨论(0)
  • 2020-12-23 11:03

    A window in one process can be written to by another process, seemingly if the NSWindowSharingType is set to NSWindowSharingReadWrite. That was added in Leopard. Note that I haven't used this myself, but I would say that it at least removes the "can't be done" obstacle for you ;-)

    0 讨论(0)
  • 2020-12-23 11:08

    Here is the overall answer received from Apple's development team.

    There is essentially no way to do this in MacOSX 10.5 and earlier that is as clean as attaching an OpenGL rendering context to another process's window. The hacks people have developed may be the best solutions in those cases.

    The closest thing we have in MacOS 10.6 is the IOSurface system; using that in 10.6 seems to be the cleanest solution. If you want clicks in the rendered-to process to be intercepted by the rendering process, you'll have to bundle up the events yourself and pass them to the rendering process using whatever method you find most appropriate.

    More information on IOSurface could be found in this StackOverflow entry

    0 讨论(0)
提交回复
热议问题