How do you run Core Animation and Core Image together on the CPU?

给你一囗甜甜゛ 提交于 2019-12-23 22:25:58

问题


Apple's Core Image Programming Guide, under the section "Getting the Best Performance" says

Avoid Core Animation animations while rendering CIImage objects with a GPU context.

If you need to use both simultaneously, you can set up both to use the CPU.

Can anyone explain this statement? Why it would be more efficient to run Core Animation and Core Image together on the CPU, rather than using the GPU?

How do you set up Core Animation to run on the CPU?


回答1:


I had the same question and came across this WWDC 2013 session 509 comment, http://asciiwwdc.com/2013/sessions/509 :

"And also be aware that both Core Animation and Core Image both make extensive use of the GPU.

So if you want your Core Animations to be smooth, you want to either stagger your Core Image operations or use a CPU CIContext so that they don't put pressure on the GPU at the same time."




回答2:


My guess they don't work simultaneously on GPU is they are both running on main thread when rendering on GPU, which will cause unpredicted problem and performance overhead, as for why they should both using CPU, should be to keep 'simultaneously'.

Since core graphics drawing is on CPU, you can draw the animation in drawRect and call setNeesDisplay periodically to performa animation on CPU.



来源:https://stackoverflow.com/questions/34867883/how-do-you-run-core-animation-and-core-image-together-on-the-cpu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!