[gst-devel] gstxoverlay - GTK app - avoid flickering
Julien Isorce
julien.isorce at gmail.com
Mon Jul 7 19:53:10 CEST 2008
Hi,
Just to share (or have some suggestions) a way to avoid flickering when
resizing or obscuring a window used through the gstxoverlay interface:
------------------------------------------------------------------------------------------
//the first 3 lines turn off the "automatically redraw background"
gtk_widget_realize(area);
gdk_window_set_back_pixmap(area->window, NULL, FALSE);
gtk_widget_set_app_paintable(area,TRUE);
//The previous lines avoid flickering, but if we have a double buffer
//the problem is now due to the fact that the gstxoverlay interface give the
XID
//of the "front buffer". (<- not exactly true but to make me understood)
//So when swaping buffers, there is this *ugly* flickering effect too.
gtk_widget_set_double_buffered(area, FALSE);
//To keep double buffered, we should have to draw in the backbuffer
//but I do no know if there is a XID (HWND) for the backfuffer
//Yes I know there is only one XID (nothing to deal with front and back
buffers)
//So I do not know a way to do that :P
------------------------------------------------------------------------------------------
static GstBusSyncReply create_window (GstBus* bus, GstMessage* message,
GtkWidget* widget)
{
// ignore anything but 'prepare-xwindow-id' element messages
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
return GST_BUS_PASS;
g_print ("setting xwindow id\n");
#ifdef WIN32
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
reinterpret_cast<gulong>GDK_WINDOW_HWND(widget->window));
#else
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
GDK_WINDOW_XWINDOW(widget->window));
#endif
gst_message_unref (message);
return GST_BUS_DROP;
}
------------------------------------------------------------------------------------------
static gboolean expose_cb(GtkWidget* widget, GdkEventExpose* event,
GstElement* videosink)
{
gst_x_overlay_expose (GST_X_OVERLAY (videosink));
return FALSE;
}
------------------------------------------------------------------------------------------
(for information, with Qt the equivalent is
widget->setAttribute(Qt::WA_NoSystemBackground); )
Sincerely
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20080707/ddecf7e0/attachment.htm>
More information about the gstreamer-devel
mailing list