basic-tutorial-5: expose_cb() is now draw_cb() and gets a cairo_t directly
authorSebastian Dröge <sebastian@centricular.com>
Mon, 7 Aug 2017 05:58:58 +0000 (08:58 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 7 Aug 2017 05:58:58 +0000 (08:58 +0300)
markdown/tutorials/basic/toolkit-integration.md

index c545df5..228c626 100644 (file)
@@ -676,16 +676,13 @@ we call it when the main window is closed, after stopping the pipeline
 /* This function is called everytime the video window needs to be redrawn (due to damage/exposure,
  * rescaling, etc). GStreamer takes care of this in the PAUSED and PLAYING states, otherwise,
  * we simply draw a black rectangle to avoid garbage showing up. */
-static gboolean expose_cb (GtkWidget *widget, GdkEventExpose *event, CustomData *data) {
+static gboolean draw_cb (GtkWidget *widget, cairo_t *cr, CustomData *data) {
   if (data->state < GST_STATE_PAUSED) {
     GtkAllocation allocation;
-    GdkWindow *window = gtk_widget_get_window (widget);
-    cairo_t *cr;
 
     /* Cairo is a 2D graphics library which we use here to clean the video window.
      * It is used by GStreamer for other reasons, so it will always be available to us. */
     gtk_widget_get_allocation (widget, &allocation);
-    cr = gdk_cairo_create (window);
     cairo_set_source_rgb (cr, 0, 0, 0);
     cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
     cairo_fill (cr);