У меня плохая привычка отвечать на свои вопросы.
Чтобы преобразовать это IOSurface
в IOSurface
с известным типом пикселя, следует использовать IOAccelerator
.
CFMutableDictionary dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);;
char pixelFormat[4] = {'A', 'R', 'G', 'B'};
CFDictionarySetValue(dict, kIOSurfaceBytesPerRow, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &bytesPerRow));
CFDictionarySetValue(dict, kIOSurfaceBytesPerElement, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &bytesPerElement));
CFDictionarySetValue(dict, kIOSurfaceWidth, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &width));
CFDictionarySetValue(dict, kIOSurfaceHeight, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &height));
CFDictionarySetValue(dict, kIOSurfacePixelFormat, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, pixelFormat));
CFDictionarySetValue(dict, kIOSurfaceAllocSize, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &bufferSize));
IOSurfaceRef surface = IOSurfaceCreate(dict);
auto const didCreateAccelerator = IOSurfaceAcceleratorCreate(kCFAllocatorDefault, 0, &accelerator);