Custom Resolution, less CPU usage
This commit is contained in:
julioverne 2020-06-29 23:42:04 -03:00
parent 8a2b10f890
commit b60375e6ea
6 changed files with 90 additions and 55 deletions

View File

@ -20,10 +20,6 @@
<true/> <true/>
<key>com.apple.private.hid.client.service-protected</key> <key>com.apple.private.hid.client.service-protected</key>
<true/> <true/>
<key>com.apple.private.hid.manager.client</key>
<true/>
<key>com.apple.private.hid.client.admin</key>
<true/>
<key>com.apple.private.IOSurface.protected-access</key> <key>com.apple.private.IOSurface.protected-access</key>
<true/> <true/>
<key>com.apple.QuartzCore.displayable-context</key> <key>com.apple.QuartzCore.displayable-context</key>
@ -36,8 +32,6 @@
<true/> <true/>
<key>com.apple.private.allow-explicit-graphics-priority</key> <key>com.apple.private.allow-explicit-graphics-priority</key>
<true/> <true/>
<key>com.apple.private.xpc.launchd.app-server</key>
<true/>
<key>com.apple.CommCenter.fine-grained</key> <key>com.apple.CommCenter.fine-grained</key>
<array> <array>
<string>spi</string> <string>spi</string>
@ -46,15 +40,5 @@
<true/> <true/>
<key>com.apple.private.security.disk-device-access</key> <key>com.apple.private.security.disk-device-access</key>
<true/> <true/>
<key>com.apple.private.touch.eeprom.access</key>
<true/>
<key>com.apple.security.exception.iokit-user-client-class</key>
<string>RootDomainUserClient</string>
<key>com.apple.private.ioaccelmemoryinfo</key>
<true/>
<key>com.apple.gpumemd.client</key>
<true/>
<key>com.apple.backboardd.virtualDisplay</key>
<true/>
</dict> </dict>
</plist> </plist>

View File

@ -7,6 +7,6 @@ Description: VNC for ios
Maintainer: Julio Maintainer: Julio
Author: julioverne, Sharat M R Author: julioverne, Sharat M R
Section: Tweaks Section: Tweaks
Version: 0.0.3a Version: 0.0.3d
Depiction: http://julioverne.github.io/description.html?id=com.julioverne.screendump13 Depiction: http://julioverne.github.io/description.html?id=com.julioverne.screendump13
Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png Icon: file:///Library/PreferenceLoader/Preferences/screendump/ScreenDump@2x.png

View File

