[742/906] cocoa: Allow setting window handle before creating the context

This commit is contained in:
Sebastian Dröge 2013-07-11 21:22:57 +02:00 committed by Tim-Philipp Müller
parent d937a7e899
commit bd60dd7f22

View file

@ -226,7 +226,6 @@ gst_gl_window_cocoa_create_context (GstGLWindow *window, GstGLAPI gl_api,
priv->gl_context = nil;
priv->external_gl_context = (NSOpenGLContext *) external_gl_context;
priv->visible = FALSE;
priv->parent = nil;
priv->thread = nil;
priv->running = TRUE;
@ -297,22 +296,24 @@ gst_gl_window_cocoa_set_window_handle (GstGLWindow * window, guintptr handle)
window_cocoa = GST_GL_WINDOW_COCOA (window);
priv = window_cocoa->priv;
g_source_remove (priv->source_id);
priv->parent = (NSWindow*) handle;
if (priv->internal_win_id) {
g_source_remove (priv->source_id);
if (GSRegisterCurrentThread()) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (GSRegisterCurrentThread()) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc] init:window_cocoa];
priv->parent = (NSWindow*) handle;
[app_thread_performer performSelectorOnMainThread:@selector(setWindow)
withObject:0 waitUntilDone:YES];
AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc] init:window_cocoa];
[app_thread_performer performSelectorOnMainThread:@selector(setWindow)
withObject:0 waitUntilDone:YES];
[pool release];
[pool release];
GSUnregisterCurrentThread();
GSUnregisterCurrentThread();
} else {
GST_DEBUG ("failed to register current thread, cannot set external window id\n");
}
}
else
GST_DEBUG ("failed to register current thread, cannot set external window id\n");
}
/* Thread safe */
@ -564,6 +565,12 @@ gst_gl_window_cocoa_get_gl_api (GstGLWindow * window)
[self orderOut:m_cocoa->priv->internal_win_id];
if (m_cocoa->priv->parent) {
NSWindow *window = m_cocoa->priv->parent;
[window setContentView: [m_cocoa->priv->internal_win_id contentView]];
}
return self;
}