Update to latest syphon framework

This commit is contained in:
Zakk 2018-10-02 17:12:24 -04:00
parent 25c1a230b7
commit 97986ad7e9
5 changed files with 29 additions and 15 deletions

2
.gitmodules vendored
View file

@ -1,4 +1,4 @@
[submodule "CapturePlugins/CSSyphonCapturePlugin/Syphon-Framework"]
path = CapturePlugins/CSSyphonCapturePlugin/Syphon-Framework
url = https://github.com/palana/Syphon-Framework.git
url = https://github.com/Syphon/Syphon-Framework.git
ignore = all

View file

@ -27,6 +27,6 @@
@property (strong) SyphonClient *syphonClient;
@property (assign) bool flipImage;
@property (assign) NSSize lastImageSize;
@property (assign) CGLContextObj sharedContext;
@end

View file

@ -20,6 +20,8 @@
self.asynchronous = NO;
self.needsDisplayOnBoundsChange = YES;
self.flipImage = NO;
_lastImageSize = NSZeroSize;
}
return self;
@ -70,8 +72,10 @@
-(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pf
{
_myCGLContext = [super copyCGLContextForPixelFormat:pf];
//_myCGLContext = [super copyCGLContextForPixelFormat:pf];
CGLCreateContext(pf, self.sharedContext, &_myCGLContext);
return _myCGLContext;
}
@ -95,7 +99,7 @@
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
SyphonImage *image = [self.syphonClient newFrameImageForContext:cgl_ctx];
SyphonImage *image = [self.syphonClient newFrameImage];
if (!image)
@ -103,6 +107,7 @@
return;
}
_lastImageSize = image.textureSize;
self.textureSize = _lastImageSize;

View file

@ -31,6 +31,7 @@
uint32_t _surfaceSeed;
bool _dummyFrameUpdate;
CGLContextObj _cgl_ctx;
CATransform3D _flipTransform;
}

View file

@ -94,6 +94,12 @@
-(void) commonInit
{
CGLPixelFormatAttribute attrib[] = {kCGLPFANoRecovery, kCGLPFAAccelerated, 0};
CGLPixelFormatObj pixelFormat = NULL;
GLint numPixelFormats = 0;
CGLChoosePixelFormat (attrib, &pixelFormat, &numPixelFormats);
CGLCreateContext(pixelFormat, NULL, &_cgl_ctx);
_renderType = kCSRenderFrameArrived;
self.canProvideTiming = YES;
@ -118,6 +124,8 @@
{
CSSyphonCaptureLayer *newLayer = [CSSyphonCaptureLayer layer];
newLayer.sharedContext = _cgl_ctx;
if (_syphon_client)
{
newLayer.syphonClient = _syphon_client;
@ -194,16 +202,11 @@
if (_syphonServer)
{
_syphon_client = [[SyphonClient alloc] initWithServerDescription:_syphonServer.copy options:nil newFrameHandler:^(SyphonClient *client) {
_syphon_client = [[SyphonClient alloc] initWithServerDescription:_syphonServer.copy context:_cgl_ctx options:nil newFrameHandler:^(SyphonClient *client) {
//Big stupid hack to force at least one layer to update the size before we kick a framedata block off
if (NSEqualSizes(self->_last_frame_size, NSZeroSize))
{
[self updateLayersWithBlock:^(CALayer *layer) {
self->_last_frame_size = ((CSSyphonCaptureLayer *)layer).lastImageSize;
}];
} else if (self->_dummyFrameUpdate) {
if (self->_dummyFrameUpdate) {
[self updateLayersWithFramedataBlock:^(CALayer *layer) {
return;
}];
@ -212,19 +215,24 @@
}
if (!self->_dummyFrameUpdate)
{
[self updateLayersWithFramedataBlock:^(CALayer *layer) {
[((CSSyphonCaptureLayer *)layer) setNeedsDisplay];
}];
[self frameArrived];
}
if (NSEqualSizes(self->_last_frame_size, NSZeroSize))
{
[self updateLayersWithBlock:^(CALayer *layer) {
self->_last_frame_size = ((CSSyphonCaptureLayer *)layer).lastImageSize;
NSLog(@"LAST SIZE %@", NSStringFromSize(self->_last_frame_size));
}];
}
}];