Skip to content

Commit ab5598a

Browse files
committed
fix: try to fix green screen on intel arch for macOS
1 parent e17b4f6 commit ab5598a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

shared/darwin/AgoraCVPixelBufferUtils.mm

+18-4
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,26 @@ + (CVPixelBufferRef)copyCVPixelBuffer:
243243

244244
// create pixel buffer directly
245245
#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, *)) {
248262
// This key is required to generate SKPicture with CVPixelBufferRef in
249263
// metal.
250-
(NSString *)kCVPixelBufferMetalCompatibilityKey : @YES,
251-
};
264+
[pixelBufferAttributes setObject:@YES forKey:(id)kCVPixelBufferMetalCompatibilityKey];
265+
}
252266

253267
CVPixelBufferRef destPixelBuffer = nil;
254268
CVReturn status = CVPixelBufferCreate(

0 commit comments

Comments
 (0)