[cogl/wip/neil/master-next: 7/8] cogl-texture-2d: Fix checking for the EGL winsys



commit f2d19415ff0578b9d5395119b26362817e68ffbd
Author: Neil Roberts <neil linux intel com>
Date:   Tue Dec 13 18:57:53 2011 +0000

    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.

 cogl/cogl-texture-2d.c             |   10 +++++-----
 cogl/winsys/cogl-winsys-egl-xlib.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 216c566..ba4c6d0 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-xlib.c b/cogl/winsys/cogl-winsys-egl-xlib.c
index 8dea09f..cd9cdd3 100644
--- a/cogl/winsys/cogl-winsys-egl-xlib.c
+++ b/cogl/winsys/cogl-winsys-egl-xlib.c
@@ -696,6 +696,8 @@ _cogl_winsys_egl_x11_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 ce5d5da..e5618da 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 4e2d9ed..66252de 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 16317b7..7686d23 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;
 



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