]> git.sesse.net Git - vlc/commitdiff
macosx_vout: Correctly change context after -lockgl.
authorPierre d'Herbemont <pdherbemont@free.fr>
Mon, 3 May 2010 10:46:15 +0000 (12:46 +0200)
committerPierre d'Herbemont <pdherbemont@free.fr>
Mon, 3 May 2010 10:46:15 +0000 (12:46 +0200)
And don't unlockgl if lockgl wasn't successful.

modules/video_output/macosx.m

index ff965fd3b542d96834661908d47a5ee1f85497c9..3394a77edea26ced7d39182d998d76793c86adb8 100644 (file)
@@ -419,7 +419,10 @@ static void OpenglSwap(vout_opengl_t *gl)
 - (BOOL)lockgl
 {
     VLCAssertMainThread();
-    CGLError err = CGLLockContext([[self openGLContext] CGLContextObj]);
+    NSOpenGLContext *context = [self openGLContext];
+    CGLError err = CGLLockContext([context CGLContextObj]);
+    if (err == kCGLNoError)
+        [context makeCurrentContext];
     return err == kCGLNoError;
 }
 
@@ -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,
-        // in this case we'll skip the rendering.
-        // This will save us for rendering two frames (or more) for nothing
-        // (one by the vout, one (or more) by drawRect)
-        _hasPendingReshape = YES;
-    }
+        @synchronized(self) {
+            // This may be cleared before -drawRect is being called,
+            // in this case we'll skip the rendering.
+            // This will save us for rendering two frames (or more) for nothing
+            // (one by the vout, one (or more) by drawRect)
+            _hasPendingReshape = YES;
+        }
 
-    [self unlockgl];
+        [self unlockgl];
 
-    [super reshape];
+        [super reshape];
+    }
 }
 
 /**