[clutter/wip/cogl-winsys-egl: 7/21] EGL: Updates GDL platform support



commit 788f31fc4515a85b8e8f241c660b51d52e4ce057
Author: Robert Bragg <robert linux intel com>
Date:   Fri Mar 4 12:50:39 2011 +0000

    EGL: Updates GDL platform support
    
    The GDL API is used for example on intel ce4100 (aka Sodaville) based
    systems as a way to allocate memory that can be composited using the
    platforms overlay hardware. This updates the Cogl EGL winsys and the
    support in Clutter so we can continue to support these platforms.

 clutter/cogl/cogl/Makefile.am               |    2 +-
 clutter/cogl/cogl/cogl-display-private.h    |    5 +
 clutter/cogl/cogl/cogl-display.c            |   12 +++
 clutter/cogl/cogl/cogl-display.h            |   12 +++
 clutter/cogl/cogl/cogl-swap-chain-private.h |    1 +
 clutter/cogl/cogl/cogl-swap-chain.c         |    8 ++
 clutter/cogl/cogl/cogl-swap-chain.h         |    5 +
 clutter/cogl/cogl/winsys/cogl-winsys-egl.c  |  131 ++++++++++++++++++++++++++-
 clutter/cogl/configure.ac                   |    2 +-
 clutter/egl/clutter-backend-egl.c           |   12 ++--
 configure.ac                                |   18 ++--
 11 files changed, 189 insertions(+), 19 deletions(-)
---
diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am
index 335f21d..3cee5fa 100644
--- a/clutter/cogl/cogl/Makefile.am
+++ b/clutter/cogl/cogl/Makefile.am
@@ -338,7 +338,7 @@ if SUPPORT_EGL_PLATFORM_POWERVR_NULL
 cogl_sources_c += \
        $(srcdir)/winsys/cogl-winsys-egl.c
 endif
-if SUPPORT_EGL_PLATFORM_POWERVR_GDL
+if SUPPORT_EGL_PLATFORM_GDL
 cogl_sources_c += \
        $(srcdir)/winsys/cogl-winsys-egl.c
 endif
diff --git a/clutter/cogl/cogl/cogl-display-private.h b/clutter/cogl/cogl/cogl-display-private.h
index 1bda21d..964dfb6 100644
--- a/clutter/cogl/cogl/cogl-display-private.h
+++ b/clutter/cogl/cogl/cogl-display-private.h
@@ -26,6 +26,7 @@
 #define __COGL_DISPLAY_PRIVATE_H
 
 #include "cogl-object-private.h"
+#include "cogl-display.h"
 #include "cogl-renderer.h"
 #include "cogl-onscreen-template.h"
 
@@ -37,6 +38,10 @@ struct _CoglDisplay
   CoglRenderer *renderer;
   CoglOnscreenTemplate *onscreen_template;
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  struct gdl_plane *gdl_plane;
+#endif
+
   void *winsys;
 };
 
diff --git a/clutter/cogl/cogl/cogl-display.c b/clutter/cogl/cogl/cogl-display.c
index bb792b7..0953f1f 100644
--- a/clutter/cogl/cogl/cogl-display.c
+++ b/clutter/cogl/cogl/cogl-display.c
@@ -121,3 +121,15 @@ cogl_display_setup (CoglDisplay *display,
 
   return TRUE;
 }
+
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+void
+cogl_gdl_display_set_plane (CoglDisplay *display,
+                            struct gdl_plane *plane)
+{
+  g_return_if_fail (display->setup == FALSE);
+
+  display->gdl_plane = plane;
+}
+#endif
+
diff --git a/clutter/cogl/cogl/cogl-display.h b/clutter/cogl/cogl/cogl-display.h
index 00ce4fb..720b86b 100644
--- a/clutter/cogl/cogl/cogl-display.h
+++ b/clutter/cogl/cogl/cogl-display.h
@@ -36,6 +36,10 @@
 
 G_BEGIN_DECLS
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+#include <@CLUTTER_CEX100_LIBGDL_PREFIX libgdl h>
+#endif
+
 /**
  * SECTION:cogl-display
  * @short_description: Represents a display pipeline
@@ -82,6 +86,14 @@ gboolean
 cogl_display_setup (CoglDisplay *display,
                     GError **error);
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+#define cogl_gdl_display_set_plane \
+  cogl_gdl_display_set_plane_EXP
+void
+cogl_gdl_display_set_plane (CoglDisplay *display,
+                            struct gdl_plane *plane);
+#endif
+
 G_END_DECLS
 
 #endif /* __COGL_DISPLAY_H__ */
diff --git a/clutter/cogl/cogl/cogl-swap-chain-private.h b/clutter/cogl/cogl/cogl-swap-chain-private.h
index 5edadeb..2f63109 100644
--- a/clutter/cogl/cogl/cogl-swap-chain-private.h
+++ b/clutter/cogl/cogl/cogl-swap-chain-private.h
@@ -32,6 +32,7 @@ struct _CoglSwapChain
 
   gboolean has_alpha;
 
+  int length;
 };
 
 #endif /* __COGL_SWAP_CHAIN_PRIVATE_H */
diff --git a/clutter/cogl/cogl/cogl-swap-chain.c b/clutter/cogl/cogl/cogl-swap-chain.c
index 9622e9e..9326146 100644
--- a/clutter/cogl/cogl/cogl-swap-chain.c
+++ b/clutter/cogl/cogl/cogl-swap-chain.c
@@ -54,6 +54,8 @@ cogl_swap_chain_new (void)
 {
   CoglSwapChain *swap_chain = g_slice_new0 (CoglSwapChain);
 
+  swap_chain->length = -1; /* no preference */
+
   return _cogl_swap_chain_object_new (swap_chain);
 }
 
@@ -64,3 +66,9 @@ cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
   swap_chain->has_alpha = has_alpha;
 }
 
+void
+cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
+                            int length)
+{
+  swap_chain->length = length;
+}
diff --git a/clutter/cogl/cogl/cogl-swap-chain.h b/clutter/cogl/cogl/cogl-swap-chain.h
index 7791e23..2f3ae58 100644
--- a/clutter/cogl/cogl/cogl-swap-chain.h
+++ b/clutter/cogl/cogl/cogl-swap-chain.h
@@ -41,6 +41,11 @@ void
 cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
                                gboolean has_alpha);
 
+#define cogl_swap_chain_set_length cogl_swap_chain_set_length_EXP
+void
+cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
+                            int length);
+
 G_END_DECLS
 
 #endif /* __COGL_SWAP_CHAIN_H__ */
diff --git a/clutter/cogl/cogl/winsys/cogl-winsys-egl.c b/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
index a48fe20..f731c03 100644
--- a/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -81,6 +81,10 @@ typedef struct _CoglRendererEGL
   EGLint egl_version_major;
   EGLint egl_version_minor;
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  gboolean gdl_initialized;
+#endif
+
   /* Function pointers for GLX specific extensions */
 #define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d, e, f)
 
@@ -105,7 +109,8 @@ typedef struct _CoglDisplayEGL
   EGLContext egl_context;
 #ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
   EGLSurface dummy_surface;
-#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT)
+#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
+      defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
   EGLSurface egl_surface;
   int egl_surface_width;
   int egl_surface_height;
@@ -242,6 +247,11 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 {
   CoglRendererEGL *egl_renderer = renderer->winsys;
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  if (egl_renderer->gdl_initialized)
+    gdl_close ();
+#endif
+
 #ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
   _cogl_renderer_xlib_disconnect (renderer);
 #endif
@@ -260,6 +270,10 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   CoglRendererXlib *xlib_renderer;
 #endif
   EGLBoolean status;
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  gdl_ret_t rc = GDL_SUCCESS;
+  gdl_display_info_t gdl_display_info;
+#endif
 
   renderer->winsys = g_slice_new0 (CoglRendererEGL);
 
@@ -282,6 +296,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   status = eglInitialize (egl_renderer->edpy,
 			  &egl_renderer->egl_version_major,
 			  &egl_renderer->egl_version_minor);
+#endif
 
   if (status != EGL_TRUE)
     {
@@ -290,6 +305,32 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
                    "Failed to initialize EGL");
       goto error;
     }
+
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  /* Check we can talk to the GDL library */
+
+  rc = gdl_init (NULL);
+  if (rc != GDL_SUCCESS)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR,
+                   COGL_WINSYS_ERROR_INIT,
+                   "GDL initialize failed. %s",
+                   gdl_get_error_string (rc));
+      goto error;
+    }
+
+  rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &gdl_display_info);
+  if (rc != GDL_SUCCESS)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR,
+                   COGL_WINSYS_ERROR_INIT,
+                   "GDL failed to get display information: %s",
+                   gdl_get_error_string (rc));
+      gdl_close ();
+      goto error;
+    }
+
+  gdl_close ();
 #endif
 
   return TRUE;
@@ -427,6 +468,12 @@ try_create_context (CoglDisplay *display,
 
     EGL_DEPTH_SIZE,      1,
 
+    /* XXX: Why does the GDL platform choose these by default? */
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+    EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,
+    EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
+#endif
+
     EGL_BUFFER_SIZE,     EGL_DONT_CARE,
 
 #if defined (HAVE_COGL_GL)
@@ -528,6 +575,8 @@ try_create_context (CoglDisplay *display,
 
   if (egl_display->dummy_surface == EGL_NO_SURFACE)
     {
+      /* FIXME: we shouldn't be calling g_set_error here we should
+       * just set error_message same goes for below. */
       g_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to create an EGL surface");
@@ -688,6 +737,81 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
   display->winsys = NULL;
 }
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+static gboolean
+gdl_plane_init (CoglDisplay *display, GError **error)
+{
+  gboolean ret = TRUE;
+  gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB;
+  gdl_rectangle_t dstRect;
+  gdl_display_info_t display_info;
+  gdl_ret_t rc = GDL_SUCCESS;
+
+  if (!display->gdl_plane)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+                   "No GDL plane specified with "
+                   "cogl_gdl_display_set_plane");
+      return FALSE;
+    }
+
+  rc = gdl_init (NULL);
+  if (rc != GDL_SUCCESS)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+                   "GDL initialize failed. %s", gdl_get_error_string (rc));
+      return FALSE;
+    }
+
+  rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &display_info);
+  if (rc != GDL_SUCCESS)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+                   "GDL failed to get display infomation: %s",
+                   gdl_get_error_string (rc));
+      gdl_close ();
+      return FALSE;
+    }
+
+  dstRect.origin.x = 0;
+  dstRect.origin.y = 0;
+  dstRect.width = display_info.tvmode.width;
+  dstRect.height = display_info.tvmode.height;
+
+  /* Configure the plane attribute. */
+  rc = gdl_plane_reset (plane);
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_config_begin (plane);
+
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_set_attr (GDL_PLANE_SRC_COLOR_SPACE, &colorSpace);
+
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_set_attr (GDL_PLANE_PIXEL_FORMAT, &pixfmt);
+
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect);
+
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES,
+                             display->swap_chain->length);
+
+  if (rc == GDL_SUCCESS)
+    rc = gdl_plane_config_end (GDL_FALSE);
+  else
+    gdl_plane_config_end (GDL_TRUE);
+
+  if (rc != GDL_SUCCESS)
+    {
+      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+                   "GDL configuration failed: %s.", gdl_get_error_string (rc));
+      ret = FALSE;
+    }
+
+  gdl_close ();
+}
+#endif
+
 static gboolean
 _cogl_winsys_display_setup (CoglDisplay *display,
                             GError **error)
@@ -699,6 +823,11 @@ _cogl_winsys_display_setup (CoglDisplay *display,
   egl_display = g_slice_new0 (CoglDisplayEGL);
   display->winsys = egl_display;
 
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  if (!gdl_plane_init (display, error))
+    goto error;
+#endif
+
   if (!create_context (display, error))
     goto error;
 
diff --git a/clutter/cogl/configure.ac b/clutter/cogl/configure.ac
index 89c43da..066c87b 100644
--- a/clutter/cogl/configure.ac
+++ b/clutter/cogl/configure.ac
@@ -271,7 +271,7 @@ AM_CONDITIONAL(SUPPORT_XLIB, [true])
 AM_CONDITIONAL(SUPPORT_EGL, [false])
 AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_X11, [false])
 AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_NULL, [false])
-AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_GDL, [false])
+AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_GDL, [false])
 AM_CONDITIONAL(SUPPORT_OSX, [false])
 AM_CONDITIONAL(SUPPORT_WIN32, [false])
 AM_CONDITIONAL(SUPPORT_CEX100, [false])
diff --git a/clutter/egl/clutter-backend-egl.c b/clutter/egl/clutter-backend-egl.c
index c09e19a..1510647 100644
--- a/clutter/egl/clutter-backend-egl.c
+++ b/clutter/egl/clutter-backend-egl.c
@@ -49,7 +49,7 @@
 #include "clutter-main.h"
 #include "clutter-stage-private.h"
 /* FIXME: We should have CLUTTER_ define for this... */
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
 #include "clutter-cex100.h"
 #endif
 
@@ -58,7 +58,7 @@ static ClutterBackendEGL *backend_singleton = NULL;
 static gchar *clutter_vblank = NULL;
 
 /* FIXME: We should have CLUTTER_ define for this... */
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
 static gdl_plane_id_t gdl_plane = GDL_PLANE_ID_UPP_C;
 static guint gdl_n_buffers = CLUTTER_CEX100_TRIPLE_BUFFERING;
 #endif
@@ -309,7 +309,7 @@ clutter_backend_egl_create_context (ClutterBackend  *backend,
                                  clutter_x11_get_use_argb_visual ());
 #endif
 
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
   cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
 #endif
 
@@ -328,8 +328,8 @@ clutter_backend_egl_create_context (ClutterBackend  *backend,
   backend->cogl_display = cogl_display_new (backend->cogl_renderer,
                                             onscreen_template);
 
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT
-  cogl_display_cex100_set_gdl_plane (backend->cogl_display, gdl_plane);
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
+  cogl_gdl_display_set_plane (backend->cogl_display, gdl_plane);
 #endif
 
   cogl_object_unref (backend->cogl_renderer);
@@ -500,7 +500,7 @@ clutter_egl_get_egl_display (void)
 }
 
 /* FIXME we should have a CLUTTER_ define for this */
-#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
 void
 clutter_cex100_set_plane (gdl_plane_id_t plane)
 {
diff --git a/configure.ac b/configure.ac
index 4e98302..b25a876 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,7 +367,7 @@ AS_CASE([$CLUTTER_FLAVOUR],
           CLUTTER_EGL_BACKEND="cex100"
 
           SUPPORT_EGL=1
-          SUPPORT_EGL_PLATFORM_POWERVR_GDL=1
+          SUPPORT_EGL_PLATFORM_GDL=1
 
           COGL_DRIVER="gles"
 
@@ -501,12 +501,6 @@ AS_IF([test "x$SUPPORT_EGL_PLATFORM_POWERVR_NULL" = "x1"],
         AC_DEFINE([COGL_HAS_FULL_WINSYS], [1], [Cogl can create its own OpenGL context])
       ])
 
-AS_IF([test "x$SUPPORT_EGL_PLATFORM_POWERVR_GDL" = "x1"],
-      [
-        AC_DEFINE([COGL_HAS_EGL_PLATFORM_POWERVR_GDL_SUPPORT], [1],
-                  [Cogl supports OpenGL[ES] using the EGL API with the GDL API])
-      ])
-
 # winsys conditionals for use in automake files...
 AM_CONDITIONAL(SUPPORT_GLX, [test "x$SUPPORT_GLX" = "x1"])
 AM_CONDITIONAL(SUPPORT_X11, [test "x$SUPPORT_X11" = "x1"])
@@ -514,10 +508,10 @@ AM_CONDITIONAL(SUPPORT_XLIB, [test "x$SUPPORT_XLIB" = "x1"])
 AM_CONDITIONAL(SUPPORT_EGL, [test "x$SUPPORT_EGL" = "x1"])
 AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_X11, [test "x$SUPPORT_EGL_PLATFORM_POWERVR_X11" = "x1"])
 AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_NULL, [test "x$SUPPORT_EGL_PLATFORM_POWERVR_NULL" = "x1"])
-AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_GDL, [test "x$SUPPORT_EGL_PLATFORM_POWERVR_GDL" = "x1"])
+AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_GDL, [test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"])
 AM_CONDITIONAL(SUPPORT_OSX, [test "x$CLUTTER_WINSYS" = "xosx"])
 AM_CONDITIONAL(SUPPORT_WIN32, [test "x$CLUTTER_WINSYS" = "xwin32"])
-AM_CONDITIONAL(SUPPORT_CEX100, [test "x$SUPPORT_EGL_PLATFORM_POWERVR_GDL" = "x1"])
+AM_CONDITIONAL(SUPPORT_CEX100, [test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"])
 AM_CONDITIONAL(SUPPORT_WAYLAND, [test "x$CLUTTER_WINSYS" = "xwayland"])
 
 dnl === COGL driver backend =====================================================
@@ -661,6 +655,10 @@ if test "x$NEED_SEPARATE_EGL" = "xyes"; then
   AC_DEFINE([HAVE_STANDALONE_EGL], 1, [Have standalone EGL library])
 fi
 
+if test "x$SUPPORT_EGL_PLATFORM_GDL" = "xyes"; then
+  COGL_DEFINES_SYMBOLS="$COGL_DEFINES_SYMBOLS COGL_HAS_EGL_PLATFORM_GDL_SUPPORT"
+fi
+
 AS_CASE([$COGL_DRIVER],
         [gl],
         [COGL_DEFINES_SYMBOLS="$COGL_DEFINES_SYMBOLS COGL_HAS_GL"
@@ -731,7 +729,7 @@ AS_IF([test "x$CLUTTER_WINSYS" = "xosx"],
 AS_IF([test "x$CLUTTER_WINSYS" = "xwin32"],
       [CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
 #define CLUTTER_WINDOWING_WIN32 1"])
-AS_IF([test "x$SUPPORT_EGL_PLATFORM_POWERVR_GDL" = "x1"],
+AS_IF([test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"],
       [CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
 #define CLUTTER_WINDOWING_CEX100 1"])
 



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