Mac OS X:一个进程可以渲染到另一个进程的窗口吗? [英] Mac OS X: Can one process render to another process's window?

查看:184
本文介绍了Mac OS X:一个进程可以渲染到另一个进程的窗口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候!

我当前正在将Web浏览器插件从Win32移植到MacOSX.插件的功能之一是,在加载插件时,它会生成一个单独的进程作为插件的引擎",并在插件的窗口中执行绘图操作(具体而言,是将OpenGL上下文附加到插件父进程的窗口并在该上下文中执行OpenGL渲染命令).我们这样做是因为插件通常在浏览器进程中作为线程加载,因此插件崩溃将导致整个浏览器瘫痪.通过将繁重的工作"划分为一个单独的过程,并使插件代码保持很小的规模,我们可以保护用户免受此类崩溃的影响.

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 separate process that serves as the "engine" of the plugin and executes drawing operations into the window of the plugin (specifically, by attaching an OpenGL context to the parent process's window and executing OpenGL rendering commands into that context). We do this because the plugin is typically loaded as a thread within the browser process, so crashes in the plugin would take down the whole browser. By partitioning the 'heavy lifting' into a separate process and keeping the plugin code very slim, we can protect users against such crashes.

我想在MacOSX上保留这种子进程渲染器体系结构,但是我听到一个令人讨厌的谣言(与Google Chrome浏览器有关),MacOSX不允许进程访问其窗口到另一个过程.我自己在这个领域内的搜寻尚无定论;如果有人对这个问题有任何了解,并且可以就如何实现该目标提供一些建议,或者可以说一个更具决定性的无法完成",那将是非常有帮助的.

I'd like to preserve this child-process-renderer architecture on MacOSX, but I've heard a nasty rumor (related to the Google Chrome web browser) that MacOSX doesn't allow a process to hand access to its windows to another process. My own search in this space has been inconclusive; if anyone has any knowledge of this problem and could either provide some advice on how to accomplish this goal or a more conclusive "can't be done," it would be extremely helpful.

谢谢您的帮助!

推荐答案

大约一年前,我正在研究一种解决方案.我在苹果邮件列表上开始了一些话题:

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/cocoa-dev@lists.apple.com/msg08056.html

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

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

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

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

我不得不恢复到使用CGWindowListCreateImage的解决方案,该解决方案获取了opengl进程窗口的屏幕抓图,并将其转换为位图以显示在主进程窗口中.由于像素数据是从视频ram传输到系统ram的,因此效率远非如此.

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.

我也尝试了浮动窗口解决方案. opengl进程窗口浮在主进程窗口上方,并响应鼠标从主窗口的移动.但是我在拖动滞后和窗口z顺序时遇到了问题.

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.

您会认为NSWindowSharingReadWrite可以满足您的要求,但是那时的重复/示例实际上是不存在的.

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 !

祝你好运

JC

这篇关于Mac OS X:一个进程可以渲染到另一个进程的窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