[clutter/wip/cogl-winsys-egl: 26/37] stash EGL GDL platform
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/cogl-winsys-egl: 26/37] stash EGL GDL platform
- Date: Mon, 4 Apr 2011 12:08:47 +0000 (UTC)
commit fd4a2216af9651bc9af07eab4aa1e4a6c0356c92
Author: Robert Bragg <robert linux intel com>
Date: Fri Mar 4 12:50:39 2011 +0000
stash EGL GDL platform
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 | 129 ++++++++++++++++++++++++++-
clutter/cogl/configure.ac | 2 +-
clutter/egl/clutter-backend-egl.c | 10 +-
configure.ac | 18 ++--
11 files changed, 186 insertions(+), 18 deletions(-)
---
diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am
index f572618..15b8dc1 100644
--- a/clutter/cogl/cogl/Makefile.am
+++ b/clutter/cogl/cogl/Makefile.am
@@ -339,7 +339,7 @@ cogl_sources_c += \
$(srcdir)/winsys/cogl-winsys-egl.c \
$(srcdir)/winsys/cogl-winsys-stub.c
endif
-if SUPPORT_EGL_PLATFORM_POWERVR_GDL
+if SUPPORT_EGL_PLATFORM_GDL
cogl_sources_c += \
$(srcdir)/winsys/cogl-winsys-egl.c \
$(srcdir)/winsys/cogl-winsys-stub.c
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..94070bd 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_display_cex100_set_gdl_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..8a0e9fd 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_display_cex100_set_gdl_plane \
+ cogl_display_cex100_set_gdl_plane_EXP
+void
+cogl_display_cex100_set_gdl_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 2590af9..1d5a24c 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;
@@ -432,6 +473,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)
@@ -533,6 +580,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");
@@ -697,6 +746,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_display_cex100_set_gdl_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)
@@ -708,6 +832,9 @@ _cogl_winsys_display_setup (CoglDisplay *display,
egl_display = g_slice_new0 (CoglDisplayEGL);
display->winsys = egl_display;
+ if (!gdl_plane_init (display, error))
+ goto error;
+
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 0c5def8..8a77b10 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
@@ -305,7 +305,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
@@ -324,7 +324,7 @@ 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
+#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
cogl_display_cex100_set_gdl_plane (backend->cogl_display, gdl_plane);
#endif
@@ -498,7 +498,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 9fe008f..04747dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,7 +365,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"
@@ -499,12 +499,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"])
@@ -512,10 +506,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 =====================================================
@@ -659,6 +653,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"
@@ -729,7 +727,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]