From 5db4db68369e10cf1278a197045bbb40a903896c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 13 Apr 2014 16:40:58 +0200 Subject: [PATCH] gl/android: Notify the window's resize callback about surface dimension changes https://bugzilla.gnome.org/show_bug.cgi?id=728107 --- .../gst/gl/android/gstglwindow_android_egl.c | 22 ++++++++++++++++++- .../gst/gl/android/gstglwindow_android_egl.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.c b/gst-libs/gst/gl/android/gstglwindow_android_egl.c index 1f23b28ee6..1a70999ce1 100644 --- a/gst-libs/gst/gl/android/gstglwindow_android_egl.c +++ b/gst-libs/gst/gl/android/gstglwindow_android_egl.c @@ -30,6 +30,7 @@ #include +#include #include "gstglwindow_android_egl.h" #define GST_CAT_DEFAULT gst_gl_window_debug @@ -212,8 +213,26 @@ draw_cb (gpointer data) GstGLWindowAndroidEGL *window_egl = draw_data->window; 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); @@ -226,8 +245,9 @@ static void gst_gl_window_android_egl_draw (GstGLWindow * window, guint width, guint height) { struct draw draw_data; + GstGLWindowAndroidEGL *window_egl = GST_GL_WINDOW_ANDROID_EGL (window); - draw_data.window = GST_GL_WINDOW_ANDROID_EGL (window); + draw_data.window = window_egl; draw_data.width = width; draw_data.height = height; diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.h b/gst-libs/gst/gl/android/gstglwindow_android_egl.h index e5ea1cb71d..0e927e3eca 100644 --- a/gst-libs/gst/gl/android/gstglwindow_android_egl.h +++ b/gst-libs/gst/gl/android/gstglwindow_android_egl.h @@ -42,6 +42,7 @@ struct _GstGLWindowAndroidEGL { /* This is actually an ANativeWindow */ EGLNativeWindowType native_window; + gint window_width, window_height; GMainContext *main_context; GMainLoop *loop;