From e1fd4232adf96922cd4ea403ebb3b731283a3948 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Sat, 22 Nov 2008 16:43:24 +0100 Subject: [PATCH] [280/906] Remove set_visible, because it's now automatically done when the first post redisplay comes. --- gst-libs/gst/gl/gstgldisplay.c | 14 ------- gst-libs/gst/gl/gstgldisplay.h | 1 - gst-libs/gst/gl/gstglwindow.h | 1 - gst-libs/gst/gl/gstglwindow_win32.c | 58 +++++++++++++++++------------ gst-libs/gst/gl/gstglwindow_x11.c | 21 +---------- 5 files changed, 37 insertions(+), 58 deletions(-) diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index 37dac437eb..dd408d2feb 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -1618,20 +1618,6 @@ gst_gl_display_create_context (GstGLDisplay *display, } -/* Called by the glimagesink element */ -void -gst_gl_display_set_visible_context (GstGLDisplay* display, gboolean visible) -{ - gst_gl_display_lock (display); - if (display->visible != visible) - { - display->visible = visible; - gst_gl_window_visible (display->gl_window, visible); - } - gst_gl_display_unlock (display); -} - - /* Called by the glimagesink element */ gboolean gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height) diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index 6909b9942a..3f9eb1bfce 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -210,7 +210,6 @@ GstGLDisplay* gst_gl_display_new (void); void gst_gl_display_create_context (GstGLDisplay* display, GLint width, GLint height); -void gst_gl_display_set_visible_context (GstGLDisplay* display, gboolean visible); gboolean gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height); void gst_gl_display_thread_add (GstGLDisplay *display, diff --git a/gst-libs/gst/gl/gstglwindow.h b/gst-libs/gst/gl/gstglwindow.h index 35c7648331..15e91421bc 100644 --- a/gst-libs/gst/gl/gstglwindow.h +++ b/gst-libs/gst/gl/gstglwindow.h @@ -71,7 +71,6 @@ void gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callbac void gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback, gpointer data); void gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data); -void gst_gl_window_visible (GstGLWindow *window, gboolean visible); void gst_gl_window_draw (GstGLWindow *window); void gst_gl_window_run_loop (GstGLWindow *window); void gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data); diff --git a/gst-libs/gst/gl/gstglwindow_win32.c b/gst-libs/gst/gl/gstglwindow_win32.c index b7edd260da..c4cb96831b 100644 --- a/gst-libs/gst/gl/gstglwindow_win32.c +++ b/gst-libs/gst/gl/gstglwindow_win32.c @@ -29,7 +29,8 @@ #include "gstglwindow.h" -#define WM_GSTGLWINDOW (WM_APP+1) +#define WM_GST_GL_WINDOW_CUSTOM (WM_APP+1) +#define WM_GST_GL_WINDOW_QUIT (WM_APP+2) void gst_gl_window_set_pixel_format (GstGLWindow *window); LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -55,6 +56,7 @@ struct _GstGLWindowPrivate GstGLWindowCB close_cb; gpointer close_data; gboolean is_closed; + gboolean visible; }; G_DEFINE_TYPE (GstGLWindow, gst_gl_window, G_TYPE_OBJECT); @@ -163,6 +165,7 @@ gst_gl_window_new (gint width, gint height) priv->close_cb = NULL; priv->close_data = NULL; priv->is_closed = FALSE; + priv->visible = FALSE; width += 2 * GetSystemMetrics (SM_CXSIZEFRAME); height += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION); @@ -259,26 +262,18 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g priv->close_data = data; } -/* Thread safe */ -void -gst_gl_window_visible (GstGLWindow *window, gboolean visible) -{ - GstGLWindowPrivate *priv = window->priv; - BOOL ret = FALSE; - - g_debug ("set visible %d\n", priv->internal_win_id); - - if (visible) - ret = ShowWindowAsync (priv->internal_win_id, SW_SHOW); - else - ret = ShowWindowAsync (priv->internal_win_id, SW_HIDE); -} - /* Thread safe */ void gst_gl_window_draw (GstGLWindow *window) { GstGLWindowPrivate *priv = window->priv; + + if (!priv->visible) + { + ShowWindowAsync (priv->internal_win_id, SW_SHOW); + priv->visible = TRUE; + } + RedrawWindow (priv->internal_win_id, NULL, NULL, RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE); } @@ -312,12 +307,12 @@ gst_gl_window_run_loop (GstGLWindow *window) /* Thread safe */ void -gst_gl_window_quit_loop (GstGLWindow *window) +gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data) { if (window) { GstGLWindowPrivate *priv = window->priv; - LRESULT res = PostMessage(priv->internal_win_id, WM_CLOSE, 0, 0); + LRESULT res = PostMessage(priv->internal_win_id, WM_GST_GL_WINDOW_QUIT, (WPARAM) data, (LPARAM) callback); g_assert (SUCCEEDED (res)); g_debug ("end loop requested\n"); } @@ -330,7 +325,7 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe if (window) { GstGLWindowPrivate *priv = window->priv; - LRESULT res = SendMessage (priv->internal_win_id, WM_GSTGLWINDOW, (WPARAM) data, (LPARAM) callback); + LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM, (WPARAM) data, (LPARAM) callback); g_assert (SUCCEEDED (res)); } } @@ -450,11 +445,30 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam } case WM_CLOSE: + { + ShowWindowAsync (priv->internal_win_id, SW_HIDE); + + if (priv->close_cb) + priv->close_cb (priv->close_data); + + priv->draw_cb = NULL; + priv->draw_data = NULL; + priv->resize_cb = NULL; + priv->resize_data = NULL; + priv->close_cb = NULL; + priv->close_data = NULL; + break; + } + + case WM_GST_GL_WINDOW_QUIT: { HWND parent_id = 0; + GstGLWindowCB destroy_cb = (GstGLWindowCB) lParam; g_debug ("WM_CLOSE\n"); + destroy_cb ((gpointer) wParam); + parent_id = GetProp (hWnd, "gl_window_parent_id"); if (parent_id) { @@ -501,11 +515,9 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam break; } - case WM_GSTGLWINDOW: + case WM_GST_GL_WINDOW_CUSTOM: { - if (priv->is_closed && priv->close_cb) - priv->close_cb (priv->close_data); - else + if (!priv->is_closed) { GstGLWindowCB custom_cb = (GstGLWindowCB) lParam; custom_cb ((gpointer) wParam); diff --git a/gst-libs/gst/gl/gstglwindow_x11.c b/gst-libs/gst/gl/gstglwindow_x11.c index 9279c6c290..d4defb0c2d 100644 --- a/gst-libs/gst/gl/gstglwindow_x11.c +++ b/gst-libs/gst/gl/gstglwindow_x11.c @@ -472,23 +472,6 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g g_mutex_unlock (priv->x_lock); } -/* Thread safe */ -void -gst_gl_window_visible (GstGLWindow *window, gboolean visible) -{ - if (window) - { - GstGLWindowPrivate *priv = window->priv; - - g_mutex_lock (priv->x_lock); - - if (priv->visible != visible) - priv->visible = visible; - - g_mutex_unlock (priv->x_lock); - } -} - /* Thread safe */ void gst_gl_window_draw (GstGLWindow *window) @@ -505,10 +488,10 @@ gst_gl_window_draw (GstGLWindow *window) XEvent event; XWindowAttributes attr; - if (priv->visible) + if (!priv->visible) { XMapWindow (priv->disp_send, priv->internal_win_id); - priv->visible = FALSE; + priv->visible = TRUE; } XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);