我想弄清楚为什么argb32_image_mark_rgb24占用Mac FreeRDP客户端的整个执行时间的25%。这个函数是从CGContextDrawImage中调用的,这个函数在我的drawRect方法中调用。在drawRect中的代码如下所示:CoreGraphics argb32_image_mark_rgb24很慢
CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];
CGImageRef cgImage = CGBitmapContextCreateImage(self->bitmap_context);
CGContextClipToRect(cgContext, CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
CGContextDrawImage(cgContext, CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height), cgImage);
CGImageRelease(cgImage);
位图上下文是这样创建的:
CGContextRef mac_create_bitmap_context(rdpContext* context)
{
CGContextRef bitmap_context;
rdpGdi* gdi = context->gdi;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (gdi->dstBpp == 16)
{
bitmap_context = CGBitmapContextCreate(gdi->primary_buffer,
gdi->width, gdi->height, 5, gdi->width * 2, colorSpace,
kCGBitmapByteOrder16Little | kCGImageAlphaNoneSkipFirst);
}
else
{
bitmap_context = CGBitmapContextCreate(gdi->primary_buffer,
gdi->width, gdi->height, 8, gdi->width * 4, colorSpace,
kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
}
CGColorSpaceRelease(colorSpace);
return bitmap_context;
}
gdi-> primary_buffer就是RDP绘制调用渲染软件缓冲。目前,RDP渲染库支持RGB565,RGB555和32bpp的大多数变体。
从我所了解的关于API的文档中,CGBitmapContextCreate()创建一个包装我的软件缓冲区的对象,但不会立即创建一个副本。只有在调用CGContextDrawImage()时才会复制像素。
我想了解以下信息:
是什么argb32_image_mark_rgb24做什么呢?它是否执行从ARGB32到3字节RGB24像素的某种转换?将3字节RGB24像素作为软件缓冲格式添加支持是否可以避免在此处出现昂贵的转换?
否则,我怎么能改变当前调用设置一个剪切矩形,然后使用整个表面绘制调用哪些副本从源矩形到目标矩形? CGContextDrawImage只需要一个矩形,而不是两个。
谢谢!