[clutter/wip/cogl-winsys-egl: 5/21] winsys: Expose environment variable to choose winsys
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/cogl-winsys-egl: 5/21] winsys: Expose environment variable to choose winsys
- Date: Thu, 21 Apr 2011 16:00:47 +0000 (UTC)
commit a856344086f71f5fc1c9b746eefaf045fba87da1
Author: Robert Bragg <robert linux intel com>
Date: Mon Apr 18 16:24:51 2011 +0100
winsys: Expose environment variable to choose winsys
This makes it possible to override the winsys that cogl uses by setting
the COGL_RENDERER environment variable e.g. to "GLX" or "EGL"
clutter/cogl/cogl/cogl-renderer.c | 8 ++++++++
clutter/cogl/cogl/winsys/cogl-winsys-egl.c | 1 +
clutter/cogl/cogl/winsys/cogl-winsys-glx.c | 1 +
clutter/cogl/cogl/winsys/cogl-winsys-private.h | 2 ++
4 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/clutter/cogl/cogl/cogl-renderer.c b/clutter/cogl/cogl/cogl-renderer.c
index 613b163..93e33a4 100644
--- a/clutter/cogl/cogl/cogl-renderer.c
+++ b/clutter/cogl/cogl/cogl-renderer.c
@@ -28,6 +28,9 @@
#include "config.h"
#endif
+#include <stdlib.h>
+#include <string.h>
+
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-object.h"
@@ -168,6 +171,7 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
{
#ifdef COGL_HAS_FULL_WINSYS
int i;
+ char *renderer_name = getenv ("COGL_RENDERER");
#endif
GString *error_message;
@@ -180,6 +184,10 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
{
const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i]();
GError *tmp_error = NULL;
+
+ if (renderer_name && strcmp (winsys->name, renderer_name) != 0)
+ continue;
+
if (!winsys->renderer_connect (renderer, &tmp_error))
{
g_string_append_c (error_message, '\n');
diff --git a/clutter/cogl/cogl/winsys/cogl-winsys-egl.c b/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
index 595ec8d..a48fe20 100644
--- a/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/clutter/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -1088,6 +1088,7 @@ _cogl_winsys_context_egl_get_egl_display (CoglContext *context)
static CoglWinsysVtable _cogl_winsys_vtable =
{
+ .name = "EGL",
.get_proc_address = _cogl_winsys_get_proc_address,
.renderer_connect = _cogl_winsys_renderer_connect,
.renderer_disconnect = _cogl_winsys_renderer_disconnect,
diff --git a/clutter/cogl/cogl/winsys/cogl-winsys-glx.c b/clutter/cogl/cogl/winsys/cogl-winsys-glx.c
index 26ad6e6..b15263c 100644
--- a/clutter/cogl/cogl/winsys/cogl-winsys-glx.c
+++ b/clutter/cogl/cogl/winsys/cogl-winsys-glx.c
@@ -1880,6 +1880,7 @@ _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
static CoglWinsysVtable _cogl_winsys_vtable =
{
+ .name = "GLX",
.get_proc_address = _cogl_winsys_get_proc_address,
.renderer_connect = _cogl_winsys_renderer_connect,
.renderer_disconnect = _cogl_winsys_renderer_disconnect,
diff --git a/clutter/cogl/cogl/winsys/cogl-winsys-private.h b/clutter/cogl/cogl/winsys/cogl-winsys-private.h
index a610848..856fc8d 100644
--- a/clutter/cogl/cogl/winsys/cogl-winsys-private.h
+++ b/clutter/cogl/cogl/winsys/cogl-winsys-private.h
@@ -54,6 +54,8 @@ typedef enum
typedef struct _CoglWinsysVtable
{
+ const char *name;
+
CoglFuncPtr
(*get_proc_address) (const char *name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]