混合 CGLayers 和 CALayers
设置如下:
我有一个 NSView,它是 CALayer 支持的视图,并且包含许多 CALayer。我有一个用于视图“背景”的 CALayer,以及许多作为子层的小 CALayer。有时,此视图可能非常大(大至 2560x1400),并且当它出现时,CALayers 中会出现非常明显的滞后。我的猜测是,核心动画在处理非常大的 CALayers 时会遇到一些问题。
所以,我想将这个“背景”层从 CALayer 更改为 CGLayer 或其他东西,它将像普通的 CGLayer 一样渲染到视图中。然而,最重要的是,小型 CALayers 仍将像现在一样运行。这样我只有小的 CALayer,“背景”层可以缓存在 CGLayer 中,希望性能会显着提高。
有人知道这是如何实现的吗?
Here's the setup:
I have a NSView which is a CALayer-backed view, and contains many CALayers. I have a CALayer for the 'background' of the view, and many small CALayers which are sublayers. Sometimes this view can be very big (as large as 2560x1400), and when it does there is a very noticeable lag in the CALayers. My guess is that Core Animation has some trouble with very large CALayers.
So, I would like to change this 'background' layer from being a CALayer to maybe a CGLayer or something, where it would be rendered like a normal CGLayer into the view. However, on top of it, the small CALayers would still operate just as they do now. That way I only have small CALayers, the 'background' layer can be cached in a CGLayer, and hopefully the performance will significantly increase.
Anyone know how this could be accomplished?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多研究后,这似乎无法完成。 NSView 要么由 CALayer 支持,要么不是。
After researching more, it doesn't look like this can be accomplished. An NSView is either CALayer-backed, or it's not.