iOS:Core Graphics 是在 OpenGL 之上实现的吗? [英] iOS: is Core Graphics implemented on top of OpenGL?

查看:13
本文介绍了iOS:Core Graphics 是在 OpenGL 之上实现的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一张图,显示了在 OpenGL 之上实现的核心图形,另一张图将它与 OpenGL 放在一起.我认为 Apple 会很聪明地让每个人都能平等地使用图形硬件,但话说回来,我对他们使用的图形芯片了解不多……也许它一直是 3D 的?

I have found one diagram that shows Core Graphics implemented above OpenGL, and another that puts it alongside OpenGL. I would think that Apple would be smart to give each equal access to the graphics hardware but then again, I don't know much about the graphics chip they are using... maybe it is 3D all the way?

这里有人知道具体情况吗?

Does anybody here know the specifics?

推荐答案

是的,在 iOS 上,Core Graphics (Quartz) 似乎分层在 OpenGL ES 之上,用于针对屏幕进行绘制,尽管不是以我们明确的方式可以访问.

Yes, on iOS Core Graphics (Quartz) appears to be layered on top of OpenGL ES for drawing that targets the screen, although not in an explicit way that we have access to.

Core Graphics 采用矢量元素(线、弧线等)和一些光栅元素(图像)并处理它们以显示到屏幕或其他形式的输出(PDF 文件、打印等).如果目标是 iOS 上的屏幕,则这些矢量元素将直接或通过 UIView 的支持层托管在 CALayer 中.

Core Graphics takes vector elements (lines, arcs, etc.) and some raster ones (images) and processes them for display to the screen or for other forms of output (PDF files, printing, etc.). If the target is the screen on iOS, those vector elements will be hosted in a CALayer, either directly or through the backing layer of a UIView.

这些 Core Animation 层是 GPU 上矩形纹理的有效包装器,这就是 Core Animation 可以在甚至原始 iPhone 硬件上提供层的平滑平移、缩放和旋转的方式.我现在找不到它的参考资料,但至少有一个 WWDC 演示文稿指出 Core Animation 使用 OpenGL ES 与 GPU 通信以执行此硬件加速.在新的双 GPU MacBook Pro 上可以观察到类似的情况,当使用 Core Animation 与应用程序交互时,更强大的 GPU 会发挥作用.

These Core Animation layers are effectively wrappers around rectangular textures on the GPU, which is how Core Animation can provide the smooth translation, scaling, and rotation of layers on even the original iPhone hardware. I can't find a reference for it right now, but at least one WWDC presentation states that OpenGL ES is used by Core Animation to communicate with the GPU to perform this hardware acceleration. Something similar can be observed on the new dual-GPU MacBook Pros, where the more powerful GPU kicks in when interacting with an application using Core Animation.

因为 Core Graphics 在绘制到屏幕时将矢量和光栅元素光栅化为 CALayer,并且 CALayer 有效地包裹了 OpenGL ES 纹理,所以我会将 OpenGL ES 放在 iOS 上的 Core Graphics 下方,但仅适用于 Core图形正在渲染到屏幕上.您看到的层次结构中并排放置的原因可能是由于三个因素:在 Mac 上,并非所有视图都是分层支持的,因此它们可能不会以相同的方式进行硬件加速;我们不能真正与支持标准 UI 元素的 OpenGL ES 交互,因此从开发人员的角度来看,它们是不同的概念;和 Core Graphics 可用于渲染到屏幕外上下文,例如 PDF 文件或图像.

Because Core Graphics rasterizes the vector and raster elements into a CALayer when drawing to the screen, and a CALayer effectively wraps around an OpenGL ES texture, I would place OpenGL ES below Core Graphics on iOS, but only for the case where Core Graphics is rendering to the screen. The reason for the side-by-side placement in the hierarchy you saw may be due to three factors: on the Mac, not all views are layer-backed, so they may not be hardware accelerated in the same way; we can't really interact with the OpenGL ES backing of standard UI elements, so from a developer's point of view they are distinct concepts; and Core Graphics can be used to render to offscreen contexts, like PDF files or images.

这篇关于iOS:Core Graphics 是在 OpenGL 之上实现的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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