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
+ gint window_width, window_height;
+
+ gst_gl_window_get_surface_dimensions (window, &window_width,
+ &window_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)
+ && (window->queue_resize || 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);
+ gst_gl_window_resize (window, width, height);
}
}
GDestroyNotify resize_notify;
gint can_draw;
+ gboolean queue_resize;
}
- (void) setDrawCallback:(GstGLWindowCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
- (void) setResizeCallback:(GstGLWindowResizeCB)cb data:(gpointer)a notify:(GDestroyNotify)notify;
+- (void) queueResize;
- (id) initWithGstGLContext: (GstGLContextCocoa *)context;
@end
gl->GetIntegerv (GL_VIEWPORT, ca_viewport);
gst_gl_context_activate (self->draw_context, TRUE);
- if (self->last_bounds.size.width != self.bounds.size.width
+ if (self->queue_resize || self->last_bounds.size.width != self.bounds.size.width
|| self->last_bounds.size.height != self.bounds.size.height) {
if (self->resize_cb) {
self->resize_cb (self->resize_data, self.bounds.size.width,
}
self->last_bounds = self.bounds;
+ self->queue_resize = FALSE;
}
src.x = self->expected_dims[0];
static void gst_gl_window_cocoa_set_preferred_size (GstGLWindow * window,
gint width, gint height);
static void gst_gl_window_cocoa_show (GstGLWindow * window);
+static void gst_gl_window_cocoa_queue_resize (GstGLWindow * window);
struct _GstGLWindowCocoaPrivate
{
window_class->set_preferred_size =
GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_set_preferred_size);
window_class->show = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_show);
+ window_class->queue_resize = GST_DEBUG_FUNCPTR (gst_gl_window_cocoa_queue_resize);
gobject_class->finalize = gst_gl_window_cocoa_finalize;
}
}
static void
+gst_gl_window_cocoa_queue_resize (GstGLWindow * window)
+{
+ GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
+ GstGLNSView *view;
+
+ if (!g_atomic_int_get (&window_cocoa->priv->view_ready))
+ return;
+
+ view = (GstGLNSView *)[window_cocoa->priv->internal_win_id contentView];
+
+ [view->layer queueResize];
+}
+
+static void
gst_gl_window_cocoa_draw (GstGLWindow * window)
{
GstGLWindowCocoa *window_cocoa = GST_GL_WINDOW_COCOA (window);
visibleRect.origin.x, visibleRect.origin.y,
visibleRect.size.width, visibleRect.size.height);
- if (window->resize) {
- window->resize (window->resize_data, width, height);
- gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
- }
+ gst_gl_window_resize (window, width, height);
+ gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
gl->Viewport (viewport_dim[0] - visibleRect.origin.x,
viewport_dim[1] - visibleRect.origin.y,
window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height,
gboolean visible)
{
+ GstGLWindow *window = GST_GL_WINDOW (window_egl);
+
GST_DEBUG ("resizing %s window from %ux%u to %ux%u",
visible ? "visible" : "invisible", window_egl->native.width,
window_egl->native.height, width, height);
vc_dispmanx_update_submit_sync (dispman_update);
- if (GST_GL_WINDOW (window_egl)->resize)
- GST_GL_WINDOW (window_egl)->
- resize (GST_GL_WINDOW (window_egl)->resize_data, width, height);
+ if (window->resize)
+ window->resize (window->resize_data, width, height);
}
window_egl->native.width = width;
eagl_layer = (CAEAGLLayer *)[window_eagl->priv->view layer];
size = eagl_layer.frame.size;
- if (window_eagl->priv->window_width != size.width ||
+ if (window->queue_resize || window_eagl->priv->window_width != size.width ||
window_eagl->priv->window_height != size.height) {
window_eagl->priv->window_width = size.width;
gst_gl_context_eagl_resize (eagl_context);
- if (window->resize)
- window->resize (window->resize_data, window_eagl->priv->window_width,
+ gst_gl_window_resize (window, window_eagl->priv->window_width,
window_eagl->priv->window_height);
}
}
GMainLoop *loop;
GThread *navigation_thread;
+ guint surface_width;
+ guint surface_height;
+
gboolean alive;
};
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);
g_return_if_fail (window_class->draw_unlocked != NULL);
window_class->draw_unlocked (window);
+
+ window->queue_resize = FALSE;
}
/**
}
window_class->draw (window);
+
+ window->queue_resize = FALSE;
}
/**
gst_gl_window_get_surface_dimensions (GstGLWindow * window, guint * width,
guint * height)
{
- GstGLWindowClass *window_class;
- g_return_if_fail (GST_GL_IS_WINDOW (window));
- window_class = GST_GL_WINDOW_GET_CLASS (window);
- g_return_if_fail (window_class->get_surface_dimensions != NULL);
- window_class->get_surface_dimensions (window, width, height);
+ if (width)
+ *width = window->priv->surface_width;
+ if (height)
+ *height = window->priv->surface_height;
}
GType gst_gl_dummy_window_get_type (void);
}
static void
-gst_gl_dummy_window_get_surface_dimensions (GstGLWindow * window, guint * width,
- guint * height)
-{
-}
-
-static void
gst_gl_dummy_window_class_init (GstGLDummyWindowClass * klass)
{
GstGLWindowClass *window_class = (GstGLWindowClass *) klass;
GST_DEBUG_FUNCPTR (gst_gl_dummy_window_get_window_handle);
window_class->set_window_handle =
GST_DEBUG_FUNCPTR (gst_gl_dummy_window_set_window_handle);
- window_class->get_surface_dimensions =
- GST_DEBUG_FUNCPTR (gst_gl_dummy_window_get_surface_dimensions);
}
static void
return ret;
}
+
+void
+gst_gl_window_queue_resize (GstGLWindow * window)
+{
+ GstGLWindowClass *window_class;
+
+ g_return_val_if_fail (GST_GL_IS_WINDOW (window), FALSE);
+ window_class = GST_GL_WINDOW_GET_CLASS (window);
+
+ window->queue_resize = TRUE;
+ if (window_class->queue_resize)
+ window_class->queue_resize (window);
+}
+
+void
+gst_gl_window_resize (GstGLWindow * window, guint width, guint height)
+{
+ g_return_if_fail (GST_GL_IS_WINDOW (window));
+
+ if (window->resize)
+ window->resize (window->resize_data, width, height);
+
+ window->priv->surface_width = width;
+ window->priv->surface_height = height;
+}
gpointer resize_data;
GDestroyNotify resize_notify;
+ gboolean queue_resize;
+
/*< private >*/
GMainContext *navigation_context;
GMainLoop *navigation_loop;
gboolean (*open) (GstGLWindow *window, GError **error);
void (*close) (GstGLWindow *window);
- void (*get_surface_dimensions) (GstGLWindow *window, guint *width, guint *height);
void (*handle_events) (GstGLWindow *window, gboolean handle_events);
void (*set_preferred_size) (GstGLWindow *window, gint width, gint height);
void (*show) (GstGLWindow *window);
gboolean (*set_render_rectangle)(GstGLWindow *window, gint x, gint y, gint width, gint height);
+ void (*queue_resize) (GstGLWindow *window);
/*< private >*/
gpointer _reserved[GST_PADDING];
double posy);
/* surfaces/rendering */
+void gst_gl_window_queue_resize (GstGLWindow *window);
void gst_gl_window_draw_unlocked (GstGLWindow *window);
void gst_gl_window_draw (GstGLWindow *window);
void gst_gl_window_show (GstGLWindow *window);
gint width,
gint height);
+/* subclass usage only */
+void gst_gl_window_resize (GstGLWindow *window, guint width, guint height);
+
GstGLContext * gst_gl_window_get_context (GstGLWindow *window);
guintptr gst_gl_window_get_display (GstGLWindow *window);
window_egl->window.window_height = height;
if (!window_egl->window.native) {
+ gst_gl_window_resize (GST_GL_WINDOW (window_egl), width, height);
+
window_egl->window.native =
wl_egl_window_create (window_egl->window.surface, width, height);
if (window_egl->window.queue)
wl_egl_window_resize (window_egl->window.native, width, height, 0, 0);
}
- if (window->resize)
- window->resize (window->resize_data, width, height);
+ gst_gl_window_resize (window, width, height);
window_egl->window.window_width = width;
window_egl->window.window_height = height;
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);
switch (uMsg) {
case WM_SIZE:
- {
- if (window->resize) {
- window->resize (window->resize_data, LOWORD (lParam),
- HIWORD (lParam));
- }
+ gst_gl_window_resize (window, LOWORD (lParam), HIWORD (lParam));
break;
- }
case WM_PAINT:
{
+ 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) {
PAINTSTRUCT ps;
BeginPaint (hWnd, &ps);
case WM_CAPTURECHANGED:
{
GST_DEBUG ("WM_CAPTURECHANGED");
+ 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);
break;
GstGLAPI gl_api, guintptr external_gl_context, GError ** error);
gboolean gst_gl_window_x11_open (GstGLWindow * window, GError ** error);
void gst_gl_window_x11_close (GstGLWindow * window);
-static void gst_gl_window_x11_get_surface_dimensions (GstGLWindow * window,
- guint * width, guint * height);
void gst_gl_window_x11_handle_events (GstGLWindow * window,
gboolean handle_events);
window_class->draw = GST_DEBUG_FUNCPTR (gst_gl_window_x11_draw);
window_class->open = GST_DEBUG_FUNCPTR (gst_gl_window_x11_open);
window_class->close = GST_DEBUG_FUNCPTR (gst_gl_window_x11_close);
- window_class->get_surface_dimensions =
- GST_DEBUG_FUNCPTR (gst_gl_window_x11_get_surface_dimensions);
window_class->handle_events =
GST_DEBUG_FUNCPTR (gst_gl_window_x11_handle_events);
window_class->set_preferred_size =
if (gst_gl_window_is_running (GST_GL_WINDOW (window_x11))
&& window_x11->allow_extra_expose_events) {
+ 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) {
GstGLContext *context = gst_gl_window_get_context (window);
GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
case CreateNotify:
case ConfigureNotify:
{
- if (window->resize)
- window->resize (window->resize_data, event.xconfigure.width,
- event.xconfigure.height);
-
- window_x11->current_width = event.xconfigure.width;
- window_x11->current_height = event.xconfigure.height;
+ gst_gl_window_resize (window, event.xconfigure.width,
+ event.xconfigure.height);
break;
}
gst_object_unref (context);
}
-
- window_x11->current_width = event.xexpose.width;
- window_x11->current_height = event.xexpose.height;
break;
case VisibilityNotify:
return (guintptr) window_x11->device;
}
-
-static void
-gst_gl_window_x11_get_surface_dimensions (GstGLWindow * window, guint * width,
- guint * height)
-{
- GstGLWindowX11 *window_x11 = GST_GL_WINDOW_X11 (window);
- if (width != NULL)
- *width = window_x11->current_width;
- if (height != NULL)
- *height = window_x11->current_height;
-}
gint depth;
gint device_width;
gint device_height;
- gint current_width;
- gint current_height;
gint connection;
XVisualInfo *visual_info;
Window parent_win;