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];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue