mirror of
https://github.com/zakk4223/CocoaSplit.git
synced 2026-05-21 06:46:14 -06:00
Restored decklink self cropping, since it was needed due to weird sampling distortion in the final render
This commit is contained in:
parent
5978c7f85e
commit
6826eab507
3 changed files with 49 additions and 10 deletions
|
|
@ -17,6 +17,7 @@
|
|||
{
|
||||
self.asynchronous = NO;
|
||||
self.needsDisplayOnBoundsChange = YES;
|
||||
|
||||
_deckLinkOGL = CreateOpenGLScreenPreviewHelper();
|
||||
_deckLinkOGL->AddRef();
|
||||
}
|
||||
|
|
@ -46,6 +47,17 @@
|
|||
|
||||
|
||||
|
||||
-(void)setContentsRect:(CGRect)contentsRect
|
||||
{
|
||||
_privateCropRect = contentsRect;
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
-(CGRect)contentsRect
|
||||
{
|
||||
return _privateCropRect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)setRenderFrame:(IDeckLinkVideoFrame *)frame
|
||||
|
|
@ -66,34 +78,57 @@
|
|||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NSSize useSize = self.bounds.size;
|
||||
CGRect newCrop;
|
||||
|
||||
newCrop.origin.x = _deckLinkFrameSize.width * _privateCropRect.origin.x;
|
||||
newCrop.origin.y = _deckLinkFrameSize.height * _privateCropRect.origin.y;
|
||||
newCrop.size.width = _deckLinkFrameSize.width * _privateCropRect.size.width;
|
||||
newCrop.size.height = _deckLinkFrameSize.height * _privateCropRect.size.height;
|
||||
|
||||
if ([self.contentsGravity isEqualToString:kCAGravityResizeAspect])
|
||||
{
|
||||
float wr = newCrop.size.width / self.bounds.size.width;
|
||||
float hr = newCrop.size.height / self.bounds.size.height;
|
||||
|
||||
float ratio = (hr < wr ? wr : hr);
|
||||
useSize = NSMakeSize(newCrop.size.width / ratio, newCrop.size.height / ratio);
|
||||
}
|
||||
|
||||
|
||||
GLint vpx = (self.bounds.size.width - useSize.width)/2;
|
||||
GLint vpy = (self.bounds.size.height - useSize.height)/2;
|
||||
|
||||
|
||||
glViewport(vpx, vpy, useSize.width, useSize.height);
|
||||
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
|
||||
NSRect cropRect;
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
GLfloat yt = 1.0 - (_privateCropRect.origin.y + _privateCropRect.size.height);
|
||||
|
||||
|
||||
glScalef(_privateCropRect.size.width, _privateCropRect.size.height, 1);
|
||||
glTranslatef(_privateCropRect.origin.x * _deckLinkFrameSize.width, yt * _deckLinkFrameSize.height, 0);
|
||||
|
||||
|
||||
|
||||
if (_deckLinkOGL)
|
||||
{
|
||||
_deckLinkOGL->PaintGL();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[super drawInCGLContext:ctx pixelFormat:pf forLayerTime:t displayTime:ts];
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1301,7 +1301,6 @@ static NSArray *_sourceTypes = nil;
|
|||
-(void)dealloc
|
||||
{
|
||||
|
||||
NSLog(@"DEALLOC INPUT");
|
||||
[self deregisterVideoInput:self.videoInput];
|
||||
for(id vInput in self.videoSources)
|
||||
{
|
||||
|
|
@ -1892,12 +1891,13 @@ static NSArray *_sourceTypes = nil;
|
|||
-(void)autoFit
|
||||
{
|
||||
|
||||
|
||||
float wr = self.size.width / self.canvas_width;
|
||||
float hr = self.size.height / self.canvas_height;
|
||||
float ratio = (hr < wr ? wr : hr);
|
||||
[self directSize:self.size.width / ratio height:self.size.height / ratio];
|
||||
CGFloat newX = (self.canvas_width/2) - self.layer.bounds.size.width/2;
|
||||
CGFloat newY = (self.canvas_height/2) - self.layer.bounds.size.height/2;
|
||||
CGFloat newX = (self.canvas_width/2) - self.layer.frame.size.width/2;
|
||||
CGFloat newY = (self.canvas_height/2) - self.layer.frame.size.height/2;
|
||||
[self positionOrigin:newX y:newY];
|
||||
}
|
||||
|
||||
|
|
@ -1934,7 +1934,11 @@ static NSArray *_sourceTypes = nil;
|
|||
|
||||
NSRect iRect = NSIntegralRect(newLayout);
|
||||
|
||||
self.layer.bounds = newLayout;
|
||||
[CATransaction begin];
|
||||
self.layer.frame = newLayout;
|
||||
[CATransaction commit];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue