From 616d27f16952d04809398edbf8f9494aac76055a Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 13 Dec 2011 18:57:53 +0000 Subject: [PATCH] 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 --- cogl/cogl-texture-2d.c | 10 +++++----- cogl/winsys/cogl-winsys-egl-x11.c | 2 ++ cogl/winsys/cogl-winsys-egl.c | 2 ++ cogl/winsys/cogl-winsys-glx.c | 3 +++ cogl/winsys/cogl-winsys-private.h | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index 216c566eb..ba4c6d086 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -460,9 +460,9 @@ _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 (), - NULL); + _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 & COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE, @@ -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, diff --git a/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/winsys/cogl-winsys-egl-x11.c index b66a6d879..3506ba964 100644 --- a/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/winsys/cogl-winsys-egl-x11.c @@ -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; diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c index ce5d5da39..e5618da0a 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -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 */ diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c index 4e2d9edc1..66252de2d 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -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, diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h index 16317b7ba..7686d23bc 100644 --- a/cogl/winsys/cogl-winsys-private.h +++ b/cogl/winsys/cogl-winsys-private.h @@ -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;