gl/calayer: only start drawing if the parent gl context is ready

otherwise we may try to use GstGLFuncs * that hasn't been set yet
This commit is contained in:
Matthew Waters 2015-02-17 16:41:17 +11:00
parent ccf8b69a67
commit 96398e5bac
2 changed files with 19 additions and 0 deletions

View file

@ -46,6 +46,7 @@ G_BEGIN_DECLS
gpointer resize_data;
GDestroyNotify resize_notify;
gint can_draw;
}
- (void) setDrawCallback:(GstGLWindowCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
- (void) setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;

View file

@ -37,6 +37,14 @@
[super dealloc];
}
static void
_context_ready (gpointer data)
{
GstGLCAOpenGLLayer *ca_layer = data;
g_atomic_int_set (&ca_layer->can_draw, 1);
}
- (id)initWithGstGLContext:(GstGLContextCocoa *)parent_gl_context {
[super init];
@ -46,6 +54,9 @@
self.asynchronous = YES;
self.needsDisplayOnBoundsChange = YES;
gst_gl_window_send_message_async (GST_GL_CONTEXT (parent_gl_context)->window,
(GstGLWindowCB) _context_ready, self, NULL);
return self;
}
@ -119,6 +130,13 @@
self->resize_notify = notify;
}
- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)interval
displayTime:(const CVTimeStamp *)timeStamp {
return g_atomic_int_get (&self->can_draw);
}
- (void)drawInCGLContext:(CGLContextObj)glContext
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)interval