static void draw_cb (gpointer data) { GstGLWindowAndroidEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (context_egl->egl_surface) { gint width, height; if (eglQuerySurface (context_egl->egl_display, context_egl->egl_surface, EGL_WIDTH, &width) && eglQuerySurface (context_egl->egl_display, context_egl->egl_surface, EGL_HEIGHT, &height) && (width != window_egl->window_width || height != window_egl->window_height)) { window_egl->window_width = width; window_egl->window_height = height; if (window->resize) window->resize (window->resize_data, width, height); } } if (window->draw) window->draw (window->draw_data); context_class->swap_buffers (context); gst_object_unref (context); }
static void draw_cb (gpointer data) { GstGLWindowWaylandEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); create_surfaces (window_egl); if (window_egl->window.subsurface) wl_subsurface_set_desync (window_egl->window.subsurface); if (window->queue_resize) { guint width, height; gst_gl_window_get_surface_dimensions (window, &width, &height); gst_gl_window_resize (window, width, height); } if (window->draw) window->draw (window->draw_data); context_class->swap_buffers (context); if (window_egl->window.subsurface) wl_subsurface_set_desync (window_egl->window.subsurface); gst_object_unref (context); }
static void draw_cb (gpointer data) { GstGLWindowWaylandEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window->draw) window->draw (window->draw_data); context_class->swap_buffers (context); gst_object_unref (context); }
static void draw_cb (gpointer data) { struct draw *draw_data = data; GstGLDummyWindow *dummy = draw_data->window; GstGLWindow *window = GST_GL_WINDOW (dummy); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window->draw) window->draw (window->draw_data); context_class->swap_buffers (context); gst_object_unref (context); }
static void window_resize (GstGLWindowWaylandEGL * window_egl, guint width, guint height) { GstGLWindow *window = GST_GL_WINDOW (window_egl); GST_DEBUG ("resizing window from %ux%u to %ux%u", window_egl->window.window_width, window_egl->window.window_height, width, height); if (window_egl->window.native) { wl_egl_window_resize (window_egl->window.native, width, height, 0, 0); } if (window->resize) window->resize (window->resize_data, width, height); window_egl->window.window_width = width; window_egl->window.window_height = height; }
static void draw_cb (gpointer data) { GstGLWindow *window = GST_GL_WINDOW (data); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window->queue_resize) { guint width, height; gst_gl_window_get_surface_dimensions (window, &width, &height); gst_gl_window_resize (window, width, height); } if (window->draw) window->draw (window->draw_data); if (context_class->swap_buffers) context_class->swap_buffers (context); gst_object_unref (context); }
static void draw_cb (gpointer data) { GstGLWindowDispmanxEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window_egl->native.width != window_egl->preferred_width || window_egl->native.height != window_egl->preferred_height) { GST_DEBUG ("dimensions don't match, attempting resize"); window_resize (window_egl, window_egl->preferred_width, window_egl->preferred_height); } if (window->draw) window->draw (window->draw_data); context_class->swap_buffers (context); gst_object_unref (context); }
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { GstGLWindowWin32 *window_win32; LRESULT ret = 0; if (uMsg == WM_CREATE) { window_win32 = GST_GL_WINDOW_WIN32 (((LPCREATESTRUCT) lParam)->lpCreateParams); GST_TRACE ("WM_CREATE"); window_win32->device = GetDC (hWnd); /* Do this, otherwise we hang on exit. We can still use it (due to the * CS_OWNDC flag in the WindowClass) after we have Released. */ ReleaseDC (hWnd, window_win32->device); SetProp (hWnd, "gl_window", window_win32); } else if (GetProp (hWnd, "gl_window")) { GstGLWindow *window; GstGLContext *context; GstGLContextClass *context_class; window_win32 = GST_GL_WINDOW_WIN32 (GetProp (hWnd, "gl_window")); window = GST_GL_WINDOW (window_win32); context = gst_gl_window_get_context (window); context_class = GST_GL_CONTEXT_GET_CLASS (context); g_assert (window_win32->internal_win_id == hWnd); switch (uMsg) { case WM_SIZE: { if (window->resize) { window->resize (window->resize_data, LOWORD (lParam), HIWORD (lParam)); } break; } case WM_PAINT: { if (window->draw) { PAINTSTRUCT ps; BeginPaint (hWnd, &ps); window->draw (window->draw_data); context_class->swap_buffers (context); EndPaint (hWnd, &ps); } break; } case WM_CLOSE: { ShowWindowAsync (window_win32->internal_win_id, SW_HIDE); GST_TRACE ("WM_CLOSE"); if (window->close) window->close (window->close_data); break; } case WM_CAPTURECHANGED: { GST_DEBUG ("WM_CAPTURECHANGED"); if (window->draw) window->draw (window->draw_data); break; } case WM_ERASEBKGND: { ret = TRUE; break; } default: { /* transmit messages to the parrent (ex: mouse/keyboard input) */ HWND parent_id = window_win32->parent_win_id; if (parent_id) PostMessage (parent_id, uMsg, wParam, lParam); ret = DefWindowProc (hWnd, uMsg, wParam, lParam); } } gst_object_unref (context); } else { ret = DefWindowProc (hWnd, uMsg, wParam, lParam); } return ret; }
LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { GstGLWindowWin32 *window_win32; if (uMsg == WM_CREATE) { window_win32 = GST_GL_WINDOW_WIN32 (((LPCREATESTRUCT) lParam)->lpCreateParams); GST_TRACE ("WM_CREATE"); window_win32->device = GetDC (hWnd); /* Do this, otherwise we hang on exit. We can still use it (due to the * CS_OWNDC flag in the WindowClass) after we have Released. */ ReleaseDC (hWnd, window_win32->device); SetProp (hWnd, "gl_window", window_win32); return 0; } else if (GetProp (hWnd, "gl_window")) { GstGLWindow *window; GstGLContext *context; GstGLContextClass *context_class; window_win32 = GST_GL_WINDOW_WIN32 (GetProp (hWnd, "gl_window")); window = GST_GL_WINDOW (window_win32); context = gst_gl_window_get_context (window); context_class = GST_GL_CONTEXT_GET_CLASS (context); g_assert (window_win32->internal_win_id == hWnd); switch (uMsg) { case WM_SIZE: { if (window->resize) { window->resize (window->resize_data, LOWORD (lParam), HIWORD (lParam)); } break; } case WM_PAINT: { if (window->draw) { PAINTSTRUCT ps; BeginPaint (hWnd, &ps); window->draw (window->draw_data); context_class->swap_buffers (context); EndPaint (hWnd, &ps); } break; } case WM_CLOSE: { ShowWindowAsync (window_win32->internal_win_id, SW_HIDE); GST_TRACE ("WM_CLOSE"); if (window->close) window->close (window->close_data); break; } case WM_GST_GL_WINDOW_QUIT: { HWND parent_id = 0; GST_TRACE ("WM_GST_GL_WINDOW_QUIT"); parent_id = window_win32->parent_win_id; if (parent_id) { WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc"); g_assert (parent_proc); SetWindowLongPtr (parent_id, GWLP_WNDPROC, (LONG_PTR) parent_proc); SetParent (hWnd, NULL); RemoveProp (parent_id, "gl_window_parent_proc"); } window_win32->is_closed = TRUE; RemoveProp (hWnd, "gl_window"); if (window_win32->internal_win_id) { if (!DestroyWindow (window_win32->internal_win_id)) GST_WARNING ("failed to destroy window %" G_GUINTPTR_FORMAT ", 0x%x", (guintptr) hWnd, (unsigned int) GetLastError ()); } PostQuitMessage (0); break; } case WM_CAPTURECHANGED: { GST_DEBUG ("WM_CAPTURECHANGED"); if (window->draw) window->draw (window->draw_data); break; } case WM_GST_GL_WINDOW_CUSTOM: { if (!window_win32->is_closed) { GstGLMessage *message = (GstGLMessage *) wParam; _run_message (message); } break; } case WM_ERASEBKGND: return TRUE; default: { /* transmit messages to the parrent (ex: mouse/keyboard input) */ HWND parent_id = window_win32->parent_win_id; if (parent_id) PostMessage (parent_id, uMsg, wParam, lParam); return DefWindowProc (hWnd, uMsg, wParam, lParam); } } gst_object_unref (context); return 0; } else { return DefWindowProc (hWnd, uMsg, wParam, lParam); } }