[Spice-devel] [spice-gtk] mingw: Fix build failure due to epoxy/egl.h header

Fabiano Fidêncio fidencio at redhat.com
Mon Mar 21 14:26:20 UTC 2016


On Mon, Mar 21, 2016 at 3:04 PM, Marc-André Lureau <mlureau at redhat.com> wrote:
> Hi
>
> ----- Original Message -----
>> epoxy/egl.h header is not provided by mingw-epoxy package.
>> Let's avoid egl usage when building using mingw then.
>>
>> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
>> ---
>>  configure.ac            |  1 -
>>  src/Makefile.am         |  2 ++
>>  src/spice-widget-priv.h |  4 ++++
>>  src/spice-widget.c      | 27 ++++++++++++++++++++++++++-
>>  4 files changed, 32 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 24fddc1..4227fd8 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -593,7 +593,6 @@ AC_MSG_NOTICE([
>>          DBus:                     ${have_dbus}
>>          WebDAV support:           ${have_phodav}
>>          LZ4 support:              ${enable_lz4}
>> -        epoxy:                    ${have_epoxy}
>>
>>          Now type 'make' to build $PACKAGE
>>
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index e393913..240d256 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -147,7 +147,9 @@ nodist_SPICE_GTK_SOURCES_COMMON = \
>>
>>  SPICE_GTK_SOURCES_COMMON +=          \
>>       spice-widget-cairo.c            \
>> +if !OS_WIN32
>>       spice-widget-egl.c              \
>> +endif
>>       $(NULL)
>>
>
> This is invalid and will fail to build egl widget on !win32.

You're right.
Squashing this patch fixes the issue:

diff --git a/src/Makefile.am b/src/Makefile.am
index 240d256..66ba58b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -147,10 +147,13 @@ nodist_SPICE_GTK_SOURCES_COMMON = \

 SPICE_GTK_SOURCES_COMMON +=            \
        spice-widget-cairo.c            \
+       $(NULL)
+
 if !OS_WIN32
+SPICE_GTK_SOURCES_COMMON +=            \
        spice-widget-egl.c              \
-endif
        $(NULL)
+endif

Shall I submit a v2?

>
>>  if WITH_GTK
>> diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
>> index 0d1c3ae..2f7e39e 100644
>> --- a/src/spice-widget-priv.h
>> +++ b/src/spice-widget-priv.h
>> @@ -24,7 +24,9 @@
>>  #include <windows.h>
>>  #endif
>>
>> +#ifndef G_OS_WIN32
>>  #include <epoxy/egl.h>
>> +#endif
>>
>>  #include "spice-widget.h"
>>  #include "spice-common.h"
>> @@ -125,6 +127,7 @@ struct _SpiceDisplayPrivate {
>>      int                     x11_accel_denominator;
>>      int                     x11_threshold;
>>  #endif
>> +#ifndef G_OS_WIN32
>>      struct {
>>          gboolean            enabled;
>>          EGLSurface          surface;
>> @@ -140,6 +143,7 @@ struct _SpiceDisplayPrivate {
>>          gboolean            call_draw_done;
>>          SpiceGlScanout      scanout;
>>      } egl;
>> +#endif
>>  };
>>
>>  int      spicex_image_create                 (SpiceDisplay *display);
>> diff --git a/src/spice-widget.c b/src/spice-widget.c
>> index a9c7869..e329809 100644
>> --- a/src/spice-widget.c
>> +++ b/src/spice-widget.c
>> @@ -530,6 +530,7 @@ static void grab_notify(SpiceDisplay *display, gboolean
>> was_grabbed)
>>  }
>>
>>  #if GTK_CHECK_VERSION(3,16,0)
>> +#ifndef G_OS_WIN32
>>  static gboolean
>>  gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user_data)
>>  {
>> @@ -562,6 +563,7 @@ gl_area_realize(GtkGLArea *area, gpointer user_data)
>>      }
>>  }
>>  #endif
>> +#endif
>>
>>  static void
>>  drawing_area_realize(GtkWidget *area, gpointer user_data)
>> @@ -578,11 +580,13 @@ drawing_area_realize(GtkWidget *area, gpointer
>> user_data)
>>          g_clear_error(&err);
>>      }
>>
>> +#ifndef G_OS_WIN32
>>      if (!spice_egl_realize_display(display, gtk_widget_get_window(area),
>>      &err)) {
>>          g_critical("egl realize failed: %s", err->message);
>>          g_clear_error(&err);
>>      }
>>  #endif
>> +#endif
>>  }
>>
>>  static void spice_display_init(SpiceDisplay *display)
>> @@ -604,6 +608,7 @@ static void spice_display_init(SpiceDisplay *display)
>>      gtk_stack_set_visible_child(GTK_STACK(widget), area);
>>
>>  #if GTK_CHECK_VERSION(3,16,0)
>> +#ifndef G_OS_WIN32
>>      area = gtk_gl_area_new();
>>      gtk_gl_area_set_required_version(GTK_GL_AREA(area), 3, 2);
>>      gtk_gl_area_set_auto_render(GTK_GL_AREA(area), false);
>> @@ -614,6 +619,7 @@ static void spice_display_init(SpiceDisplay *display)
>>      gtk_stack_add_named(GTK_STACK(widget), area, "gl-area");
>>      gtk_widget_show_all(widget);
>>  #endif
>> +#endif
>>
>>      g_signal_connect(display, "grab-broken-event", G_CALLBACK(grab_broken),
>>      NULL);
>>      g_signal_connect(display, "grab-notify", G_CALLBACK(grab_notify), NULL);
>> @@ -1182,6 +1188,7 @@ static gboolean do_color_convert(SpiceDisplay *display,
>> GdkRectangle *r)
>>      return true;
>>  }
>>
>> +#ifndef G_OS_WIN32
>>  static void set_egl_enabled(SpiceDisplay *display, bool enabled)
>>  {
>>      SpiceDisplayPrivate *d = display->priv;
>> @@ -1211,6 +1218,7 @@ static void set_egl_enabled(SpiceDisplay *display, bool
>> enabled)
>>
>>      d->egl.enabled = enabled;
>>  }
>> +#endif
>>
>>  static gboolean draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
>>  {
>> @@ -1218,11 +1226,13 @@ static gboolean draw_event(GtkWidget *widget, cairo_t
>> *cr, gpointer data)
>>      SpiceDisplayPrivate *d = display->priv;
>>      g_return_val_if_fail(d != NULL, false);
>>
>> +#ifndef G_OS_WIN32
>>      if (d->egl.enabled &&
>>          g_str_equal(gtk_stack_get_visible_child_name(GTK_STACK(display)),
>>          "draw-area")) {
>>          spice_egl_update_display(display);
>>          return false;
>>      }
>> +#endif
>>
>>      if (d->mark == 0 || d->data == NULL ||
>>          d->area.width == 0 || d->area.height == 0)
>> @@ -1826,8 +1836,10 @@ static void size_allocate(GtkWidget *widget,
>> GtkAllocation *conf, gpointer data)
>>          d->ww = conf->width;
>>          d->wh = conf->height;
>>          recalc_geometry(widget);
>> +#ifndef G_OS_WIN32
>>          if (d->egl.enabled)
>>              spice_egl_resize_display(display, conf->width, conf->height);
>> +#endif
>>      }
>>
>>      d->mx = conf->x;
>> @@ -1867,7 +1879,9 @@ static void realize(GtkWidget *widget)
>>  static void unrealize(GtkWidget *widget)
>>  {
>>      spicex_image_destroy(SPICE_DISPLAY(widget));
>> +#ifndef G_OS_WIN32
>>      spice_egl_unrealize_display(SPICE_DISPLAY(widget));
>> +#endif
>>
>>      GTK_WIDGET_CLASS(spice_display_parent_class)->unrealize(widget);
>>  }
>> @@ -2250,7 +2264,9 @@ static void invalidate(SpiceChannel *channel,
>>          .height = h
>>      };
>>
>> +#ifndef G_OS_WIN32
>>      set_egl_enabled(display, false);
>> +#endif
>>
>>      if (!gtk_widget_get_window(GTK_WIDGET(display)))
>>          return;
>> @@ -2315,7 +2331,9 @@ static void cursor_set(SpiceCursorChannel *channel,
>>      } else
>>          g_warn_if_reached();
>>
>> +#ifndef G_OS_WIN32
>>      spice_egl_cursor_set(display);
>> +#endif
>>      if (d->show_cursor) {
>>          /* unhide */
>>          gdk_cursor_unref(d->show_cursor);
>> @@ -2463,6 +2481,7 @@ static void cursor_reset(SpiceCursorChannel *channel,
>> gpointer data)
>>      gdk_window_set_cursor(window, NULL);
>>  }
>>
>> +#ifndef G_OS_WIN32
>>  static void gl_scanout(SpiceDisplay *display)
>>  {
>>      SpiceDisplayPrivate *d = display->priv;
>> @@ -2502,6 +2521,7 @@ static void gl_draw(SpiceDisplay *display,
>>          spice_display_gl_draw_done(SPICE_DISPLAY_CHANNEL(d->display));
>>      }
>>  }
>> +#endif
>>
>>  static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer
>>  data)
>>  {
>> @@ -2538,10 +2558,12 @@ static void channel_new(SpiceSession *s, SpiceChannel
>> *channel, gpointer data)
>>                             primary.stride, primary.shmid, primary.data,
>>                             display);
>>              mark(display, primary.marked);
>>          }
>> +#ifndef G_OS_WIN32
>>          spice_g_signal_connect_object(channel, "notify::gl-scanout",
>>                                        G_CALLBACK(gl_scanout), display,
>>                                        G_CONNECT_SWAPPED);
>>          spice_g_signal_connect_object(channel, "gl-draw",
>>                                        G_CALLBACK(gl_draw), display,
>>                                        G_CONNECT_SWAPPED);
>> +#endif
>>
>>          spice_channel_connect(channel);
>>          return;
>> @@ -2693,6 +2715,7 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay
>> *display)
>>      g_return_val_if_fail(d != NULL, NULL);
>>      g_return_val_if_fail(d->display != NULL, NULL);
>>
>> +#ifndef G_OS_WIN32
>>      if (d->egl.enabled) {
>>          GdkPixbuf *tmp;
>>
>> @@ -2707,7 +2730,9 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay
>> *display)
>>                                         (GdkPixbufDestroyNotify)g_free,
>>                                         NULL);
>>          pixbuf = gdk_pixbuf_flip(tmp, false);
>>          g_object_unref(tmp);
>> -    } else {
>> +    } else
>> +#endif
>> +    {
>>          guchar *src, *dest;
>>          int x, y;
>>
>> --
>> 2.5.0
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/spice-devel
>>


More information about the Spice-devel mailing list