mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 06:16:36 +00:00
[742/906] cocoa: Allow setting window handle before creating the context
This commit is contained in:
parent
d937a7e899
commit
bd60dd7f22
1 changed files with 21 additions and 14 deletions
|
@ -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;
|
||||
|
||||
priv->parent = (NSWindow*) handle;
|
||||
if (priv->internal_win_id) {
|
||||
g_source_remove (priv->source_id);
|
||||
|
||||
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];
|
||||
|
||||
[pool release];
|
||||
|
||||
GSUnregisterCurrentThread();
|
||||
}
|
||||
else
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue