混合 CGLayers 和 CALayers

发布于 2024-09-25 17:44:11 字数 371 浏览 9 评论 0原文

设置如下:

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两相知 2024-10-02 17:44:11

经过更多研究后,这似乎无法完成。 NSView 要么由 CALayer 支持,要么不是。

After researching more, it doesn't look like this can be accomplished. An NSView is either CALayer-backed, or it's not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文