I have an app which captures a display (CGDisplayCapture or CGDisplayCaptureWithOptions), grabs its drawing context, and then draw image on it:
//1. capture
auto cpErr = CGDisplayCaptureWithOptions( mDid, kCGCaptureNoOptions );
if ( cpErr != kCGErrorSuccess )
{
LOGEX( "😂 Failed to capture Display, ID:%d", mDId );
return;
}
// Grab context
context = CGDisplayGetDrawingContext( mDId );
//Draw image
CGContextDrawImage( context, rect, image );
CGContextFlush( context );
The video is pretty good, but two issues:
-
When captured, according to the document, it only capture the event on that display, actually, when the app running, all system key event (i.g. Shift+Cmd+R) and swipe won't work.
-
CGContextDrawImage is taking pretty high CPU usage, in my Mac mini 2018, it is taking over 20%
Anyone got the solution to the above issues?
-Thanks :)