mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-22 10:57:08 +00:00
mac/vulkan: log colorspace changes of metal layer
since we have a mapping layer between vulkan and metal (MoltenVK) we don't actually know which colorspace is used/mapped to. log colorspace changes to actually see which colorspace was chosen.
This commit is contained in:
@@ -136,3 +136,17 @@ extension MTLPixelFormat {
|
||||
return "raw pixel format " + String(self.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
extension CGColorSpace {
|
||||
public var longName: String {
|
||||
let description = String(describing: self)
|
||||
guard let colorSpaceName = self.name as? String,
|
||||
let regex = try? NSRegularExpression(pattern: ".*\\((.*)\\)", options: .caseInsensitive),
|
||||
let result = regex.firstMatch(in: description, options: [], range: NSRange(location: 0, length: description.count)),
|
||||
let range = Range(result.range(at: 1), in: description) else { return description }
|
||||
|
||||
let nameList = description[range].components(separatedBy: "; ").filter { !$0.hasPrefix("kCGColorSpace") }
|
||||
let simpleName = colorSpaceName.replacingOccurrences(of: "kCGColorSpace", with: "")
|
||||
return "\(simpleName) (\(nameList.joined(separator: ", ")))"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,23 @@ class MetalLayer: CAMetalLayer {
|
||||
}
|
||||
}
|
||||
|
||||
// workaround for nil to none-nil values, oldValue is same as current in those cases
|
||||
var previousColorspace: CGColorSpace?
|
||||
override var colorspace: CGColorSpace? {
|
||||
didSet {
|
||||
if colorspace != previousColorspace {
|
||||
log.verbose("Metal layer colorspace changed: \(colorspace?.longName ?? "nil")")
|
||||
}
|
||||
previousColorspace = colorspace
|
||||
}
|
||||
}
|
||||
|
||||
init(common com: MacCommon) {
|
||||
common = com
|
||||
super.init()
|
||||
|
||||
pixelFormat = .rgba16Float
|
||||
previousColorspace = colorspace
|
||||
backgroundColor = NSColor.black.cgColor
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user