fix: use windows nominal resolution for better performance
This commit is contained in:
1 parent
ad8d870364
commit
a7cc3bed0c
2 files changed
+5
-4
No files matched your search
@@ -18,8 +18,7 @@ extension CGWindowID {
|
||||
func screenshot() -> CGImage? {
|
||||
// CGSHWCaptureWindowList
|
||||
var windowId_ = self
|
||||
let options: CGSWindowCaptureOptions = [.captureIgnoreGlobalClipShape, .windowCaptureNominalResolution]
|
||||
let list = CGSHWCaptureWindowList(cgsMainConnectionId, &windowId_, 1, options).takeRetainedValue() as! [CGImage]
|
||||
let list = CGSHWCaptureWindowList(cgsMainConnectionId, &windowId_, 1, [.ignoreGlobalClipShape, .nominalResolution]).takeRetainedValue() as! [CGImage]
|
||||
return list.first
|
||||
|
||||
// // CGWindowListCreateImage
|
||||
|
||||
@@ -13,8 +13,10 @@ typealias CGSSpaceID = UInt64
|
||||
|
||||
struct CGSWindowCaptureOptions: OptionSet {
|
||||
let rawValue: UInt32
|
||||
static let windowCaptureNominalResolution = CGSWindowCaptureOptions(rawValue: 1 << 0x0200)
|
||||
static let captureIgnoreGlobalClipShape = CGSWindowCaptureOptions(rawValue: 1 << 0x0800)
|
||||
static let ignoreGlobalClipShape = CGSWindowCaptureOptions(rawValue: 1 << 11)
|
||||
// on a retina display, 1px is spread on 4px, so nominalResolution is 1/4 of bestResolution
|
||||
static let nominalResolution = CGSWindowCaptureOptions(rawValue: 1 << 9)
|
||||
static let bestResolution = CGSWindowCaptureOptions(rawValue: 1 << 8)
|
||||
}
|
||||
|
||||
enum SLPSMode: UInt32 {
|
||||
|
||||
Reference in new issue
Block a user