From 8b0b154d6efe5923b3760e9ae77ef26bbc087814 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sat, 9 Mar 2013 22:53:09 +1100 Subject: [PATCH] [676/906] windwo_win32: port to new API --- gst-libs/gst/gl/win32/gstglwindow_win32.c | 92 ++++++++++--------- gst-libs/gst/gl/win32/gstglwindow_win32.h | 4 +- gst-libs/gst/gl/win32/gstglwindow_win32_egl.c | 5 +- gst-libs/gst/gl/win32/gstglwindow_win32_egl.h | 3 +- gst-libs/gst/gl/win32/gstglwindow_win32_wgl.c | 10 +- gst-libs/gst/gl/win32/gstglwindow_win32_wgl.h | 3 +- 6 files changed, 56 insertions(+), 61 deletions(-) diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c index 0ecb1d79ee..35735b975a 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.c @@ -69,6 +69,8 @@ G_DEFINE_TYPE_WITH_CODE (GstGLWindowWin32, gst_gl_window_win32, HHOOK hHook; +gboolean gst_gl_window_win32_create_context (GstGLWindow * window, + GstGLAPI gl_api, guintptr external_gl_context, GError ** error); guintptr gst_gl_window_win32_get_gl_context (GstGLWindow * window); gboolean gst_gl_window_win32_activate (GstGLWindow * window, gboolean activate); void gst_gl_window_win32_set_window_handle (GstGLWindow * window, @@ -85,37 +87,12 @@ void gst_gl_window_win32_send_message (GstGLWindow * window, static void gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass) { - GstGLWindowClass *window_class; - WNDCLASS wc; - ATOM atom = 0; - HINSTANCE hinstance = GetModuleHandle (NULL); - - window_class = (GstGLWindowClass *) klass; + GstGLWindowClass *window_class = (GstGLWindowClass *) klass; g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private)); - atom = GetClassInfo (hinstance, "GSTGL", &wc); - - if (atom == 0) { - ZeroMemory (&wc, sizeof (WNDCLASS)); - - wc.lpfnWndProc = window_proc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hinstance; - wc.hIcon = LoadIcon (NULL, IDI_WINLOGO); - wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = "GSTGL"; - - atom = RegisterClass (&wc); - - if (atom == 0) - GST_WARNING ("Failed to register window class %lud\n", GetLastError ()); - } - + window_class->create_context = + GST_DEBUG_FUNCPTR (gst_gl_window_win32_create_context); window_class->get_gl_context = GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_gl_context); window_class->activate = GST_DEBUG_FUNCPTR (gst_gl_window_win32_activate); @@ -139,25 +116,20 @@ gst_gl_window_win32_init (GstGLWindowWin32 * window) /* Must be called in the gl thread */ GstGLWindowWin32 * -gst_gl_window_win32_new (GstGLAPI gl_api, guintptr external_gl_context, - GError ** error) +gst_gl_window_win32_new (void) { GstGLWindowWin32 *window = NULL; const gchar *user_choice; user_choice = g_getenv ("GST_GL_PLATFORM"); -#if HAVE_WGL +#if GST_GL_HAVE_PLATFORM_WGL if (!window && (!user_choice || g_strstr_len (user_choice, 3, "wgl"))) - window = - GST_GL_WINDOW_WIN32 (gst_gl_window_win32_wgl_new (gl_api, - external_gl_context, error)); + window = GST_GL_WINDOW_WIN32 (gst_gl_window_win32_wgl_new ()); #endif -#if HAVE_EGL +#if GST_GL_HAVE_PLATFORM_EGL if (!window && (!user_choice || g_strstr_len (user_choice, 3, "egl"))) - window = - GST_GL_WINDOW_WIN32 (gst_gl_window_win32_egl_new (gl_api, - external_gl_context, error)); + window = GST_GL_WINDOW_WIN32 (gst_gl_window_win32_egl_new ()); #endif if (!window) { GST_WARNING ("Failed to create win32 window, user_choice:%s", @@ -165,30 +137,61 @@ gst_gl_window_win32_new (GstGLAPI gl_api, guintptr external_gl_context, return NULL; } - window->priv->gl_api = gl_api; - window->priv->external_gl_context = external_gl_context; - window->priv->error = error; - return window; } gboolean -gst_gl_window_win32_open_device (GstGLWindowWin32 * window_win32, - GError ** error) +gst_gl_window_win32_create_context (GstGLWindow * window, GstGLAPI gl_api, + guintptr external_gl_context, GError ** error) { + GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window); + WNDCLASSEX wc; + ATOM atom = 0; HINSTANCE hinstance = GetModuleHandle (NULL); static gint x = 0; static gint y = 0; + GST_LOG ("Attempting to create a win32 window"); + x += 20; y += 20; + atom = GetClassInfoEx (hinstance, "GSTGL", &wc); + + if (atom == 0) { + ZeroMemory (&wc, sizeof (WNDCLASSEX)); + + wc.cbSize = sizeof (WNDCLASSEX); + wc.lpfnWndProc = window_proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hinstance; + wc.hIcon = LoadIcon (NULL, IDI_WINLOGO); + wc.hIconSm = NULL; + wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "GSTGL"; + + atom = RegisterClassEx (&wc); + + if (atom == 0) { + GST_WARNING ("Failed to register window class %lud\n", GetLastError ()); + goto failure; + } + } + window_win32->internal_win_id = 0; window_win32->device = 0; window_win32->is_closed = FALSE; window_win32->visible = FALSE; + window_win32->priv->gl_api = gl_api; + window_win32->priv->external_gl_context = external_gl_context; + window_win32->priv->error = error; + window_win32->internal_win_id = CreateWindowEx (0, "GSTGL", "OpenGL renderer", @@ -211,6 +214,7 @@ gst_gl_window_win32_open_device (GstGLWindowWin32 * window_win32, ShowCursor (TRUE); + GST_LOG ("Created a win32 window"); return TRUE; failure: diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.h b/gst-libs/gst/gl/win32/gstglwindow_win32.h index 526b05b456..1552481689 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.h +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.h @@ -74,9 +74,7 @@ struct _GstGLWindowWin32Class { GType gst_gl_window_win32_get_type (void); -GstGLWindowWin32 * gst_gl_window_win32_new (GstGLAPI gl_api, - guintptr external_gl_context, GError ** error); -gboolean gst_gl_window_win32_open_device (GstGLWindowWin32 *window_win32, GError ** error); +GstGLWindowWin32 * gst_gl_window_win32_new (void); G_END_DECLS diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32_egl.c b/gst-libs/gst/gl/win32/gstglwindow_win32_egl.c index 7508b0f85f..8f046e8398 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32_egl.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32_egl.c @@ -80,14 +80,11 @@ gst_gl_window_win32_egl_init (GstGLWindow * window) /* Must be called in the gl thread */ GstGLWindowWin32EGL * -gst_gl_window_win32_egl_new (GstGLAPI gl_api, guintptr external_gl_context, - GError ** error) +gst_gl_window_win32_egl_new (void) { GstGLWindowWin32EGL *window = g_object_new (GST_GL_TYPE_WINDOW_WIN32_EGL, NULL); - gst_gl_window_win32_open_device (GST_GL_WINDOW_WIN32 (window), error); - return window; } diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32_egl.h b/gst-libs/gst/gl/win32/gstglwindow_win32_egl.h index c82c9e07da..f3167f4430 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32_egl.h +++ b/gst-libs/gst/gl/win32/gstglwindow_win32_egl.h @@ -62,8 +62,7 @@ struct _GstGLWindowWin32EGLClass { GType gst_gl_window_win32_egl_get_type (void); -GstGLWindowWin32EGL * gst_gl_window_win32_egl_new (GstGLAPI gl_api, - guintptr external_gl_context, GError ** error); +GstGLWindowWin32EGL * gst_gl_window_win32_egl_new (void); G_END_DECLS diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.c b/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.c index 8e7b67e91a..8fa166bd5f 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.c @@ -80,14 +80,11 @@ gst_gl_window_win32_wgl_init (GstGLWindowWin32WGL * window) /* Must be called in the gl thread */ GstGLWindowWin32WGL * -gst_gl_window_win32_wgl_new (GstGLAPI gl_api, guintptr external_gl_context, - GError ** error) +gst_gl_window_win32_wgl_new (void) { GstGLWindowWin32WGL *window = g_object_new (GST_GL_TYPE_WINDOW_WIN32_WGL, NULL); - gst_gl_window_win32_open_device (GST_GL_WINDOW_WIN32 (window), error); - return window; } @@ -110,7 +107,8 @@ gst_gl_window_win32_wgl_create_context (GstGLWindowWin32 * window_win32, } g_assert (window_wgl->wgl_context); - GST_LOG ("gl context id: %ld", (gulong) window_wgl->wgl_context); + GST_LOG ("gl context id: %" G_GUINTPTR_FORMAT, + (guintptr) window_wgl->wgl_context); return TRUE; @@ -127,7 +125,7 @@ gst_gl_window_win32_wgl_destroy_context (GstGLWindowWin32 * window_win32) if (window_wgl->wgl_context) wglDeleteContext (window_wgl->wgl_context); - window_wgl->wgl_context = 0; + window_wgl->wgl_context = NULL; } static gboolean diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.h b/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.h index b28a5a1c68..ac1a108824 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.h +++ b/gst-libs/gst/gl/win32/gstglwindow_win32_wgl.h @@ -55,8 +55,7 @@ struct _GstGLWindowWin32WGLClass { GType gst_gl_window_win32_wgl_get_type (void); -GstGLWindowWin32WGL * gst_gl_window_win32_wgl_new (GstGLAPI gl_api, - guintptr external_gl_context, GError ** error); +GstGLWindowWin32WGL * gst_gl_window_win32_wgl_new (void); G_END_DECLS