@ -19,6 +19,9 @@ static size_t bits_per_sample = 8;
static size_t size_image; static size_t size_image;
static size_t prefferH;
static size_t prefferW;
static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef); static CFTypeRef (*$GSSystemCopyCapability)(CFStringRef);
static CFTypeRef (*$GSSystemGetCapability)(CFStringRef); static CFTypeRef (*$GSSystemGetCapability)(CFStringRef);
static BOOL (*$MGGetBoolAnswer)(CFStringRef); static BOOL (*$MGGetBoolAnswer)(CFStringRef);
@ -83,10 +86,15 @@ static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size)
return good; return good;
} }
static void upFrameLoop();
static IOSurfaceRef screenSurface = NULL; static IOSurfaceRef screenSurface = NULL;
static IOMobileFramebufferRef framebufferConnection = NULL; static IOMobileFramebufferRef framebufferConnection = NULL;
@interface FrameUpdater : NSObject
@property (nonatomic, retain) NSTimer* myTimer;
- (void)startFrameLoop;
- (void)stopFrameLoop;
@end
static void VNCSetup() static void VNCSetup()
{ {
if(!screenSurface) { if(!screenSurface) {
@ -100,8 +108,8 @@ static void VNCSetup()
//width = size.width/2; //width = size.width/2;
//height = size.height/2; //height = size.height/2;
width = IOSurfaceGetWidth(screenSurface) / 2; width = prefferW==0?IOSurfaceGetWidth(screenSurface):prefferW;
height = IOSurfaceGetHeight(screenSurface) / 2; height = prefferW==0?IOSurfaceGetHeight(screenSurface):prefferH;
size_image = IOSurfaceGetAllocSize(screenSurface); size_image = IOSurfaceGetAllocSize(screenSurface);
bytesPerRow = IOSurfaceGetBytesPerRow(screenSurface); bytesPerRow = IOSurfaceGetBytesPerRow(screenSurface);
@ -149,11 +157,15 @@ static void VNCSettings(bool shouldStart, NSString* password)
VNCUpdateRunState(CCSisEnabled); VNCUpdateRunState(CCSisEnabled);
} }
static void VNCUpdateRunState(bool shouldStart) static void VNCUpdateRunState(bool shouldStart)
{ {
if(screen == NULL) { if(screen == NULL) {
return; return;
} }
if(CCSPassword && CCSPassword.length) { if(CCSPassword && CCSPassword.length) {
screen->authPasswdData = (void *) CCSPassword; screen->authPasswdData = (void *) CCSPassword;
} else { } else {
@ -167,12 +179,14 @@ static void VNCUpdateRunState(bool shouldStart)
rfbRunEventLoop(screen, -1, true); rfbRunEventLoop(screen, -1, true);
isLoopFrame = YES; isLoopFrame = YES;
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
upFrameLoop(); [[FrameUpdater shared] startFrameLoop];
});
} else { } else {
isLoopFrame = NO; isLoopFrame = NO;
[[FrameUpdater shared] stopFrameLoop];
rfbShutdownServer(screen, true); rfbShutdownServer(screen, true);
} }
isVNCRunning = shouldStart; isVNCRunning = shouldStart;
@ -188,35 +202,90 @@ static void loadPrefs(void)
defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, CFSTR("mobile"), kCFPreferencesAnyHost)?:@{}; defaults = (NSDictionary *)CFPreferencesCopyMultiple(keyList, appID, CFSTR("mobile"), kCFPreferencesAnyHost)?:@{};
CFRelease(keyList); CFRelease(keyList);
} }
prefferH = [[defaults objectForKey:@"height"]?:@(0) intValue];
prefferW = [[defaults objectForKey:@"width"]?:@(0) intValue];
BOOL isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue]; BOOL isEnabled = [[defaults objectForKey:@"CCSisEnabled"]?:@NO boolValue];
NSString *password = [defaults objectForKey:@"CCSPassword"]; NSString *password = [defaults objectForKey:@"CCSPassword"];
VNCSettings(isEnabled, password); VNCSettings(isEnabled, password);
} }
} }
static void upFrameLoop()
static uint32_t oldSeed;
@implementation FrameUpdater
{
NSOperationQueue *q;
}
@synthesize myTimer;
+ (id)shared
{
static __strong FrameUpdater* initFrame;
if(!initFrame) {
initFrame = [[[self class] alloc] init];
}
return initFrame;
}
- (id)init
{
self = [super init];
q = [[NSOperationQueue alloc] init];
return self;
}
- (void)_upFrameLoop
{
if(isLoopFrame && CCSisEnabled) {
//check if screen changed
uint32_t newSeed = IOSurfaceGetSeed(screenSurface);
if(oldSeed != newSeed && rfbIsActive(screen)) {
oldSeed = newSeed;
[q addOperationWithBlock: ^{
IOSurfaceAcceleratorTransferSurface(accelerator, screenSurface, static_buffer, NULL, NULL, NULL, NULL);
rfbMarkRectAsModified(screen, 0, 0, width, height);
}];
}
} else {
[self stopFrameLoop];
}
}
- (void)stopFrameLoop
{
if(myTimer && [myTimer isValid]) {
dispatch_async(dispatch_get_main_queue(), ^(void){
[myTimer invalidate];
});
}
}
- (void)startFrameLoop
{ {
if(size_image == 0) { if(size_image == 0) {
VNCSetup(); VNCSetup();
} }
while(isLoopFrame && CCSisEnabled) { [self stopFrameLoop];
if(rfbIsActive(screen) && IOSurfaceIsInUse(screenSurface)) { dispatch_async(dispatch_get_main_queue(), ^(void){
IOSurfaceAcceleratorTransferSurface(accelerator, screenSurface, static_buffer, NULL, NULL, NULL, NULL); myTimer = [NSTimer scheduledTimerWithTimeInterval:1/400 target:self selector:@selector(_upFrameLoop) userInfo:nil repeats:YES];
//check if screen changed });
void * buffBytes = IOSurfaceGetBaseAddress(static_buffer);
if(buffBytes && !(memcmp(buffBytes, "\xFF\x00\xFF\xFF\xFF\x00\xFF\xFF\xFF", 9) == 0)) {
rfbMarkRectAsModified(screen, 0, 0, width, height);
}
//sleep(1/100);
}
} }
-(void)dealloc
{
[self stopFrameLoop];
} }
@end
static void restartServer()
{
exit(0);
}
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.cosmosgenius.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.cosmosgenius.screendump/preferences.changed"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)restartServer, CFSTR("com.cosmosgenius.screendump/restart"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs(); loadPrefs();

View File

@ -20,10 +20,6 @@
<true/> <true/>
<key>com.apple.private.hid.client.service-protected</key> <key>com.apple.private.hid.client.service-protected</key>
<true/> <true/>
<key>com.apple.private.hid.manager.client</key>
<true/>
<key>com.apple.private.hid.client.admin</key>
<true/>
<key>com.apple.private.IOSurface.protected-access</key> <key>com.apple.private.IOSurface.protected-access</key>
<true/> <true/>
<key>com.apple.QuartzCore.displayable-context</key> <key>com.apple.QuartzCore.displayable-context</key>
@ -36,9 +32,6 @@
<true/> <true/>
<key>com.apple.private.allow-explicit-graphics-priority</key> <key>com.apple.private.allow-explicit-graphics-priority</key>
<true/> <true/>
<key>com.apple.private.xpc.launchd.app-server</key>
<true/>
<key>com.apple.CommCenter.fine-grained</key> <key>com.apple.CommCenter.fine-grained</key>
<array> <array>
<string>spi</string> <string>spi</string>
@ -47,15 +40,5 @@
<true/> <true/>
<key>com.apple.private.security.disk-device-access</key> <key>com.apple.private.security.disk-device-access</key>
<true/> <true/>
<key>com.apple.private.touch.eeprom.access</key>
<true/>
<key>com.apple.security.exception.iokit-user-client-class</key>
<string>RootDomainUserClient</string>
<key>com.apple.private.ioaccelmemoryinfo</key>
<true/>
<key>com.apple.gpumemd.client</key>
<true/>
<key>com.apple.backboardd.virtualDisplay</key>
<true/>
</dict> </dict>
</plist> </plist>

View File

@ -7,4 +7,3 @@ Maintainer: Sharat M R <cosmosgenius@gmail.com>
Author: Sharat M R <cosmosgenius@gmail.com> Author: Sharat M R <cosmosgenius@gmail.com>
Section: Tweaks Section: Tweaks
Version: 0.0.3 Version: 0.0.3
Installed-Size: 3100