summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <julien.isorce@gmail.com>2013-11-30 16:38:13 +0000
committerMatthew Waters <ystreet00@gmail.com>2014-03-15 18:37:03 +0100
commit7a689108d9da606952eda5a41ca1afc71cf94893 (patch)
treea52e546ef39e1100db7ad648db1f224a12e46dc6
parentb90d824626c7ab22c47d1cb9634c5d311eb1ca9e (diff)
[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
-rw-r--r--gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m33
1 files changed, 27 insertions, 6 deletions
diff --git a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
index 564cc2fcd..a94915eba 100644
--- a/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
+++ b/gst-libs/gst/gl/cocoa/gstglwindow_cocoa.m
@@ -175,25 +175,39 @@ 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) {
GstGLContextCocoa *context = (GstGLContextCocoa *) gst_gl_window_get_context (window);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AppThreadPerformer* app_thread_performer = [[AppThreadPerformer alloc] init:window_cocoa];
-
GSRegisterCurrentThread();
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);
}
+ 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)
withObject:0 waitUntilDone:YES];
[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)
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) {
static gint x = 0;
static gint y = 0;
@@ -566,9 +587,9 @@ gst_gl_window_cocoa_send_message_async (GstGLWindow * window,
- (void) setWindow {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *window = m_cocoa->priv->parent;
-
+
[m_cocoa->priv->internal_win_id orderOut:m_cocoa->priv->internal_win_id];
-
+
[window setContentView: [m_cocoa->priv->internal_win_id contentView]];
[pool release];