[839/906] cocoa: allow to call set_window_handle before to create glcontext

So that it actually make cocoa videooverlay example work again.

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=719758
This commit is contained in:
Julien Isorce 2013-11-30 16:38:13 +00:00 committed by Matthew Waters
parent b90d824626
commit 7a689108d9

View file

@ -175,25 +175,39 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
window_cocoa = GST_GL_WINDOW_COCOA (window); window_cocoa = GST_GL_WINDOW_COCOA (window);
priv = window_cocoa->priv; priv = window_cocoa->priv;
priv->parent = (NSWindow*) handle;
if (priv->internal_win_id) { if (priv->internal_win_id) {
GstGLContextCocoa *context = (GstGLContextCocoa *) gst_gl_window_get_context (window); GstGLContextCocoa *context = (GstGLContextCocoa *) gst_gl_window_get_context (window);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc] init:window_cocoa]; AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc] init:window_cocoa];
GSRegisterCurrentThread(); GSRegisterCurrentThread();
if (context) { if (context) {
g_source_remove (context->priv->source_id); if (context->priv->source_id) {
g_source_remove (context->priv->source_id);
context->priv->source_id = 0;
}
gst_object_unref (context); gst_object_unref (context);
} }
if (handle) {
priv->parent = (NSWindow*) handle;
priv->visible = TRUE;
} else {
/* bring back our internal window */
priv->parent = priv->internal_win_id;
priv->visible = FALSE;
}
[app_thread_performer performSelectorOnMainThread:@selector(setWindow) [app_thread_performer performSelectorOnMainThread:@selector(setWindow)
withObject:0 waitUntilDone:YES]; withObject:0 waitUntilDone:YES];
[pool release]; [pool release];
} else {
/* not internal window yet so delay it to the next drawing */
priv->parent = (NSWindow*) handle;
priv->visible = FALSE;
} }
} }
@ -215,6 +229,13 @@ gst_gl_window_cocoa_draw (GstGLWindow * window, guint width, guint height)
[app_thread_performer performSelector:@selector(updateWindow) [app_thread_performer performSelector:@selector(updateWindow)
onThread:priv->thread withObject:nil waitUntilDone:YES]; onThread:priv->thread withObject:nil waitUntilDone:YES];
/* useful when set_window_handle is called before
* the internal NSWindow */
if (priv->parent && !priv->visible) {
gst_gl_window_cocoa_set_window_handle (window, (guintptr) priv->parent);
priv->visible = TRUE;
}
if (!priv->parent && !priv->visible) { if (!priv->parent && !priv->visible) {
static gint x = 0; static gint x = 0;
static gint y = 0; static gint y = 0;
@ -566,9 +587,9 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
- (void) setWindow { - (void) setWindow {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window = m_cocoa->priv->parent; NSWindow *window = m_cocoa->priv->parent;
[m_cocoa->priv->internal_win_id orderOut:m_cocoa->priv->internal_win_id]; [m_cocoa->priv->internal_win_id orderOut:m_cocoa->priv->internal_win_id];
[window setContentView: [m_cocoa->priv->internal_win_id contentView]]; [window setContentView: [m_cocoa->priv->internal_win_id contentView]];
[pool release]; [pool release];