划线时避免颜色空间转换,Mac OS X 10.11 SDK [英] Avoiding colorspace transformations when blitting, Mac OS X 10.11 SDK

查看:112
本文介绍了划线时避免颜色空间转换,Mac OS X 10.11 SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用从CGColorSpaceCreateDeviceRGB()返回的颜色空间时,将对任何CGContextDrawImage()调用颜色空间转换,与不使用该转换的blit相比,其性能要差5-6倍.

When using the colorspace returned from CGColorSpaceCreateDeviceRGB(), a colorspace transformation will be applied on any CGContextDrawImage() call, leading to 5-6x worse performance than blitting without this transform.

为避免这种色彩空间转换,我们一直在使用通过系统监视器配置文件创建的色彩空间:

To avoid this colorspace transformation, we have been using the colorspace created with the system monitor profile:

CMProfileRef smp = 0;
if (CMGetSystemProfile(&smp) == noErr)
{
    colorSpace = CGColorSpaceCreateWithPlatformColorSpace(smp);
    CMCloseProfile(smp);
}
else
    colorSpace = CGColorSpaceCreateDeviceRGB();

上面的方法效果很好,并且完全禁用了CGContextDrawImage()的颜色空间转换.

The above works well and completely disables the colorspace transformations for CGContextDrawImage().

自10.6起,CMGetSystemProfile已被标记为已弃用,但是由于我们没有找到其他避免这些色彩空间转换的可能性,因此我们将其保留在代码中以实现高性能打印.

CMGetSystemProfile has been marked deprecated since 10.6, but since we haven't found any other possibility to avoid these colorspace transformations, we have kept it in our code for high-performance blitting.

在10.11 SDK中,删除了ColorSpace API CMGetSystemProfile().是否有适当的替代方法,或关于如何禁用色彩空间转换的替代方法?

In 10.11 SDK, the ColorSpace API CMGetSystemProfile() is removed. Is there a suitable replacement, or an alternative method on how to disable colorspace transformations?

推荐答案

要回答我自己的问题,

我最终使用的解决方案是使用

the solution that I ended up using is to get the color space from the main display ID, using the functions CGDisplayCopyColorSpace and CGMainDisplayID:

colorSpace = ::CGDisplayCopyColorSpace(::CGMainDisplayID());

if (!colorSpace)
    colorSpace = CGColorSpaceCreateDeviceRGB();

此功能在10.11 SDK中可用,并将创建一个避免通过调用CGContextDrawImage()进行颜色空间转换的颜色空间.

This is available with 10.11 SDK, and will create a colorspace which avoids colorspace transformations with calls to CGContextDrawImage().

使用Instruments分析调用栈将显示一个与我们之前使用的代码相同的调用栈.

Analyzing the call stack with Instruments shows a callstack that is identical to the previous code we've been using.

这篇关于划线时避免颜色空间转换,Mac OS X 10.11 SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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