mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[676/906] windwo_win32: port to new API
This commit is contained in:
parent
7f69a236b9
commit
8b0b154d6e
6 changed files with 56 additions and 61 deletions
|
@ -69,6 +69,8 @@ G_DEFINE_TYPE_WITH_CODE (GstGLWindowWin32, gst_gl_window_win32,
|
||||||
|
|
||||||
HHOOK hHook;
|
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);
|
guintptr gst_gl_window_win32_get_gl_context (GstGLWindow * window);
|
||||||
gboolean gst_gl_window_win32_activate (GstGLWindow * window, gboolean activate);
|
gboolean gst_gl_window_win32_activate (GstGLWindow * window, gboolean activate);
|
||||||
void gst_gl_window_win32_set_window_handle (GstGLWindow * window,
|
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
|
static void
|
||||||
gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
|
gst_gl_window_win32_class_init (GstGLWindowWin32Class * klass)
|
||||||
{
|
{
|
||||||
GstGLWindowClass *window_class;
|
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
|
||||||
WNDCLASS wc;
|
|
||||||
ATOM atom = 0;
|
|
||||||
HINSTANCE hinstance = GetModuleHandle (NULL);
|
|
||||||
|
|
||||||
window_class = (GstGLWindowClass *) klass;
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private));
|
g_type_class_add_private (klass, sizeof (GstGLWindowWin32Private));
|
||||||
|
|
||||||
atom = GetClassInfo (hinstance, "GSTGL", &wc);
|
window_class->create_context =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_gl_window_win32_create_context);
|
||||||
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->get_gl_context =
|
window_class->get_gl_context =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_gl_context);
|
GST_DEBUG_FUNCPTR (gst_gl_window_win32_get_gl_context);
|
||||||
window_class->activate = GST_DEBUG_FUNCPTR (gst_gl_window_win32_activate);
|
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 */
|
/* Must be called in the gl thread */
|
||||||
GstGLWindowWin32 *
|
GstGLWindowWin32 *
|
||||||
gst_gl_window_win32_new (GstGLAPI gl_api, guintptr external_gl_context,
|
gst_gl_window_win32_new (void)
|
||||||
GError ** error)
|
|
||||||
{
|
{
|
||||||
GstGLWindowWin32 *window = NULL;
|
GstGLWindowWin32 *window = NULL;
|
||||||
const gchar *user_choice;
|
const gchar *user_choice;
|
||||||
|
|
||||||
user_choice = g_getenv ("GST_GL_PLATFORM");
|
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")))
|
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "wgl")))
|
||||||
window =
|
window = GST_GL_WINDOW_WIN32 (gst_gl_window_win32_wgl_new ());
|
||||||
GST_GL_WINDOW_WIN32 (gst_gl_window_win32_wgl_new (gl_api,
|
|
||||||
external_gl_context, error));
|
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_EGL
|
#if GST_GL_HAVE_PLATFORM_EGL
|
||||||
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "egl")))
|
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "egl")))
|
||||||
window =
|
window = GST_GL_WINDOW_WIN32 (gst_gl_window_win32_egl_new ());
|
||||||
GST_GL_WINDOW_WIN32 (gst_gl_window_win32_egl_new (gl_api,
|
|
||||||
external_gl_context, error));
|
|
||||||
#endif
|
#endif
|
||||||
if (!window) {
|
if (!window) {
|
||||||
GST_WARNING ("Failed to create win32 window, user_choice:%s",
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->priv->gl_api = gl_api;
|
|
||||||
window->priv->external_gl_context = external_gl_context;
|
|
||||||
window->priv->error = error;
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_window_win32_open_device (GstGLWindowWin32 * window_win32,
|
gst_gl_window_win32_create_context (GstGLWindow * window, GstGLAPI gl_api,
|
||||||
GError ** error)
|
guintptr external_gl_context, GError ** error)
|
||||||
{
|
{
|
||||||
|
GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window);
|
||||||
|
WNDCLASSEX wc;
|
||||||
|
ATOM atom = 0;
|
||||||
HINSTANCE hinstance = GetModuleHandle (NULL);
|
HINSTANCE hinstance = GetModuleHandle (NULL);
|
||||||
|
|
||||||
static gint x = 0;
|
static gint x = 0;
|
||||||
static gint y = 0;
|
static gint y = 0;
|
||||||
|
|
||||||
|
GST_LOG ("Attempting to create a win32 window");
|
||||||
|
|
||||||
x += 20;
|
x += 20;
|
||||||
y += 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->internal_win_id = 0;
|
||||||
window_win32->device = 0;
|
window_win32->device = 0;
|
||||||
window_win32->is_closed = FALSE;
|
window_win32->is_closed = FALSE;
|
||||||
window_win32->visible = 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,
|
window_win32->internal_win_id = CreateWindowEx (0,
|
||||||
"GSTGL",
|
"GSTGL",
|
||||||
"OpenGL renderer",
|
"OpenGL renderer",
|
||||||
|
@ -211,6 +214,7 @@ gst_gl_window_win32_open_device (GstGLWindowWin32 * window_win32,
|
||||||
|
|
||||||
ShowCursor (TRUE);
|
ShowCursor (TRUE);
|
||||||
|
|
||||||
|
GST_LOG ("Created a win32 window");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
|
|
|
@ -74,9 +74,7 @@ struct _GstGLWindowWin32Class {
|
||||||
|
|
||||||
GType gst_gl_window_win32_get_type (void);
|
GType gst_gl_window_win32_get_type (void);
|
||||||
|
|
||||||
GstGLWindowWin32 * gst_gl_window_win32_new (GstGLAPI gl_api,
|
GstGLWindowWin32 * gst_gl_window_win32_new (void);
|
||||||
guintptr external_gl_context, GError ** error);
|
|
||||||
gboolean gst_gl_window_win32_open_device (GstGLWindowWin32 *window_win32, GError ** error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,11 @@ gst_gl_window_win32_egl_init (GstGLWindow * window)
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
GstGLWindowWin32EGL *
|
GstGLWindowWin32EGL *
|
||||||
gst_gl_window_win32_egl_new (GstGLAPI gl_api, guintptr external_gl_context,
|
gst_gl_window_win32_egl_new (void)
|
||||||
GError ** error)
|
|
||||||
{
|
{
|
||||||
GstGLWindowWin32EGL *window =
|
GstGLWindowWin32EGL *window =
|
||||||
g_object_new (GST_GL_TYPE_WINDOW_WIN32_EGL, NULL);
|
g_object_new (GST_GL_TYPE_WINDOW_WIN32_EGL, NULL);
|
||||||
|
|
||||||
gst_gl_window_win32_open_device (GST_GL_WINDOW_WIN32 (window), error);
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,7 @@ struct _GstGLWindowWin32EGLClass {
|
||||||
|
|
||||||
GType gst_gl_window_win32_egl_get_type (void);
|
GType gst_gl_window_win32_egl_get_type (void);
|
||||||
|
|
||||||
GstGLWindowWin32EGL * gst_gl_window_win32_egl_new (GstGLAPI gl_api,
|
GstGLWindowWin32EGL * gst_gl_window_win32_egl_new (void);
|
||||||
guintptr external_gl_context, GError ** error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,11 @@ gst_gl_window_win32_wgl_init (GstGLWindowWin32WGL * window)
|
||||||
|
|
||||||
/* Must be called in the gl thread */
|
/* Must be called in the gl thread */
|
||||||
GstGLWindowWin32WGL *
|
GstGLWindowWin32WGL *
|
||||||
gst_gl_window_win32_wgl_new (GstGLAPI gl_api, guintptr external_gl_context,
|
gst_gl_window_win32_wgl_new (void)
|
||||||
GError ** error)
|
|
||||||
{
|
{
|
||||||
GstGLWindowWin32WGL *window =
|
GstGLWindowWin32WGL *window =
|
||||||
g_object_new (GST_GL_TYPE_WINDOW_WIN32_WGL, NULL);
|
g_object_new (GST_GL_TYPE_WINDOW_WIN32_WGL, NULL);
|
||||||
|
|
||||||
gst_gl_window_win32_open_device (GST_GL_WINDOW_WIN32 (window), error);
|
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +107,8 @@ gst_gl_window_win32_wgl_create_context (GstGLWindowWin32 * window_win32,
|
||||||
}
|
}
|
||||||
g_assert (window_wgl->wgl_context);
|
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;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ gst_gl_window_win32_wgl_destroy_context (GstGLWindowWin32 * window_win32)
|
||||||
|
|
||||||
if (window_wgl->wgl_context)
|
if (window_wgl->wgl_context)
|
||||||
wglDeleteContext (window_wgl->wgl_context);
|
wglDeleteContext (window_wgl->wgl_context);
|
||||||
window_wgl->wgl_context = 0;
|
window_wgl->wgl_context = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -55,8 +55,7 @@ struct _GstGLWindowWin32WGLClass {
|
||||||
|
|
||||||
GType gst_gl_window_win32_wgl_get_type (void);
|
GType gst_gl_window_win32_wgl_get_type (void);
|
||||||
|
|
||||||
GstGLWindowWin32WGL * gst_gl_window_win32_wgl_new (GstGLAPI gl_api,
|
GstGLWindowWin32WGL * gst_gl_window_win32_wgl_new (void);
|
||||||
guintptr external_gl_context, GError ** error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue