[clutter-gst] refactoring: Do not depend on any GL symbol



commit c369b5bb7bfb557ce92bacc34810b8afe320cc60
Author: Damien Lespiau <damien lespiau intel com>
Date:   Tue Sep 27 14:42:41 2011 +0100

    refactoring: Do not depend on any GL symbol
    
    Since Cogl 1.8.0 we can use cogl_renderer_get_n_fragment_texture_units()
    to know the number of texture image units available for fragment
    shaders and we can thus avoid using the direct GL call glGetIntegerv and
    linking against libGL.
    
    This does not work on OS X though as we can't get the CoglContext out of
    the ClutterBackend is that case. Make sure to special case this.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=657225

 clutter-gst/Makefile.am              |   17 ++++++++++-------
 clutter-gst/clutter-gst-video-sink.c |   33 ++++++++++++++++++++++++++++++++-
 configure.ac                         |   30 ++++++++++++++++++++++++++----
 3 files changed, 68 insertions(+), 12 deletions(-)
---
diff --git a/clutter-gst/Makefile.am b/clutter-gst/Makefile.am
index a3f4c44..f75994f 100644
--- a/clutter-gst/Makefile.am
+++ b/clutter-gst/Makefile.am
@@ -61,13 +61,16 @@ INCLUDES =					\
 	-I$(top_srcdir)/clutter-gst/shaders	\
 	$(NULL)
 
-AM_CPPFLAGS =				\
-	-DCLUTTER_GST_COMPILATION	\
-	-DG_DISABLE_DEPRECATED		\
-	-DG_DISABLE_SINGLE_INCLUDES	\
-	-DCOGL_DISABLE_DEPRECATED	\
-	-DCLUTTER_DISABLE_DEPRECATED	\
-	-DG_LOG_DOMAIN=\"Clutter-Gst\"	\
+AM_CPPFLAGS =					\
+	-DCLUTTER_GST_COMPILATION		\
+	-DG_DISABLE_DEPRECATED			\
+	-DG_DISABLE_SINGLE_INCLUDES		\
+	-DCOGL_DISABLE_DEPRECATED		\
+	-DCOGL_ENABLE_EXPERIMENTAL_API		\
+	-DCOGL_ENABLE_EXPERIMENTAL_2_0_API	\
+	-DCLUTTER_DISABLE_DEPRECATED		\
+	-DCLUTTER_ENABLE_EXPERIMENTAL_API	\
+	-DG_LOG_DOMAIN=\"Clutter-Gst\"		\
 	$(NULL)
 
 AM_CFLAGS = 				\
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c
index 3246693..090480a 100644
--- a/clutter-gst/clutter-gst-video-sink.c
+++ b/clutter-gst/clutter-gst-video-sink.c
@@ -380,6 +380,37 @@ _string_array_to_char_array (char	*dst,
 }
 #endif
 
+#if defined (HAVE_COGL_1_8) && !defined (HAVE_CLUTTER_OSX)
+static gint
+get_n_fragment_texture_units (void)
+{
+  ClutterBackend *backend;
+  CoglContext *context;
+  CoglDisplay *display;
+  CoglRenderer *renderer;
+  gint n;
+
+  backend = clutter_get_default_backend ();
+  context = clutter_backend_get_cogl_context (backend);
+  display = cogl_context_get_display (context);
+  renderer = cogl_display_get_renderer (display);
+
+  n = cogl_renderer_get_n_fragment_texture_units (renderer);
+  g_message ("get_n_fragment_texture_units () -> %d", n);
+
+  return n;
+}
+#else
+static gint
+get_n_fragment_texture_units (void)
+{
+  gint n_texture_units;
+
+  glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &n_texture_units);
+  return n_texture_units;
+}
+#endif
+
 static CoglHandle
 _create_cogl_program (const char *source)
 {
@@ -796,7 +827,7 @@ clutter_gst_build_renderers_list (void)
       NULL
     };
 
-  glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &nb_texture_units);
+  nb_texture_units = get_n_fragment_texture_units();
 
   if (nb_texture_units >= 3)
     features |= CLUTTER_GST_MULTI_TEXTURE;
diff --git a/configure.ac b/configure.ac
index 1fafe5e..0a9d840 100644
--- a/configure.ac
+++ b/configure.ac
@@ -163,10 +163,32 @@ dnl issues
 dnl Why don't we "just" link against GL? check the cogl/clutter configure.ac :)
 dnl Hopefully this will be enough for the time being.
 
-clutter_soname=`$PKG_CONFIG --variable soname_infix clutter-1.0`
-AS_CASE([$clutter_soname],
-        [glx], [AC_CHECK_LIB([GL], [glGetIntegerv], [GL_LDFLAGS="-lGL"])])
-AC_SUBST([GL_LDFLAGS])
+dnl With Cogl 1.8.0 all of the above is moot because we can use
+dnl cogl_renderer_get_n_fragment_texture_units() and never depend on GL/GLES
+dnl directly. However let's not hard depend on cogl 1.8.0 just yet.
+dnl Well, obviously just a little detail remaining, it's not possible to grab
+dnl the CoglContext on OS X yet.
+
+PKG_CHECK_EXISTS([clutter-osx-1.0],
+                 [
+                   AC_DEFINE([HAVE_CLUTTER_OSX], [1],
+                             ["Defined if building Clutter for OS X"])
+                 ])
+PKG_CHECK_EXISTS([cogl-1.0 >= 1.8.0],
+                 [
+                   have_cogl_1_8=yes
+                   AC_DEFINE([HAVE_COGL_1_8], [1],
+                             ["Defined if cogl-1.0 >= 1.8.0 is available"])
+                 ])
+
+AS_IF([test "x$have_cogl_1_8" != xyes],
+      [
+        clutter_soname=`$PKG_CONFIG --variable soname_infix clutter-1.0`
+        AS_CASE([$clutter_soname],
+                [glx],
+                [AC_CHECK_LIB([GL], [glGetIntegerv], [GL_LDFLAGS="-lGL"])])
+        AC_SUBST([GL_LDFLAGS])
+      ])
 
 dnl ========================================================================
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]