Permalink
Browse files

cleaned up a couple small things in various classes

  • Loading branch information...
1 parent 1463ec7 commit 01fb212f7dfbadc31df08f8292c153bd6b5131b2 @mrRay committed Jul 27, 2015
@@ -14,7 +14,7 @@
@interface MCXServiceDelegate : NSObject <NSXPCListenerDelegate> {
- NSMutableDictionary *tmpServiceDelegates; // used to temporarily store service delegates
+ __block NSMutableDictionary *tmpServiceDelegates; // used to temporarily store service delegates
}
/* this method may only be called before you "resume" the service listener which an instance of
@@ -27,7 +27,7 @@ - (BOOL) listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConn
//NSLog(@"%s",__func__);
// make the service i'll be exporting, set it up with the passed connection
- MCXService *exported = [[MCXService alloc] init];
+ __block MCXService *exported = [[MCXService alloc] init];
[newConnection setExportedInterface:[NSXPCInterface interfaceWithProtocol:@protocol(MCXService)]];
[newConnection setExportedObject:exported];
[exported release];
@@ -58,10 +58,11 @@ - (void) establishConnection {
// make the actual connection, configure it, then resume it
OSSpinLockLock(&connLock);
+ __block id bss = self;
void (^errHandlerBlock)(void) = ^(void) {
- NSLog(@"%@ err handler for %@",[self className],connServiceIdentifier);
+ NSLog(@"%@ err handler for %@",[bss className],connServiceIdentifier);
// just try to establish a connection again- this automatically kills any remnants of the old conn and fetches new listener endpoints
- [self establishConnection];
+ [bss establishConnection];
};
conn = [[NSXPCConnection alloc] initWithServiceName:connServiceIdentifier];
[conn setRemoteObjectInterface:[NSXPCInterface interfaceWithProtocol:@protocol(MCXService)]];
@@ -52,8 +52,9 @@ - (void) establishConnection {
//NSLog(@"%s",__func__);
// if the mgr's classes aren't available yet, wait and then call this method again later
if (![_mcxTestAppServiceMgr classesAvailable]) {
+ __block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [self establishConnection];
+ [bss establishConnection];
});
return;
}
@@ -66,14 +67,15 @@ - (void) establishConnection {
NSLog(@"\t\terr: bailing, listener nil, %s",__func__);
return;
}
+ __block id bss = self;
void (^errHandlerBlock)(void) = ^(void) {
- NSLog(@"%@ err handler",[self className]);
+ NSLog(@"%@ err handler",[bss className]);
// immediately inform the remote mgr that a listener error handler has been tripped- this clears its cache of classes and will re-launch the XPC service
[_mcxTestAppServiceMgr listenerErrHandlerTripped];
// try to establish a connection later- this automatically waits for the remote mgr to relaunch the XPC service and re-establish its cache of classes
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0001*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [self establishConnection];
+ [bss establishConnection];
});
};
@@ -52,8 +52,9 @@ - (void) establishConnection {
//NSLog(@"%s",__func__);
// if the mgr's classes aren't available yet, wait and then call this method again later
if (![_mcxTestAppServiceMgr classesAvailable]) {
+ __block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [self establishConnection];
+ [bss establishConnection];
});
return;
}
@@ -66,14 +67,15 @@ - (void) establishConnection {
NSLog(@"\t\terr: bailing, listener nil, %s",__func__);
return;
}
+ __block id bss = self;
void (^errHandlerBlock)(void) = ^(void) {
- NSLog(@"%@ err handler",[self className]);
+ NSLog(@"%@ err handler",[bss className]);
// immediately inform the remote mgr that a listener error handler has been tripped- this clears its cache of classes and will re-launch the XPC service
[_mcxTestAppServiceMgr listenerErrHandlerTripped];
// try to establish a connection later- this automatically waits for the remote mgr to relaunch the XPC service and re-establish its cache of classes
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0001*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [self establishConnection];
+ [bss establishConnection];
});
};
@@ -33,8 +33,9 @@ - (void) makeSureXPCServiceIsAvailable {
NSLog(@"%s",__func__);
// loop a small delay while there aren't any available classes
if (![_mcxTestAppServiceMgr classesAvailable]) {
+ __block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [self makeSureXPCServiceIsAvailable];
+ [bss makeSureXPCServiceIsAvailable];
});
return;
}
@@ -20,6 +20,7 @@ extern id _globalVVBufferCopier;
VVBufferPixFormat copyPixFormat; // VVBufferPF_BGRA by default
BOOL copyAndResize; // NO by default. if NO, copies preserve the size of the passed buffer- if NO, resizes the buffer while copying it
NSSize copySize; // only used if "copyAndResize" is YES;
+ VVSizingMode copySizingMode;
}
/// there's a global (singleton) instance of VVBufferCopier- by default this is created when you set up the global VVBufferPool, but if you want to override it and create it to work with a different context, this is how.
@@ -51,5 +52,6 @@ extern id _globalVVBufferCopier;
@property (assign,readwrite) BOOL copyAndResize;
/// the "copySize" is only used if "copyAndResize" is YES
@property (assign,readwrite) NSSize copySize;
+@property (assign,readwrite) VVSizingMode copySizingMode;
@end
@@ -51,6 +51,7 @@ - (void) generalInit {
copyPixFormat = VVBufferPF_BGRA;
copyAndResize = NO;
copySize = NSMakeSize(320,240);
+ copySizingMode = VVSizingModeStretch;
}
- (void) dealloc {
//NSLog(@"%s",__func__);
@@ -139,7 +140,9 @@ - (VVBuffer *) copyToNewBuffer:(VVBuffer *)n {
if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([tmpTex target]);
- GLDRAWTEXQUADMACRO([tmpTex name],[tmpTex target],[tmpTex flipped],[tmpTex glReadySrcRect],NSMakeRect(0,0,size.width,size.height));
+ //GLDRAWTEXQUADMACRO([tmpTex name],[tmpTex target],[tmpTex flipped],[tmpTex glReadySrcRect],NSMakeRect(0,0,size.width,size.height));
+ NSRect dstRect = [VVSizingTool rectThatFitsRect:[tmpTex glReadySrcRect] inRect:NSMakeRect(0,0,size.width,size.height) sizingMode:[self copySizingMode]];
+ GLDRAWTEXQUADMACRO([tmpTex name],[tmpTex target],[tmpTex flipped],[tmpTex glReadySrcRect],dstRect);
glDisable([tmpTex target]);
//NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]);
// do any cleanup/flush my context
@@ -247,7 +250,9 @@ - (void) sizeVariantCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([a target]);
- GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],NSMakeRect(0,0,bSize.width,bSize.height));
+ //GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],NSMakeRect(0,0,bSize.width,bSize.height));
+ NSRect dstRect = [VVSizingTool rectThatFitsRect:[a glReadySrcRect] inRect:NSMakeRect(0,0,bSize.width,bSize.height) sizingMode:[self copySizingMode]];
+ GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],dstRect);
glDisable([a target]);
//NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]);
// do any cleanup/flush my context
@@ -269,7 +274,7 @@ - (void) ignoreSizeCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
//NSLog(@"%s ... %@ -> %@",__func__,a,b);
if (deleted || a==nil || b==nil)
return;
- NSSize aSize = [a size];
+ //NSSize aSize = [a size];
NSSize bSize = [b size];
[a retain];
[b retain];
@@ -296,7 +301,9 @@ - (void) ignoreSizeCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([a target]);
- GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],NSMakeRect(0,0,aSize.width,aSize.height));
+ //GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],NSMakeRect(0,0,aSize.width,aSize.height));
+ NSRect dstRect = [VVSizingTool rectThatFitsRect:[a glReadySrcRect] inRect:NSMakeRect(0,0,bSize.width,bSize.height) sizingMode:VVSizingModeCopy];
+ GLDRAWTEXQUADMACRO([a name],[a target],[a flipped],[a glReadySrcRect],dstRect);
glDisable([a target]);
//NSLog(@"\t\tjust copied %d to %d",[a name],[b name]);
//glColor4f(1,0,0,1);
@@ -391,6 +398,7 @@ - (void) copyRedFrameToThisBuffer:(VVBuffer *)b {
@synthesize copyPixFormat;
@synthesize copyAndResize;
@synthesize copySize;
+@synthesize copySizingMode;
@end
@@ -108,7 +108,8 @@ extern long _spriteGLViewSysVers;
@property (readonly) BOOL deleted;
@property (assign,readwrite) BOOL initialized;
-@property (assign,readwrite) BOOL flipped;
+- (BOOL) flipped;
+- (void) setFlipped:(BOOL)n;
@property (readonly) double localToBackingBoundsMultiplier;
@property (readonly) MutLockArray *vvSubviews;
@property (assign, readwrite) BOOL spritesNeedUpdate;

0 comments on commit 01fb212

Please sign in to comment.