How to detect hardware acceleration for Core Image?

南楼画角 提交于 2019-12-04 19:15:29

I found the answer in Technical Q&A QA1218
"How do I tell if a particular display is being hardware accelerated by Quartz Extreme?"

It's as simple as this:

NSNumber* curScreenNum = [self.window.screen.deviceDescription objectForKey:@"NSScreenNumber"];
if (CGDisplayUsesOpenGLAcceleration(curScreenNum.integerValue))
{
    // Do accelerated stuff
}

Works as expected in my cases.

https://developer.apple.com/library/ios/documentation/graphicsimaging/Conceptual/CoreImaging/ci_concepts/ci_concepts.html#//apple_ref/doc/uid/TP30001185-CH2-TPXREF101

I guess you could go with this to determine whether your desired filters are available. They probably shouldn't be available if Core Image is not available.

If filterNamesInCategory returns the CIMotionBlur filter's name even when it is not available then you should file a bug report with Apple's bug reporter.

As a further test, you could call filterWithName and check for a non-nil result. If you get back nil, you know the filter is available.

Or are you saying that on platforms without hardware acceleration, you get back a filter but it doesn't work? If that's the case then again, time to file a bug report.

Or, are you saying that on non-hardware-accellerated platforms, you get back a filter that works, but it is too slow to be useful?

Poking around in the docs I don't see any way to tell if Core Image is hardware-accellerated for a given platform or not.

However, CI filters are built on top of OpenGL, and you CAN query the OpenGL driver to see if it's hardware-accellerated or not. My guess is that the result of such a query would also tell you if CIFilters were hardware-accellerated or not.

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