1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-09 16:39:49 +00:00

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.
This commit is contained in:
Akemi 2018-06-06 16:57:31 +02:00 committed by Jan Ekström
parent e72093581b
commit e5c4164088

View File

@ -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
}
}