From: David Schleef Date: Sun, 6 Jan 2008 03:01:39 +0000 (+0000) Subject: [052/906] * sys/glsink/glimagesink.c: * sys/glsink/glimagesink.h: * sys/glsink/gstglb... X-Git-Tag: 1.16.2~955^2~2203 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0fc0cebe63e7142ffc4ceeda3664ad70bb48380;p=platform%2Fupstream%2Fgst-plugins-base.git [052/906] * sys/glsink/glimagesink.c: * sys/glsink/glimagesink.h: * sys/glsink/gstglbuffer.h: * sys/glsink/gstgldisplay.c: * sys/glsink/gstgldisplay.h: * sys/glsink/gstglupload.c: Handle xoverlay exposes correctly. This means glimagesink works correctly most of the time in totem (fullscreening being an execption). Doesn't handle expose events directly to the GL window. --- diff --git a/gst-libs/gst/gl/gstglbuffer.h b/gst-libs/gst/gl/gstglbuffer.h index cf2e014..0cf27de 100644 --- a/gst-libs/gst/gl/gstglbuffer.h +++ b/gst-libs/gst/gl/gstglbuffer.h @@ -41,6 +41,9 @@ struct _GstGLBuffer { GType gst_gl_buffer_get_type (void); +#define gst_gl_buffer_ref(x) ((GstGLBuffer *)(gst_buffer_ref((GstBuffer *)(x)))) +#define gst_gl_buffer_unref(x) (gst_buffer_unref((GstBuffer *)(x))) + GstGLBuffer * gst_gl_buffer_new (GstGLDisplay *display, int width, int height); GstGLBuffer * gst_gl_buffer_new_with_format (GstGLDisplay *display, diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index d90e5e7..99a732e 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -345,18 +345,49 @@ gst_gl_display_set_window (GstGLDisplay * display, Window window) { g_mutex_lock (display->lock); - if (window != display->parent_window) { - gst_gl_display_destroy_tmp_window (display); - + if (display->display == NULL) { display->parent_window = window; + } else { + if (window != display->parent_window) { + XSync (display->display, False); + + gst_gl_display_destroy_tmp_window (display); - gst_gl_display_init_tmp_window (display); + display->parent_window = window; + + gst_gl_display_init_tmp_window (display); + } } g_mutex_unlock (display->lock); } void +gst_gl_display_update_window (GstGLDisplay * display) +{ + XWindowAttributes attr; + + g_return_if_fail (display != NULL); + + g_mutex_lock (display->lock); + if (display->window != None && display->parent_window != None) { + XSync (display->display, False); + XGetWindowAttributes (display->display, display->parent_window, &attr); + + GST_DEBUG ("new size %d %d", attr.width, attr.height); + + if (display->win_width != attr.width || display->win_height != attr.height) { + XResizeWindow (display->display, display->window, + attr.width, attr.height); + //XSync (display->display, False); + } + display->win_width = attr.width; + display->win_height = attr.height; + } + g_mutex_unlock (display->lock); +} + +void gst_gl_display_update_attributes (GstGLDisplay * display) { XWindowAttributes attr; @@ -376,6 +407,17 @@ gst_gl_display_update_attributes (GstGLDisplay * display) } void +gst_gl_display_set_window_size (GstGLDisplay * display, int width, int height) +{ + if (display->win_width != width || display->win_height != height) { + display->win_width = width; + display->win_height = height; + XResizeWindow (display->display, display->window, width, height); + XSync (display->display, False); + } +} + +void gst_gl_display_clear (GstGLDisplay * display) { gst_gl_display_lock (display); @@ -752,7 +794,7 @@ gst_gl_display_draw_image (GstGLDisplay * display, GstVideoFormat type, void gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture, - int width, int height) + int width, int height, gboolean sync) { g_return_if_fail (width > 0); g_return_if_fail (height > 0); @@ -763,7 +805,7 @@ gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture, g_assert (display->window != None); g_assert (display->context != NULL); - gst_gl_display_update_attributes (display); + //gst_gl_display_update_attributes (display); #if 0 /* Doesn't work */ { @@ -778,10 +820,11 @@ gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture, } #endif -#if 1 - /* Doesn't work */ - glXSwapIntervalSGI (1); -#endif + if (sync) { + glXSwapIntervalSGI (1); + } else { + glXSwapIntervalSGI (0); + } glViewport (0, 0, display->win_width, display->win_height); diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index 5886884..1b2c9df 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -71,16 +71,15 @@ void gst_gl_display_unlock (GstGLDisplay *display); void gst_gl_display_set_window (GstGLDisplay *display, Window window); void gst_gl_display_update_attributes (GstGLDisplay *display); void gst_gl_display_clear (GstGLDisplay *display); -void gst_gl_display_draw_image (GstGLDisplay * display, GstVideoFormat type, - void *data, int width, int height); -void gst_gl_display_draw_rbo (GstGLDisplay * display, GLuint rbo, - int width, int height); void gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture, - int width, int height); + int width, int height, gboolean sync); void gst_gl_display_check_error (GstGLDisplay *display, int line); GLuint gst_gl_display_upload_texture_rectangle (GstGLDisplay *display, GstVideoFormat type, void *data, int width, int height); void gst_gl_display_set_visible (GstGLDisplay *display, gboolean visible); +void gst_gl_display_set_window_size (GstGLDisplay *display, int width, + int height); +void gst_gl_display_update_window (GstGLDisplay * display); #endif