Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash caused by screensaver or display sleep #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Antumbra/AGlowManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ @implementation AGlowManager {
BOOL canMirror;
NSTimer *timer;
AGlowFade *currentFade;
BOOL reset;
}

@synthesize glows;
Expand Down Expand Up @@ -79,6 +80,23 @@ -(void)colorFromGlow:(AGlow *)glow{
NSLog(@"mirror");
CGDirectDisplayID disp = (CGDirectDisplayID) [[[glow.mirrorAreaWindow.screen deviceDescription]objectForKey:@"NSScreenNumber"] intValue];
CGImageRef first = CGDisplayCreateImageForRect(disp, glow.mirrorAreaWindow.frame);
if (!first) {
reset = YES;
int64_t secondsToWaitBeforeRepeat = 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(secondsToWaitBeforeRepeat * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self colorFromGlow:glow];
});
return;
} else {
if (reset) {
reset = NO;
[self stopMirroring];
[[NSNotificationCenter defaultCenter]postNotificationName:@"doneMirroring" object:nil];
[self mirror];
CGImageRelease(first);
return;
}
}
GPUImagePicture *pic = [[GPUImagePicture alloc]initWithCGImage:first];
GPUImageAverageColor *average = [[GPUImageAverageColor alloc]init];
[pic addTarget:average];
Expand All @@ -100,6 +118,23 @@ -(void)augmentFromGlow:(AGlow *)glow{
NSLog(@"augmenting");
CGDirectDisplayID disp = (CGDirectDisplayID) [[[glow.mirrorAreaWindow.screen deviceDescription]objectForKey:@"NSScreenNumber"] intValue];
CGImageRef first = CGDisplayCreateImageForRect(disp, glow.mirrorAreaWindow.frame);
if (!first) {
reset = YES;
int64_t secondsToWaitBeforeRepeat = 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(secondsToWaitBeforeRepeat * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self augmentFromGlow:glow];
});
return;
} else {
if (reset) {
reset = NO;
[self stopMirroring];
[[NSNotificationCenter defaultCenter]postNotificationName:@"doneMirroring" object:nil];
[self augment];
CGImageRelease(first);
return;
}
}
GPUImagePicture *pic = [[GPUImagePicture alloc]initWithCGImage:first];
GPUImageSaturationFilter *sat = [[GPUImageSaturationFilter alloc]init];
sat.saturation = 2.0;
Expand All @@ -125,6 +160,23 @@ -(void)balancedFromGlow:(AGlow *)glow{
NSLog(@"balanced");
CGDirectDisplayID disp = (CGDirectDisplayID) [[[glow.mirrorAreaWindow.screen deviceDescription]objectForKey:@"NSScreenNumber"] intValue];
CGImageRef first = CGDisplayCreateImageForRect(disp, glow.mirrorAreaWindow.frame);
if (!first) {
reset = YES;
int64_t secondsToWaitBeforeRepeat = 1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(secondsToWaitBeforeRepeat * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self balancedFromGlow:glow];
});
return;
} else {
if (reset) {
reset = NO;
[self stopMirroring];
[[NSNotificationCenter defaultCenter]postNotificationName:@"doneMirroring" object:nil];
[self balance];
CGImageRelease(first);
return;
}
}
GPUImagePicture *pic = [[GPUImagePicture alloc]initWithCGImage:first];
GPUImageSaturationFilter *sat = [[GPUImageSaturationFilter alloc]init];
sat.saturation = 1.5;
Expand Down