Commit 9a004176 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx_vout: Correctly change context after -lockgl.

And don't unlockgl if lockgl wasn't successful.
(cherry picked from commit 0484b127c762d7519726db78e2017cb762a20c1a)
parent 4c2fbffb
...@@ -419,7 +419,10 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -419,7 +419,10 @@ static void OpenglSwap(vout_opengl_t *gl)
- (BOOL)lockgl - (BOOL)lockgl
{ {
VLCAssertMainThread(); VLCAssertMainThread();
CGLError err = CGLLockContext([[self openGLContext] CGLContextObj]); NSOpenGLContext *context = [self openGLContext];
CGLError err = CGLLockContext([context CGLContextObj]);
if (err == kCGLNoError)
[context makeCurrentContext];
return err == kCGLNoError; return err == kCGLNoError;
} }
...@@ -493,21 +496,21 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -493,21 +496,21 @@ static void OpenglSwap(vout_opengl_t *gl)
} }
} }
[self lockgl]; if ([self lockgl]) {
glViewport((width - x) / 2, (height - y) / 2, x, y);
glViewport((width - x) / 2, (height - y) / 2, x, y); @synchronized(self) {
// This may be cleared before -drawRect is being called,
@synchronized(self) { // in this case we'll skip the rendering.
// This may be cleared before -drawRect is being called, // This will save us for rendering two frames (or more) for nothing
// in this case we'll skip the rendering. // (one by the vout, one (or more) by drawRect)
// This will save us for rendering two frames (or more) for nothing _hasPendingReshape = YES;
// (one by the vout, one (or more) by drawRect) }
_hasPendingReshape = YES;
}
[self unlockgl]; [self unlockgl];
[super reshape]; [super reshape];
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment