@@ -243,12 +243,26 @@ + (CVPixelBufferRef)copyCVPixelBuffer:
243
243
244
244
// create pixel buffer directly
245
245
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
246
- // Create new buffer with Metal compatibility
247
- NSDictionary *pixelBufferAttributes = @{
246
+ NSMutableDictionary *pixelBufferAttributes =
247
+ [NSMutableDictionary dictionaryWithDictionary: @{
248
+ (id )kCVPixelBufferIOSurfacePropertiesKey : @{},
249
+ #if (TARGET_OS_IOS)
250
+ (id )kCVPixelBufferOpenGLESCompatibilityKey : @YES ,
251
+ #elif (TARGET_OS_OSX)
252
+ (id )kCVPixelBufferOpenGLCompatibilityKey : @YES ,
253
+ #endif
254
+ (id )kCVPixelBufferCGImageCompatibilityKey : @YES ,
255
+ (id )kCVPixelBufferCGBitmapContextCompatibilityKey : @YES ,
256
+ (id )kCVPixelBufferPixelFormatTypeKey : @(sourceFormat),
257
+ (id )kCVPixelBufferWidthKey : @(sourceWidth),
258
+ (id )kCVPixelBufferHeightKey : @(sourceHeight)
259
+ }];
260
+
261
+ if (@available (macOS 10.11 , *)) {
248
262
// This key is required to generate SKPicture with CVPixelBufferRef in
249
263
// metal.
250
- ( NSString *) kCVPixelBufferMetalCompatibilityKey : @YES ,
251
- };
264
+ [pixelBufferAttributes setObject: @YES forKey: ( id ) kCVPixelBufferMetalCompatibilityKey ];
265
+ }
252
266
253
267
CVPixelBufferRef destPixelBuffer = nil ;
254
268
CVReturn status = CVPixelBufferCreate (
0 commit comments