Skip to content

Commit

Permalink
cleaned up a couple small things in various classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrRay committed Jul 27, 2015
1 parent 1463ec7 commit 01fb212
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion MultiClassXPC/MCXServiceDelegate.h
Expand Up @@ -14,7 +14,7 @@




@interface MCXServiceDelegate : NSObject <NSXPCListenerDelegate> { @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 /* this method may only be called before you "resume" the service listener which an instance of
Expand Down
2 changes: 1 addition & 1 deletion MultiClassXPC/MCXServiceDelegate.m
Expand Up @@ -27,7 +27,7 @@ - (BOOL) listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConn
//NSLog(@"%s",__func__); //NSLog(@"%s",__func__);


// make the service i'll be exporting, set it up with the passed connection // 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 setExportedInterface:[NSXPCInterface interfaceWithProtocol:@protocol(MCXService)]];
[newConnection setExportedObject:exported]; [newConnection setExportedObject:exported];
[exported release]; [exported release];
Expand Down
5 changes: 3 additions & 2 deletions MultiClassXPC/MCXServiceManager.m
Expand Up @@ -58,10 +58,11 @@ - (void) establishConnection {


// make the actual connection, configure it, then resume it // make the actual connection, configure it, then resume it
OSSpinLockLock(&connLock); OSSpinLockLock(&connLock);
__block id bss = self;
void (^errHandlerBlock)(void) = ^(void) { 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 // 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 = [[NSXPCConnection alloc] initWithServiceName:connServiceIdentifier];
[conn setRemoteObjectInterface:[NSXPCInterface interfaceWithProtocol:@protocol(MCXService)]]; [conn setRemoteObjectInterface:[NSXPCInterface interfaceWithProtocol:@protocol(MCXService)]];
Expand Down
8 changes: 5 additions & 3 deletions MultiClassXPCTestApp/ClassAMCXRemote.m
Expand Up @@ -52,8 +52,9 @@ - (void) establishConnection {
//NSLog(@"%s",__func__); //NSLog(@"%s",__func__);
// if the mgr's classes aren't available yet, wait and then call this method again later // if the mgr's classes aren't available yet, wait and then call this method again later
if (![_mcxTestAppServiceMgr classesAvailable]) { if (![_mcxTestAppServiceMgr classesAvailable]) {
__block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self establishConnection]; [bss establishConnection];
}); });
return; return;
} }
Expand All @@ -66,14 +67,15 @@ - (void) establishConnection {
NSLog(@"\t\terr: bailing, listener nil, %s",__func__); NSLog(@"\t\terr: bailing, listener nil, %s",__func__);
return; return;
} }
__block id bss = self;
void (^errHandlerBlock)(void) = ^(void) { 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 // 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]; [_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 // 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(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0001*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self establishConnection]; [bss establishConnection];
}); });


}; };
Expand Down
8 changes: 5 additions & 3 deletions MultiClassXPCTestApp/ClassBMCXRemote.m
Expand Up @@ -52,8 +52,9 @@ - (void) establishConnection {
//NSLog(@"%s",__func__); //NSLog(@"%s",__func__);
// if the mgr's classes aren't available yet, wait and then call this method again later // if the mgr's classes aren't available yet, wait and then call this method again later
if (![_mcxTestAppServiceMgr classesAvailable]) { if (![_mcxTestAppServiceMgr classesAvailable]) {
__block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self establishConnection]; [bss establishConnection];
}); });
return; return;
} }
Expand All @@ -66,14 +67,15 @@ - (void) establishConnection {
NSLog(@"\t\terr: bailing, listener nil, %s",__func__); NSLog(@"\t\terr: bailing, listener nil, %s",__func__);
return; return;
} }
__block id bss = self;
void (^errHandlerBlock)(void) = ^(void) { 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 // 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]; [_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 // 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(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0001*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self establishConnection]; [bss establishConnection];
}); });


}; };
Expand Down
3 changes: 2 additions & 1 deletion MultiClassXPCTestApp/MCXTestAppDelegate.m
Expand Up @@ -33,8 +33,9 @@ - (void) makeSureXPCServiceIsAvailable {
NSLog(@"%s",__func__); NSLog(@"%s",__func__);
// loop a small delay while there aren't any available classes // loop a small delay while there aren't any available classes
if (![_mcxTestAppServiceMgr classesAvailable]) { if (![_mcxTestAppServiceMgr classesAvailable]) {
__block id bss = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self makeSureXPCServiceIsAvailable]; [bss makeSureXPCServiceIsAvailable];
}); });
return; return;
} }
Expand Down
2 changes: 2 additions & 0 deletions VVBufferPool/VVBufferCopier.h
Expand Up @@ -20,6 +20,7 @@ extern id _globalVVBufferCopier;
VVBufferPixFormat copyPixFormat; // VVBufferPF_BGRA by default 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 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; 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. /// 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.
Expand Down Expand Up @@ -51,5 +52,6 @@ extern id _globalVVBufferCopier;
@property (assign,readwrite) BOOL copyAndResize; @property (assign,readwrite) BOOL copyAndResize;
/// the "copySize" is only used if "copyAndResize" is YES /// the "copySize" is only used if "copyAndResize" is YES
@property (assign,readwrite) NSSize copySize; @property (assign,readwrite) NSSize copySize;
@property (assign,readwrite) VVSizingMode copySizingMode;


@end @end
16 changes: 12 additions & 4 deletions VVBufferPool/VVBufferCopier.m
Expand Up @@ -51,6 +51,7 @@ - (void) generalInit {
copyPixFormat = VVBufferPF_BGRA; copyPixFormat = VVBufferPF_BGRA;
copyAndResize = NO; copyAndResize = NO;
copySize = NSMakeSize(320,240); copySize = NSMakeSize(320,240);
copySizingMode = VVSizingModeStretch;
} }
- (void) dealloc { - (void) dealloc {
//NSLog(@"%s",__func__); //NSLog(@"%s",__func__);
Expand Down Expand Up @@ -139,7 +140,9 @@ - (VVBuffer *) copyToNewBuffer:(VVBuffer *)n {
if (context!=nil) { if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj]; CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([tmpTex target]); 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]); glDisable([tmpTex target]);
//NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]); //NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]);
// do any cleanup/flush my context // do any cleanup/flush my context
Expand Down Expand Up @@ -247,7 +250,9 @@ - (void) sizeVariantCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
if (context!=nil) { if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj]; CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([a target]); 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]); glDisable([a target]);
//NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]); //NSLog(@"\t\tjust copied %ld to %ld",[n name],[returnMe name]);
// do any cleanup/flush my context // do any cleanup/flush my context
Expand All @@ -269,7 +274,7 @@ - (void) ignoreSizeCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
//NSLog(@"%s ... %@ -> %@",__func__,a,b); //NSLog(@"%s ... %@ -> %@",__func__,a,b);
if (deleted || a==nil || b==nil) if (deleted || a==nil || b==nil)
return; return;
NSSize aSize = [a size]; //NSSize aSize = [a size];
NSSize bSize = [b size]; NSSize bSize = [b size];
[a retain]; [a retain];
[b retain]; [b retain];
Expand All @@ -296,7 +301,9 @@ - (void) ignoreSizeCopyThisBuffer:(VVBuffer *)a toThisBuffer:(VVBuffer *)b {
if (context!=nil) { if (context!=nil) {
CGLContextObj cgl_ctx = [context CGLContextObj]; CGLContextObj cgl_ctx = [context CGLContextObj];
glEnable([a target]); 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]); glDisable([a target]);
//NSLog(@"\t\tjust copied %d to %d",[a name],[b name]); //NSLog(@"\t\tjust copied %d to %d",[a name],[b name]);
//glColor4f(1,0,0,1); //glColor4f(1,0,0,1);
Expand Down Expand Up @@ -391,6 +398,7 @@ - (void) copyRedFrameToThisBuffer:(VVBuffer *)b {
@synthesize copyPixFormat; @synthesize copyPixFormat;
@synthesize copyAndResize; @synthesize copyAndResize;
@synthesize copySize; @synthesize copySize;
@synthesize copySizingMode;




@end @end
3 changes: 2 additions & 1 deletion VVUIToolbox/VVSpriteGLView.h
Expand Up @@ -108,7 +108,8 @@ extern long _spriteGLViewSysVers;


@property (readonly) BOOL deleted; @property (readonly) BOOL deleted;
@property (assign,readwrite) BOOL initialized; @property (assign,readwrite) BOOL initialized;
@property (assign,readwrite) BOOL flipped; - (BOOL) flipped;
- (void) setFlipped:(BOOL)n;
@property (readonly) double localToBackingBoundsMultiplier; @property (readonly) double localToBackingBoundsMultiplier;
@property (readonly) MutLockArray *vvSubviews; @property (readonly) MutLockArray *vvSubviews;
@property (assign, readwrite) BOOL spritesNeedUpdate; @property (assign, readwrite) BOOL spritesNeedUpdate;
Expand Down

0 comments on commit 01fb212

Please sign in to comment.