[vlc-commits] iOS vout: re-use existing OpenGL context if available and compatible

Felix Paul Kühne git at videolan.org
Mon Sep 14 14:34:06 CEST 2015


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Sep 14 14:32:59 2015 +0200| [79f2fd00415347595727e654d648b38064c74e5f] | committer: Felix Paul Kühne

iOS vout: re-use existing OpenGL context if available and compatible

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=79f2fd00415347595727e654d648b38064c74e5f
---

 modules/video_output/ios2.m |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/ios2.m b/modules/video_output/ios2.m
index 8cdda5a..178b057 100644
--- a/modules/video_output/ios2.m
+++ b/modules/video_output/ios2.m
@@ -612,7 +612,16 @@ static void ZeroCopyDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *su
     layer.drawableProperties = [NSDictionary dictionaryWithObject:kEAGLColorFormatRGBA8 forKey: kEAGLDrawablePropertyColorFormat];
     layer.opaque = YES;
 
-    _eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+    /* a client app may have already created a rendering context,
+     * so re-use it if it is valid */
+    EAGLContext *existingContext = [EAGLContext currentContext];
+    if (existingContext) {
+        if ([existingContext API] == kEAGLRenderingAPIOpenGLES2)
+             _eaglContext = [EAGLContext currentContext];
+    }
+
+    if (!_eaglContext)
+        _eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
     if (unlikely(!_eaglContext))
         return nil;
     if (unlikely(![EAGLContext setCurrentContext:_eaglContext]))



More information about the vlc-commits mailing list