mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
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:
parent
ccf8b69a67
commit
96398e5bac
2 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue