[waffle] [PATCH 09/12] glx: implement platform-specific information
Frank Henigman
fjhenigman at google.com
Wed Jan 6 11:56:38 PST 2016
Implement the platform hook of waffle_display_info_json() so it can
pick up glx-specific information.
Signed-off-by: Frank Henigman <fjhenigman at google.com>
---
src/waffle/glx/glx_display.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/waffle/glx/glx_display.h | 4 ++++
src/waffle/glx/glx_platform.c | 4 ++++
src/waffle/glx/glx_platform.h | 3 +++
4 files changed, 52 insertions(+)
diff --git a/src/waffle/glx/glx_display.c b/src/waffle/glx/glx_display.c
index 24e967c..6e7cc65 100644
--- a/src/waffle/glx/glx_display.c
+++ b/src/waffle/glx/glx_display.c
@@ -25,6 +25,8 @@
#include <stdlib.h>
+#include "json.h"
+
#include "wcore_error.h"
#include "linux_platform.h"
@@ -134,6 +136,45 @@ glx_display_supports_context_api(struct wcore_display *wc_self,
}
}
+void
+glx_display_info_json(struct wcore_display *wc_self, struct json *jj)
+{
+ struct glx_display *self = glx_display(wc_self);
+ struct glx_platform *plat = glx_platform(wc_self->platform);
+ Display *dpy = self->x11.xlib;
+ int screen = self->x11.screen;
+
+ int major, minor;
+ if (!plat->glXQueryVersion(dpy, &major, &minor)) {
+ wcore_errorf(WAFFLE_ERROR_UNKNOWN, "glXQueryVersion failed");
+ return json_append(jj, NULL);
+ }
+
+ const char *svendor = plat->glXQueryServerString(dpy, screen, GLX_VENDOR);
+ const char *sversion = plat->glXQueryServerString(dpy, screen, GLX_VERSION);
+ const char *sext = plat->glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
+ const char *cvendor = plat->glXGetClientString(dpy, GLX_VENDOR);
+ const char *cversion = plat->glXGetClientString(dpy, GLX_VERSION);
+ const char *cext = plat->glXGetClientString(dpy, GLX_EXTENSIONS);
+
+ json_appendv(jj,
+ "version", "{",
+ "major", json_num(major),
+ "minor", json_num(minor),
+ "}",
+ "server", "{",
+ "vendor", json_str(svendor),
+ "version", json_str(sversion),
+ "extensions", "[", json_split(sext, " "), "]",
+ "}",
+ "client", "{",
+ "vendor", json_str(cvendor),
+ "version", json_str(cversion),
+ "extensions", "[", json_split(cext, " "), "]",
+ "}",
+ "");
+}
+
union waffle_native_display*
glx_display_get_native(struct wcore_display *wc_self)
{
diff --git a/src/waffle/glx/glx_display.h b/src/waffle/glx/glx_display.h
index 4b8f687..00d35ad 100644
--- a/src/waffle/glx/glx_display.h
+++ b/src/waffle/glx/glx_display.h
@@ -38,6 +38,7 @@
#include "x11_display.h"
+struct json;
struct wcore_platform;
struct glx_display {
@@ -66,5 +67,8 @@ bool
glx_display_supports_context_api(struct wcore_display *wc_self,
int32_t context_api);
+void
+glx_display_info_json(struct wcore_display *wc_self, struct json *);
+
union waffle_native_display*
glx_display_get_native(struct wcore_display *wc_self);
diff --git a/src/waffle/glx/glx_platform.c b/src/waffle/glx/glx_platform.c
index 4fb2eed..ea49f09 100644
--- a/src/waffle/glx/glx_platform.c
+++ b/src/waffle/glx/glx_platform.c
@@ -105,6 +105,9 @@ glx_platform_create(void)
RETRIEVE_GLX_SYMBOL(glXMakeCurrent);
RETRIEVE_GLX_SYMBOL(glXQueryExtensionsString);
+ RETRIEVE_GLX_SYMBOL(glXQueryServerString);
+ RETRIEVE_GLX_SYMBOL(glXQueryVersion);
+ RETRIEVE_GLX_SYMBOL(glXGetClientString);
RETRIEVE_GLX_SYMBOL(glXGetProcAddress);
RETRIEVE_GLX_SYMBOL(glXGetVisualFromFBConfig);
@@ -186,6 +189,7 @@ static const struct wcore_platform_vtbl glx_platform_vtbl = {
.connect = glx_display_connect,
.destroy = glx_display_destroy,
.supports_context_api = glx_display_supports_context_api,
+ .info_json = glx_display_info_json,
.get_native = glx_display_get_native,
},
diff --git a/src/waffle/glx/glx_platform.h b/src/waffle/glx/glx_platform.h
index 36ddff6..aefc0ee 100644
--- a/src/waffle/glx/glx_platform.h
+++ b/src/waffle/glx/glx_platform.h
@@ -47,6 +47,9 @@ struct glx_platform {
Bool (*glXMakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
const char *(*glXQueryExtensionsString)(Display *dpy, int screen);
+ const char *(*glXQueryServerString)(Display *dpy, int screen, int name);
+ const char *(*glXQueryVersion)(Display *dpy, int *major, int *minor);
+ const char *(*glXGetClientString)(Display *dpy, int name);
void *(*glXGetProcAddress)(const GLubyte *procname);
XVisualInfo *(*glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config);
--
2.6.0.rc2.230.g3dd15c0
More information about the waffle
mailing list