cogl-texture-2d: Fix checking for the EGL winsys

CoglTexture2D had an assert to verify that the EGL winsys was being
used. This doesn't make any sense any more because the EGL winsys
can't be used directly but instead it is just a base winsys for the
platform winsys's. To fix this this patch adds a set of 'criteria'
flags to each winsys, one of which is 'uses EGL'. CoglTexture2D can
use this to determine if the winsys is supported.

Eventually we might want to expose these flags publically so that an
application can select a winsys based on certain conditions. For
example, an application may need a winsys that uses X or EGL but
doesn't care exactly which one it is.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2011-12-13 18:57:53 +00:00
parent 9000f8330d
commit 616d27f169
5 changed files with 26 additions and 5 deletions

View File

@ -460,8 +460,8 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
CoglTexture2D *tex_2d;
GLenum gl_error;
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx) ==
_cogl_winsys_egl_get_vtable (),
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->criteria &
COGL_WINSYS_CRITERIA_USES_EGL,
NULL);
_COGL_RETURN_VAL_IF_FAIL (ctx->private_feature_flags &
@ -547,8 +547,8 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
{
EGLImageKHR image;
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx) ==
_cogl_winsys_egl_get_vtable (),
_COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->criteria &
COGL_WINSYS_CRITERIA_USES_EGL,
NULL);
image = _cogl_egl_create_image (ctx,
EGL_WAYLAND_BUFFER_WL,

View File

@ -696,6 +696,8 @@ _cogl_winsys_egl_xlib_get_vtable (void)
vtable.id = COGL_WINSYS_ID_EGL_XLIB;
vtable.name = "EGL_XLIB";
vtable.criteria |= (COGL_WINSYS_CRITERIA_USES_X11 |
COGL_WINSYS_CRITERIA_USES_XLIB);
vtable.renderer_connect = _cogl_winsys_renderer_connect;
vtable.renderer_disconnect = _cogl_winsys_renderer_disconnect;

View File

@ -640,6 +640,8 @@ _cogl_winsys_context_egl_get_egl_display (CoglContext *context)
static CoglWinsysVtable _cogl_winsys_vtable =
{
.criteria = COGL_WINSYS_CRITERIA_USES_EGL,
/* This winsys is only used as a base for the EGL-platform
winsys's so it does not have an ID or a name */

View File

@ -2056,6 +2056,9 @@ static CoglWinsysVtable _cogl_winsys_vtable =
{
.id = COGL_WINSYS_ID_GLX,
.name = "GLX",
.criteria = (COGL_WINSYS_CRITERIA_USES_X11 |
COGL_WINSYS_CRITERIA_USES_XLIB),
.renderer_get_proc_address = _cogl_winsys_renderer_get_proc_address,
.renderer_connect = _cogl_winsys_renderer_connect,
.renderer_disconnect = _cogl_winsys_renderer_disconnect,

View File

@ -54,9 +54,23 @@ typedef enum
COGL_WINSYS_RECTANGLE_STATE_ENABLE
} CoglWinsysRectangleState;
/* These criteria flags are hard-coded features of the winsys
regardless of the underlying driver or GPU. We might eventually
want to use these in a mechanism for the application to specify
criteria for the winsys instead of a specific winsys but for now
they are only used internally to assert that an EGL winsys is
selected */
typedef enum
{
COGL_WINSYS_CRITERIA_USES_X11 = (1 << 0),
COGL_WINSYS_CRITERIA_USES_XLIB = (1 << 1),
COGL_WINSYS_CRITERIA_USES_EGL = (1 << 2)
} CoglWinsysCriteria;
typedef struct _CoglWinsysVtable
{
CoglWinsysID id;
CoglWinsysCriteria criteria;
const char *name;