From e5c41640885bafb11513f1cada7a462ee79b0aee Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 6 Jun 2018 16:57:31 +0200 Subject: cocoa-cb: add logging for CGL pixel format attributes depending on the capabilities of the system and testing of various attributes the resulting CGL pixel format can change. due to that probing it can be helpful to know which pixel format is used to create the CGL context. added some verbose logging that outputs final pixel format. --- video/out/cocoa-cb/video_layer.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'video/out/cocoa-cb/video_layer.swift') diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift index 0e14e45dc3..ccc84f8fa8 100644 --- a/video/out/cocoa-cb/video_layer.swift +++ b/video/out/cocoa-cb/video_layer.swift @@ -148,6 +148,18 @@ class VideoLayer: CAOpenGLLayer { override func copyCGLPixelFormat(forDisplayMask mask: UInt32) -> CGLPixelFormatObj { if cglPixelFormat != nil { return cglPixelFormat! } + let attributeLookUp: [UInt32:String] = [ + kCGLOGLPVersion_3_2_Core.rawValue: "kCGLOGLPVersion_3_2_Core", + kCGLOGLPVersion_Legacy.rawValue: "kCGLOGLPVersion_Legacy", + kCGLPFAOpenGLProfile.rawValue: "kCGLPFAOpenGLProfile", + kCGLPFAAccelerated.rawValue: "kCGLPFAAccelerated", + kCGLPFADoubleBuffer.rawValue: "kCGLPFADoubleBuffer", + kCGLPFABackingStore.rawValue: "kCGLPFABackingStore", + kCGLPFAAllowOfflineRenderers.rawValue: "kCGLPFAAllowOfflineRenderers", + kCGLPFASupportsAutomaticGraphicsSwitching.rawValue: "kCGLPFASupportsAutomaticGraphicsSwitching", + 0: "" + ] + let glVersions: [CGLOpenGLProfile] = [ kCGLOGLPVersion_3_2_Core, kCGLOGLPVersion_Legacy @@ -175,6 +187,13 @@ class VideoLayer: CAOpenGLLayer { if err == kCGLBadAttribute || err == kCGLBadPixelFormat || pix == nil { glAttributes.remove(at: index) } else { + var attArray = glAttributes.map({ (value: _CGLPixelFormatAttribute) -> String in + return attributeLookUp[value.rawValue]! + }) + attArray.removeLast() + + mpv.sendVerbose("Created CGL pixel format with attributes: " + + "\(attArray.joined(separator: ", "))") break verLoop } } -- cgit v1.2.3