From 0c459222f8f592c0e0ea151c7bf1bb73cd5fcf6b Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 3 Feb 2015 11:07:58 +1100 Subject: [PATCH] gstglwindow_cocoa: fix slow render rate In gst_gl_window_cocoa_draw we used to just call setNeedsDisplay:YES. That was creating an implicit CA transaction which was getting committed at the next runloop iteration. Since we don't know how often the main runloop is running, and when we run it implicitly (from gst_gl_window_cocoa_nsapp_iteration) we only do so every 200ms, use an explicit CA transaction instead and commit it immediately. CA transactions nest and debounce automatically so this will never result in extra work. --- gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m index 678fd63..a0f09ea 100644 --- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m @@ -24,6 +24,7 @@ #endif #include +#include #include "gstgl_cocoa_private.h" @@ -280,11 +281,12 @@ gst_gl_window_cocoa_draw (GstGLWindow * window) GstGLNSView *view = (GstGLNSView *)[window_cocoa->priv->internal_win_id contentView]; /* this redraws the GstGLCAOpenGLLayer which calls - * gst_gl_window_cocoa_draw_thread() + * gst_gl_window_cocoa_draw_thread(). Use an explicit CATransaction since we + * don't know how often the main runloop is running. */ - dispatch_sync (dispatch_get_main_queue(), ^{ - [view setNeedsDisplay:YES]; - }); + [CATransaction begin]; + [view setNeedsDisplay:YES]; + [CATransaction commit]; } static void -- 2.7.4