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.
This commit is contained in:
Robert Bragg 2011-03-04 12:50:39 +00:00
parent ce2da79440
commit 7037812ae6
9 changed files with 175 additions and 3 deletions

View File

@ -338,7 +338,7 @@ if SUPPORT_EGL_PLATFORM_POWERVR_NULL
cogl_sources_c += \ cogl_sources_c += \
$(srcdir)/winsys/cogl-winsys-egl.c $(srcdir)/winsys/cogl-winsys-egl.c
endif endif
if SUPPORT_EGL_PLATFORM_POWERVR_GDL if SUPPORT_EGL_PLATFORM_GDL
cogl_sources_c += \ cogl_sources_c += \
$(srcdir)/winsys/cogl-winsys-egl.c $(srcdir)/winsys/cogl-winsys-egl.c
endif endif

View File

@ -26,6 +26,7 @@
#define __COGL_DISPLAY_PRIVATE_H #define __COGL_DISPLAY_PRIVATE_H
#include "cogl-object-private.h" #include "cogl-object-private.h"
#include "cogl-display.h"
#include "cogl-renderer.h" #include "cogl-renderer.h"
#include "cogl-onscreen-template.h" #include "cogl-onscreen-template.h"
@ -37,6 +38,10 @@ struct _CoglDisplay
CoglRenderer *renderer; CoglRenderer *renderer;
CoglOnscreenTemplate *onscreen_template; CoglOnscreenTemplate *onscreen_template;
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
struct gdl_plane *gdl_plane;
#endif
void *winsys; void *winsys;
}; };

View File

@ -121,3 +121,15 @@ cogl_display_setup (CoglDisplay *display,
return TRUE; 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

View File

@ -36,6 +36,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
#include <@CLUTTER_CEX100_LIBGDL_PREFIX@libgdl.h>
#endif
/** /**
* SECTION:cogl-display * SECTION:cogl-display
* @short_description: Represents a display pipeline * @short_description: Represents a display pipeline
@ -82,6 +86,14 @@ gboolean
cogl_display_setup (CoglDisplay *display, cogl_display_setup (CoglDisplay *display,
GError **error); 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 G_END_DECLS
#endif /* __COGL_DISPLAY_H__ */ #endif /* __COGL_DISPLAY_H__ */

View File

@ -32,6 +32,7 @@ struct _CoglSwapChain
gboolean has_alpha; gboolean has_alpha;
int length;
}; };
#endif /* __COGL_SWAP_CHAIN_PRIVATE_H */ #endif /* __COGL_SWAP_CHAIN_PRIVATE_H */

View File

@ -54,6 +54,8 @@ cogl_swap_chain_new (void)
{ {
CoglSwapChain *swap_chain = g_slice_new0 (CoglSwapChain); CoglSwapChain *swap_chain = g_slice_new0 (CoglSwapChain);
swap_chain->length = -1; /* no preference */
return _cogl_swap_chain_object_new (swap_chain); 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; swap_chain->has_alpha = has_alpha;
} }
void
cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
int length)
{
swap_chain->length = length;
}

View File

@ -41,6 +41,11 @@ void
cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain, cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
gboolean has_alpha); 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 G_END_DECLS
#endif /* __COGL_SWAP_CHAIN_H__ */ #endif /* __COGL_SWAP_CHAIN_H__ */

View File

@ -81,6 +81,10 @@ typedef struct _CoglRendererEGL
EGLint egl_version_major; EGLint egl_version_major;
EGLint egl_version_minor; EGLint egl_version_minor;
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
gboolean gdl_initialized;
#endif
/* Function pointers for GLX specific extensions */ /* Function pointers for GLX specific extensions */
#define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d, e, f) #define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d, e, f)
@ -105,7 +109,8 @@ typedef struct _CoglDisplayEGL
EGLContext egl_context; EGLContext egl_context;
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT #ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
EGLSurface dummy_surface; 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; EGLSurface egl_surface;
int egl_surface_width; int egl_surface_width;
int egl_surface_height; int egl_surface_height;
@ -242,6 +247,11 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
{ {
CoglRendererEGL *egl_renderer = renderer->winsys; 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 #ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
_cogl_renderer_xlib_disconnect (renderer); _cogl_renderer_xlib_disconnect (renderer);
#endif #endif
@ -260,6 +270,10 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
CoglRendererXlib *xlib_renderer; CoglRendererXlib *xlib_renderer;
#endif #endif
EGLBoolean status; 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); renderer->winsys = g_slice_new0 (CoglRendererEGL);
@ -282,6 +296,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
status = eglInitialize (egl_renderer->edpy, status = eglInitialize (egl_renderer->edpy,
&egl_renderer->egl_version_major, &egl_renderer->egl_version_major,
&egl_renderer->egl_version_minor); &egl_renderer->egl_version_minor);
#endif
if (status != EGL_TRUE) if (status != EGL_TRUE)
{ {
@ -290,6 +305,32 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
"Failed to initialize EGL"); "Failed to initialize EGL");
goto error; 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 #endif
return TRUE; return TRUE;
@ -427,6 +468,12 @@ try_create_context (CoglDisplay *display,
EGL_DEPTH_SIZE, 1, 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, EGL_BUFFER_SIZE, EGL_DONT_CARE,
#if defined (HAVE_COGL_GL) #if defined (HAVE_COGL_GL)
@ -528,6 +575,8 @@ try_create_context (CoglDisplay *display,
if (egl_display->dummy_surface == EGL_NO_SURFACE) 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, g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_CONTEXT, COGL_WINSYS_ERROR_CREATE_CONTEXT,
"Unable to create an EGL surface"); "Unable to create an EGL surface");
@ -688,6 +737,81 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
display->winsys = NULL; 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 static gboolean
_cogl_winsys_display_setup (CoglDisplay *display, _cogl_winsys_display_setup (CoglDisplay *display,
GError **error) GError **error)
@ -699,6 +823,11 @@ _cogl_winsys_display_setup (CoglDisplay *display,
egl_display = g_slice_new0 (CoglDisplayEGL); egl_display = g_slice_new0 (CoglDisplayEGL);
display->winsys = egl_display; 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)) if (!create_context (display, error))
goto error; goto error;

View File

@ -271,7 +271,7 @@ AM_CONDITIONAL(SUPPORT_XLIB, [true])
AM_CONDITIONAL(SUPPORT_EGL, [false]) AM_CONDITIONAL(SUPPORT_EGL, [false])
AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_X11, [false]) AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_X11, [false])
AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_POWERVR_NULL, [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_OSX, [false])
AM_CONDITIONAL(SUPPORT_WIN32, [false]) AM_CONDITIONAL(SUPPORT_WIN32, [false])
AM_CONDITIONAL(SUPPORT_CEX100, [false]) AM_CONDITIONAL(SUPPORT_CEX100, [false])