gstxoverlay - GTK app - avoid flickering

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

gstxoverlay - GTK app - avoid flickering

Julien Isorce
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.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel